math math - 3 months ago 23x
Python Question

How to load an RSA key from a PEM file and use it in python-crypto

I have not found a way to load an RSA private key from a PEM file to use it in python-crypto (signature).

python-openssl can load a PEM file but the PKey object can't be used to retrieved key information (p, q, ...) to use with Crypto.PublicKey.construct().


is this (close to) what you tried doing?

public_key_filename = 'public_key.pem'
rsa = M2Crypto.RSA.load_pub_key(pk)

That should work. The issue might be with openssl too, does it work when you just use openssl (not in Python)?

Link to Me Too Crypto