0

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?

tavier
  • 1,744
  • 4
  • 24
  • 53
  • 1-10 seconds on my PC with Bouncy Castle 1.7.0 Running for x64 speed up very much... 1-2 seconds max – xanatos Jun 22 '15 at 12:41
  • That makes me wonder what could be different on my PC (and my team's PCs for that matter :) ) – tavier Jun 22 '15 at 12:45
  • I'm using a common laptop... an Intel I5-4200 . Debug and Release don't change very much... And running with/without debugger doesn't change anything too. – xanatos Jun 22 '15 at 12:46
  • See http://stackoverflow.com/questions/10507634/bouncycastle-how-long-should-it-take-to-generate-a-rsa-keypair ... Other persons had the same problem. – xanatos Jun 22 '15 at 12:47
  • Hey, thanks a ton for the link. I think that indicates that I do not have any option but to live with what it is :) – tavier Jun 23 '15 at 05:48
  • @asish As I've written you can try running your app at 64 bits... It will speed up very much. And you can try the latest version of Bouncy if you aren't already using it. – xanatos Jun 23 '15 at 06:17
  • Actually, I am running it on my Windows Phone device and I only have an x86 version...Also, I installed it as a newGetPackage and it shows 1.7.0 – tavier Jun 23 '15 at 07:03

0 Answers0