diff options
Diffstat (limited to 'crypto/test')
-rw-r--r-- | crypto/test/BouncyCastle.Crypto.Tests.csproj | 2 | ||||
-rw-r--r-- | crypto/test/src/pqc/crypto/test/HSSTest.cs | 40 |
2 files changed, 36 insertions, 6 deletions
diff --git a/crypto/test/BouncyCastle.Crypto.Tests.csproj b/crypto/test/BouncyCastle.Crypto.Tests.csproj index 0264491a3..08fcae206 100644 --- a/crypto/test/BouncyCastle.Crypto.Tests.csproj +++ b/crypto/test/BouncyCastle.Crypto.Tests.csproj @@ -30,7 +30,7 @@ <EmbeddedResource Include="data\**\*.*" Exclude="**\README.txt" /> </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.0" /> <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> diff --git a/crypto/test/src/pqc/crypto/test/HSSTest.cs b/crypto/test/src/pqc/crypto/test/HSSTest.cs index 29b5e1f5a..45cabb906 100644 --- a/crypto/test/src/pqc/crypto/test/HSSTest.cs +++ b/crypto/test/src/pqc/crypto/test/HSSTest.cs @@ -13,16 +13,46 @@ namespace Org.BouncyCastle.Pqc.Crypto.Tests public class HSSTest { [Test] + public void TestOneLevelKeyGenAndSign() + { + byte[] msg = Strings.ToByteArray("Hello, world!"); + IAsymmetricCipherKeyPairGenerator kpGen = new HssKeyPairGenerator(); + + var lmsParameters = new LmsParameters[] + { + new LmsParameters(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4) + }; + kpGen.Init(new HssKeyGenerationParameters(lmsParameters, new SecureRandom())); + + AsymmetricCipherKeyPair kp = kpGen.GenerateKeyPair(); + + HssSigner signer = new HssSigner(); + + signer.Init(true, kp.Private); + + byte[] sig = signer.GenerateSignature(msg); + + signer.Init(false, kp.Public); + + Assert.True(signer.VerifySignature(msg, sig)); + + HssPublicKeyParameters hssPubKey = (HssPublicKeyParameters)kp.Public; + + hssPubKey.GenerateLmsContext(sig); + } + + [Test] public void TestKeyGenAndSign() { byte[] msg = Strings.ToByteArray("Hello, world!"); 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) - }, new SecureRandom())); + var lmsParameters = 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(lmsParameters, new SecureRandom())); AsymmetricCipherKeyPair kp = kpGen.GenerateKeyPair(); |