Skip to main content
Check a hardware security module (HSM) and provision keys on it through an hsm net on a Lager Box. The HSM generates and keeps the private keys. Lager reads only public keys and signatures.

Syntax

If you give no command, Lager lists the 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:
  1. The first line of stdin, if you give --password-stdin.
  2. The LAGER_HSM_PASSWORD environment variable.
  3. A prompt that does not show what you type.
There is no --password option. A value on the command line stays in the shell history, and other users can see it in the process list.
If the network between your computer and the box is not trusted, use the box only through Tailscale or an SSH tunnel. The CLI sends the password to the box API over plain HTTP, the same as all other box API traffic. Lager does not store the password, and the box removes it from its logs.
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


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

An 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

A lager python script gets the driver from the net. Each method that logs in takes auth_key_id and password as keyword arguments.
Run the script with lager python script.py --box my-lager-box --passenv LAGER_HSM_PASSWORD. The --passenv option keeps the password off the command line.

Supported Hardware

Troubleshooting