Skip to content

Commit 13e9507

Browse files
committed
Allow rsa.PSSSaltLengthEqualsHash as option
This commit adds support to the salt length set to rsa.PSSSaltLengthEqualsHash when signing with an RSA key. This is currently supported, but the user must sspecify the length to the digest size. Adding rsa.PSSSaltLengthEqualsHash allows using a key generated by the TPM for TLS client authentication, Go will set this option by default if an RSA key is used. Signed-off-by: Mariano Cano <[email protected]>
1 parent 02cf9e2 commit 13e9507

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

attest/application_key_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,18 @@ func testKeySign(t *testing.T, tpm *TPM) {
288288
},
289289
digest: []byte("1234567890123456789012345678901212345678901234567890123456789012"),
290290
},
291+
{
292+
name: "RSA2048-PSS-SHA256, explicit salt len",
293+
keyOpts: &KeyConfig{
294+
Algorithm: RSA,
295+
Size: 2048,
296+
},
297+
signOpts: &rsa.PSSOptions{
298+
SaltLength: rsa.PSSSaltLengthEqualsHash,
299+
Hash: crypto.SHA256,
300+
},
301+
digest: []byte("12345678901234567890123456789012"),
302+
},
291303
{
292304
name: "RSA2048-PSS-SHA256, explicit salt len",
293305
keyOpts: &KeyConfig{

attest/wrapped_tpm20.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,8 @@ func signRSA(rw io.ReadWriter, key tpmutil.Handle, digest []byte, opts crypto.Si
652652
}
653653

654654
if pss, ok := opts.(*rsa.PSSOptions); ok {
655-
if pss.SaltLength != rsa.PSSSaltLengthAuto && pss.SaltLength != len(digest) {
656-
return nil, fmt.Errorf("PSS salt length %d is incorrect, expected rsa.PSSSaltLengthAuto or %d", pss.SaltLength, len(digest))
655+
if pss.SaltLength != rsa.PSSSaltLengthAuto && pss.SaltLength != rsa.PSSSaltLengthEqualsHash && pss.SaltLength != len(digest) {
656+
return nil, fmt.Errorf("PSS salt length %d is incorrect, expected rsa.PSSSaltLengthAuto, rsa.PSSSaltLengthEqualsHash or %d", pss.SaltLength, len(digest))
657657
}
658658
scheme.Alg = tpm2.AlgRSAPSS
659659
}

0 commit comments

Comments
 (0)