views:

1754

answers:

1

Hi all,

I have the modulus of an RSA public key. I want to use this public key with the Python library "M2Crypto", but it requires a public key in PEM format.

Thus, I have to convert the RSA modulus to a PEM file.

The modulus can be found here.

Any ideas?

Thanks a lot, hevalbaranov

+2  A: 

The M2Crypto library has a way to reconstruct a public key. You need to know the public exponent, e (often 65337 for RSA keys, but other numbers such as 3 or 17 have been used), and the modulus, n (which is the 512-bit number provided in the question). Note that the docs describe the length-encoded format used for e and n.

Once the public key has been reconstructed, it can be saved into a file and used again later without the hassle of conversion.

erickson
No, I just want to encrypt messages with a python library (m2crypt) instead of the js library.And I want to use the key but as you can see, the rsa key I found is not same as a ssh public key file.
sid3k
It's not a joke.The question is simple, I've got a public RSA key and want to use it with a python library that does not support the format of the public key.I need to convert it.
sid3k
Okay then, you need to provide the public exponent of the key. For normal RSA keys, this is often 65537. But for a tiny 512-bit key, I'm not sure if the same exponent would be used.
erickson
all right, thanks for help.
sid3k