{"record":{"id":"242e03da9ac5f2cd","repo":"golang/go","slug":"unsupported-aead-04x","errorCode":null,"errorMessage":"unsupported AEAD %04x","messagePattern":"unsupported AEAD %04x","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/crypto/hpke/aead.go","lineNumber":39,"sourceCode":"\taead(key []byte) (cipher.AEAD, error)\n}\n\n// NewAEAD returns the AEAD implementation for the given AEAD ID.\n//\n// Applications are encouraged to use specific implementations like [AES128GCM]\n// or [ChaCha20Poly1305] instead, unless runtime agility is required.\nfunc NewAEAD(id uint16) (AEAD, error) {\n\tswitch id {\n\tcase 0x0001: // AES-128-GCM\n\t\treturn AES128GCM(), nil\n\tcase 0x0002: // AES-256-GCM\n\t\treturn AES256GCM(), nil\n\tcase 0x0003: // ChaCha20Poly1305\n\t\treturn ChaCha20Poly1305(), nil\n\tcase 0xFFFF: // Export-only\n\t\treturn ExportOnly(), nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported AEAD %04x\", id)\n\t}\n}\n\n// AES128GCM returns an AES-128-GCM AEAD implementation.\nfunc AES128GCM() AEAD { return aes128GCM }\n\n// AES256GCM returns an AES-256-GCM AEAD implementation.\nfunc AES256GCM() AEAD { return aes256GCM }\n\n// ChaCha20Poly1305 returns a ChaCha20Poly1305 AEAD implementation.\nfunc ChaCha20Poly1305() AEAD { return chacha20poly1305AEAD }\n\n// ExportOnly returns a placeholder AEAD implementation that cannot encrypt or\n// decrypt, but only export secrets with [Sender.Export] or [Recipient.Export].\n//\n// When this is used, [Sender.Seal] and [Recipient.Open] return errors.\nfunc ExportOnly() AEAD { return exportOnlyAEAD{} }\n","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/crypto/hpke/aead.go#L21-L57","documentation":"`hpke.NewAEAD(id uint16)` resolves an AEAD algorithm identifier from the HPKE IANA registry. Only four IDs are recognized: 0x0001 (AES-128-GCM), 0x0002 (AES-256-GCM), 0x0003 (ChaCha20Poly1305), and 0xFFFF (Export-only). Any other ID returns this error. Callers normally receive the ID from a KEM/key-package header parsed off the wire.","triggerScenarios":"A peer proposes an AEAD the local registry does not support (e.g. AES-128-CCM, 0x000D); a malformed/test vector with a typo'd ID; an implementation that only knows a subset (e.g. excludes Export-only); version skew between two HPKE stacks.","commonSituations":"Interop with a newer draft/RFC that added an AEAD not in this Go version; cipher-suite negotiation bug where the receiver honors an ID it never registered; fuzz/corruption of the HPKE mode byte.","solutions":["Inspect the suite ID bytes being parsed and compare against the four supported constants; log the value for diagnosis.","Update the Go toolchain / x/crypto to a version that supports the AEAD you need.","If you control both peers, restrict configuration to one of {0x0001, 0x0002, 0x0003}.","Treat the error as a hard protocol failure — do not fall back to a weaker AEAD silently."],"exampleFix":"// before\na, err := hpke.NewAEAD(suite.AEADID) // suite from peer, may be 0x000D\n// after\nswitch suite.AEADID {\ncase 0x0001, 0x0002, 0x0003:\n    a, err = hpke.NewAEAD(suite.AEADID)\ndefault:\n    return fmt.Errorf(\"peer offered unsupported AEAD %04x\", suite.AEADID)\n}","handlingStrategy":"type-guard","validationCode":"supportedAEAD := map[uint16]bool{0x0001:true, 0x0002:true, 0x0003:true, 0xFFFF:true}\nif !supportedAEAD[id] {\n    return fmt.Errorf(\"AEAD %04x not supported\", id)\n}","typeGuard":"func isSupportedAEAD(id uint16) bool {\n    switch id {\n    case 0x0001, 0x0002, 0x0003, 0xFFFF:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Pin both HPKE peers to a known-good suite (e.g. AES-256-GCM).","Treat unsupported AEAD as a hard protocol failure — never silently downgrade."],"tags":["crypto","hpke","cipher-suite","protocol-negotiation"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}