Skip to content

Commit 3804f98

Browse files
committed
corrected use of BOTH in MLKEMPrivateKeyParameters.
Removed null checks on "both" construction for ML-KEM and ML-DSA
1 parent ca4632b commit 3804f98

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

core/src/main/java/org/bouncycastle/pqc/crypto/mlkem/MLKEMPrivateKeyParameters.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public MLKEMPrivateKeyParameters(MLKEMParameters params, byte[] encoding, MLKEMP
8181
}
8282
}
8383

84-
this.prefFormat = BOTH;
84+
this.prefFormat = (seed == null) ? EXPANDED_KEY : BOTH;
8585
}
8686

8787
private MLKEMPrivateKeyParameters(MLKEMPrivateKeyParameters params, int preferredFormat)

core/src/main/java/org/bouncycastle/pqc/crypto/util/PrivateKeyInfoFactory.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -395,16 +395,10 @@ private static XMSSPrivateKey xmssCreateKeyStructure(XMSSPrivateKeyParameters ke
395395
private static ASN1Sequence getBasicPQCEncoding(byte[] seed, byte[] expanded)
396396
{
397397
ASN1EncodableVector v = new ASN1EncodableVector(2);
398-
399-
if (seed != null)
400-
{
401-
v.add(new DEROctetString(seed));
402-
}
403398

404-
if (expanded != null)
405-
{
406-
v.add(new DEROctetString(expanded));
407-
}
399+
v.add(new DEROctetString(seed));
400+
401+
v.add(new DEROctetString(expanded));
408402

409403
return new DERSequence(v);
410404
}

0 commit comments

Comments
 (0)