Java Cipher and AS3crypto and RSA use

142 views
Skip to first unread message

Douglas Knudsen

unread,
Dec 2, 2008, 1:30:26 PM12/2/08
to As3Crypto Discussion List
Ok, used AS3Crypto on current project, works a treat! Using RSA
encryption. I have a C++ client encrypt a string, pass to a Flex
application, and it decrypts it, no issues. I'm trying to do the same
with Java now, havea Java client pass a encrypted string to a Flex
application. But I constantly get a error in Flex/AS3:

TypeError: Error #2007: Parameter bytes must be non-null.
PKCS#1 unpad: i=0, expected b[i]==2, got b[i]=3d

Looks like some issue with the padding. Anyone have any direction to
advise on here using Java to RSA encrypt a string and then using
AS3Crypto to decrypt it?

DK

Rowan Hick

unread,
Dec 2, 2008, 2:55:14 PM12/2/08
to as3c...@googlegroups.com
Hi

We had an issue with new lines in the base 64 encoding - we were
trying Ruby (via OpenSSL) to encrypt, passing a Base64 encoded string
over to AS3 Crypto to decrypt. From what I recall - it appears that
the Base64 decoding within AS3Crypto wasn't handling new lines
correctly, so the string before it got passed to get decrypted, was
garbled by the Base64 decoding.

I'll connect with my developer who was working on it and post back a
response as to what he did to fix it. Let me know in a day or so you
haven't heard back from me.

In the end we ditched using AS3Crypto as it was too slow compared to a
Java implementation. Held lots of promise, but for the volume of data
we're dealing with impractical.

Kind Regards,


Rowan

Douglas Knudsen

unread,
Dec 4, 2008, 10:15:38 AM12/4/08
to As3Crypto Discussion List
Rowan, thanks for pinging your developers. Hoping their response is a
boon here!

I did find the Base64 encoder in as3crypto lib were not working the
same as the Base64Encoder/Decoder classes built into Flex 3 and didn't
agree with Java's. So, I'm using the built in ones now. These agree
with Java codes. It might have been line breaks, not sure, saw a 4
char difference in length. In testing and puttzing around, seems the
issue lies in the actual encrypting code or in byte code diffs not
sure which. java bytes go -127 - 128 and Flash goes 0 - 255


DK

On Dec 2, 2:55 pm, "Rowan Hick" <rowan.h...@gmail.com> wrote:
> Hi
>
> We had an issue with new lines in the base 64 encoding - we were
> trying Ruby (via OpenSSL) to encrypt, passing a Base64 encoded string
> over to AS3 Crypto to decrypt. From what I recall - it appears that
> the Base64 decoding within AS3Crypto wasn't handling new lines
> correctly, so the string before it got passed to get decrypted, was
> garbled by the Base64 decoding.
>
> I'll connect with my developer who was working on it and post back a
> response as to what he did to fix it. Let me know in a day or so you
> haven't heard back from me.
>
> In the end we ditched using AS3Crypto as it was too slow compared to a
> Java implementation. Held lots of promise, but for the volume of data
> we're dealing with impractical.
>
> Kind Regards,
>
> Rowan
>
> On Tue, Dec 2, 2008 at 1:30 PM, Douglas Knudsen
>
Reply all
Reply to author
Forward
0 new messages