Skip to content

Commit

Permalink
Fix dilithium conventional CSR creation
Browse files Browse the repository at this point in the history
  • Loading branch information
danvangeest committed Oct 26, 2020
1 parent c20f87f commit 9af8b9a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/certificate/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ func GetPrivateKeyPEMBock(key crypto.Signer) (*pem.Block, error) {
if err != nil {
return nil, err
}
return &pem.Block{Type: "ALT PRIVATE KEY", Bytes: keyBuf}, nil
return &pem.Block{Type: "PRIVATE KEY", Bytes: keyBuf}, nil
default:
return nil, fmt.Errorf("%w: unable to format Key", verror.VcertError)
}
Expand All @@ -470,6 +470,12 @@ func GetEncryptedPrivateKeyPEMBock(key crypto.Signer, password []byte) (*pem.Blo
return nil, err
}
return x509.EncryptPEMBlock(rand.Reader, "EC PRIVATE KEY", b, password, x509.PEMCipherAES256)
case *iqrcrypto.DilithiumPrivateKey:
derKey, err := iqrcrypto.IqrDilithiumExportPrivateKeyPKCS8(key.(*iqrcrypto.DilithiumPrivateKey))
if err != nil {
return nil, err
}
return x509.EncryptPEMBlock(rand.Reader, "PRIVATE KEY", derKey, password, x509.PEMCipherAES256)
default:
return nil, fmt.Errorf("%w: unable to format Key", verror.VcertError)
}
Expand Down

0 comments on commit 9af8b9a

Please sign in to comment.