Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BouncyCastle RSA

 
Paul Murtagh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Just wondering if anybody came across (and found a solution) to this problem;
When running AES from the bouncy castle API, key generation works fine. However I am trying to work with public key encryption and when I try to generate a key pair using RSA, my emulator freezes and seems to be stuck in some kind of loop.
(working with "Crypto Recipes" from Enterprise J2ME)
Any comments or suggestions?
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a bug to me -- have you contacted Jon Eaves or the BC developers in general ( feedback-crypto@bouncycastle.org )?
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, this is not a bug. It is a feature.
Generating a public key pair on a device is *extremely slow*. It could take more than 10 minutes to finish. So, I would go have lunch and then check back. But that is why we do not recommand generate keys on the device -- you should generate them on a PC and then import into the device. The code in the book should show you how to do that (key serialization etc.)
cheers
Michael
 
Paul Murtagh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Juan,
Thanks for getting back to me, I tried running the key generator again and this time I left it alone for 2 hours and still it did not complete generation.
I am running this program on a phone emulator on my computer (2.5Ghz) I can't imagine how the generation could take any longer than this?
 
Jon Eaves
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depending on what version of the library you are using this is either a bug or a feature.
There was a bug in the lightweight J2ME/MIDP BigInteger that would cause the prime generation to go into an infinite loop under some circumstances. This was introduced with the introduction of a speedup for the Montgomery number calculations.
However, it's been fixed in version 1.21. So, grab the latest release (1.23) and you should be fine. It will take ages to compute however. Now this has been fixed, I should do a test on my 7210 to see exactly how long.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic