[PYTHON-CRYPTO] Segmentation Fault with RSA.RSA.public_encrypt
Kershaw, PJ (Philip)
P.J.Kershaw at RL.AC.UK
Fri Aug 1 17:17:00 CEST 2008
Hi all,
I've got a suspected problem with RSA.RSA.public_encrypt. If I load a public key from an X.509 cert. PEM file and then try and encrypt something I get a segmentation fault. If I comment out a call to check_key:
def public_encrypt(self, data, padding):
#assert self.check_key(), 'key is not initialised'
return m2.rsa_public_encrypt(self.rsa, data, padding)
... all works OK. Here's the code I used to test:
from M2Crypto import X509, RSA
text = 'Hello world'
x509Cert = X509.load_cert('./test.crt')
rsaPubKey = x509Cert.get_pubkey().get_rsa()
encrypted = rsaPubKey.public_encrypt(text, RSA.pkcs1_padding)
priKey = RSA.load_key('./test.key')
decrypted = priKey.private_decrypt(encrypted, RSA.pkcs1_padding)
print decrypted
Is it a bug or have I used the API wrongly?
Cheers,
Phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-crypto/attachments/20080801/3df1e61b/attachment.html>
More information about the python-crypto
mailing list