
Pubkeystr = keys.publickey().exportKey(format='PEM', passphrase=None, pkcs=1)ĭef encrypt_val(session_key, cipher = pubcipher): Privkeystr = keys.exportKey(format='PEM', passphrase=None, pkcs=1)

Privcipher = PKCS1_OAEP.new(privkey) # message = crypt(ciphertext) Pubcipher = PKCS1_OAEP.new(pubkey) # ciphertext = cipher.encrypt(message) Keys = RSA.generate(1024, random_generator) Can anyone take a look and tell me what I'm doing wrong? from Crypto.Cipher import AES, PKCS1_OAEPįrom Crypto.Random import get_random_bytes ModBits = (self._key.n)ĪttributeError: 'bytes' object has no attribute 'n' But the minute I introduce RSA (and PKCS1_OAEP), it all goes down the tubes - the session_key encrypts fine but when I try and decrypt it, I get the following error: Traceback (most recent call last):įile "enctest.py", line 77, in decrypt_valįile "/usr/lib/python3.6/site-packages/Crypto/Cipher/PKCS1_OAEP.py", line 187, in decrypt When I try to create a symmetric encryption key and encrypt/decrypt variables, it all works fine. I'm working on implementing a public key encryption from P圜ryptodome on Python 3.6.
