Encryption libraries incorrect
nwalsh1995 opened this issue · 2 comments
From the docs:
On CPython (the regular Python), one of the following libraries is required:
The python-nss library
The pycryptopp library
The cryptography library
The PyCrypto library
Using python 3.6, I tried to use the cryptography
library but it was throwing this error:
File "/Users/aaaa/venv/lib/python3.6/site-packages/beaker/session.py", line 273, in _encrypt_data
return nonce + b64encode(crypto.aesEncrypt(data, encrypt_key))
AttributeError: module 'beaker.crypto' has no attribute 'aesEncrypt'
Looking into the code there are the following statements from /beaker/crypto/__init__.py
:
try:
from beaker.crypto.nsscrypto import getKeyLength, aesEncrypt, aesDecrypt
keyLength = getKeyLength()
except ImportError:
try:
from beaker.crypto.pycrypto import getKeyLength, aesEncrypt, aesDecrypt
keyLength = getKeyLength()
except ImportError:
pass
Note that pycrypto attempts to use pycryptopp and pycrypto. So it seems like only the cryptography
library is not supported. I haven't traced through the rest of the code to determine if it was being used somewhere else, but switching from the cryptography library to pycrypto fixed my issue.
I would make the changes for the docs but I am unsure if the cryptography
library would be used anywhere thats supported, so I have created this issue.
Are you sure you are using the most recent Beaker version?
I don't see the code you are mentioning in current codebase: https://github.com/bbangert/beaker/blob/f377072eb1fb99bce73734eaff1350fbcd6514b7/beaker/crypto/__init__.py
The current version of beaker allows to choose the crypto backend based on a crypto_type
option.
Hi @amol-, that is correct sorry. I was using 1.8 version. Closing out.