Skip to content

Commit

Permalink
Change x509 CSR hash algorithm for TPM RSA3072 keys
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-krieger committed Oct 1, 2024
1 parent 865353b commit 406b514
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion examples/cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ func di() (err error) { //nolint:gocyclo
}
hmacSha256, hmacSha384 := hmac.New(sha256.New, secret), hmac.New(sha512.New384, secret)

var sigAlg x509.SignatureAlgorithm
var keyType protocol.KeyType
var key crypto.Signer
switch diKey {
Expand All @@ -240,6 +241,7 @@ func di() (err error) { //nolint:gocyclo
keyType = protocol.Rsa2048RestrKeyType
key, err = rsa.GenerateKey(rand.Reader, 2048)
case "rsa3072":
sigAlg = x509.SHA384WithRSA
keyType = protocol.RsaPkcsKeyType
key, err = rsa.GenerateKey(rand.Reader, 3072)
default:
Expand All @@ -261,7 +263,8 @@ func di() (err error) { //nolint:gocyclo

// Generate Java implementation-compatible mfg string
csrDER, err := x509.CreateCertificateRequest(rand.Reader, &x509.CertificateRequest{
Subject: pkix.Name{CommonName: "device.go-fdo"},
Subject: pkix.Name{CommonName: "device.go-fdo"},
SignatureAlgorithm: sigAlg,
}, key)
if err != nil {
return fmt.Errorf("error creating CSR for device certificate chain: %w", err)
Expand Down

0 comments on commit 406b514

Please sign in to comment.