hsm net on a Lager Box. The HSM generates and keeps the private keys. Lager reads only public keys and signatures.
Syntax
hsm nets on the box:
Commands
Login
A command that logs in uses an authentication key on the HSM. Give the key ID with--auth-key-id. The default is 1, which is the factory authentication key.
Lager reads the password from these sources, in this order:
- The first line of stdin, if you give
--password-stdin. - The
LAGER_HSM_PASSWORDenvironment variable. - A prompt that does not show what you type.
--password option. A value on the command line stays in the shell history, and other users can see it in the process list.
The factory login is authentication key
1 with the password password. Replace that key before you put keys on the HSM that matter.
lager hsm NET_NAME info
Show the firmware version, the serial number, the part number and the use of the audit log. This command does not log in.
Options
Output
lager hsm NET_NAME blink
Blink the LED on the HSM. Use this command to find one HSM among several.
lager hsm NET_NAME objects
List the objects on the HSM that the authentication key can see.
Output
lager hsm NET_NAME generate
Generate an asymmetric key on the HSM. The private key does not leave the HSM. The command prints the public key as PEM.
The default capability is
sign-ecdsa for an EC key and sign-eddsa for an Ed25519 key. The authentication key must have each capability that you give the new key.
The CLI cannot generate RSA keys at this time. The HSM takes between a few seconds and more than a minute to generate one RSA key. That is longer than the box lets one device call run before it treats the device as stuck. To generate an RSA key, use the Python API in a
lager python script. The CLI can sign with an RSA key that is already on the HSM.lager hsm NET_NAME pubkey
Print the public key of an asymmetric key as PEM.
lager hsm NET_NAME sign
Sign data with an asymmetric key. The command prints the signature as hex, or writes the raw signature to a file.
Give exactly one of
--data-file and --data-hex. The HSM hashes the data itself, so give the message, not a digest. An ECDSA signature is DER-encoded.
lager hsm NET_NAME delete
Delete an object from the HSM. You cannot undo this.
lager hsm NET_NAME reset
Erase every object on the HSM and restore the factory login. You cannot undo this. The HSM restarts, and the command waits until it answers again.
The confirmation prompt also reads stdin. Thus
delete and reset with --password-stdin also need --yes.
Creating HSM Nets
hsm net has one channel, 0. The address carries the serial number of the HSM, so the net stays on the same device when you connect more than one.
Python API
Alager python script gets the driver from the net. Each method that logs in takes auth_key_id and password as keyword arguments.
lager python script.py --box my-lager-box --passenv LAGER_HSM_PASSWORD. The --passenv option keeps the password off the command line.

