diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-10-22 02:17:26 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-10-22 02:17:26 +0700 |
commit | c9f432da291298401537c8cfb1314134f21d66ac (patch) | |
tree | c11169c8bfa929f13826eca3625fda914f9313c4 /crypto/test | |
parent | Remove extraneous class (diff) | |
download | BouncyCastle.NET-ed25519-c9f432da291298401537c8cfb1314134f21d66ac.tar.xz |
Refactoring in Pqc.Crypto.Lms
- add missing factory entries
Diffstat (limited to 'crypto/test')
-rw-r--r-- | crypto/test/src/pqc/crypto/lms/test/HssTests.cs | 214 | ||||
-rw-r--r-- | crypto/test/src/pqc/crypto/lms/test/LmsKeyGenTests.cs | 8 | ||||
-rw-r--r-- | crypto/test/src/pqc/crypto/lms/test/LmsTests.cs | 50 | ||||
-rw-r--r-- | crypto/test/src/pqc/crypto/lms/test/TypeTests.cs | 32 | ||||
-rw-r--r-- | crypto/test/src/pqc/crypto/test/HSSTest.cs | 50 | ||||
-rw-r--r-- | crypto/test/src/pqc/crypto/test/LMSTest.cs | 26 |
6 files changed, 190 insertions, 190 deletions
diff --git a/crypto/test/src/pqc/crypto/lms/test/HssTests.cs b/crypto/test/src/pqc/crypto/lms/test/HssTests.cs index fcc3cb9c6..cbfbdbdd7 100644 --- a/crypto/test/src/pqc/crypto/lms/test/HssTests.cs +++ b/crypto/test/src/pqc/crypto/lms/test/HssTests.cs @@ -27,19 +27,19 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests FixedSecureRandom.Source[] source = { new FixedSecureRandom.Source(fixedSource) }; SecureRandom rand = new FixedSecureRandom(source); - HSSPrivateKeyParameters generatedPrivateKey = HSS.GenerateHssKeyPair( - new HSSKeyGenerationParameters(new LMSParameters[] + HssPrivateKeyParameters generatedPrivateKey = Hss.GenerateHssKeyPair( + new HssKeyGenerationParameters(new LmsParameters[] { - new LMSParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4), - new LMSParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w2), + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4), + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w2), }, rand) ); - HSSSignature sigFromGeneratedPrivateKey = HSS.GenerateSignature(generatedPrivateKey, Hex.Decode("ABCDEF")); + HssSignature sigFromGeneratedPrivateKey = Hss.GenerateSignature(generatedPrivateKey, Hex.Decode("ABCDEF")); byte[] keyPairEnc = generatedPrivateKey.GetEncoded(); - HSSPrivateKeyParameters reconstructedPrivateKey = HSSPrivateKeyParameters.GetInstance(keyPairEnc); + HssPrivateKeyParameters reconstructedPrivateKey = HssPrivateKeyParameters.GetInstance(keyPairEnc); Assert.True(reconstructedPrivateKey.Equals(generatedPrivateKey)); reconstructedPrivateKey.GetPublicKey(); @@ -54,7 +54,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests // // Check the reconstructed key can verify a signature. // - Assert.True(HSS.VerifySignature(reconstructedPrivateKey.GetPublicKey(), sigFromGeneratedPrivateKey, + Assert.True(Hss.VerifySignature(reconstructedPrivateKey.GetPublicKey(), sigFromGeneratedPrivateKey, Hex.Decode("ABCDEF"))); } @@ -67,10 +67,10 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests { var blocks = LoadVector("pqc.lms.testcase_1.txt"); - HSSPublicKeyParameters publicKey = HSSPublicKeyParameters.GetInstance(blocks[0]); + HssPublicKeyParameters publicKey = HssPublicKeyParameters.GetInstance(blocks[0]); byte[] message = blocks[1]; - HSSSignature signature = HSSSignature.GetInstance(blocks[2], publicKey.L); - Assert.True(HSS.VerifySignature(publicKey, signature, message), "Test Case 1 "); + HssSignature signature = HssSignature.GetInstance(blocks[2], publicKey.L); + Assert.True(Hss.VerifySignature(publicKey, signature, message), "Test Case 1 "); } /** @@ -82,16 +82,16 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests { var blocks = LoadVector("pqc.lms.testcase_2.txt"); - HSSPublicKeyParameters publicKey = HSSPublicKeyParameters.GetInstance(blocks[0]); + HssPublicKeyParameters publicKey = HssPublicKeyParameters.GetInstance(blocks[0]); byte[] message = blocks[1]; byte[] sig = blocks[2]; - HSSSignature signature = HSSSignature.GetInstance(sig, publicKey.L); - Assert.True(HSS.VerifySignature(publicKey, signature, message), "Test Case 2 Signature"); + HssSignature signature = HssSignature.GetInstance(sig, publicKey.L); + Assert.True(Hss.VerifySignature(publicKey, signature, message), "Test Case 2 Signature"); - LMSPublicKeyParameters lmsPub = LMSPublicKeyParameters.GetInstance(blocks[3]); - LMSSignature lmsSignature = LMSSignature.GetInstance(blocks[4]); + LmsPublicKeyParameters lmsPub = LmsPublicKeyParameters.GetInstance(blocks[3]); + LmsSignature lmsSignature = LmsSignature.GetInstance(blocks[4]); - Assert.True(LMS.VerifySignature(lmsPub, lmsSignature, message), "Test Case 2 Signature 2"); + Assert.True(Lms.VerifySignature(lmsPub, lmsSignature, message), "Test Case 2 Signature 2"); } private IList<byte[]> LoadVector(string vector) @@ -132,9 +132,9 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests { byte[] seed = Hex.Decode("558b8966c48ae9cb898b423c83443aae014a72f1b1ab5cc85cf1d892903b5439"); int level = 0; - LMSPrivateKeyParameters lmsPrivateKey = LMS.GenerateKeys(LMSigParameters.GetParametersByID(6), + LmsPrivateKeyParameters lmsPrivateKey = Lms.GenerateKeys(LMSigParameters.GetParametersByID(6), LMOtsParameters.GetParametersByID(3), level, Hex.Decode("d08fabd4a2091ff0a8cb4ed834e74534"), seed); - LMSPublicKeyParameters publicKey = lmsPrivateKey.GetPublicKey(); + LmsPublicKeyParameters publicKey = lmsPrivateKey.GetPublicKey(); Assert.True(Arrays.AreEqual(publicKey.GetT1(), Hex.Decode("32a58885cd9ba0431235466bff9651c6c92124404d45fa53cf161c28f1ad5a8e"))); Assert.True(Arrays.AreEqual(publicKey.GetI(), Hex.Decode("d08fabd4a2091ff0a8cb4ed834e74534"))); @@ -149,9 +149,9 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests { byte[] seed = Hex.Decode("a1c4696e2608035a886100d05cd99945eb3370731884a8235e2fb3d4d71f2547"); int level = 1; - LMSPrivateKeyParameters lmsPrivateKey = LMS.GenerateKeys(LMSigParameters.GetParametersByID(5), + LmsPrivateKeyParameters lmsPrivateKey = Lms.GenerateKeys(LMSigParameters.GetParametersByID(5), LMOtsParameters.GetParametersByID(4), level, Hex.Decode("215f83b7ccb9acbcd08db97b0d04dc2b"), seed); - LMSPublicKeyParameters publicKey = lmsPrivateKey.GetPublicKey(); + LmsPublicKeyParameters publicKey = lmsPrivateKey.GetPublicKey(); Assert.True(Arrays.AreEqual(publicKey.GetT1(), Hex.Decode("a1cd035833e0e90059603f26e07ad2aad152338e7a5e5984bcd5f7bb4eba40b7"))); Assert.True(Arrays.AreEqual(publicKey.GetI(), Hex.Decode("215f83b7ccb9acbcd08db97b0d04dc2b"))); @@ -174,11 +174,11 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests FixedSecureRandom.Source[] source = { new FixedSecureRandom.Source(fixedSource) }; SecureRandom rand = new FixedSecureRandom(source); - HSSPrivateKeyParameters keyPair = HSS.GenerateHssKeyPair( - new HSSKeyGenerationParameters(new LMSParameters[] + HssPrivateKeyParameters keyPair = Hss.GenerateHssKeyPair( + new HssKeyGenerationParameters(new LmsParameters[] { - new LMSParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4), - new LMSParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w2), + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4), + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w2), }, rand)); // @@ -194,7 +194,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests // Check that HSS public keys have value equality after deserialization. // Use external sourced pk for deserialization. // - Assert.True(keyPair.GetPublicKey().Equals(HSSPublicKeyParameters.GetInstance(Hex.Decode(expectedPk))), + Assert.True(keyPair.GetPublicKey().Equals(HssPublicKeyParameters.GetInstance(Hex.Decode(expectedPk))), "HSSPrivateKeyParameterss equal are deserialization"); // @@ -205,11 +205,11 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests FixedSecureRandom.Source[] source1 = { new FixedSecureRandom.Source(fixedSource) }; SecureRandom rand1 = new FixedSecureRandom(source1); - HSSPrivateKeyParameters regenKeyPair = HSS.GenerateHssKeyPair( - new HSSKeyGenerationParameters(new LMSParameters[] + HssPrivateKeyParameters regenKeyPair = Hss.GenerateHssKeyPair( + new HssKeyGenerationParameters(new LmsParameters[] { - new LMSParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4), - new LMSParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w2), + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4), + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w2), }, rand1)); Assert.True( @@ -231,8 +231,8 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests // // Deserialize them and see if they still equal. // - LMSPrivateKeyParameters pk1O = LMSPrivateKeyParameters.GetInstance(pk1); - LMSPrivateKeyParameters pk2O = LMSPrivateKeyParameters.GetInstance(pk2); + LmsPrivateKeyParameters pk1O = LmsPrivateKeyParameters.GetInstance(pk1); + LmsPrivateKeyParameters pk2O = LmsPrivateKeyParameters.GetInstance(pk2); Assert.True(pk1O.Equals(pk2O), "LmsPrivateKey still equal after deserialization"); @@ -249,11 +249,11 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests // Use a real secure random this time. SecureRandom rand1 = new SecureRandom(); - HSSPrivateKeyParameters differentKey = HSS.GenerateHssKeyPair( - new HSSKeyGenerationParameters(new LMSParameters[] + HssPrivateKeyParameters differentKey = Hss.GenerateHssKeyPair( + new HssKeyGenerationParameters(new LmsParameters[] { - new LMSParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4), - new LMSParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w2), + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4), + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w2), }, rand1) ); @@ -273,8 +273,8 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests // // Deserialize them and see if they still equal. // - LMSPrivateKeyParameters pk1O = LMSPrivateKeyParameters.GetInstance(pk1); - LMSPrivateKeyParameters pk2O = LMSPrivateKeyParameters.GetInstance(pk2); + LmsPrivateKeyParameters pk1O = LmsPrivateKeyParameters.GetInstance(pk1); + LmsPrivateKeyParameters pk2O = LmsPrivateKeyParameters.GetInstance(pk2); Assert.False(pk1O.Equals(pk2O), "LmsPrivateKey not suddenly equal after deserialization"); } @@ -355,22 +355,22 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests // // Deserialize pub key from reference impl. // - HSSPublicKeyParameters vectorSourcedPubKey = HSSPublicKeyParameters.GetInstance(hssPubEnc); - var lmsParams = new List<LMSParameters>(); + HssPublicKeyParameters vectorSourcedPubKey = HssPublicKeyParameters.GetInstance(hssPubEnc); + var lmsParams = new List<LmsParameters>(); for (int i = 0; i != lmsParameters.Count; i++) { - lmsParams.Add(new LMSParameters(lmsParameters[i], lmOtsParameters[i])); + lmsParams.Add(new LmsParameters(lmsParameters[i], lmOtsParameters[i])); } // // Using our fixed entropy source generate hss keypair // - LMSParameters[] lmsParamsArray = new LMSParameters[lmsParams.Count]; + LmsParameters[] lmsParamsArray = new LmsParameters[lmsParams.Count]; lmsParams.CopyTo(lmsParamsArray, 0); - HSSPrivateKeyParameters keyPair = HSS.GenerateHssKeyPair( - new HSSKeyGenerationParameters( + HssPrivateKeyParameters keyPair = Hss.GenerateHssKeyPair( + new HssKeyGenerationParameters( lmsParamsArray, fixRnd) ); @@ -378,7 +378,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests // Public Key should match vector. // Encoded value equality. - HSSPublicKeyParameters generatedPubKey = keyPair.GetPublicKey(); + HssPublicKeyParameters generatedPubKey = keyPair.GetPublicKey(); Assert.True(Arrays.AreEqual(hssPubEnc, generatedPubKey.GetEncoded())); // Value equality. @@ -388,12 +388,12 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests // // Generate a signature using the keypair we generated. // - HSSSignature sig = HSS.GenerateSignature(keyPair, message); + HssSignature sig = Hss.GenerateSignature(keyPair, message); - HSSSignature signatureFromVector = null; + HssSignature signatureFromVector = null; if (!Arrays.AreEqual(sig.GetEncoded(), encodedSigFromVector)) { - signatureFromVector = HSSSignature.GetInstance(encodedSigFromVector, d); + signatureFromVector = HssSignature.GetInstance(encodedSigFromVector, d); signatureFromVector.Equals(sig); } @@ -401,13 +401,13 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests Assert.True(Arrays.AreEqual(sig.GetEncoded(), encodedSigFromVector)); // Check we can verify our generated signature with the vectors sourced public key. - Assert.True(HSS.VerifySignature(vectorSourcedPubKey, sig, message)); + Assert.True(Hss.VerifySignature(vectorSourcedPubKey, sig, message)); // Deserialize the signature from the vector. - signatureFromVector = HSSSignature.GetInstance(encodedSigFromVector, d); + signatureFromVector = HssSignature.GetInstance(encodedSigFromVector, d); // Can we verify signature from vector with public key from vector. - Assert.True(HSS.VerifySignature(vectorSourcedPubKey, signatureFromVector, message)); + Assert.True(Hss.VerifySignature(vectorSourcedPubKey, signatureFromVector, message)); // // Check our generated signature and the one deserialized from the vector @@ -486,23 +486,23 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests FixedSecureRandom.Source[] source = { new FixedSecureRandom.Source(fixedESBuffer.ToArray()) }; FixedSecureRandom fixRnd = new FixedSecureRandom(source); fixedESBuffer.SetLength(0); - var lmsParams = new List<LMSParameters>(); + var lmsParams = new List<LmsParameters>(); for (int i = 0; i != lmsParameters.Count; i++) { - lmsParams.Add(new LMSParameters(lmsParameters[i], lmOtsParameters[i])); + lmsParams.Add(new LmsParameters(lmsParameters[i], lmOtsParameters[i])); } - LMSParameters[] lmsParamsArray = new LMSParameters[lmsParams.Count]; + LmsParameters[] lmsParamsArray = new LmsParameters[lmsParams.Count]; lmsParams.CopyTo(lmsParamsArray, 0); - HSSPrivateKeyParameters keyPair = HSS.GenerateHssKeyPair( - new HSSKeyGenerationParameters(lmsParamsArray, fixRnd) + HssPrivateKeyParameters keyPair = Hss.GenerateHssKeyPair( + new HssKeyGenerationParameters(lmsParamsArray, fixRnd) ); Assert.True(Arrays.AreEqual(hssPubEnc, keyPair.GetPublicKey().GetEncoded())); - HSSPublicKeyParameters pubKeyFromVector = HSSPublicKeyParameters.GetInstance(hssPubEnc); - HSSPublicKeyParameters pubKeyGenerated = null; + HssPublicKeyParameters pubKeyFromVector = HssPublicKeyParameters.GetInstance(hssPubEnc); + HssPublicKeyParameters pubKeyGenerated = null; Assert.AreEqual(1024, keyPair.GetUsagesRemaining()); @@ -512,11 +512,11 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests // Split the space up with a shard. // - HSSPrivateKeyParameters shard1 = keyPair.ExtractKeyShard(500); + HssPrivateKeyParameters shard1 = keyPair.ExtractKeyShard(500); pubKeyGenerated = shard1.GetPublicKey(); - HSSPrivateKeyParameters pair = shard1; + HssPrivateKeyParameters pair = shard1; int c = 0; for (int i = 0; i < keyPair.IndexLimit; i++) @@ -525,7 +525,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests { try { - HSS.IncrementIndex(pair); + Hss.IncrementIndex(pair); Assert.Fail("shard should be exhausted."); } catch (Exception ex) @@ -541,17 +541,17 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests if (i % 5 == 0) { - HSSSignature sigCalculated = HSS.GenerateSignature(pair, message); + HssSignature sigCalculated = Hss.GenerateSignature(pair, message); Assert.True(Arrays.AreEqual(sigCalculated.GetEncoded(), sigVectors[c])); - Assert.True(HSS.VerifySignature(pubKeyFromVector, sigCalculated, message)); - Assert.True(HSS.VerifySignature(pubKeyGenerated, sigCalculated, message)); + Assert.True(Hss.VerifySignature(pubKeyFromVector, sigCalculated, message)); + Assert.True(Hss.VerifySignature(pubKeyGenerated, sigCalculated, message)); - HSSSignature sigFromVector = HSSSignature.GetInstance(sigVectors[c], + HssSignature sigFromVector = HssSignature.GetInstance(sigVectors[c], pubKeyFromVector.L); - Assert.True(HSS.VerifySignature(pubKeyFromVector, sigFromVector, message)); - Assert.True(HSS.VerifySignature(pubKeyGenerated, sigFromVector, message)); + Assert.True(Hss.VerifySignature(pubKeyFromVector, sigFromVector, message)); + Assert.True(Hss.VerifySignature(pubKeyGenerated, sigFromVector, message)); Assert.True(sigCalculated.Equals(sigFromVector)); @@ -561,7 +561,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests } else { - HSS.IncrementIndex(pair); + Hss.IncrementIndex(pair); } } } @@ -576,32 +576,32 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests [Test] public void TestRemaining() { - HSSPrivateKeyParameters keyPair = HSS.GenerateHssKeyPair( - new HSSKeyGenerationParameters(new LMSParameters[] + HssPrivateKeyParameters keyPair = Hss.GenerateHssKeyPair( + new HssKeyGenerationParameters(new LmsParameters[] { - new LMSParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w2), - new LMSParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w2) + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w2), + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w2) }, new SecureRandom()) ); - LMSPrivateKeyParameters lmsKey = keyPair.GetKeys()[keyPair.L - 1]; + LmsPrivateKeyParameters lmsKey = keyPair.GetKeys()[keyPair.L - 1]; // // There should be a max of 32768 signatures for this key. // Assert.True(1024 == keyPair.GetUsagesRemaining()); - HSS.IncrementIndex(keyPair); - HSS.IncrementIndex(keyPair); - HSS.IncrementIndex(keyPair); - HSS.IncrementIndex(keyPair); - HSS.IncrementIndex(keyPair); + Hss.IncrementIndex(keyPair); + Hss.IncrementIndex(keyPair); + Hss.IncrementIndex(keyPair); + Hss.IncrementIndex(keyPair); + Hss.IncrementIndex(keyPair); Assert.True(5 == keyPair.GetIndex()); // Next key is at index 5! Assert.True(1024 - 5 == keyPair.GetUsagesRemaining()); - HSSPrivateKeyParameters shard = keyPair.ExtractKeyShard(10); + HssPrivateKeyParameters shard = keyPair.ExtractKeyShard(10); Assert.True(15 == shard.IndexLimit); Assert.True(5 == shard.GetIndex()); @@ -614,29 +614,29 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests // for (int t = 0; t < 17; t++) { - HSS.IncrementIndex(keyPair); + Hss.IncrementIndex(keyPair); } // We have used 32 keys. Assert.True(1024 - 32 == keyPair.GetUsagesRemaining()); - HSS.GenerateSignature(keyPair, Encoding.ASCII.GetBytes("Foo")); + Hss.GenerateSignature(keyPair, Encoding.ASCII.GetBytes("Foo")); // // This should trigger the generation of a new key. // - LMSPrivateKeyParameters potentialNewLMSKey = keyPair.GetKeys()[keyPair.L - 1]; + LmsPrivateKeyParameters potentialNewLMSKey = keyPair.GetKeys()[keyPair.L - 1]; Assert.False(potentialNewLMSKey.Equals(lmsKey)); } [Test] public void TestSharding() { - HSSPrivateKeyParameters keyPair = HSS.GenerateHssKeyPair( - new HSSKeyGenerationParameters(new LMSParameters[] + HssPrivateKeyParameters keyPair = Hss.GenerateHssKeyPair( + new HssKeyGenerationParameters(new LmsParameters[] { - new LMSParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w2), - new LMSParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w2) + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w2), + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w2) }, new SecureRandom()) ); @@ -644,13 +644,13 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests Assert.True(1024 == keyPair.IndexLimit); Assert.True(0 == keyPair.GetIndex()); Assert.False(keyPair.IsShard()); - HSS.IncrementIndex(keyPair); + Hss.IncrementIndex(keyPair); // // Take a shard that should cross boundaries // - HSSPrivateKeyParameters shard = keyPair.ExtractKeyShard(48); + HssPrivateKeyParameters shard = keyPair.ExtractKeyShard(48); Assert.True(shard.IsShard()); Assert.True(48 == shard.GetUsagesRemaining()); Assert.True(49 == shard.IndexLimit); @@ -662,22 +662,22 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests int t = 47; while (--t >= 0) { - HSS.IncrementIndex(shard); + Hss.IncrementIndex(shard); } - HSSSignature sig = HSS.GenerateSignature(shard, Encoding.ASCII.GetBytes("Cats")); + HssSignature sig = Hss.GenerateSignature(shard, Encoding.ASCII.GetBytes("Cats")); // // Test it validates and nothing has gone wrong with the public keys. // - Assert.True(HSS.VerifySignature(keyPair.GetPublicKey(), sig, Encoding.ASCII.GetBytes("Cats"))); - Assert.True(HSS.VerifySignature(shard.GetPublicKey(), sig, Encoding.ASCII.GetBytes("Cats"))); + Assert.True(Hss.VerifySignature(keyPair.GetPublicKey(), sig, Encoding.ASCII.GetBytes("Cats"))); + Assert.True(Hss.VerifySignature(shard.GetPublicKey(), sig, Encoding.ASCII.GetBytes("Cats"))); // Signing again should Assert.Fail. try { - HSS.GenerateSignature(shard, Encoding.ASCII.GetBytes("Cats")); + Hss.GenerateSignature(shard, Encoding.ASCII.GetBytes("Cats")); Assert.Fail(); } catch (Exception ex) @@ -686,7 +686,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests } // Should work without throwing. - HSS.GenerateSignature(keyPair, Encoding.ASCII.GetBytes("Cats")); + Hss.GenerateSignature(keyPair, Encoding.ASCII.GetBytes("Cats")); } /** @@ -721,15 +721,15 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests { HSSSecureRandom rand = new HSSSecureRandom(); - HSSPrivateKeyParameters keyPair = HSS.GenerateHssKeyPair( - new HSSKeyGenerationParameters(new LMSParameters[] + HssPrivateKeyParameters keyPair = Hss.GenerateHssKeyPair( + new HssKeyGenerationParameters(new LmsParameters[] { - new LMSParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w2), - new LMSParameters(LMSigParameters.lms_sha256_n32_h10, LMOtsParameters.sha256_n32_w1), + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w2), + new LmsParameters(LMSigParameters.lms_sha256_n32_h10, LMOtsParameters.sha256_n32_w1), }, rand) ); - HSSPublicKeyParameters pk = keyPair.GetPublicKey(); + HssPublicKeyParameters pk = keyPair.GetPublicKey(); int ctr = 0; @@ -753,7 +753,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests // The test will take over an hour to complete. // Pack_Int32_To_BE(ctr, message, 0); - HSSSignature sig = HSS.GenerateSignature(keyPair, message); + HssSignature sig = Hss.GenerateSignature(keyPair, message); Assert.True(ctr % 1024 == sig.Signature.Q); @@ -781,7 +781,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests Assert.True(keyPair.GetKeys()[t].GetIndex() - 1 == qValues[t]); } - Assert.True(HSS.VerifySignature(pk, sig, message)); + Assert.True(Hss.VerifySignature(pk, sig, message)); Assert.True(sig.Signature.SigParameters.ID == LMSigParameters.lms_sha256_n32_h10.ID); { @@ -790,12 +790,12 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests // byte[] rawSig = sig.GetEncoded(); rawSig[100] ^= 1; - HSSSignature parsedSig = HSSSignature.GetInstance(rawSig, pk.L); - Assert.False(HSS.VerifySignature(pk, parsedSig, message)); + HssSignature parsedSig = HssSignature.GetInstance(rawSig, pk.L); + Assert.False(Hss.VerifySignature(pk, parsedSig, message)); try { - HSSSignature.GetInstance(rawSig, 0); + HssSignature.GetInstance(rawSig, 0); Assert.Fail(); } catch (Exception ex) @@ -812,7 +812,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests byte[] newMsg = new byte[message.Length]; message.CopyTo(newMsg, 0); newMsg[1] ^= 1; - Assert.False(HSS.VerifySignature(pk, sig, newMsg)); + Assert.False(Hss.VerifySignature(pk, sig, newMsg)); } { @@ -821,14 +821,14 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests // byte[] pkEnc = pk.GetEncoded(); pkEnc[35] ^= 1; - HSSPublicKeyParameters rebuiltPk = HSSPublicKeyParameters.GetInstance(pkEnc); - Assert.False(HSS.VerifySignature(rebuiltPk, sig, message)); + HssPublicKeyParameters rebuiltPk = HssPublicKeyParameters.GetInstance(pkEnc); + Assert.False(Hss.VerifySignature(rebuiltPk, sig, message)); } } else { // Skip some keys. - HSS.IncrementIndex(keyPair); + Hss.IncrementIndex(keyPair); } ctr++; diff --git a/crypto/test/src/pqc/crypto/lms/test/LmsKeyGenTests.cs b/crypto/test/src/pqc/crypto/lms/test/LmsKeyGenTests.cs index fb66db457..0aa937b6c 100644 --- a/crypto/test/src/pqc/crypto/lms/test/LmsKeyGenTests.cs +++ b/crypto/test/src/pqc/crypto/lms/test/LmsKeyGenTests.cs @@ -32,11 +32,11 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests int level = 1; // This is the second level, we use this because it signs the message. // Generate the private key. - LMSPrivateKeyParameters lmsPrivateKey = LMS.GenerateKeys(LMSigParameters.GetParametersByID(5), + LmsPrivateKeyParameters lmsPrivateKey = Lms.GenerateKeys(LMSigParameters.GetParametersByID(5), LMOtsParameters.GetParametersByID(4), level, I, seed); // This derives the public key. - LMSPublicKeyParameters publicKey = lmsPrivateKey.GetPublicKey(); + LmsPublicKeyParameters publicKey = lmsPrivateKey.GetPublicKey(); // From the vector. string pkEnc = "0000000500000004215f83b7ccb9acbcd08db97b0d04dc2ba1cd035833e0e90059603f26e07ad2aad152338e7a5e5984bcd5f7bb4eba40b7"; @@ -49,7 +49,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests // lmsPrivateKey.ExtractKeyShard(3); - LMSSignature signature = LMS.GenerateSign(lmsPrivateKey, msg); + LmsSignature signature = Lms.GenerateSign(lmsPrivateKey, msg); // The expected signature as encoded. string sigEnc = "00000004\n" + @@ -140,7 +140,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests Assert.True(Arrays.AreEqual(Hex.Decode(sigEnc), signature.GetEncoded())); // Sanity test - Assert.True(LMS.VerifySignature(publicKey, signature, msg)); + Assert.True(Lms.VerifySignature(publicKey, signature, msg)); } } } diff --git a/crypto/test/src/pqc/crypto/lms/test/LmsTests.cs b/crypto/test/src/pqc/crypto/lms/test/LmsTests.cs index a5bc26252..f7ab226ec 100644 --- a/crypto/test/src/pqc/crypto/lms/test/LmsTests.cs +++ b/crypto/test/src/pqc/crypto/lms/test/LmsTests.cs @@ -14,8 +14,8 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests public void TestCoefFunc() { byte[] S = Hex.Decode("1234"); - Assert.AreEqual(0, LM_OTS.Coef(S, 7, 1)); - Assert.AreEqual(1, LM_OTS.Coef(S, 0, 4)); + Assert.AreEqual(0, LMOts.Coef(S, 7, 1)); + Assert.AreEqual(1, LMOts.Coef(S, 0, 4)); } [Test] @@ -27,7 +27,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests byte[] I = Hex.Decode("d08fabd4a2091ff0a8cb4ed834e74534"); LMOtsPrivateKey privateKey = new LMOtsPrivateKey(parameter, I, 0, seed); - LMOtsPublicKey publicKey = LM_OTS.LmsOtsGeneratePublicKey(privateKey); + LMOtsPublicKey publicKey = LMOts.LmsOtsGeneratePublicKey(privateKey); byte[] ms = new byte[32]; for (int t = 0; t < ms.Length; t++) @@ -35,23 +35,23 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests ms[t] = (byte)t; } - LMSContext ctx = privateKey.GetSignatureContext(null, null); + LmsContext ctx = privateKey.GetSignatureContext(null, null); ctx.BlockUpdate(ms, 0, ms.Length); - LMOtsSignature sig = LM_OTS.LMOtsGenerateSignature(privateKey, ctx.GetQ(), ctx.C); - Assert.True(LM_OTS.LMOtsValidateSignature(publicKey, sig, ms, false)); + LMOtsSignature sig = LMOts.LMOtsGenerateSignature(privateKey, ctx.GetQ(), ctx.C); + Assert.True(LMOts.LMOtsValidateSignature(publicKey, sig, ms, false)); // Recreate signature { byte[] recreatedSignature = sig.GetEncoded(); - Assert.True(LM_OTS.LMOtsValidateSignature(publicKey, LMOtsSignature.GetInstance(recreatedSignature), ms, false)); + Assert.True(LMOts.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)); + Assert.True(LMOts.LMOtsValidateSignature(LMOtsPublicKey.GetInstance(recreatedPubKey), sig, ms, false)); } // Vandalise signature @@ -59,14 +59,14 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests byte[] vandalisedSignature = sig.GetEncoded(); vandalisedSignature[256] ^= 1; // Single bit error - Assert.False(LM_OTS.LMOtsValidateSignature(publicKey, LMOtsSignature.GetInstance(vandalisedSignature), ms, false)); + Assert.False(LMOts.LMOtsValidateSignature(publicKey, LMOtsSignature.GetInstance(vandalisedSignature), ms, false)); } // Vandalise public key. { byte[] vandalisedPubKey = Arrays.Clone(publicKey.GetEncoded()); vandalisedPubKey[50] ^= 1; - Assert.False(LM_OTS.LMOtsValidateSignature(LMOtsPublicKey.GetInstance(vandalisedPubKey), sig, ms, false)); + Assert.False(LMOts.LMOtsValidateSignature(LMOtsPublicKey.GetInstance(vandalisedPubKey), sig, ms, false)); } // @@ -76,10 +76,10 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests { byte[] vandalisedPubKey = Arrays.Clone(publicKey.GetEncoded()); vandalisedPubKey[3] += 1; - LM_OTS.LMOtsValidateSignature(LMOtsPublicKey.GetInstance(vandalisedPubKey), sig, ms, false); + LMOts.LMOtsValidateSignature(LMOtsPublicKey.GetInstance(vandalisedPubKey), sig, ms, false); Assert.True(false, "Must fail as public key type not match signature type."); } - catch (LMSException ex) + catch (LmsException ex) { Assert.True(ex.Message.Contains("public key and signature ots types do not match")); } @@ -100,22 +100,22 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests byte[] seed = Hex.Decode("a1c4696e2608035a886100d05cd99945eb3370731884a8235e2fb3d4d71f2547"); int level = 1; - LMSPrivateKeyParameters lmsPrivateKey = LMS.GenerateKeys( + LmsPrivateKeyParameters lmsPrivateKey = Lms.GenerateKeys( LMSigParameters.GetParametersByID(5), LMOtsParameters.GetParametersByID(4), level, Hex.Decode("215f83b7ccb9acbcd08db97b0d04dc2b"), seed); - LMSPublicKeyParameters publicKey = lmsPrivateKey.GetPublicKey(); + LmsPublicKeyParameters publicKey = lmsPrivateKey.GetPublicKey(); lmsPrivateKey.ExtractKeyShard(3); - LMSSignature signature = LMS.GenerateSign(lmsPrivateKey, msg); - Assert.True(LMS.VerifySignature(publicKey, signature, msg)); + LmsSignature signature = Lms.GenerateSign(lmsPrivateKey, msg); + Assert.True(Lms.VerifySignature(publicKey, signature, msg)); // Serialize / Deserialize - Assert.True(LMS.VerifySignature( - LMSPublicKeyParameters.GetInstance(publicKey.GetEncoded()), - LMSSignature.GetInstance(signature.GetEncoded()), msg)); + Assert.True(Lms.VerifySignature( + LmsPublicKeyParameters.GetInstance(publicKey.GetEncoded()), + LmsSignature.GetInstance(signature.GetEncoded()), msg)); // // Vandalise signature. @@ -123,7 +123,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests { byte[] bustedSig = Arrays.Clone(signature.GetEncoded()); bustedSig[100] ^= 1; - Assert.False(LMS.VerifySignature(publicKey, LMSSignature.GetInstance(bustedSig), msg)); + Assert.False(Lms.VerifySignature(publicKey, LmsSignature.GetInstance(bustedSig), msg)); } // @@ -132,7 +132,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests { byte[] msg2 = Arrays.Clone(msg); msg2[10] ^= 1; - Assert.False(LMS.VerifySignature(publicKey, signature, msg2)); + Assert.False(Lms.VerifySignature(publicKey, signature, msg2)); } } @@ -145,7 +145,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests byte[] I = Hex.Decode("d08fabd4a2091ff0a8cb4ed834e74534"); LMOtsPrivateKey privateKey = new LMOtsPrivateKey(parameter, I, 0, seed); - LMOtsPublicKey publicKey = LM_OTS.LmsOtsGeneratePublicKey(privateKey); + LMOtsPublicKey publicKey = LMOts.LmsOtsGeneratePublicKey(privateKey); byte[] ms = new byte[32]; for (int t = 0; t < ms.Length; t++) @@ -153,12 +153,12 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests ms[t] = (byte)t; } - LMSContext ctx = privateKey.GetSignatureContext(null, null); + LmsContext ctx = privateKey.GetSignatureContext(null, null); ctx.BlockUpdate(ms, 0, ms.Length); - LMOtsSignature sig = LM_OTS.LMOtsGenerateSignature(privateKey, ctx.GetQ(), ctx.C); - Assert.True(LM_OTS.LMOtsValidateSignature(publicKey, sig, ms, false)); + LMOtsSignature sig = LMOts.LMOtsGenerateSignature(privateKey, ctx.GetQ(), ctx.C); + Assert.True(LMOts.LMOtsValidateSignature(publicKey, sig, ms, false)); try { diff --git a/crypto/test/src/pqc/crypto/lms/test/TypeTests.cs b/crypto/test/src/pqc/crypto/lms/test/TypeTests.cs index 948ce4747..10f21e9f3 100644 --- a/crypto/test/src/pqc/crypto/lms/test/TypeTests.cs +++ b/crypto/test/src/pqc/crypto/lms/test/TypeTests.cs @@ -15,27 +15,27 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests [Test] public void TestTypeForType() { - LMSSignature dummySig = new LMSSignature(0, null, null, null); + LmsSignature dummySig = new LmsSignature(0, null, null, null); { - var keys = new List<LMSPrivateKeyParameters>(); - keys.Add(new LMSPrivateKeyParameters(LMSigParameters.lms_sha256_n32_h5, null, 0, null, 0, new byte[32])); + var keys = new List<LmsPrivateKeyParameters>(); + keys.Add(new LmsPrivateKeyParameters(LMSigParameters.lms_sha256_n32_h5, null, 0, null, 0, new byte[32])); - var sig = new List<LMSSignature>(); + var sig = new List<LmsSignature>(); sig.Add(dummySig); - object o = new HSSPrivateKeyParameters(0, keys, sig, 1, 2); - Assert.True(o.Equals(HSSPrivateKeyParameters.GetInstance(o))); + object o = new HssPrivateKeyParameters(0, keys, sig, 1, 2); + Assert.True(o.Equals(HssPrivateKeyParameters.GetInstance(o))); } { - object o = new HSSPublicKeyParameters(0, null); - Assert.True(o.Equals(HSSPublicKeyParameters.GetInstance(o))); + object o = new HssPublicKeyParameters(0, null); + Assert.True(o.Equals(HssPublicKeyParameters.GetInstance(o))); } { - object o = new HSSSignature(0, null, null); - Assert.True(o.Equals(HSSSignature.GetInstance(o, 0))); + object o = new HssSignature(0, null, null); + Assert.True(o.Equals(HssSignature.GetInstance(o, 0))); } { @@ -49,18 +49,18 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms.Tests } { - object o = new LMSPrivateKeyParameters(LMSigParameters.lms_sha256_n32_h5, null, 0, null, 0, null); - Assert.True(o.Equals(LMSPrivateKeyParameters.GetInstance(o))); + object o = new LmsPrivateKeyParameters(LMSigParameters.lms_sha256_n32_h5, null, 0, null, 0, null); + Assert.True(o.Equals(LmsPrivateKeyParameters.GetInstance(o))); } { - object o = new LMSPublicKeyParameters(null, null, null, null); - Assert.True(o.Equals(LMSPublicKeyParameters.GetInstance(o))); + object o = new LmsPublicKeyParameters(null, null, null, null); + Assert.True(o.Equals(LmsPublicKeyParameters.GetInstance(o))); } { - object o = new LMSSignature(0, null, null, null); - Assert.True(o.Equals(LMSSignature.GetInstance(o))); + object o = new LmsSignature(0, null, null, null); + Assert.True(o.Equals(LmsSignature.GetInstance(o))); } } } diff --git a/crypto/test/src/pqc/crypto/test/HSSTest.cs b/crypto/test/src/pqc/crypto/test/HSSTest.cs index 678f1cbab..29b5e1f5a 100644 --- a/crypto/test/src/pqc/crypto/test/HSSTest.cs +++ b/crypto/test/src/pqc/crypto/test/HSSTest.cs @@ -16,17 +16,17 @@ namespace Org.BouncyCastle.Pqc.Crypto.Tests public void TestKeyGenAndSign() { byte[] msg = Strings.ToByteArray("Hello, world!"); - IAsymmetricCipherKeyPairGenerator kpGen = new HSSKeyPairGenerator(); + IAsymmetricCipherKeyPairGenerator kpGen = new HssKeyPairGenerator(); - kpGen.Init(new HSSKeyGenerationParameters( - new LMSParameters[]{ - new LMSParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4), - new LMSParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4) + kpGen.Init(new HssKeyGenerationParameters( + new LmsParameters[]{ + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4), + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4) }, new SecureRandom())); AsymmetricCipherKeyPair kp = kpGen.GenerateKeyPair(); - HSSSigner signer = new HSSSigner(); + HssSigner signer = new HssSigner(); signer.Init(true, kp.Private); @@ -41,26 +41,26 @@ namespace Org.BouncyCastle.Pqc.Crypto.Tests public void TestKeyGenAndUsage() { byte[] msg = Strings.ToByteArray("Hello, world!"); - IAsymmetricCipherKeyPairGenerator kpGen = new HSSKeyPairGenerator(); + IAsymmetricCipherKeyPairGenerator kpGen = new HssKeyPairGenerator(); - kpGen.Init(new HSSKeyGenerationParameters( - new LMSParameters[]{ - new LMSParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4), - new LMSParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4) + kpGen.Init(new HssKeyGenerationParameters( + new LmsParameters[]{ + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4), + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4) }, new SecureRandom())); AsymmetricCipherKeyPair kp = kpGen.GenerateKeyPair(); - HSSPrivateKeyParameters privKey = (HSSPrivateKeyParameters)kp.Private; + HssPrivateKeyParameters privKey = (HssPrivateKeyParameters)kp.Private; - HSSPublicKeyParameters pubKey = (HSSPublicKeyParameters)kp.Public; + HssPublicKeyParameters pubKey = (HssPublicKeyParameters)kp.Public; - LMSParameters lmsParam = pubKey.LmsPublicKey.GetLmsParameters(); + LmsParameters lmsParam = pubKey.LmsPublicKey.GetLmsParameters(); Assert.AreEqual(LMSigParameters.lms_sha256_n32_h5, lmsParam.LMSigParameters); Assert.AreEqual(LMOtsParameters.sha256_n32_w4, lmsParam.LMOtsParameters); - HSSSigner signer = new HSSSigner(); + HssSigner signer = new HssSigner(); signer.Init(true, privKey); @@ -82,21 +82,21 @@ namespace Org.BouncyCastle.Pqc.Crypto.Tests byte[] msg1 = Strings.ToByteArray("Hello, world!"); byte[] msg2 = Strings.ToByteArray("Now is the time"); - IAsymmetricCipherKeyPairGenerator kpGen = new HSSKeyPairGenerator(); + IAsymmetricCipherKeyPairGenerator kpGen = new HssKeyPairGenerator(); - kpGen.Init(new HSSKeyGenerationParameters( - new LMSParameters[]{ - new LMSParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4), - new LMSParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4) + kpGen.Init(new HssKeyGenerationParameters( + new LmsParameters[]{ + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4), + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4) }, new SecureRandom())); AsymmetricCipherKeyPair kp = kpGen.GenerateKeyPair(); - HSSPrivateKeyParameters privKey = ((HSSPrivateKeyParameters)kp.Private).ExtractKeyShard(2); + HssPrivateKeyParameters privKey = ((HssPrivateKeyParameters)kp.Private).ExtractKeyShard(2); - Assert.AreEqual(2, ((HSSPrivateKeyParameters)kp.Private).GetIndex()); + Assert.AreEqual(2, ((HssPrivateKeyParameters)kp.Private).GetIndex()); - HSSSigner signer = new HSSSigner(); + HssSigner signer = new HssSigner(); Assert.AreEqual(0, privKey.GetIndex()); @@ -130,11 +130,11 @@ namespace Org.BouncyCastle.Pqc.Crypto.Tests Assert.AreEqual("hss private key shard is exhausted", e.Message); } - signer.Init(true, ((HSSPrivateKeyParameters)kp.Private)); + signer.Init(true, ((HssPrivateKeyParameters)kp.Private)); sig = signer.GenerateSignature(msg1); - Assert.AreEqual(3, ((HSSPrivateKeyParameters)kp.Private).GetIndex()); + Assert.AreEqual(3, ((HssPrivateKeyParameters)kp.Private).GetIndex()); Assert.False(Arrays.AreEqual(sig1, sig)); diff --git a/crypto/test/src/pqc/crypto/test/LMSTest.cs b/crypto/test/src/pqc/crypto/test/LMSTest.cs index 7d9cc6da5..4392d1851 100644 --- a/crypto/test/src/pqc/crypto/test/LMSTest.cs +++ b/crypto/test/src/pqc/crypto/test/LMSTest.cs @@ -20,14 +20,14 @@ namespace Org.BouncyCastle.Pqc.Crypto.Tests public void TestKeyGenAndSign() { byte[] msg = Strings.ToByteArray("Hello, world!"); - IAsymmetricCipherKeyPairGenerator kpGen = new LMSKeyPairGenerator(); + IAsymmetricCipherKeyPairGenerator kpGen = new LmsKeyPairGenerator(); - kpGen.Init(new LMSKeyGenerationParameters( - new LMSParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4), new SecureRandom())); + kpGen.Init(new LmsKeyGenerationParameters( + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4), new SecureRandom())); AsymmetricCipherKeyPair kp = kpGen.GenerateKeyPair(); - LMSSigner signer = new LMSSigner(); + LmsSigner signer = new LmsSigner(); signer.Init(true, kp.Private); @@ -44,18 +44,18 @@ namespace Org.BouncyCastle.Pqc.Crypto.Tests byte[] msg1 = Strings.ToByteArray("Hello, world!"); byte[] msg2 = Strings.ToByteArray("Now is the time"); - IAsymmetricCipherKeyPairGenerator kpGen = new LMSKeyPairGenerator(); + IAsymmetricCipherKeyPairGenerator kpGen = new LmsKeyPairGenerator(); - kpGen.Init(new LMSKeyGenerationParameters( - new LMSParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4), new SecureRandom())); + kpGen.Init(new LmsKeyGenerationParameters( + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4), new SecureRandom())); AsymmetricCipherKeyPair kp = kpGen.GenerateKeyPair(); - LMSPrivateKeyParameters privKey = ((LMSPrivateKeyParameters)kp.Private).ExtractKeyShard(2); + LmsPrivateKeyParameters privKey = ((LmsPrivateKeyParameters)kp.Private).ExtractKeyShard(2); - Assert.AreEqual(2, ((LMSPrivateKeyParameters)kp.Private).GetIndex()); + Assert.AreEqual(2, ((LmsPrivateKeyParameters)kp.Private).GetIndex()); - LMSSigner signer = new LMSSigner(); + LmsSigner signer = new LmsSigner(); Assert.AreEqual(2, privKey.GetUsagesRemaining()); Assert.AreEqual(0, privKey.GetIndex()); @@ -90,11 +90,11 @@ namespace Org.BouncyCastle.Pqc.Crypto.Tests Assert.AreEqual("ots private key exhausted", e.Message); } - signer.Init(true, ((LMSPrivateKeyParameters)kp.Private)); + signer.Init(true, ((LmsPrivateKeyParameters)kp.Private)); sig = signer.GenerateSignature(msg1); - Assert.AreEqual(3, ((LMSPrivateKeyParameters)kp.Private).GetIndex()); + Assert.AreEqual(3, ((LmsPrivateKeyParameters)kp.Private).GetIndex()); Assert.False(Arrays.AreEqual(sig1, sig)); @@ -105,7 +105,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Tests PrivateKeyInfo pInfo = PrivateKeyInfoFactory.CreatePrivateKeyInfo(kp.Private);//TODO AsymmetricKeyParameter pKey = PrivateKeyFactory.CreateKey(pInfo.GetEncoded()); - signer.Init(false, ((LMSPrivateKeyParameters)pKey).GetPublicKey()); + signer.Init(false, ((LmsPrivateKeyParameters)pKey).GetPublicKey()); Assert.True(signer.VerifySignature(msg1, sig1)); } |