Skip to content

Commit f9db22d

Browse files
authored
Merge pull request #1555 from smallstep/scep-password
Change scep password type to string
2 parents 86c029d + 52baf52 commit f9db22d

File tree

5 files changed

+12
-17
lines changed

5 files changed

+12
-17
lines changed

api/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func scepFromProvisioner(p *provisioner.SCEP) *models.SCEP {
248248
DecrypterCertificate: []byte(redacted),
249249
DecrypterKeyPEM: []byte(redacted),
250250
DecrypterKeyURI: redacted,
251-
DecrypterKeyPassword: []byte(redacted),
251+
DecrypterKeyPassword: redacted,
252252
EncryptionAlgorithmIdentifier: p.EncryptionAlgorithmIdentifier,
253253
Options: p.Options,
254254
Claims: p.Claims,

api/api_test.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,11 +1584,6 @@ func TestProvisionersResponse_MarshalJSON(t *testing.T) {
15841584
err = json.Unmarshal(b, &key)
15851585
require.NoError(t, err)
15861586

1587-
var encodedPassword bytes.Buffer
1588-
enc := base64.NewEncoder(base64.StdEncoding, &encodedPassword)
1589-
_, err = enc.Write([]byte("super-secret-password"))
1590-
require.NoError(t, err)
1591-
15921587
r := ProvisionersResponse{
15931588
Provisioners: provisioner.List{
15941589
&provisioner.SCEP{
@@ -1602,7 +1597,7 @@ func TestProvisionersResponse_MarshalJSON(t *testing.T) {
16021597
DecrypterCertificate: []byte{1, 2, 3, 4},
16031598
DecrypterKeyPEM: []byte{5, 6, 7, 8},
16041599
DecrypterKeyURI: "softkms:path=/path/to/private.key",
1605-
DecrypterKeyPassword: encodedPassword.Bytes(),
1600+
DecrypterKeyPassword: "super-secret-password",
16061601
},
16071602
&provisioner.JWK{
16081603
EncryptedKey: "eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJlbmMiOiJBMTI4R0NNIiwicDJjIjoxMDAwMDAsInAycyI6IlhOdmYxQjgxSUlLMFA2NUkwcmtGTGcifQ.XaN9zcPQeWt49zchUDm34FECUTHfQTn_.tmNHPQDqR3ebsWfd.9WZr3YVdeOyJh36vvx0VlRtluhvYp4K7jJ1KGDr1qypwZ3ziBVSNbYYQ71du7fTtrnfG1wgGTVR39tWSzBU-zwQ5hdV3rpMAaEbod5zeW6SHd95H3Bvcb43YiiqJFNL5sGZzFb7FqzVmpsZ1efiv6sZaGDHtnCAL6r12UG5EZuqGfM0jGCZitUz2m9TUKXJL5DJ7MOYbFfkCEsUBPDm_TInliSVn2kMJhFa0VOe5wZk5YOuYM3lNYW64HGtbf-llN2Xk-4O9TfeSPizBx9ZqGpeu8pz13efUDT2WL9tWo6-0UE-CrG0bScm8lFTncTkHcu49_a5NaUBkYlBjEiw.thPcx3t1AUcWuEygXIY3Fg",
@@ -1626,7 +1621,7 @@ func TestProvisionersResponse_MarshalJSON(t *testing.T) {
16261621
"decrypterCertificate": []byte("*** REDACTED ***"),
16271622
"decrypterKey": "*** REDACTED ***",
16281623
"decrypterKeyPEM": []byte("*** REDACTED ***"),
1629-
"decrypterKeyPassword": []byte("*** REDACTED ***"),
1624+
"decrypterKeyPassword": "*** REDACTED ***",
16301625
"minimumPublicKeyLength": 2048,
16311626
"encryptionAlgorithmIdentifier": 2,
16321627
},
@@ -1668,7 +1663,7 @@ func TestProvisionersResponse_MarshalJSON(t *testing.T) {
16681663
DecrypterCertificate: []byte{1, 2, 3, 4},
16691664
DecrypterKeyPEM: []byte{5, 6, 7, 8},
16701665
DecrypterKeyURI: "softkms:path=/path/to/private.key",
1671-
DecrypterKeyPassword: encodedPassword.Bytes(),
1666+
DecrypterKeyPassword: "super-secret-password",
16721667
},
16731668
&provisioner.JWK{
16741669
EncryptedKey: "eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJlbmMiOiJBMTI4R0NNIiwicDJjIjoxMDAwMDAsInAycyI6IlhOdmYxQjgxSUlLMFA2NUkwcmtGTGcifQ.XaN9zcPQeWt49zchUDm34FECUTHfQTn_.tmNHPQDqR3ebsWfd.9WZr3YVdeOyJh36vvx0VlRtluhvYp4K7jJ1KGDr1qypwZ3ziBVSNbYYQ71du7fTtrnfG1wgGTVR39tWSzBU-zwQ5hdV3rpMAaEbod5zeW6SHd95H3Bvcb43YiiqJFNL5sGZzFb7FqzVmpsZ1efiv6sZaGDHtnCAL6r12UG5EZuqGfM0jGCZitUz2m9TUKXJL5DJ7MOYbFfkCEsUBPDm_TInliSVn2kMJhFa0VOe5wZk5YOuYM3lNYW64HGtbf-llN2Xk-4O9TfeSPizBx9ZqGpeu8pz13efUDT2WL9tWo6-0UE-CrG0bScm8lFTncTkHcu49_a5NaUBkYlBjEiw.thPcx3t1AUcWuEygXIY3Fg",

api/models/scep.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type SCEP struct {
2828
DecrypterCertificate []byte `json:"decrypterCertificate"`
2929
DecrypterKeyPEM []byte `json:"decrypterKeyPEM"`
3030
DecrypterKeyURI string `json:"decrypterKey"`
31-
DecrypterKeyPassword []byte `json:"decrypterKeyPassword"`
31+
DecrypterKeyPassword string `json:"decrypterKeyPassword"`
3232
EncryptionAlgorithmIdentifier int `json:"encryptionAlgorithmIdentifier"`
3333
Options *provisioner.Options `json:"options,omitempty"`
3434
Claims *provisioner.Claims `json:"claims,omitempty"`

authority/provisioner/scep.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type SCEP struct {
4747
DecrypterCertificate []byte `json:"decrypterCertificate,omitempty"`
4848
DecrypterKeyPEM []byte `json:"decrypterKeyPEM,omitempty"`
4949
DecrypterKeyURI string `json:"decrypterKey,omitempty"`
50-
DecrypterKeyPassword []byte `json:"decrypterKeyPassword,omitempty"`
50+
DecrypterKeyPassword string `json:"decrypterKeyPassword,omitempty"`
5151

5252
// Numerical identifier for the ContentEncryptionAlgorithm as defined in github.com/mozilla-services/pkcs7
5353
// at https://github.com/mozilla-services/pkcs7/blob/33d05740a3526e382af6395d3513e73d4e66d1cb/encrypt.go#L63
@@ -289,14 +289,14 @@ func (s *SCEP) Init(config Config) (err error) {
289289
}
290290
if s.decrypter, err = kmsDecrypter.CreateDecrypter(&kmsapi.CreateDecrypterRequest{
291291
DecryptionKeyPEM: decryptionKeyPEM,
292-
Password: s.DecrypterKeyPassword,
292+
Password: []byte(s.DecrypterKeyPassword),
293293
PasswordPrompter: kmsapi.NonInteractivePasswordPrompter,
294294
}); err != nil {
295295
return fmt.Errorf("failed creating decrypter: %w", err)
296296
}
297297
if s.signer, err = s.keyManager.CreateSigner(&kmsapi.CreateSignerRequest{
298298
SigningKeyPEM: decryptionKeyPEM, // TODO(hs): support distinct signer key in the future?
299-
Password: s.DecrypterKeyPassword,
299+
Password: []byte(s.DecrypterKeyPassword),
300300
PasswordPrompter: kmsapi.NonInteractivePasswordPrompter,
301301
}); err != nil {
302302
return fmt.Errorf("failed creating signer: %w", err)
@@ -331,14 +331,14 @@ func (s *SCEP) Init(config Config) (err error) {
331331
}
332332
if s.decrypter, err = kmsDecrypter.CreateDecrypter(&kmsapi.CreateDecrypterRequest{
333333
DecryptionKey: decryptionKeyURI,
334-
Password: s.DecrypterKeyPassword,
334+
Password: []byte(s.DecrypterKeyPassword),
335335
PasswordPrompter: kmsapi.NonInteractivePasswordPrompter,
336336
}); err != nil {
337337
return fmt.Errorf("failed creating decrypter: %w", err)
338338
}
339339
if s.signer, err = s.keyManager.CreateSigner(&kmsapi.CreateSignerRequest{
340340
SigningKey: decryptionKeyURI, // TODO(hs): support distinct signer key in the future?
341-
Password: s.DecrypterKeyPassword,
341+
Password: []byte(s.DecrypterKeyPassword),
342342
PasswordPrompter: kmsapi.NonInteractivePasswordPrompter,
343343
}); err != nil {
344344
return fmt.Errorf("failed creating signer: %w", err)

authority/provisioners.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ func ProvisionerToCertificates(p *linkedca.Provisioner) (provisioner.Interface,
992992
s.DecrypterCertificate = decrypter.Certificate
993993
s.DecrypterKeyPEM = decrypter.Key
994994
s.DecrypterKeyURI = decrypter.KeyUri
995-
s.DecrypterKeyPassword = decrypter.KeyPassword
995+
s.DecrypterKeyPassword = string(decrypter.KeyPassword)
996996
}
997997
return s, nil
998998
case *linkedca.ProvisionerDetails_Nebula:
@@ -1255,7 +1255,7 @@ func ProvisionerToLinkedca(p provisioner.Interface) (*linkedca.Provisioner, erro
12551255
Certificate: p.DecrypterCertificate,
12561256
Key: p.DecrypterKeyPEM,
12571257
KeyUri: p.DecrypterKeyURI,
1258-
KeyPassword: p.DecrypterKeyPassword,
1258+
KeyPassword: []byte(p.DecrypterKeyPassword),
12591259
},
12601260
},
12611261
},

0 commit comments

Comments
 (0)