IntelliJ Java IDE
The moose likes Java Micro Edition and the fly likes BC works fine in simulator, but stops working after awhile on nokia phone? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Reply Bookmark "BC works fine in simulator, but stops working after awhile on nokia phone?" Watch "BC works fine in simulator, but stops working after awhile on nokia phone?" New topic
Author

BC works fine in simulator, but stops working after awhile on nokia phone?

Lonely Coder
Greenhorn

Joined: Sep 23, 2011
Posts: 2
Greetings,

I am new here, I am not new to programming, but am kinda new to encryption.
Great work with the Bouncy Castle (BC), however I have run into a major problem.

I have a server in C#, and the client in J2ME.
They are using Rijndael Encryption, and I am using the initialization vector.

The server is using the built in .NET encryption.

For the client, I am using eclipse, and the emulator is the S60 SDK, and sun wtk also works fine.

I can encrypt/decrpyt data fine on both client and server, when running the emulators.

However, when I put the J2ME app on my Nokia phone and run it over the internet or over bluetooth, then after several packets are sent, the server suddenly starts complaining:
"System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed"

After the server gets that error, none of the data from the client can be successfully decrypted again. If I log out of the client app, it still gives the same error. I basically have to restart the app.

Any ideas please? I am stumped about this.
Lonely Coder
Greenhorn

Joined: Sep 23, 2011
Posts: 2
I did some more debugging last night which led me to think it's a bug in the BouncyCastle code somewhere.

What I did, was run the server and client normally, until the server is unable to "remove padding"

Then, I ran a custom function, on the client, that encrypts and decrypts data, using byte arrays of fixed key, iv, and input data.

The function works the fine before the client gets stuck, but after it gets stuck, I get this error when decrypting: InvalidCipherTextException: pad block corrupted

Please help!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 12513

"LonelyCoder",

We don't have many rules here at the JavaRanch, but we do insist that you use your Real Name and not some sort of "handle" or obvious alias. If you're not sure about this, see http://www.javaranch.com/name.jsp .


One of the most odious afflictions that Business has inflicted on the modern English language is "pro-active". Most of the time it's simply redundantly used in place of the simple old word "active". And a good deal of the rest of the time it means "You're not overworked enough yet, so go out and find more!"
 
 
subject: BC works fine in simulator, but stops working after awhile on nokia phone?
 
Threads others viewed
Runniny standard J2ME middlets on blackberry emulator
Uncaught exception java/lang/OutOfMemoryError while running application in Nokia S60
I am having problem while deploying and running my J2ME game on Nokia 3510 phone Plz
Unable to create/find new file
Wtk Emulator = OK... Nokia phone = NOT OK??
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture