Skip to content

Commit b0dffe2

Browse files
committed
Fix NPE creating ML-DSA PrivateKeyInfo (when no seed)
- actually the public key is derivable, so don't encode it
1 parent 429e25e commit b0dffe2

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

crypto/src/pkcs/PrivateKeyInfoFactory.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,8 @@ public static PrivateKeyInfo CreatePrivateKeyInfo(AsymmetricKeyParameter private
253253
if (seed != null)
254254
return PrivateKeyInfo.Create(algID, new DerOctetString(seed), attributes, publicKey: null);
255255

256+
// NOTE: The public key can be derived from the private key
256257
DerBitString publicKey = null;
257-
MLDsaPublicKeyParameters mlDsaPubKey = mlDsaKey.GetPublicKey();
258-
if (mlDsaPubKey != null)
259-
{
260-
// TODO[pqc] Avoid redundant copies?
261-
publicKey = new DerBitString(publicKey.GetEncoded());
262-
}
263258

264259
return PrivateKeyInfo.Create(algID, new DerOctetString(mlDsaKey.GetEncoded()), attributes, publicKey);
265260
}

0 commit comments

Comments
 (0)