forked from secure-systems-lab/securesystemslib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds basic Signer and Key implementations to generate signatures on a hardware security module (HSMSigner) and to export the corresponding public key (HSMKey). Supported keys are ecdsa on SECG curves secp256r1 (NIST P-256) or secp384r1 (NIST P-384), which correspond to securesystemslib signing schemes "ecdsa-sha2-nistp256" and "ecdsa-sha2-nistp384". Tests are performed on SoftHSM (virtual hsm). **Caveat** HSMSigner and HSMKey use the token from a passed PyKCS11 session. This means that users must identify the correct slot, token and key, open a session, optionally log in (for signing), and also log out and close the session afterwards. This is not user-friendly. Ideally, the user only identifies the correct slot, token and key out-of-band (e.g. with pkcs11-tool, yubico-piv-tool or ykman) and then passes a stable identifier to HSMSigner. Maybe labels? Slot id is not stable. **Other ideas** - HSMKey is an SSlibKey with an *import key from HSM* method. The method could be moved to different import API (see secure-systems-lab#466), and HSMKey could be removed. - HSMSigner could live in a dedicated _hsm_signer.py, this would better hide the conditional imports. Signed-off-by: Lukas Puehringer <[email protected]>
- Loading branch information
Showing
11 changed files
with
497 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Run Securesystemslib HSM tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout securesystemslib | ||
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: "pip" | ||
cache-dependency-path: "requirements*.txt" | ||
|
||
- 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 | ||
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: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install --upgrade tox | ||
- name: Run tox | ||
run: tox -e hsm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,3 +51,4 @@ check-quote-consistency=yes | |
|
||
[TYPECHECK] | ||
generated-members=shake_128s.* | ||
ignored-modules=PyKCS11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# | ||
# This file is autogenerated by pip-compile with python 3.8 | ||
# To update, run: | ||
# | ||
# pip-compile --output-file=requirements-hsm-pinned.txt requirements-hsm.txt | ||
# | ||
asn1crypto==1.5.1 | ||
# via -r requirements-hsm.txt | ||
cffi==1.15.1 | ||
# via cryptography | ||
cryptography==38.0.4 | ||
# via -r requirements-hsm.txt | ||
pycparser==2.21 | ||
# via cffi | ||
pykcs11==1.5.11 | ||
# via -r requirements-hsm.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
asn1crypto | ||
cryptography | ||
PyKCS11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.