{"record":{"id":"e0274e9cf84c3cdf","repo":"peass-ng/PEASS-ng","slug":"sbox-provided-did-not-map-to-a-known-one","errorCode":null,"errorMessage":"SBOX provided did not map to a known one","messagePattern":"SBOX provided did not map to a known one","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/engines/Gost28147Engine.cs","lineNumber":378,"sourceCode":"\t\t\t\tthrow new ArgumentException(\"Unknown S-Box - possible types: \"\n\t\t\t\t\t+ \"\\\"Default\\\", \\\"E-Test\\\", \\\"E-A\\\", \\\"E-B\\\", \\\"E-C\\\", \\\"E-D\\\", \\\"D-Test\\\", \\\"D-A\\\".\");\n\t\t\t}\n\n\t\t\treturn Arrays.Clone(sBox);\n\t\t}\n\n\t\tpublic static string GetSBoxName(byte[] sBox)\n\t\t{\n\t\t\tforeach (string name in sBoxes.Keys)\n\t\t\t{\n\t\t\t\tbyte[] sb = (byte[])sBoxes[name];\n\t\t\t\tif (Arrays.AreEqual(sb, sBox))\n\t\t\t\t{\n\t\t\t\t\treturn name;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthrow new ArgumentException(\"SBOX provided did not map to a known one\");\n\t\t}\n\t}\n}\n","sourceCodeStart":360,"sourceCodeEnd":382,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/engines/Gost28147Engine.cs#L360-L382","documentation":"GetSBoxName performs the reverse mapping of GetSBox: it iterates the known S-Box tables and compares each against the provided bytes with Arrays.AreEqual. If no known table matches, it throws ArgumentException.","triggerScenarios":"Calling GetSBoxName with an S-Box byte array that does not byte-for-byte equal any of the eight built-in tables (wrong length, wrong ordering, or custom table).","commonSituations":"Loading S-Box bytes from an external config/file with different byte ordering; using S-Boxes from a newer GOST standard (TC 26) not in this library; a corrupted or truncated S-Box array.","solutions":["Obtain the S-Box array from GetSBox() using a valid name instead of hand-built bytes","Verify the byte array matches one of the standard tables exactly (same length, same order)","If a custom/standard table is required, add it to the engine's sBoxes table (local modification) rather than expecting reverse lookup"],"exampleFix":"// before\nbyte[] custom = File.ReadAllBytes(\"my_sbox.bin\");\nstring name = Gost28147Engine.GetSBoxName(custom);\n// after\nbyte[] sbox = Gost28147Engine.GetSBox(\"D-A\");\nstring name = Gost28147Engine.GetSBoxName(sbox);","handlingStrategy":"validation","validationCode":"if (sBox == null || sBox.Length == 0) throw new ArgumentException(\"S-Box bytes missing\");\n// pre-verify against a table obtained from GetSBox(name)\nif (!sBox.SequenceEqual(Gost28147Engine.GetSBox(expectedName))) throw new InvalidOperationException(\"S-Box not recognized\");","typeGuard":"bool IsKnownSBox(byte[] sBox) => sBox != null && new[]{\"Default\",\"E-Test\",\"E-A\",\"E-B\",\"E-C\",\"E-D\",\"D-Test\",\"D-A\"}.Any(n => Gost28147Engine.GetSBox(n).SequenceEqual(sBox));","tryCatchPattern":"try { string name = Gost28147Engine.GetSBoxName(sBox); }\ncatch (ArgumentException) { /* treat as unknown parameter set; require explicit name */ }","preventionTips":["Always source S-Box bytes via GetSBox(name) rather than hand-assembling them","Record the S-Box name alongside key material in configs","Pin the exact GOST parameter set version your data was encrypted with"],"tags":["csharp","cryptography","gost","sbox"],"backgroundTag":"unknown-cipher-parameter-name","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}