 |
BOOK: Beginning Cryptography with Java  | This is the forum to discuss the Wrox book Beginning Cryptography with Java by David Hook; ISBN: 9780764596339 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning Cryptography with Java section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 16th, 2007, 04:28 PM
|
|
Registered User
|
|
Join Date: Jul 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Intermittent RSA block problems
I am encrypting values using 1024 bit RSA encryption using the bouncycastle provider. Both the encryption and decryption of data is working correctly, however, intermittently in our application server(WebSphere 6.0.2) I start getting "too much data for RSA block" errors when attempting to decrypt an encrypted value. I put in a trap for the error so that the data being decrypted would be dumped to the log. The data is a valid 128 byte string and when I copy and paste it into a stand-alone Test program it decrypts the value without a problem. We have clustered application servers and this problem is only occurring on one of the two servers. We recycle the application server and the problem will go away for 24 hours or so and then reappear.
Has anyone experienced anything like this? My hunch is that something else is corrupting the JVM in the application server which in turn is corrupting the Cipher used for the decryption. The Cipher is established in a Singleton which is called statically to decrypt the data.
Any help would be appreciated.
Peter Searls
Sr. Programmer Analyst
Holland America Line
206.298.5120
|
|

July 16th, 2007, 07:14 PM
|
|
Wrox Author
|
|
Join Date: Aug 2005
Posts: 206
Thanks: 0
Thanked 20 Times in 20 Posts
|
|
It sounds like a synchronization issue. Cipher classes are not thread safe, are there any assumptions in the code that they could be?
Regards,
David
|
|

July 16th, 2007, 08:25 PM
|
|
Registered User
|
|
Join Date: Jul 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by dgh
It sounds like a synchronization issue. Cipher classes are not thread safe, are there any assumptions in the code that they could be?
Regards,
David
|
Hi David,
Good thought, we did make an assumption that the doFinal() was thread safe. It is the only method on the Cipher that is called to decode the data. But that still wouldn't account for the fact that this ran for almost 4 weeks without problem and now shows up infrequently and only on one server.
Pete
Peter Searls
Sr. Programmer Analyst
Holland America Line
206.298.5120
|
|

July 16th, 2007, 08:55 PM
|
|
Wrox Author
|
|
Join Date: Aug 2005
Posts: 206
Thanks: 0
Thanked 20 Times in 20 Posts
|
|
doFinal is not thread safe - a thread can be interrupted while it's inside it, if this happens when the internal buffer has already been loaded, the next attempt will cause the exception.
Try fixing that first and see how it goes.
Regards,
David
|
|

July 16th, 2007, 09:15 PM
|
|
Registered User
|
|
Join Date: Jul 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by dgh
doFinal is not thread safe - a thread can be interrupted while it's inside it, if this happens when the internal buffer has already been loaded, the next attempt will cause the exception.
Try fixing that first and see how it goes.
Regards,
David
|
Thanks David I will give it a shot and see what happens. I'll post the results one way or the other.
Peter Searls
Sr. Programmer Analyst
Holland America Line
206.298.5120
|
|

July 17th, 2007, 07:54 PM
|
|
Registered User
|
|
Join Date: Jul 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by psearls55
Quote:
|
quote:Originally posted by dgh
|
Quote:
doFinal is not thread safe - a thread can be interrupted while it's inside it, if this happens when the internal buffer has already been loaded, the next attempt will cause the exception.
Try fixing that first and see how it goes.
Regards,
David
Hi David,
I was able to run concurrent threads in test mode and force the RSA error to occur. Then when I added synchronization around the doFinal() on the Cipher the errors went away. Thanks for the help.
|
Thanks David I will give it a shot and see what happens. I'll post the results one way or the other.
Peter Searls
Sr. Programmer Analyst
Holland America Line
206.298.5120
|
Peter Searls
Sr. Programmer Analyst
Holland America Line
206.298.5120
|
|
 |