Skip to content

Add HSMSigner #472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,26 @@ jobs:
python -m pip install --upgrade pip
pip install --upgrade tox

- name: Install system dependencies
shell: bash
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get install -y softhsm2
echo "PYKCS11LIB=/usr/lib/softhsm/libsofthsm2.so" >> $GITHUB_ENV

elif [ "$RUNNER_OS" == "macOS" ]; then
brew install softhsm
echo "PYKCS11LIB=$(brew --prefix softhsm)/lib/softhsm/libsofthsm2.so" >> $GITHUB_ENV

# TODO: Uncomment when testing on Windows
# elif [ "$RUNNER_OS" == "Windows" ]; then
# choco install softhsm.install
# echo "PYKCS11LIB=C:\SoftHSM2\lib\softhsm2-x64.dll" >> $GITHUB_ENV

else
echo "$RUNNER_OS not supported"
exit 1
fi

- name: Run tox
run: tox -e ${{ matrix.toxenv }}
9 changes: 8 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@ follow_imports = silent

# let's not install typeshed annotations for GCPSigner
[mypy-google.*]
ignore_missing_imports = True
ignore_missing_imports = True

# Suppress error messages for non-annotating dependencies
[mypy-PyKCS11.*]
ignore_missing_imports = True

[mypy-asn1crypto.*]
ignore_missing_imports = True
1 change: 1 addition & 0 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ check-quote-consistency=yes

[TYPECHECK]
generated-members=shake_128s.*
ignored-modules=PyKCS11
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ crypto = ["cryptography>=37.0.0"]
gcpkms = ["google-cloud-kms"]
pynacl = ["pynacl>1.2.0"]
PySPX = ["PySPX==0.5.0"]
asn1 = ["asn1crypto"]
pykcs11 = ["PyKCS11"]
Comment on lines +50 to +51
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feels like this isn't the correct way to use this system. pykcs11 without asn1 doesn't make sense so why offer that as option?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asn1crypto is only an immediate dependency for pubkey export. For signing we don't use it.

Copy link
Member Author

@lukpueh lukpueh Dec 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I agree, telling users to run

pip install securesystemslib[crypto, asn1, pykcs11]

is not a lot better, than

pip install cryptography asn1crypto pykcs11 securesystemslib

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Listing extra dependencies by feature, otoh, seems prone to redundancy. cryptography, for instance, is used for many different features.


[tool.setuptools]
include-package-data = true
Expand Down
27 changes: 22 additions & 5 deletions requirements-pinned.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
cffi==1.15.1 # via cryptography, pynacl
cryptography==38.0.3
pycparser==2.21 # via cffi
#
# This file is autogenerated by pip-compile with python 3.8
# To update, run:
#
# pip-compile --output-file=requirements-pinned.txt requirements.txt
#
asn1crypto==1.5.1
# via -r requirements.txt
cffi==1.15.1
# via
# cryptography
# pynacl
# pyspx
cryptography==38.0.3 ; python_version >= "3"
# via -r requirements.txt
pycparser==2.21
# via cffi
pykcs11==1.5.11
# via -r requirements.txt
pynacl==1.5.0
six==1.16.0 # via pynacl
PySPX==0.5.0
# via -r requirements.txt
pyspx==0.5.0
# via -r requirements.txt
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@
cryptography >= 37.0.0; python_version >= '3'
pynacl
PySPX
PyKCS11
asn1crypto
2 changes: 2 additions & 0 deletions securesystemslib/signer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Some implementations are provided by default but more can be added by users.
"""
from securesystemslib.signer._gcp_signer import GCPSigner
from securesystemslib.signer._hsm_signer import HSMSigner
from securesystemslib.signer._key import KEY_FOR_TYPE_AND_SCHEME, Key, SSlibKey
from securesystemslib.signer._signature import GPGSignature, Signature
from securesystemslib.signer._signer import (
Expand All @@ -21,6 +22,7 @@
SSlibSigner.ENVVAR_URI_SCHEME: SSlibSigner,
SSlibSigner.FILE_URI_SCHEME: SSlibSigner,
GCPSigner.SCHEME: GCPSigner,
HSMSigner.SCHEME: HSMSigner,
}
)

Expand Down
Loading