Skip to content

Commit f11ed96

Browse files
committed
Fix to GenerateChallenge
crypto/x509 now enforces that rsa public keys must have NULL parameters. The old no longer solves the issue and instead will silently fail when parsing the key, ultimately causing a null pointer dereference at (pubkey := cert.PublicKey.(*rsa.PublicKey)). Currently working with crypto/x509 to add support for RSAES-OAEP keys golang/go#30416
1 parent 493ca9f commit f11ed96

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

verification/verification.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ func GenerateChallenge(ekcert []byte, aikpub []byte, secret []byte) (asymenc []b
7171
* The EK certificate has an OID for rsaesOaep which will break
7272
* parsing. Replace it with rsaEncryption instead.
7373
*/
74-
ekcert = bytes.Replace(ekcert, []byte{0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x07}, []byte{0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01}, 1)
7574
cert, err := x509.ParseCertificate(ekcert)
75+
if err != nil {
76+
return nil, nil, fmt.Errorf("ParseCertificate failed: %v", err)
77+
}
7678
pubkey := cert.PublicKey.(*rsa.PublicKey)
7779

7880
asymplain := []byte{0x00, 0x00, 0x00, 0x06, 0x00, 0xff, 0x00, 0x10}

0 commit comments

Comments
 (0)