RSA in python

Heikki Toivonen heikki at osafoundation.org
Tue Feb 21 14:10:01 EST 2006


Abhisek Datta wrote:
> -----BEGIN RSA PUBLIC KEY-----
> MIGJAoGBALxi3tGXlSwRgn7/Km6mTSge+5ijQgIn3GvnZOeYyOo1DkubVtTaFj26
> GWtJo43MEe1a5UlWKJEOpbKVCr4AASfFj8YmmRewH4SXdZ+w1Bad8amyzL2h8F7J
> wJojOnocSs6xDE7o86CpZRUlojBefanMdCpu074QFktE63OD1zBBAgMBAAE=
> -----END RSA PUBLIC KEY-----
> 
> Traceback (most recent call last):
[...]
> M2Crypto.RSA.RSAError: no start line

The files in M2Crypto tests directory don't have any files that have
"BEGIN RSA PUBLIC KEY" in them - haven't checked if this is legal or not.

However, plain OpenSSL does not like that file either:

$ openssl rsa -in rsa_heikki.pem -pubin
3440:error:0906D06C:PEM routines:PEM_read_bio:no
startline:pem_lib.c:644:Expecting: PUBLIC KEY

$ openssl rsa -in rsa_heikki.pem -check
2140:error:0906D06C:PEM routines:PEM_read_bio:no
startline:pem_lib.c:644:Expecting: ANY PRIVATE KEY

If I take out the "RSA " part from the delimiter lines I get:

$ openssl rsa -in rsa_heikki2.pem -pubin
unable to load Public Key
3124:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong
tag:tasn_dec.c:
1282:
3124:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1
error:ta
sn_dec.c:374:Type=X509_ALGOR
3124:error:0D08303A:asn1 encoding
routines:ASN1_TEMPLATE_NOEXP_D2I:nested asn1 e
rror:tasn_dec.c:743:Field=algor, Type=X509_PUBKEY
3124:error:0906700D:PEM routines:PEM_ASN1_read_bio:ASN1 lib:pem_oth.c:83:

$ openssl rsa -in rsa_heikki2.pem -check
unable to load Private Key
2304:error:0906D06C:PEM routines:PEM_read_bio:no start
line:pem_lib.c:644:Expect
ing: ANY PRIVATE KEY


My suggestion would be to ask on the openssl-users list.

-- 
  Heikki Toivonen


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 257 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20060221/e7987764/attachment.sig>


More information about the Python-list mailing list