diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-10-20 18:23:49 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-10-20 18:23:49 +0700 |
commit | 1a2ca44e3fa181180e9aa65692a55111c32353f1 (patch) | |
tree | e6af5a363b8fb35ad094dc0d5a6d7d9dde16a78d /crypto/test | |
parent | Add Inverse64 method (diff) | |
download | BouncyCastle.NET-ed25519-1a2ca44e3fa181180e9aa65692a55111c32353f1.tar.xz |
Fix BinaryReader usage in Pqc.Crypto.Lms
Diffstat (limited to 'crypto/test')
-rw-r--r-- | crypto/test/src/pqc/crypto/lms/test/LmsTests.cs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/crypto/test/src/pqc/crypto/lms/test/LmsTests.cs b/crypto/test/src/pqc/crypto/lms/test/LmsTests.cs index 5a7a84031..a5bc26252 100644 --- a/crypto/test/src/pqc/crypto/lms/test/LmsTests.cs +++ b/crypto/test/src/pqc/crypto/lms/test/LmsTests.cs @@ -42,10 +42,22 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests LMOtsSignature sig = LM_OTS.LMOtsGenerateSignature(privateKey, ctx.GetQ(), ctx.C); Assert.True(LM_OTS.LMOtsValidateSignature(publicKey, sig, ms, false)); - // Vandalise signature + // Recreate signature + { + byte[] recreatedSignature = sig.GetEncoded(); + Assert.True(LM_OTS.LMOtsValidateSignature(publicKey, LMOtsSignature.GetInstance(recreatedSignature), ms, false)); + } + + // Recreate public key. + { + byte[] recreatedPubKey = Arrays.Clone(publicKey.GetEncoded()); + Assert.True(LM_OTS.LMOtsValidateSignature(LMOtsPublicKey.GetInstance(recreatedPubKey), sig, ms, false)); + } + + // Vandalise signature { - byte[] vandalisedSignature = sig.GetEncoded(); // Arrays.clone(sig); + byte[] vandalisedSignature = sig.GetEncoded(); vandalisedSignature[256] ^= 1; // Single bit error Assert.False(LM_OTS.LMOtsValidateSignature(publicKey, LMOtsSignature.GetInstance(vandalisedSignature), ms, false)); } |