{"record":{"id":"e72842db7b82e9c4","repo":"OpenNHP/opennhp","slug":"unknown-symmetric-mode-name-s","errorCode":null,"errorMessage":"unknown symmetric mode name: %s","messagePattern":"unknown symmetric mode name: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nhp/core/ztdo/noise.go","lineNumber":103,"sourceCode":"\tswitch mode {\n\tcase \"AES-256-GCM-64\":\n\t\treturn AES256GCM64Tag, nil\n\tcase \"AES-256-GCM-96\":\n\t\treturn AES256GCM96Tag, nil\n\tcase \"AES-256-GCM-104\":\n\t\treturn AES256GCM104Tag, nil\n\tcase \"AES-256-GCM-112\":\n\t\treturn AES256GCM112Tag, nil\n\tcase \"AES-256-GCM-120\":\n\t\treturn AES256GCM120Tag, nil\n\tcase \"AES-256-GCM-128\":\n\t\treturn AES256GCM128Tag, nil\n\tcase \"SM4-GCM-64\":\n\t\treturn SM4GCM64Tag, nil\n\tcase \"SM4-GCM-128\":\n\t\treturn SM4GCM128Tag, nil\n\tdefault:\n\t\treturn 0, fmt.Errorf(\"unknown symmetric mode name: %s\", mode)\n\t}\n}\nfunc (mode SymmetricCipherMode) newCipherBlock(key []byte) (cipher.Block, error) {\n\tswitch mode {\n\tcase AES256GCM64Tag, AES256GCM96Tag, AES256GCM104Tag,\n\t\tAES256GCM112Tag, AES256GCM120Tag, AES256GCM128Tag:\n\t\tif len(key) != 32 {\n\t\t\treturn nil, fmt.Errorf(\"invalid key length for AES-256-GCM\")\n\t\t}\n\t\treturn aes.NewCipher(key)\n\tcase SM4GCM64Tag, SM4GCM128Tag:\n\t\tif len(key) < 16 {\n\t\t\treturn nil, fmt.Errorf(\"invalid key length for SM4-GCM\")\n\t\t} else {\n\t\t\tkey = key[:16]\n\t\t}\n\t\treturn sm4.NewCipher(key)\n\tdefault:","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/nhp/core/ztdo/noise.go#L85-L121","documentation":"NewSymmetricCipherMode converts a cipher-suite name string (e.g. \"AES-256-GCM-128\", \"SM4-GCM-64\") into a SymmetricCipherMode tag. Any name not matching a known case hits the default branch and returns this error. It enforces the closed set of Noise symmetric ciphers supported by the ztdo package.","triggerScenarios":"Calling NewSymmetricCipherMode with a mode string other than the exact accepted names (AES-256-GCM-64/96/104/112/120/128, SM4-GCM-64, SM4-GCM-128) — typos, wrong case, or unsupported suite names (nhp/core/ztdo/noise.go:103).","commonSituations":"Config files specifying cipher names like \"aes-256-gcm\" (wrong case/format) or a newer/older protocol draft name not in this build; hand-written protocol negotiation tables.","solutions":["Use an exact supported name, e.g. NewSymmetricCipherMode(\"AES-256-GCM-128\") or NewSymmetricCipherMode(\"SM4-GCM-128\")","Check spelling and case: the switch is case-sensitive and expects hyphenated names","Print the supported mode list and align your config/negotiation code with it"],"exampleFix":"// before\nmode, err := NewSymmetricCipherMode(\"aes-256-gcm\") // unknown name\n// after\nmode, err := NewSymmetricCipherMode(\"AES-256-GCM-128\")","handlingStrategy":"validation","validationCode":"supported := map[string]bool{\"AES-256-GCM-64\": true, \"AES-256-GCM-96\": true, \"AES-256-GCM-104\": true, \"AES-256-GCM-112\": true, \"AES-256-GCM-120\": true, \"AES-256-GCM-128\": true, \"SM4-GCM-64\": true, \"SM4-GCM-128\": true}\nif !supported[modeName] { return fmt.Errorf(\"unsupported cipher mode %q\", modeName) }","typeGuard":null,"tryCatchPattern":"mode, err := NewSymmetricCipherMode(name)\nif err != nil {\n\t// fall back to default suite\n\tmode, err = NewSymmetricCipherMode(\"AES-256-GCM-128\")\n}","preventionTips":["Use constants, not hand-typed strings, for cipher names","Validate cipher names at config load time","Remember the switch is exact-match and case-sensitive"],"tags":["go","crypto","noise-protocol","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"6e04ca5ff03222a699c24205cd4bf8fee9af7ffe","analyzedAt":"2026-09-07T15:44:59.941Z","contentChangedAt":"2026-09-07T15:44:59.941Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}