Skip to content

Commit 8ded3db

Browse files
Merge pull request #7 from codespree/main
Fixes bug in Hash-ML-DSA
2 parents 8edc744 + 6db2c69 commit 8ded3db

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ml_dsa.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ pub(crate) fn sign_internal<
190190
h256_xof(&[tr, &[0u8], &[ctx.len().to_le_bytes()[0]], ctx, message])
191191
} else {
192192
// 6c. From HashML-DSA.Sign(): 𝑀′ ← BytesToBits(IntegerToBytes(1,1) ∥ IntegerToBytes(|𝑐𝑡𝑥|,1) ∥ 𝑐𝑡𝑥 ∥ OID ∥ PH𝑀 )
193-
h256_xof(&[tr, &[1u8], &[oid.len().to_le_bytes()[0]], ctx, oid, phm])
193+
h256_xof(&[tr, &[1u8], &[ctx.len().to_le_bytes()[0]], ctx, oid, phm])
194194
};
195195
let mut mu = [0u8; 64];
196196
h6.read(&mut mu);
@@ -391,7 +391,7 @@ pub(crate) fn verify_internal<
391391
h256_xof(&[tr, &[0u8], &[ctx.len().to_le_bytes()[0]], ctx, m])
392392
} else {
393393
// 7c. From HashML-DSA.Verify(): 18: 𝑀′ ← BytesToBits(IntegerToBytes(1,1) ∥ IntegerToBytes(|𝑐𝑡𝑥|,1) ∥ 𝑐𝑡𝑥 ∥ OID ∥ PH𝑀 )
394-
h256_xof(&[tr, &[1u8], &[oid.len().to_le_bytes()[0]], ctx, oid, phm])
394+
h256_xof(&[tr, &[1u8], &[ctx.len().to_le_bytes()[0]], ctx, oid, phm])
395395
};
396396
let mut mu = [0u8; 64];
397397
h7.read(&mut mu);

0 commit comments

Comments
 (0)