java.lang.IllegalArgumentException: Key length not 128/192/256 bits!

948 views
Skip to first unread message

Tommaso Checchi

unread,
Sep 25, 2013, 6:12:27 AM9/25/13
to rob...@googlegroups.com
Hi,
as by the title, I got this exception when running compiled code which uses a 128-bit key... 
The stack trace was:
at org.bouncycastle.crypto.engines.AESFastEngine.generateWorkingKey(Unknown Source)
at org.bouncycastle.crypto.engines.AESFastEngine.init(Unknown Source)
at org.bouncycastle.crypto.modes.CFBBlockCipher.init(Unknown Source)
at org.bouncycastle.crypto.BufferedBlockCipher.init(Unknown Source)
 
In fact the key used was 127 bytes, and it looks like that java's crypto libraries and bouncycastle have significant differences.
Original Java code generates a 128 bit (16 bytes) key from a 635 bytes cipher, while robovm-ed code generates a 127 bytes key from a 634 bytes (sometimes 635 indeed) cipher.

And uhm, not being a security expert I can't really make sense of this :D
Any thoughts?

Thanks,
Tommaso


Tommaso Checchi

unread,
Sep 26, 2013, 9:32:51 AM9/26/13
to rob...@googlegroups.com
Replying to myself again - this wasn't due to roboVM at all, it was due to bouncycastle selecting the wrong padding to decode the data.

Niklas Therning

unread,
Sep 30, 2013, 8:53:23 AM9/30/13
to Tommaso Checchi, rob...@googlegroups.com
Great! I'm glad to hear it worked out.


--
You received this message because you are subscribed to the Google Groups "RoboVM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robovm+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages