Skip to content

Commit c30fd65

Browse files
committed
missing file - mu bounds checking
1 parent 9ec242f commit c30fd65

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

core/src/main/java/org/bouncycastle/pqc/crypto/mldsa/MLDSASigner.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ public byte[] generateMu()
106106
public byte[] generateMuSignature(byte[] mu)
107107
throws CryptoException, DataLengthException
108108
{
109+
if (mu.length != MLDSAEngine.CrhBytes)
110+
{
111+
throw new DataLengthException("mu value must be " + MLDSAEngine.CrhBytes + " bytes");
112+
}
109113
byte[] rnd = new byte[MLDSAEngine.RndBytes];
110114
if (random != null)
111115
{
@@ -140,6 +144,11 @@ public byte[] generateSignature()
140144

141145
public boolean verifyMu(byte[] mu)
142146
{
147+
if (mu.length != MLDSAEngine.CrhBytes)
148+
{
149+
throw new DataLengthException("mu value must be " + MLDSAEngine.CrhBytes + " bytes");
150+
}
151+
143152
boolean isTrue = engine.verifyInternalMu(mu);
144153

145154
reset();
@@ -158,6 +167,11 @@ public boolean verifySignature(byte[] signature)
158167

159168
public boolean verifyMuSignature(byte[] mu, byte[] signature)
160169
{
170+
if (mu.length != MLDSAEngine.CrhBytes)
171+
{
172+
throw new DataLengthException("mu value must be " + MLDSAEngine.CrhBytes + " bytes");
173+
}
174+
161175
msgDigest.reset();
162176

163177
boolean isTrue = engine.verifyInternalMuSignature(mu, signature, signature.length, msgDigest, pubKey.rho, pubKey.t1);

0 commit comments

Comments
 (0)