Documentation
¶
Index ¶
- Constants
- func ExecStarter(cfg TokenConfig) starter
- func RunHelper(args []string) error
- type Helper
- func (h *Helper) Close() error
- func (h *Helper) CurrentKeyVersion(context.Context) (string, error)
- func (h *Helper) DecryptableKeyVersions() []string
- func (h *Helper) Info() Info
- func (h *Helper) Unwrap(ctx context.Context, wrapped []byte, encCtx map[string]string) ([]byte, error)
- func (h *Helper) Wrap(ctx context.Context, dek []byte, encCtx map[string]string) ([]byte, error)
- type HelperOptions
- type InProcess
- type Info
- type Token
- type TokenConfig
Constants ¶
const ( RestartExit = "exit" RestartDeadline = "deadline" )
Restart reasons for aerolvm_pkcs11_helper_restarts_total{reason}.
const ( IVAuto = "auto" IVHSM = "hsm" IVCaller = "caller" )
IV modes (SB_SECRET_PKCS11_GCM_IV).
const HelperFlag = "--pkcs11-helper"
HelperFlag starts `sandboxd` as the PKCS#11 helper (cmd/sandboxd).
const OpDeadline = 5 * time.Second
OpDeadline bounds every helper op. A vendor C_Encrypt can block inside the helper; past this deadline sandboxd kills and replaces the helper, which frees any session stuck in a C call (eng D25).
const StartTimeout = 15 * time.Second
StartTimeout covers C_Initialize, login, the IV probe and the first key lookup in a fresh helper.
Variables ¶
This section is empty.
Functions ¶
func ExecStarter ¶
func ExecStarter(cfg TokenConfig) starter
ExecStarter runs this same binary with HelperFlag and the token settings as flags. The helper exits when its parent does.
Types ¶
type Helper ¶
type Helper struct {
// contains filtered or unexported fields
}
Helper is the sandboxd side of the PKCS#11 helper (eng D5): a secrets.DataKeyWrapper that forwards each call over the helper's socket and keeps the helper running. The vendor library never loads into sandboxd, so a vendor crash costs a helper restart, not the daemon.
func StartHelper ¶
func StartHelper(opts HelperOptions) (*Helper, error)
StartHelper launches the helper and waits until it serves. It always returns a Helper whose supervisor keeps (re)starting the helper; the error is the first start's, so boot can refuse under strict boot or warn and carry on, as for the other providers.
func (*Helper) CurrentKeyVersion ¶
CurrentKeyVersion implements secrets.KeyVersioner: the label new wraps use, in the form secrets.WrappedKeyVersion reports, so the rewrap sweep moves rows on older labels to it (§11, eng D23).
func (*Helper) DecryptableKeyVersions ¶
DecryptableKeyVersions lists the labels this node still opens, current first, for aerolvm_key_decryptable (eng D23: a rotation waits until every member can open the new label before switching to it).
func (*Helper) Info ¶
Info is what the helper reported about its token at its last start; the zero Info until a start succeeds.
type HelperOptions ¶
type HelperOptions struct {
// Socket is the helper's Unix socket. Its directory is made 0700, and
// the helper makes the socket 0600.
Socket string
Token TokenConfig
// contains filtered or unexported fields
}
HelperOptions configures the sandboxd side of the helper.
type InProcess ¶
type InProcess struct {
// contains filtered or unexported fields
}
InProcess is the token used directly as a secrets.DataKeyWrapper, for the short-lived `sandboxd key` CLI: a vendor crash there only ends the command, so it needs no helper (§2). sandboxd itself always uses Helper.
func OpenInProcess ¶
func OpenInProcess(cfg TokenConfig) (*InProcess, error)
OpenInProcess opens the token in this process.
type Info ¶
type Info struct {
HardwareSlot bool `json:"hardware_slot"`
TokenLabel string `json:"token_label"`
Manufacturer string `json:"manufacturer"`
Model string `json:"model"`
KeyLabel string `json:"key_label"`
DecryptLabels []string `json:"decrypt_labels,omitempty"`
IVMode string `json:"iv_mode"`
}
Info describes the token the helper opened, for the hardware-slot rule and the custody report.
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
Token is one HSM token opened by the helper: a logged-in session pool and the configured key labels.
func OpenToken ¶
func OpenToken(cfg TokenConfig) (*Token, error)
OpenToken opens the vendor module and the configured token.
func (*Token) Close ¶
func (t *Token) Close()
Close closes every pooled session and finalizes the module.
type TokenConfig ¶
type TokenConfig struct {
Module string
TokenLabel string
PINFile string
KeyLabel string
DecryptLabels []string
IVMode string
// Sessions is the session pool: the foreground cap plus the background
// slots (eng D13), so background work never takes a session a create
// needs.
Sessions int
}
TokenConfig is the SB_SECRET_PKCS11_* settings, handed to the helper as flags so it never re-reads sandboxd's configuration.