golang/go · error
crypto/dsa: use of DSA is not allowed in FIPS 140-only mode
Error message
crypto/dsa: use of DSA is not allowed in FIPS 140-only mode
What it means
In FIPS 140-only mode, dsa.GenerateParameters refuses to run because DSA is not an approved algorithm under FIPS-only policy. The check is the first statement, before any parameter sizing or prime generation.
Source
Thrown at src/crypto/dsa/dsa.go:68
// in a set of DSA parameters. See FIPS 186-3, section 4.2.
type ParameterSizes int
const (
L1024N160 ParameterSizes = iota
L2048N224
L2048N256
L3072N256
)
// numMRTests is the number of Miller-Rabin primality tests that we perform. We
// pick the largest recommended number from table C.1 of FIPS 186-3.
const numMRTests = 64
// GenerateParameters puts a random, valid set of DSA parameters into params.
// This function can take many seconds, even on fast machines.
func GenerateParameters(params *Parameters, rand io.Reader, sizes ParameterSizes) error {
if fips140only.Enforced() {
return errors.New("crypto/dsa: use of DSA is not allowed in FIPS 140-only mode")
}
// This function doesn't follow FIPS 186-3 exactly in that it doesn't
// use a verification seed to generate the primes. The verification
// seed doesn't appear to be exported or used by other code and
// omitting it makes the code cleaner.
var L, N int
switch sizes {
case L1024N160:
L = 1024
N = 160
case L2048N224:
L = 2048
N = 224
case L2048N256:
L = 2048
N = 256View on GitHub (pinned to b6b368adc5)
Solutions
- Migrate to an approved signature scheme: ecdsa.GenerateKey or ed25519.GenerateKey.
- If FIPS-only is not required, rebuild without FIPS 140-only enforcement.
- Pre-generate DSA parameters in a non-FIPS environment and load them, if DSA is unavoidable (still not FIPS-approved).
Example fix
// before var params dsa.Parameters dsa.GenerateParameters(¶ms, rand.Reader, dsa.L2048N256) // after priv, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
Defensive patterns
Strategy: fallback
Validate before calling
func genParams(rand io.Reader) (*dsa.PrivateKey, error) {
if fipsEnabled() {
// DSA not approved under FIPS; use ECDSA instead.
priv, err := ecdsa.GenerateKey(elliptic.P256(), rand)
return (*dsa.PrivateKey)(unsafe.Pointer(priv)), err // illustrative; prefer returning ecdsa key
}
var params dsa.Parameters
return dsa.GenerateParameters(¶ms, rand, dsa.L2048N256)
} Try / catch
err := dsa.GenerateParameters(¶ms, rand.Reader, sizes)
if err != nil && strings.Contains(err.Error(), "FIPS 140-only mode") {
// fall back to ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
} Prevention
- Detect FIPS-only mode at startup and route signing to an approved scheme.
- Keep DSA out of FIPS-bound service paths.
- Document which signature schemes are permitted in each deployment.
When it happens
Trigger: Calling dsa.GenerateParameters(¶ms, rand, sizes) in a binary built/run with FIPS 140-only enforcement.
Common situations: Generating DSA keys in a FIPS-regulated deployment; CI pipeline switched to a FIPS toolchain; compliance-mandated runtime.
Related errors
- crypto/des: use of DES is not allowed in FIPS 140-only mode
- crypto/des: use of TripleDES is not allowed in FIPS 140-only
- crypto/ecdh: only crypto/rand.Reader is allowed in FIPS 140-
- crypto/ecdh: use of X25519 is not allowed in FIPS 140-only m
- crypto/dsa: invalid public key
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/03a283545ddabcd1.
Report an issue: GitHub.