Skip to content
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

HSM support for keys (#21) #733

Merged
merged 9 commits into from
Jan 14, 2022
Merged

HSM support for keys (#21) #733

merged 9 commits into from
Jan 14, 2022

Conversation

ximon18
Copy link
Member

@ximon18 ximon18 commented Nov 23, 2021

This PR implements support in Krill for creating signing key pairs in HSMs rather than using OpenSSL to create key files on disk.

It isn't strictly limited to Hardware Security Modules, it supports anything that implements either the PKCS#11 v2.20+ interface or the KMIP 1.2+ TTLV over TCP/TLS protocol, and that supports the necessary operations (primarily RSA key pair creation, deletion and signing with the created private key, but also surrounding operations such as modifying key attributes, locating keys, querying HSM metadata, etc). These can be hardware or software, servers or USB keys, etc.

When enabled the hsm feature causes Krill to start tracking the relationship between key identifiers (as used in certificates) and the signer which possesses the actual public and private key pair to which the key identifier refers. This tracking is done using an aggregate store backed by files on disk, just as the other core data in Krill is managed.

To use the new functionality one must add one or more [[signers]] blocks to krill.conf, see the comments in defaults/krill-hsm.conf for more information and remember to restart Krill after changing the configuration file.

Note that by default OpenSSL is still used for the generation of one-off keys and for generating random byte sequences. One-off key creation, signing and deletion can be assigned to an actual HSM if desired. Random generation is always handled by OpenSSL.

Testing

This PR (or earlier very similar versions of it) have been tested with the following cryptographic tokens: (in alphabetic order)

Cryptographic Token Name Tested Protocols Tested Token Form Test Results
AWS CloudHSM PKCS#11 Cloud Service #556
Kryptus kNET HSM PKCS#11 & KMIP Cloud Service #554, #565
PyKMIP KMIP Software #564
SoftHSMv2 PKCS#11 Software #553
Utimaco Security Server PKCS#11 Software Simulator #732
YubiHSM 2 PKCS#11 USB key #555

Special thanks to for providing the YubiHSM 2 that I tested with.

The GitHub Actions CI workflow has been extended to run the Krill test suite both in its usual mode of operation using OpenSSL as the signer, and additionally with SoftHSMv2 as the signer via its PKCS#11 interface, and PyKMIP as the signer via its KMIP interface.

The end-to-end test has also been updated to use SoftHSMv2 as the backing signer rather than OpenSSL. See the test results.

Known limitations

This PR:

@ximon18 ximon18 marked this pull request as ready for review November 23, 2021 09:02
@ximon18 ximon18 marked this pull request as draft November 23, 2021 09:04
Adds support for PKCS#11 v2.20 and/or KMIP 1.2 compatible HSMs.
Includes backward compatible extensions to the krill.conf syntax.
Excludes HSM specific API (REST, krillc, Prometheus) or UI extensions.
@ximon18 ximon18 marked this pull request as ready for review November 30, 2021 20:11
Add developer docs describing connection related logic common to the PKCS#11 and KMIP signers.
Replace the `pkcs11` crate with the `cryptoki` crate in order to support non x86_64 architectures, e.g. ARMv7 on a Raspberry Pi 4b.

Changes:
- Logs crpytoki call names rather than PKCS#11 call names as we don't know which PKCS#11 calls Cryptoki actually makes on our behalf.
- Lacks supported capability checking (see parallaxsecond/rust-cryptoki#78).
- Lacks library re-initialization to force flush the library "cache" of available tokens (see parallaxsecond/rust-cryptoki#75).
@ximon18 ximon18 added hsm Relates to adding HSM support to Krill enhancement New feature or request labels Jan 14, 2022
@ximon18 ximon18 merged commit b0be88b into dev Jan 14, 2022
@ximon18 ximon18 deleted the hsm branch January 14, 2022 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hsm Relates to adding HSM support to Krill
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant