Skip to content

Commit 596509b

Browse files
authored
Add KeySpec Input and Output (#35)
* Amended tests to check for KeySpec amend * One extra check * Added KeySpec naming And moved to use it as the main record of the selected key spec. * Output KeySpec in logging
1 parent 96da627 commit 596509b

File tree

14 files changed

+344
-93
lines changed

14 files changed

+344
-93
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/nsmithuk/local-kms
33
go 1.17
44

55
require (
6-
github.com/aws/aws-sdk-go v1.35.0
6+
github.com/aws/aws-sdk-go v1.42.19
77
github.com/btcsuite/btcd v0.22.0-beta
88
github.com/satori/go.uuid v1.2.0
99
github.com/sirupsen/logrus v1.4.2
@@ -15,5 +15,5 @@ require (
1515
github.com/golang/snappy v0.0.1 // indirect
1616
github.com/jmespath/go-jmespath v0.4.0 // indirect
1717
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
18-
golang.org/x/sys v0.0.0-20191210023423-ac6580df4449 // indirect
18+
golang.org/x/sys v0.0.0-20210423082822-04245dca01da // indirect
1919
)

go.sum

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
2-
github.com/aws/aws-sdk-go v1.35.0 h1:Pxqn1MWNfBCNcX7jrXCCTfsKpg5ms2IMUMmmcGtYJuo=
3-
github.com/aws/aws-sdk-go v1.35.0/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48=
2+
github.com/aws/aws-sdk-go v1.42.19 h1:L/aM1QwsqVia9qIqexTHwYN+lgLYuOtf11VDgz0YIyw=
3+
github.com/aws/aws-sdk-go v1.42.19/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q=
44
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
55
github.com/btcsuite/btcd v0.22.0-beta h1:LTDpDKUM5EeOFBPM8IXpinEcmZ6FWfNZbE3lfrfdnWo=
66
github.com/btcsuite/btcd v0.22.0-beta/go.mod h1:9n5ntfhhHQBIhUvlhDvD3Qg6fRUj4jkN0VB8L8svzOA=
@@ -20,7 +20,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
2020
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2121
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
2222
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
23-
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
2423
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
2524
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
2625
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
@@ -64,17 +63,21 @@ golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPh
6463
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
6564
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
6665
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
67-
golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI=
68-
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
66+
golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q=
67+
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
6968
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
7069
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
7170
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
7271
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
7372
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
74-
golang.org/x/sys v0.0.0-20191210023423-ac6580df4449 h1:gSbV7h1NRL2G1xTg/owz62CST1oJBmxy4QpMMregXVQ=
75-
golang.org/x/sys v0.0.0-20191210023423-ac6580df4449/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
76-
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
73+
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
74+
golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c=
75+
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
76+
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
7777
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
78+
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
79+
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
80+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
7881
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
7982
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
8083
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=

src/cmk/aes_key.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func NewAesKey(metadata KeyMetadata, policy string, origin KeyOrigin) *AesKey {
3232
//---
3333

3434
k.Metadata.KeyUsage = UsageEncryptDecrypt
35+
k.Metadata.KeySpec = SpecSymmetricDefault
3536
k.Metadata.CustomerMasterKeySpec = SpecSymmetricDefault
3637
k.Metadata.EncryptionAlgorithms = []EncryptionAlgorithm{EncryptionAlgorithmAes}
3738

@@ -182,6 +183,7 @@ func (k *AesKey) UnmarshalYAML(unmarshal func(interface{}) error) error {
182183
k.Metadata.Enabled = false
183184
}
184185

186+
k.Metadata.KeySpec = SpecSymmetricDefault
185187
k.Metadata.CustomerMasterKeySpec = SpecSymmetricDefault
186188
k.Metadata.EncryptionAlgorithms = []EncryptionAlgorithm{EncryptionAlgorithmAes}
187189

src/cmk/ecc_key.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type ecdsaSignature struct {
2727
R, S *big.Int
2828
}
2929

30-
func NewEccKey(spec CustomerMasterKeySpec, metadata KeyMetadata, policy string) (*EccKey, error) {
30+
func NewEccKey(spec KeySpec, metadata KeyMetadata, policy string) (*EccKey, error) {
3131

3232
var curve elliptic.Curve
3333

@@ -62,6 +62,7 @@ func NewEccKey(spec CustomerMasterKeySpec, metadata KeyMetadata, policy string)
6262
//---
6363

6464
k.Metadata.KeyUsage = UsageSignVerify
65+
k.Metadata.KeySpec = spec
6566
k.Metadata.CustomerMasterKeySpec = spec
6667

6768
switch spec {
@@ -257,13 +258,13 @@ func (k *EccKey) UnmarshalYAML(unmarshal func(interface{}) error) error {
257258

258259
switch bitLen {
259260
case 256:
260-
k.Metadata.CustomerMasterKeySpec = SpecEccNistP256
261+
k.Metadata.KeySpec = SpecEccNistP256
261262
k.Metadata.SigningAlgorithms = []SigningAlgorithm{SigningAlgorithmEcdsaSha256}
262263
case 384:
263-
k.Metadata.CustomerMasterKeySpec = SpecEccNistP384
264+
k.Metadata.KeySpec = SpecEccNistP384
264265
k.Metadata.SigningAlgorithms = []SigningAlgorithm{SigningAlgorithmEcdsaSha384}
265266
case 521:
266-
k.Metadata.CustomerMasterKeySpec = SpecEccNistP521
267+
k.Metadata.KeySpec = SpecEccNistP521
267268
k.Metadata.SigningAlgorithms = []SigningAlgorithm{SigningAlgorithmEcdsaSha512}
268269
default:
269270
return &UnmarshalYAMLError{
@@ -273,6 +274,8 @@ func (k *EccKey) UnmarshalYAML(unmarshal func(interface{}) error) error {
273274
}
274275
}
275276

277+
k.Metadata.CustomerMasterKeySpec = k.Metadata.KeySpec
278+
276279
if k.Metadata.KeyUsage != UsageSignVerify {
277280
return &UnmarshalYAMLError{
278281
fmt.Sprintf(

src/cmk/key.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ const (
1919

2020
//---
2121

22-
type CustomerMasterKeySpec string
22+
type KeySpec string
2323

2424
const (
25-
SpecSymmetricDefault CustomerMasterKeySpec = "SYMMETRIC_DEFAULT"
26-
SpecEccNistP256 CustomerMasterKeySpec = "ECC_NIST_P256"
27-
SpecEccNistP384 CustomerMasterKeySpec = "ECC_NIST_P384"
28-
SpecEccNistP521 CustomerMasterKeySpec = "ECC_NIST_P521"
29-
SpecEccSecp256k1 CustomerMasterKeySpec = "ECC_SECG_P256K1"
30-
SpecRsa2048 CustomerMasterKeySpec = "RSA_2048"
31-
SpecRsa3072 CustomerMasterKeySpec = "RSA_3072"
32-
SpecRsa4096 CustomerMasterKeySpec = "RSA_4096"
25+
SpecSymmetricDefault KeySpec = "SYMMETRIC_DEFAULT"
26+
SpecEccNistP256 KeySpec = "ECC_NIST_P256"
27+
SpecEccNistP384 KeySpec = "ECC_NIST_P384"
28+
SpecEccNistP521 KeySpec = "ECC_NIST_P521"
29+
SpecEccSecp256k1 KeySpec = "ECC_SECG_P256K1"
30+
SpecRsa2048 KeySpec = "RSA_2048"
31+
SpecRsa3072 KeySpec = "RSA_3072"
32+
SpecRsa4096 KeySpec = "RSA_4096"
3333
)
3434

3535
//---
@@ -150,7 +150,8 @@ type KeyMetadata struct {
150150

151151
SigningAlgorithms []SigningAlgorithm `json:",omitempty"`
152152
EncryptionAlgorithms []EncryptionAlgorithm `json:",omitempty"`
153-
CustomerMasterKeySpec CustomerMasterKeySpec `json:",omitempty"`
153+
KeySpec KeySpec `json:",omitempty"`
154+
CustomerMasterKeySpec KeySpec `json:",omitempty"`
154155
}
155156

156157
type ParametersForImport struct {
@@ -169,7 +170,7 @@ func (e *UnmarshalYAMLError) Error() string {
169170
}
170171

171172
func defaultSeededKeyMetadata(metadata *KeyMetadata) {
172-
metadata.Arn = config.ArnPrefix() + "key/" +metadata.KeyId
173+
metadata.Arn = config.ArnPrefix() + "key/" + metadata.KeyId
173174
metadata.AWSAccountId = config.AWSAccountId
174175
metadata.CreationDate = time.Now().Unix()
175176
metadata.Enabled = true

src/cmk/rsa_key.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type RsaKey struct {
1717
PrivateKey RsaPrivateKey
1818
}
1919

20-
func NewRsaKey(spec CustomerMasterKeySpec, usage KeyUsage, metadata KeyMetadata, policy string) (*RsaKey, error) {
20+
func NewRsaKey(spec KeySpec, usage KeyUsage, metadata KeyMetadata, policy string) (*RsaKey, error) {
2121

2222
var bits int
2323

@@ -48,6 +48,7 @@ func NewRsaKey(spec CustomerMasterKeySpec, usage KeyUsage, metadata KeyMetadata,
4848
k.Policy = policy
4949

5050
k.Metadata.KeyUsage = usage
51+
k.Metadata.KeySpec = spec
5152
k.Metadata.CustomerMasterKeySpec = spec
5253

5354
switch usage {
@@ -253,11 +254,11 @@ func (k *RsaKey) UnmarshalYAML(unmarshal func(interface{}) error) error {
253254
bitLen := key.N.BitLen()
254255
switch bitLen {
255256
case 2048:
256-
k.Metadata.CustomerMasterKeySpec = SpecRsa2048
257+
k.Metadata.KeySpec = SpecRsa2048
257258
case 3072:
258-
k.Metadata.CustomerMasterKeySpec = SpecRsa3072
259+
k.Metadata.KeySpec = SpecRsa3072
259260
case 4096:
260-
k.Metadata.CustomerMasterKeySpec = SpecRsa4096
261+
k.Metadata.KeySpec = SpecRsa4096
261262
default:
262263
return &UnmarshalYAMLError{
263264
fmt.Sprintf(
@@ -266,6 +267,8 @@ func (k *RsaKey) UnmarshalYAML(unmarshal func(interface{}) error) error {
266267
}
267268
}
268269

270+
k.Metadata.CustomerMasterKeySpec = k.Metadata.KeySpec
271+
269272
switch k.Metadata.KeyUsage {
270273
case UsageSignVerify:
271274
k.Metadata.SigningAlgorithms = []SigningAlgorithm{
@@ -291,4 +294,3 @@ func (k *RsaKey) UnmarshalYAML(unmarshal func(interface{}) error) error {
291294
}
292295
return nil
293296
}
294-

src/data/database_key.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ func (d *Database) LoadKey(arn string) (cmk.Key, error) {
5757

5858
//---
5959

60+
// Migrate old keys to new naming
61+
if key.GetMetadata().KeySpec == "" {
62+
key.GetMetadata().KeySpec = key.GetMetadata().CustomerMasterKeySpec
63+
}
64+
65+
//---
66+
6067
// Delete key if it has expired
6168
if key.GetMetadata().DeletionDate != 0 && key.GetMetadata().DeletionDate < time.Now().Unix() {
6269
d.DeleteObject(arn)

src/handler/create_key.go

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,20 @@ func (r *RequestHandler) CreateKey() Response {
8080
body.Policy = &policy
8181
}
8282

83-
if body.CustomerMasterKeySpec == nil {
83+
if body.KeySpec != nil && body.CustomerMasterKeySpec != nil {
84+
// Both values cannot be set
85+
86+
msg := fmt.Sprintf("You cannot specify KeySpec and CustomerMasterKeySpec in the same request. CustomerMasterKeySpec is deprecated.")
87+
r.logger.Warnf(msg)
88+
return NewValidationExceptionResponse(msg)
89+
} else if body.KeySpec == nil && body.CustomerMasterKeySpec != nil {
90+
// If we only have CustomerMasterKeySpec, copy it over to KeySpec
91+
body.KeySpec = body.CustomerMasterKeySpec
92+
93+
} else if body.KeySpec == nil && body.CustomerMasterKeySpec == nil {
94+
// If neither are set, the default is SYMMETRIC_DEFAULT
8495
sd := "SYMMETRIC_DEFAULT"
85-
body.CustomerMasterKeySpec = &sd
96+
body.KeySpec = &sd
8697
}
8798

8899
if body.Origin != nil {
@@ -91,8 +102,8 @@ func (r *RequestHandler) CreateKey() Response {
91102
// nop
92103
case "EXTERNAL":
93104

94-
if *body.CustomerMasterKeySpec != "SYMMETRIC_DEFAULT" {
95-
msg := fmt.Sprintf("KeySpec %s is not supported for Origin %s", *body.CustomerMasterKeySpec, *body.Origin)
105+
if *body.KeySpec != "SYMMETRIC_DEFAULT" {
106+
msg := fmt.Sprintf("KeySpec %s is not supported for Origin %s", *body.KeySpec, *body.Origin)
96107

97108
r.logger.Warnf(msg)
98109
return NewValidationExceptionResponse(msg)
@@ -122,7 +133,7 @@ func (r *RequestHandler) CreateKey() Response {
122133

123134
var key cmk.Key
124135

125-
switch *body.CustomerMasterKeySpec {
136+
switch *body.KeySpec {
126137
case "SYMMETRIC_DEFAULT":
127138

128139
if body.KeyUsage != nil && *body.KeyUsage != "ENCRYPT_DECRYPT" {
@@ -142,12 +153,12 @@ func (r *RequestHandler) CreateKey() Response {
142153
}
143154

144155
if *body.KeyUsage != "SIGN_VERIFY" {
145-
msg := fmt.Sprintf("KeyUsage ENCRYPT_DECRYPT is not compatible with KeySpec %s", *body.CustomerMasterKeySpec)
156+
msg := fmt.Sprintf("KeyUsage ENCRYPT_DECRYPT is not compatible with KeySpec %s", *body.KeySpec)
146157
r.logger.Warnf(msg)
147158
return NewValidationExceptionResponse(msg)
148159
}
149160

150-
key, err = cmk.NewEccKey(cmk.CustomerMasterKeySpec(*body.CustomerMasterKeySpec), metadata, *body.Policy)
161+
key, err = cmk.NewEccKey(cmk.KeySpec(*body.KeySpec), metadata, *body.Policy)
151162
if err != nil {
152163
r.logger.Error(err)
153164
return NewInternalFailureExceptionResponse(err.Error())
@@ -162,22 +173,22 @@ func (r *RequestHandler) CreateKey() Response {
162173
}
163174

164175
if !(*body.KeyUsage == "SIGN_VERIFY" || *body.KeyUsage == "ENCRYPT_DECRYPT") {
165-
msg := fmt.Sprintf("KeyUsage %s is not compatible with KeySpec %s", *body.KeyUsage, *body.CustomerMasterKeySpec)
176+
msg := fmt.Sprintf("KeyUsage %s is not compatible with KeySpec %s", *body.KeyUsage, *body.KeySpec)
166177
r.logger.Warnf(msg)
167178
return NewValidationExceptionResponse(msg)
168179
}
169180

170-
key, err = cmk.NewRsaKey(cmk.CustomerMasterKeySpec(*body.CustomerMasterKeySpec), cmk.KeyUsage(*body.KeyUsage), metadata, *body.Policy)
181+
key, err = cmk.NewRsaKey(cmk.KeySpec(*body.KeySpec), cmk.KeyUsage(*body.KeyUsage), metadata, *body.Policy)
171182
if err != nil {
172183
r.logger.Error(err)
173184
return NewInternalFailureExceptionResponse(err.Error())
174185
}
175186

176187
default:
177188

178-
msg := fmt.Sprintf("1 validation error detected: Value '%s' at 'customerMasterKeySpec' "+
189+
msg := fmt.Sprintf("1 validation error detected: Value '%s' at 'KeySpec' "+
179190
"failed to satisfy constraint: Member must satisfy enum value set: [RSA_2048, ECC_NIST_P384, "+
180-
"ECC_NIST_P256, ECC_NIST_P521, RSA_3072, ECC_SECG_P256K1, RSA_4096, SYMMETRIC_DEFAULT]", *body.CustomerMasterKeySpec)
191+
"ECC_NIST_P256, ECC_NIST_P521, RSA_3072, ECC_SECG_P256K1, RSA_4096, SYMMETRIC_DEFAULT]", *body.KeySpec)
181192

182193
r.logger.Warnf(msg)
183194

@@ -193,7 +204,7 @@ func (r *RequestHandler) CreateKey() Response {
193204
return NewInternalFailureExceptionResponse(err.Error())
194205
}
195206

196-
r.logger.Infof("New key created: %s\n", key.GetArn())
207+
r.logger.Infof("New %s key created: %s\n", key.GetMetadata().KeySpec, key.GetArn())
197208

198209
//--------------------------------
199210
// Create the tags

src/handler/generate_data_key_pair.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (r *RequestHandler) generateDataKeyPair() (Response, *GenerateDataKeyPairRe
7171

7272
//----------------------------------
7373

74-
keyPairSpec := cmk.CustomerMasterKeySpec(*body.KeyPairSpec)
74+
keyPairSpec := cmk.KeySpec(*body.KeyPairSpec)
7575

7676
var publicKey interface{}
7777
var privateKey interface{}
@@ -167,7 +167,7 @@ func (r *RequestHandler) generateDataKeyPair() (Response, *GenerateDataKeyPairRe
167167
return NewInvalidKeyUsageException(msg), nil
168168
}
169169

170-
msg := fmt.Sprintf("%s key CustomerMasterKeySpec is %s which is not valid for GenerateDataKeyPair.", k.GetArn(), k.GetMetadata().CustomerMasterKeySpec)
170+
msg := fmt.Sprintf("%s key KeySpec is %s which is not valid for GenerateDataKeyPair.", k.GetArn(), k.GetMetadata().CustomerMasterKeySpec)
171171
r.logger.Warnf(msg)
172172
return NewInvalidKeyUsageException(msg), nil
173173
}

src/handler/get_public_key.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (r *RequestHandler) GetPublicKey() Response {
6666

6767
return NewResponse(200, &struct {
6868
KeyId string
69-
CustomerMasterKeySpec cmk.CustomerMasterKeySpec
69+
CustomerMasterKeySpec cmk.KeySpec
7070
//EncryptionAlgorithms []cmk.EncryptionAlgorithm
7171
SigningAlgorithms []cmk.SigningAlgorithm
7272
KeyUsage cmk.KeyUsage

0 commit comments

Comments
 (0)