Documentation
¶
Overview ¶
Package pkcs11 implements a signing key backed by a PKCS#11 token or HSM. The private key never leaves the token: signing is performed on-device via the PKCS#11 C_Sign operation. Ed25519 (CKM_EDDSA) is the only key algorithm today; see algo.go for the per-algorithm seam.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Module string
TokenLabel string
Slot *uint
KeyLabel string
KeyID []byte
PIN string
PINEnv string
PINFile string
Algorithm config.Algorithm
}
Config describes how to open a key on a PKCS#11 token. Exactly one of TokenLabel/Slot selects the token, at least one of KeyLabel/KeyID selects the key, and exactly one of PIN/PINEnv/PINFile supplies the user PIN. Algorithm defaults to "ed25519" when empty.
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
Signer signs on a PKCS#11 token. It owns a single long-lived session; the mutex serializes signing (PKCS#11 sessions are not safe for concurrent use) and guards Close.
func Open ¶
Open loads the PKCS#11 module, logs into the selected token, locates the key, and caches its public key. Any failure is returned (fatal at startup for the chain). On success the returned Signer holds an open, logged-in session that must be released with Close.
func (*Signer) Close ¶
Close logs out, closes the session, and tears down the module. It is idempotent.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package pkcs11test provides SoftHSM2-backed helpers for exercising the PKCS#11 signer in tests.
|
Package pkcs11test provides SoftHSM2-backed helpers for exercising the PKCS#11 signer in tests. |