pyauth / python-pkcs11

PKCS#11/Cryptoki support for Python
MIT License
150 stars 71 forks source link

Enable AES counter mode #168

Open solney opened 12 months ago

solney commented 12 months ago

Here is a PR to expose AES_CTR mode.

The documentation states that it was not supported due to lack of hardware supporting it. We have been able to enable and use it successfully with a software HSM (SoftHSM), and on the AWS CloudHSM platform.

To run tests against SoftHSM

In a fresh env e.g docker container

docker run --rm -it  -v $(pwd):/work -w /work ubuntu:20.04 bash

Install deps

apt-get update
apt-get install softhsm pip -y
pip install -r dev-requirements.txt -r requirements.txt pytest

Install project deps and run tests:

softhsm2-util  --init-token --free --label test-python-pkcs11 --pin 1234 --so-pin 1234
export PKCS11_MODULE=/usr/lib/softhsm/libsofthsm2.so
export PKCS11_TOKEN_LABEL=test-python-pkcs11
export PKCS11_TOKEN_PIN=1234
export PKCS11_TOKEN_SO_PIN=1234
pytest -v tests/test_aes.py