{Bouncy Castle} RsaKeyPairGenerator.GenerateKeyPair takes very long

1.1k Views Asked by At

I am using BC library for cryptography. Code:

RsaKeyPairGenerator generator = new RsaKeyPairGenerator();
KeyGenerationParameters genParams = new KeyGenerationParameters(new SecureRandom(), 2048);
generator.Init(genParams);
AsymmetricCipherKeyPair kp = generator.GenerateKeyPair();

Below line of code takes very long (more than a minute) to execute:

AsymmetricCipherKeyPair kp = generator.GenerateKeyPair();

Surprisingly, sometimes it takes little less (approximately 17-18 secs) to execute the same piece of code.

Any ideas?

0

There are 0 best solutions below