{"record":{"id":"d1e581a7a3f218aa","repo":"golang/go","slug":"crypto-des-use-of-tripledes-is-not-allowed-in-fip","errorCode":null,"errorMessage":"crypto/des: use of TripleDES is not allowed in FIPS 140-only mode","messagePattern":"crypto/des: use of TripleDES is not allowed in FIPS 140-only mode","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/crypto/des/cipher.go","lineNumber":81,"sourceCode":"\t}\n\tif len(dst) < BlockSize {\n\t\tpanic(\"crypto/des: output not full block\")\n\t}\n\tif alias.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {\n\t\tpanic(\"crypto/des: invalid buffer overlap\")\n\t}\n\tcryptBlock(c.subkeys[:], dst, src, true)\n}\n\n// A tripleDESCipher is an instance of TripleDES encryption.\ntype tripleDESCipher struct {\n\tcipher1, cipher2, cipher3 desCipher\n}\n\n// NewTripleDESCipher creates and returns a new [cipher.Block].\nfunc NewTripleDESCipher(key []byte) (cipher.Block, error) {\n\tif fips140only.Enforced() {\n\t\treturn nil, errors.New(\"crypto/des: use of TripleDES is not allowed in FIPS 140-only mode\")\n\t}\n\n\tif len(key) != 24 {\n\t\treturn nil, KeySizeError(len(key))\n\t}\n\n\tc := new(tripleDESCipher)\n\tc.cipher1.generateSubkeys(key[:8])\n\tc.cipher2.generateSubkeys(key[8:16])\n\tc.cipher3.generateSubkeys(key[16:])\n\treturn c, nil\n}\n\nfunc (c *tripleDESCipher) BlockSize() int { return BlockSize }\n\nfunc (c *tripleDESCipher) Encrypt(dst, src []byte) {\n\tif len(src) < BlockSize {\n\t\tpanic(\"crypto/des: input not full block\")","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/crypto/des/cipher.go#L63-L99","documentation":"In FIPS 140-only mode, the des package refuses to construct a TripleDES (3DES) cipher. Although stronger than single DES, 3DES is deprecated and not approved for new FIPS use, so NewTripleDESCipher short-circuits before key-length validation.","triggerScenarios":"Calling des.NewTripleDESCipher(key) in a binary with FIPS 140-only enforcement enabled.","commonSituations":"Legacy systems using 3DES (e.g. older TLS/JCE/PKCS interop) moved into a FIPS-regulated runtime; FIPS toolchain build picked up by CI without crypto audit.","solutions":["Migrate to AES (aes.NewCipher) for all new encryption.","If FIPS-only is not required, rebuild the binary without FIPS 140-only enforcement.","For existing 3DES data, decrypt in a non-FIPS context and re-encrypt with AES."],"exampleFix":"// before\nblock, err := des.NewTripleDESCipher(key24)\n// after\nblock, err := aes.NewCipher(key16)","handlingStrategy":"validation","validationCode":"func newBlock(key []byte) (cipher.Block, error) {\n    if fipsEnabled() {\n        return nil, errors.New(\"TripleDES is unavailable in FIPS-only mode; configure AES\")\n    }\n    return des.NewTripleDESCipher(key)\n}","typeGuard":null,"tryCatchPattern":"block, err := des.NewTripleDESCipher(key)\nif err != nil && strings.Contains(err.Error(), \"FIPS 140-only mode\") {\n    // migrate to AES or rebuild without FIPS-only mode\n}","preventionTips":["Treat 3DES as deprecated; plan migration to AES.","Gate legacy-crypto paths behind a feature flag so they can be disabled in FIPS builds.","Run a crypto audit when adopting a FIPS toolchain."],"tags":["crypto","des","tripledes","fips","compliance","go","security"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}