Is there any openssl binding in python 3.4 that binds the function RSA_public_decrypt() from libopenssl that allows us to decrypt stuff using a public key? For some reason, I need to do this in a project.
I had the same problem, I found this slightly hacky (note the *.hazmat.* imports) solution
def do_decrypt_cryptography(message, private_key):
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import padding
return private_key.decrypt(message,
padding.OAEP(mgf=padding.MGF1(algorithm=hashes.SHA1()),
algorithm=hashes.SHA1(),
label=None))
Have you tried the M2Crypto library? It looks like the M2Crypto.RSA.RSA class has a public_decrypt(self, data, padding) function. M2Crypto is a Python wrapper for OpenSSL, but I'm not sure if that public_decrypt function directly calls the C OpenSSL RSA_public_decrypt() function. If you go that route, I'd double check the source to make sure.
http://www.heikkitoivonen.net/m2crypto/api/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With