{"record":{"id":"03a283545ddabcd1","repo":"golang/go","slug":"crypto-dsa-use-of-dsa-is-not-allowed-in-fips-140","errorCode":null,"errorMessage":"crypto/dsa: use of DSA is not allowed in FIPS 140-only mode","messagePattern":"crypto/dsa: use of DSA is not allowed in FIPS 140-only mode","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/crypto/dsa/dsa.go","lineNumber":68,"sourceCode":"// in a set of DSA parameters. See FIPS 186-3, section 4.2.\ntype ParameterSizes int\n\nconst (\n\tL1024N160 ParameterSizes = iota\n\tL2048N224\n\tL2048N256\n\tL3072N256\n)\n\n// numMRTests is the number of Miller-Rabin primality tests that we perform. We\n// pick the largest recommended number from table C.1 of FIPS 186-3.\nconst numMRTests = 64\n\n// GenerateParameters puts a random, valid set of DSA parameters into params.\n// This function can take many seconds, even on fast machines.\nfunc GenerateParameters(params *Parameters, rand io.Reader, sizes ParameterSizes) error {\n\tif fips140only.Enforced() {\n\t\treturn errors.New(\"crypto/dsa: use of DSA is not allowed in FIPS 140-only mode\")\n\t}\n\n\t// This function doesn't follow FIPS 186-3 exactly in that it doesn't\n\t// use a verification seed to generate the primes. The verification\n\t// seed doesn't appear to be exported or used by other code and\n\t// omitting it makes the code cleaner.\n\n\tvar L, N int\n\tswitch sizes {\n\tcase L1024N160:\n\t\tL = 1024\n\t\tN = 160\n\tcase L2048N224:\n\t\tL = 2048\n\t\tN = 224\n\tcase L2048N256:\n\t\tL = 2048\n\t\tN = 256","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/crypto/dsa/dsa.go#L50-L86","documentation":"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.","triggerScenarios":"Calling dsa.GenerateParameters(&params, rand, sizes) in a binary built/run with FIPS 140-only enforcement.","commonSituations":"Generating DSA keys in a FIPS-regulated deployment; CI pipeline switched to a FIPS toolchain; compliance-mandated runtime.","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)."],"exampleFix":"// before\nvar params dsa.Parameters\ndsa.GenerateParameters(&params, rand.Reader, dsa.L2048N256)\n// after\npriv, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)","handlingStrategy":"fallback","validationCode":"func genParams(rand io.Reader) (*dsa.PrivateKey, error) {\n    if fipsEnabled() {\n        // DSA not approved under FIPS; use ECDSA instead.\n        priv, err := ecdsa.GenerateKey(elliptic.P256(), rand)\n        return (*dsa.PrivateKey)(unsafe.Pointer(priv)), err // illustrative; prefer returning ecdsa key\n    }\n    var params dsa.Parameters\n    return dsa.GenerateParameters(&params, rand, dsa.L2048N256)\n}","typeGuard":null,"tryCatchPattern":"err := dsa.GenerateParameters(&params, rand.Reader, sizes)\nif err != nil && strings.Contains(err.Error(), \"FIPS 140-only mode\") {\n    // fall back to ecdsa.GenerateKey(elliptic.P256(), rand.Reader)\n}","preventionTips":["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."],"tags":["crypto","dsa","fips","compliance","go","security"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}