Skip to content

Commit

Permalink
HSMSigner: Tweak docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
jku committed Mar 4, 2023
1 parent bc30a6b commit 9a3ab72
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions securesystemslib/signer/_hsm_signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,26 +83,34 @@ class HSMSigner(Signer):
Supports signing schemes "ecdsa-sha2-nistp256" and "ecdsa-sha2-nistp384".
HSMSigner uses the first token it finds, if multiple tokens are available. They can
be instantiated with Signer.from_priv_key_uri(). These private key URI schemes are
supported:
HSMSigners should be instantiated with Signer.from_priv_key_uri() as in the usage
example below.
The private key URI scheme is: "hsm:<KEYID>?<FILTERS>" where both KEYID and
FILTERS are optional. Example URIs:
* "hsm:":
Sign with key on PIV digital signature slot 9c.
Sign with a key with default keyid 2 (PIV digital signature slot 9c) on the
only token/smartcard available.
* "hsm:2?label=YubiKey+PIV+%2315835999":
Sign with key with keyid 2 (PIV slot 9c) on a token with label
"YubiKey+PIV+%2315835999"
Usage::
# Store public key and URI for your HSM device for later use. By default
# slot 9c is selected.
uri, pubkey = HSMSigner.import_()
# sign with PIV slot 9c, verify with existing public key
# later, use the uri and pubkey to sign
def pin_handler(secret: str) -> str:
return getpass(f"Enter {secret}: ")
signer = Signer.from_priv_key_uri("hsm:", public_key, pin_handler)
signer = Signer.from_priv_key_uri(uri, pubkey, pin_handler)
sig = signer.sign(b"DATA")
public_key.verify_signature(sig, b"DATA")
pubkey.verify_signature(sig, b"DATA")
Arguments:
hsm_keyid: Key identifier on the token.
token_filter: dictionary of token field names and values
public_key: The related public key instance.
pin_handler: A function that returns the HSM user login pin, needed for
signing. It receives the string argument "pin".
Expand Down

0 comments on commit 9a3ab72

Please sign in to comment.