RSA Private/Public key generation

180 views
Skip to first unread message

theodore

unread,
Aug 23, 2009, 11:57:21 PM8/23/09
to As3Crypto Discussion List
Hi All,

I'm having some difficulties generating RSA public/private keys that
are functional with as3crypto. I'm using the PEM class to read a
public key and it's consistently returning null.

The commands I'm using to generate the keys are as follows:

openssl genrsa -out private_key.pem 2048
openssl rsa -in private_key.pem -pubout -out public_key.pem

The public key is (I've removed the line breaks in my variable
declaration):

-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvAUMxtMPd1QSILO27Tgh
CeMt8yyaBNbc9B7UYcAGNpow2VFuW/RbrPh46hp1h34NgiAuUxtmPyvp9TT6UQbM
Xh6ii2b/HkSWwFCIcD1X7E943Y1I+E4eor5max0nSb54kM6PvG3fHVESAhR6bCiH
arrGXGQc2i7Eu8S4YGTaXw8ob0WK3O0yt71XeH8A/zK/0EzV+BZn62OazhflkoDR
E00gM4zLE7GumvGTo/lCrnySprAT9AxjAAgmpiDtMqj2KlcZBxmP34Gmjo2MrloR
zV3W73DinzRoidj/ePOKGlq1ERlQwAoVvaFEFwO7iFWr6fqlOPSwTV5AIws/PQ4g
xQIDAQAB
-----END PUBLIC KEY-----

I'm using the swc binary as I couldn't get the source to compile.


Thanks in advance for your help,
Theo

Joey Parrish

unread,
Aug 24, 2009, 3:43:08 PM8/24/09
to as3c...@googlegroups.com
On Sun, Aug 23, 2009 at 10:57 PM, theodore <th...@t6d.com> wrote:
I'm having some difficulties generating RSA public/private keys that
are functional with as3crypto. I'm using the PEM class to read a
public key and it's consistently returning null.

The public key is (I've removed the line breaks in my variable
declaration):

Try with linebreaks in the declaration.  I think I recall seeing it return null with one dash too few or missing a line break.

--Joey

theodore

unread,
Aug 24, 2009, 7:02:16 PM8/24/09
to As3Crypto Discussion List
Thanks for the tip; I've solved the problem.

I managed to resolve this issue by:

1. Adding line breaks
2. Reducing the size of the public key being generated.

This then presented me with the following error: “I DONT KNOW HOW TO
HANDLE DER stuff of TYPE 24″.

A quick google produced:

"# Gonzalo Says:
January 10th, 2008 at 8:02 am
I think I solved it, but please check it.
In the readRSAPublicKey function (PEM.as file) you have:
arr[1].position = 1; // there’s a 0×00 byte up front. find out why
later. like, read a spec.
But I realized that that was not true in my case, so I change that
line with this one (taken from the bit string reading):
if (arr[1][arr[1].position]==0) { arr[1].position++; }
and now everything works :) Hope that helps to others."


If anyone else encounters the same problem I've uploaded the re-
compiled swc to http://t6d.com/files/as3crypto.swc.

Thanks for the help Joey.


On Aug 25, 5:43 am, Joey Parrish <joey.parr...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages