From fc3e516d427e5359f9b7d8deed8bfd7c5c2c90c9 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Wed, 6 Dec 2023 22:42:30 +0700 Subject: Add fast coprime test --- crypto/test/src/crypto/test/RsaTest.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'crypto/test') 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); + } + } + } } -- cgit 1.4.1