Documentation
¶
Overview ¶
Package fips reports whether this binary performs cryptographic operations through a FIPS 140-3 validated module.
Detection is gated on the fips build tag. Without it, ActiveBackend always reports BackendNone and Enabled always reports false, so ordinary builds carry no FIPS-related code. Built with -tags fips, two backends are recognised:
BackendBoringCrypto: the FIPS Go compiler in https://github.com/golang-fips/go, which routes the crypto packages through a system OpenSSL and is probed via crypto/boring. It requires CGO_ENABLED=1, an amd64 Linux runtime, a kernel in FIPS mode (/proc/sys/crypto/fips_enabled is 1), and a system OpenSSL that can be loaded via dlopen().
BackendNativeGo: upstream Go's native Go Cryptographic Module, probed via crypto/fips140. It requires the binary to be built with GOFIPS140 set to a module version (for example v1.0.0), or to run with GODEBUG=fips140=on. See https://go.dev/doc/security/fips140.
crypto/boring only has buildable files when the boringcrypto build tag is set (GOEXPERIMENT=boringcrypto), so that probe is isolated behind the tag. This keeps the fips build tag usable on a toolchain that ships the native module instead of the golang-fips fork.
This package depends only on the standard library. FIPS-compliant SSH algorithm sets live in the gitlab.com/gitlab-org/labkit/v2/fips/sshalgo subpackage, which pulls in golang.org/x/crypto.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Enabled ¶
func Enabled() bool
Enabled reports whether cryptographic operations are backed by a FIPS module. Callers that need to know which module should use ActiveBackend instead.
Enabled is derived from ActiveBackend rather than probing the backends a second time, so the two cannot disagree.
func LogStatus ¶
LogStatus records this binary's FIPS posture at info level, under the fips_backend field. Services should call it once during start-up: the posture is fixed for the lifetime of the process, and an operator diagnosing a FIPS deployment needs it in the logs of every component.
A nil logger falls back to slog.Default.
Types ¶
type Backend ¶
type Backend string
Backend identifies the cryptographic backend satisfying FIPS 140-3 for this binary. It is a string so it renders usefully in logs and metrics labels.
const ( // BackendNone indicates no FIPS backend is active. Either the binary was // not built with the fips build tag, or it was but neither backend // activated at runtime. BackendNone Backend = "none" // BackendBoringCrypto indicates a BoringCrypto-compatible backend is // handling crypto operations, i.e. the external OpenSSL library used by // the golang-fips toolchain. BackendBoringCrypto Backend = "boringcrypto" // BackendNativeGo indicates upstream Go's native Go Cryptographic Module // is handling crypto operations. BackendNativeGo Backend = "native-go" )
func ActiveBackend ¶
func ActiveBackend() Backend
ActiveBackend reports which cryptographic backend is satisfying FIPS 140-3 for this binary. Without the fips build tag no backend is compiled in, so this is always BackendNone.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package sshalgo provides the SSH algorithm sets a server should offer, filtered for FIPS 140-3 compliance when the binary is built with the fips build tag.
|
Package sshalgo provides the SSH algorithm sets a server should offer, filtered for FIPS 140-3 compliance when the binary is built with the fips build tag. |