warvair / as3crypto

Automatically exported from code.google.com/p/as3crypto
0 stars 0 forks source link

readRSAPublicKey fails to load key with arr[1].position = 1; #32

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Checkout v1.3, and do a readRSAPublicKey on this key 
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDSInLDKp9pNoaN0rfnulUinVw0
3kezfhkwOXbocpyPKgOqylC9HGUChNYtfTI18jnt8TiI3RoptutBSLZ7xTooybXs
7NZWkjnzPZBpXDkQykd8LrWc1cy8VxHALbil4s8Ua87R8KAHXZukyGuonWs3yvFN
/CB48WZjSgnTOzHuHwIDAQAB
-----END PUBLIC KEY-----

You should get an EOF error in DER.as, at the line der.readBytes(bs,0,len);
 len will be an insanely large number.

Try the precompiled version and you will not have a problem.  The
difference between the two is one line in PEM.as

v1.3
arr[1].position = 1; // there's a 0x00 byte up front. find out why later.
like, read a spec.

trunk
arr[1].position = 0; // there's a 0x00 byte up front. find out why later.
like, read a spec.

Setting the value to 0 in v1.3 clears up the issue.

On what operating system?
Versions specified above, working on OSX.

Please provide any additional information below.
I had to go to 1.3 to get support for connecting to gmail. I've changed the
code to make it work but I don't understand what I've done.  I figure
that's probably dangerous for me.

Thank you,
Eric

Original issue reported on code.google.com by steim...@gmail.com on 30 Dec 2009 at 10:50

GoogleCodeExporter commented 9 years ago
I've been experiencing the same issue and used the following workaround:

[code]
                if ((arr[1] as ByteArray).readUnsignedByte() != 0x00)
                {
                    arr[1].position = 0;
                }
[/code]

Original comment by hansal...@gmail.com on 22 Feb 2010 at 4:48