I generated a private key using
openssl req -x509 -out anytime-pub.der -outform der -new -newkey rsa:2048 -keyout anytime.pem -days 3650
In my old code, I use M2Crypto to download the key file to decrypt something, and it works.
from M2Crypto import RSA
ServerRSA = RSA.load_key('keys/anytime.pem', passwd)
key = ServerRSA.private_decrypt(b64decode(cipher),1)
but when I use pycrypto to do the same thing, the error below occurs:
>>> from Crypto.PublicKey import RSA
>>> key = RSA.importKey(open('keys/anytime.pem', 'r'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/xyzkizer/Projects/AnytimeBackend/env/lib/python2.7/site-packages/Crypto/PublicKey/RSA.py", line 641, in importKey
raise ValueError("PEM encryption format not supported.")
ValueError: PEM encryption format not supported.
Can someone tell me what my mistake is?
Thanks!
Kizer source
share