diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-12-06 22:42:30 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-12-06 22:42:30 +0700 |
commit | fc3e516d427e5359f9b7d8deed8bfd7c5c2c90c9 (patch) | |
tree | f3f1c05d3bfb66b590f3cdcb6082c55352cc7560 /crypto/test/src | |
parent | Refactoring in Math.Raw.Nat (diff) | |
download | BouncyCastle.NET-ed25519-fc3e516d427e5359f9b7d8deed8bfd7c5c2c90c9.tar.xz |
Add fast coprime test
Diffstat (limited to 'crypto/test/src')
-rw-r--r-- | crypto/test/src/crypto/test/RsaTest.cs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/crypto/test/src/crypto/test/RsaTest.cs b/crypto/test/src/crypto/test/RsaTest.cs index 3c01baa85..58c10f59c 100644 --- a/crypto/test/src/crypto/test/RsaTest.cs +++ b/crypto/test/src/crypto/test/RsaTest.cs @@ -2,7 +2,6 @@ using System; using NUnit.Framework; -using Org.BouncyCastle.Crypto; using Org.BouncyCastle.Crypto.Digests; using Org.BouncyCastle.Crypto.Encodings; using Org.BouncyCastle.Crypto.Engines; @@ -751,5 +750,23 @@ namespace Org.BouncyCastle.Crypto.Tests Assert.AreEqual(Name + ": Okay", resultText); } - } + + [Test, Explicit] + public void BenchPublicKeyModulusValidation() + { + SecureRandom secureRandom = SecureRandom.GetInstance("SHA512PRNG", false); + secureRandom.SetSeed(2); + + var kpg = new RsaKeyPairGenerator(); + kpg.Init(new RsaKeyGenerationParameters(BigInteger.ValueOf(0x11), secureRandom, 2048, 100)); + + var kp = kpg.GenerateKeyPair(); + var pub = (RsaKeyParameters)kp.Public; + + for (int i = 0; i < 1000000; ++i) + { + new RsaKeyParameters(false, pub.Modulus, pub.Exponent); + } + } + } } |