As I understand it, I should be able to use RSA to ensure authenticity or confidentiality, as I wish. In my case, I want to ensure authenticity, so I encrypt the data with the private key and let everyone decrypt it with the public key. The data is not confidential, but I have to guarantee that it was created by the owner of the public (and private) key.
When I try to decrypt using PyCrypto, I get No private key . Error from PyCrypto. The code looks like this:
def _decrypt_rsa(decrypt_key_file, cipher_text): from Crypto.PublicKey import RSA from base64 import b64decode key = open(decrypt_key_file, "r").read() rsakey = RSA.importKey(key) raw_cipher_data = b64decode(cipher_text) decrypted = rsakey.decrypt(raw_cipher_data) return decrypted
I call it along the path to the public key file (in OpenSSH format.) The encrypted data is not generated by me, and this was not done with Python, but PHP. PHP has an openssl_public_decrypt function that easily decrypts this data.
Is it possible to decrypt public key usage using PyCrypto?
source share