Всем привет.
Пытаюсь реализовать следующий алгоритм криптографии: https://habrahabr.ru/post/265309/
        data = 'test'
        # Подпись сообщения цифровой подписью
        gateway_private_key_file = open('{0}{1}'.format(GCryptHelper.get_keys_directory(), 'gateway_private_key.pem'), 'rb')
        gateway_private_key = RSA.importKey(gateway_private_key_file.read())
        data_hash = SHA.new(data)
        signature = PKCS1_v1_5.new(gateway_private_key)
        signature = signature.sign(data_hash)
        # Шифрование подписи открытым ключем принимающей стороны
        gcrypt_public_key_file = open('{0}{1}'.format(GCryptHelper.get_keys_directory(), 'gcrypt_public_key.pem'), 'rb')
        gcrypt_public_key = RSA.importKey(gcrypt_public_key_file.read())
        cipher_rsa = PKCS1_OAEP.new(gcrypt_public_key)
        signature = cipher_rsa.encrypt(signature[:128]) + cipher_rsa.encrypt(signature[128:])
        # Генерирование сеансовго ключа и шифрование данных
        session_key = Random.new().read(32)
        i_vector = Random.new().read(16)
        obj = AES.new(session_key, AES.MODE_CFB, i_vector)
        cipher_data = i_vector + obj.encrypt(data)
        # Шифрование сеансового ключа открытым ключем принимающей стороны
        cipher_session_key = cipher_rsa.encrypt(session_key)
        gcrypt_private_key_file = open('{0}{1}'.format(
            GCryptHelper.get_keys_directory(),
            'gcrypt_private_key.pem'
        ), 'rb')
        session_key = cipher_rsa.decrypt(cipher_session_key)
В самом конце, где идёт попытка расшивровать session_key - я получаю ошибку:
Traceback (most recent call last):
  File "/Users/Vir/Work/Gateway/app/system/helpers/gcrypt/gcrypt.py", line 100, in <module>
    GCryptHelper.encrypt('test')
  File "/Users/Vir/Work/Gateway/app/system/helpers/gcrypt/gcrypt.py", line 42, in encrypt
    print(cipher_rsa.decrypt(cipher_session_key))
  File "/Users/Vir/Work/Envs/gateway/lib/python3.5/site-packages/Crypto/Cipher/PKCS1_OAEP.py", line 189, in decrypt
    modBits = Crypto.Util.number.size(self._key.n)
AttributeError: 'bytes' object has no attribute 'n'
В чем дело? Я понимаю, что decrypt принимает строку, но при попытке сделать cipher_rsa.decrypt(cipher_session_key.decode()), получаю ошибку:
Traceback (most recent call last):
  File "/Users/Vir/Work/Gateway/app/system/helpers/gcrypt/gcrypt.py", line 100, in <module>
    GCryptHelper.encrypt('test')
  File "/Users/Vir/Work/Gateway/app/system/helpers/gcrypt/gcrypt.py", line 42, in encrypt
    session_key = cipher_rsa.decrypt(cipher_session_key.decode())
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x95 in position 0: invalid start byte
