{"record":{"id":"aab61fb447d47ff9","repo":"shadowsocks/shadowsocks-windows","slug":"method-not-found","errorCode":null,"errorMessage":"method not found","messagePattern":"method not found","errorType":"exception","errorClass":"System.Exception","httpStatus":null,"severity":"error","filePath":"shadowsocks-csharp/Encryption/AEAD/AEADEncryptor.cs","lineNumber":79,"sourceCode":"            InitEncryptorInfo(method);\r\n            InitKey(password);\r\n            // Initialize all-zero nonce for each connection\r\n            _encNonce = new byte[nonceLen];\r\n            _decNonce = new byte[nonceLen];\r\n        }\r\n\r\n        protected abstract Dictionary<string, EncryptorInfo> getCiphers();\r\n\r\n        protected void InitEncryptorInfo(string method)\r\n        {\r\n            method = method.ToLower();\r\n            _method = method;\r\n            ciphers = getCiphers();\r\n            CipherInfo = ciphers[_method];\r\n            _innerLibName = CipherInfo.InnerLibName;\r\n            _cipher = CipherInfo.Type;\r\n            if (_cipher == 0) {\r\n                throw new System.Exception(\"method not found\");\r\n            }\r\n            keyLen = CipherInfo.KeySize;\r\n            saltLen = CipherInfo.SaltSize;\r\n            tagLen = CipherInfo.TagSize;\r\n            nonceLen = CipherInfo.NonceSize;\r\n        }\r\n\r\n        protected void InitKey(string password)\r\n        {\r\n            byte[] passbuf = Encoding.UTF8.GetBytes(password);\r\n            // init master key\r\n            if (_Masterkey == null) _Masterkey = new byte[keyLen];\r\n            if (_Masterkey.Length != keyLen) Array.Resize(ref _Masterkey, keyLen);\r\n            DeriveKey(passbuf, _Masterkey, keyLen);\r\n            // init session key\r\n            if (_sessionKey == null) _sessionKey = new byte[keyLen];\r\n        }\r\n\r","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/shadowsocks/shadowsocks-windows/blob/891d971682eefcaa2e640258d3b352a3ad3b2233/shadowsocks-csharp/Encryption/AEAD/AEADEncryptor.cs#L61-L97","documentation":"Thrown from AEADEncryptor.InitEncryptorInfo when, after looking up the method in the cipher dictionary, CipherInfo.Type equals 0. A Type of 0 is the sentinel for 'unrecognised' in this codebase, so the requested AEAD method name is not among the AEAD ciphers returned by getCiphers(). Note this relies on the dictionary containing the key (else a KeyNotFoundException would fire first), so typically the key exists with Type 0.","triggerScenarios":"Passing a stream-cipher or legacy method name (e.g. \"aes-256-cfb\", \"rc4-md5\") to an AEAD-only encryptor; a typo in the method string; a method that the AEAD provider's cipher table maps to Type 0 because it is not supported by that backend.","commonSituations":"User selects a non-AEAD method while the AEAD path is active; config carries an old method after the server switched to AEAD; copy-paste of method names between server and client where one side only supports AEAD.","solutions":["Use an AEAD method name supported by the chosen backend (e.g. aes-256-gcm, aes-128-gcm, chacha20-ietf-poly1305).","Verify the exact method string matches between client and server (lowercase, no extra whitespace).","If the user should be able to pick any method, route stream ciphers to the non-AEAD encryptor instead of the AEAD one."],"exampleFix":"// before\nciphers = getCiphers();\nCipherInfo = ciphers[_method];\nif (_cipher == 0) throw new System.Exception(\"method not found\");\n\n// after: fail with a helpful, specific message\nif (!ciphers.TryGetValue(_method, out var info) || info.Type == 0)\n    throw new System.Exception($\"AEAD method not found or unsupported: {_method}\");","handlingStrategy":"validation","validationCode":"// Validate method is in the AEAD set before constructing the encryptor\nvar aeadMethods = EncryptorFactory.GetAeadMethodNames();\nif (!aeadMethods.Contains(method.ToLower()))\n    throw new ArgumentException($\"Not an AEAD method: {method}\");","typeGuard":"bool IsAeadMethod(string method, IEnumerable<string> known) =>\n    known.Contains((method ?? \"\").ToLower());","tryCatchPattern":"try { EncryptorFactory.GetEncryptor(method, password); }\ncatch (Exception ex) when (ex.Message == \"method not found\")\n{ /* route to stream-cipher encryptor or report unsupported method */ }","preventionTips":["Match the method string exactly between client and server (lowercase).","Surface supported method names in the UI selection list only.","Reject legacy stream-cipher names when the AEAD path is required."],"tags":["encryption","aead","cipher","configuration"],"backgroundTag":null,"analyzedSha":"891d971682eefcaa2e640258d3b352a3ad3b2233","analyzedAt":"2026-08-13T10:12:34.434Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}