hmackey

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package hmackey checks operator-supplied HMAC keys (salts, webhook secrets) at config load (ADR-0038). Go's FIPS 140-3 module refuses an HMAC key shorter than 112 bits: under GODEBUG=fips140=only it panics inside hmac.New, which would crash a request goroutine or a background worker long after startup. So in FIPS mode (crypto/fips140.Enabled(): fips140=on or only, the default in a FIPS build) a short key refuses to start, naming the setting; outside FIPS mode it only warns, so existing deployments keep running. Keys are never stretched: receivers such as GitHub compute the HMAC with the raw secret.

Index

Constants

View Source
const MinFIPS = 14

MinFIPS is the shortest HMAC key Go's FIPS 140-3 module accepts: 112 bits.

Variables

This section is empty.

Functions

func Check

func Check(log *slog.Logger, flag string, key []byte) error

Check validates one HMAC key named by flag (the config key or CLI flag an operator would change). An empty key is the caller's business (feature off, or a random key generated later) and passes. In FIPS mode a key under MinFIPS bytes is an error; otherwise it is logged as a warning on log (nil: slog.Default) and accepted.

func Usable

func Usable(key []byte) bool

Usable reports whether key can be used with HMAC in the current mode without risking the module's panic: always outside FIPS mode, and only at MinFIPS bytes or more inside it. Request-path code uses it as a last guard so a key that slipped past Check is a refusal, never a panic.

Types

This section is empty.

Directories

Path Synopsis
Package hmackeytest lets tests run hmackey's checks as if FIPS mode were on or off.
Package hmackeytest lets tests run hmackey's checks as if FIPS mode were on or off.
internal
fipsmode
Package fipsmode is the FIPS-mode probe internal/hmackey consults.
Package fipsmode is the FIPS-mode probe internal/hmackey consults.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL