diff --git a/kms/platform/kms_darwin.go b/kms/platform/kms_darwin.go index d1cd8cac..00e75c0d 100644 --- a/kms/platform/kms_darwin.go +++ b/kms/platform/kms_darwin.go @@ -25,7 +25,7 @@ func newKMS(ctx context.Context, opts apiv1.Options) (*KMS, error) { return newTPMKMS(ctx, opts) case apiv1.SoftKMS: return newSoftKMS(ctx, opts) - case apiv1.DefaultKMS, apiv1.MacKMS: + case apiv1.PlatformKMS, apiv1.DefaultKMS, apiv1.MacKMS: return newMacKMS(ctx, opts) default: return nil, fmt.Errorf("failed parsing options: unsupported backend %q", backend) diff --git a/kms/platform/kms_other.go b/kms/platform/kms_other.go index 60fc56ea..d7233473 100644 --- a/kms/platform/kms_other.go +++ b/kms/platform/kms_other.go @@ -18,7 +18,7 @@ func newKMS(ctx context.Context, opts apiv1.Options) (*KMS, error) { switch backend { case apiv1.SoftKMS: return newSoftKMS(ctx, opts) - case apiv1.DefaultKMS, apiv1.TPMKMS: + case apiv1.PlatformKMS, apiv1.DefaultKMS, apiv1.TPMKMS: return newTPMKMS(ctx, opts) default: return nil, fmt.Errorf("failed parsing options: unsupported backend %q", backend) diff --git a/kms/platform/kms_test.go b/kms/platform/kms_test.go index ba8ba2ab..f08bc662 100644 --- a/kms/platform/kms_test.go +++ b/kms/platform/kms_test.go @@ -329,6 +329,14 @@ func TestNew(t *testing.T) { shouldSkipNow(t, platformKMS) assert.Equal(t, platformKMS.Type(), k.Type()) }, assert.NoError}, + {"ok platformKMS type", args{t.Context(), apiv1.Options{Type: apiv1.PlatformKMS}}, func(t *testing.T, k *KMS) { + shouldSkipNow(t, platformKMS) + assert.Equal(t, platformKMS.Type(), k.Type()) + }, assert.NoError}, + {"ok backend type", args{t.Context(), apiv1.Options{Type: platformKMS.Type()}}, func(t *testing.T, k *KMS) { + shouldSkipNow(t, platformKMS) + assert.Equal(t, platformKMS.Type(), k.Type()) + }, assert.NoError}, {"ok softkms uri", args{t.Context(), apiv1.Options{URI: "kms:backend=softkms"}}, func(t *testing.T, k *KMS) { assert.Equal(t, apiv1.SoftKMS, k.Type()) }, assert.NoError}, @@ -354,6 +362,14 @@ func TestNew(t *testing.T) { } } +func TestLoadKeyManagerNewFunc(t *testing.T) { + fn, ok := apiv1.LoadKeyManagerNewFunc(apiv1.PlatformKMS) + require.True(t, ok) + km, err := fn(t.Context(), apiv1.Options{}) + require.NoError(t, err) + assert.IsType(t, &KMS{}, km) +} + func TestKMS_Type(t *testing.T) { softKMS := mustKMS(t, "kms:backend=softkms") assert.Equal(t, apiv1.SoftKMS, softKMS.Type()) diff --git a/kms/platform/kms_windows.go b/kms/platform/kms_windows.go index af0dede4..662dff29 100644 --- a/kms/platform/kms_windows.go +++ b/kms/platform/kms_windows.go @@ -26,7 +26,7 @@ func newKMS(ctx context.Context, opts apiv1.Options) (*KMS, error) { return newCAPIKMS(ctx, opts) case apiv1.SoftKMS: return newSoftKMS(ctx, opts) - case apiv1.DefaultKMS, apiv1.TPMKMS: + case apiv1.PlatformKMS, apiv1.DefaultKMS, apiv1.TPMKMS: // Add enable-cng=true if necessary if opts.URI, err = withEnableCNG(opts.URI); err != nil { return nil, err