{"record":{"id":"1fff2bf34f488800","repo":"peass-ng/PEASS-ng","slug":"invalid-parameter-passed-to-gost28147-init","errorCode":null,"errorMessage":"invalid parameter passed to Gost28147 init - ","messagePattern":"invalid parameter passed to Gost28147 init - ","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/engines/Gost28147Engine.cs","lineNumber":185,"sourceCode":"\t\t\t\tthis.S = Arrays.Clone(sBox);\n\n\t\t\t\t//\n\t\t\t\t// set key if there is one\n\t\t\t\t//\n\t\t\t\tif (param.Parameters != null)\n\t\t\t\t{\n\t\t\t\t\tworkingKey = generateWorkingKey(forEncryption,\n\t\t\t\t\t\t\t((KeyParameter)param.Parameters).GetKey());\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (parameters is KeyParameter)\n\t\t\t{\n\t\t\t\tworkingKey = generateWorkingKey(forEncryption,\n\t\t\t\t\t\t\t\t\t((KeyParameter)parameters).GetKey());\n\t\t\t}\n\t\t\telse if (parameters != null)\n\t\t\t{\n\t\t\t\tthrow new ArgumentException(\"invalid parameter passed to Gost28147 init - \"\n\t\t\t\t\t+ Platform.GetTypeName(parameters));\n\t\t\t}\n\t\t}\n\n\t\tpublic virtual string AlgorithmName\n\t\t{\n\t\t\tget { return \"Gost28147\"; }\n\t\t}\n\n\t\tpublic virtual bool IsPartialBlockOkay\n\t\t{\n\t\t\tget { return false; }\n\t\t}\n\n\t\tpublic virtual int GetBlockSize()\n\t\t{\n\t\t\treturn BlockSize;\n\t\t}","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/engines/Gost28147Engine.cs#L167-L203","documentation":"Gost28147Engine.Init throws this ArgumentException when the parameters object is neither a KeyParameter nor ParametersWithSBox (nor null, which is tolerated for parameter-less re-init). The message appends the runtime type name of the unsupported parameter.","triggerScenarios":"Calling Init(forEncryption, parameters) with e.g. ParametersWithIV, ParametersWithRandom, or a custom ICipherParameters implementation; parameters != null but not one of the two supported types.","commonSituations":"Copy-pasting an AES-mode Init call (ParametersWithIV) into GOST code; wrapping parameters in an extra layer like ParametersWithRandom for no reason.","solutions":["Pass new KeyParameter(keyBytes), optionally wrapped in ParametersWithSBox","Unwrap the extra ParametersWithIV/ParametersWithRandom layer before Init","If parameters may be null intentionally, ensure it is actually null, not a wrong type"],"exampleFix":"// before\nengine.Init(true, new ParametersWithIV(new KeyParameter(key), iv));\n// after\nengine.Init(true, new KeyParameter(key));","handlingStrategy":"type-guard","validationCode":"if (parameters != null && parameters is not KeyParameter && parameters is not ParametersWithSBox) throw new ArgumentException(\"Unsupported GOST parameters\");","typeGuard":"static bool IsGostParameter(ICipherParameters p) => p == null || p is KeyParameter || p is ParametersWithSBox;","tryCatchPattern":"try { engine.Init(forEncryption, parameters); } catch (ArgumentException ex) { /* unwrap/convert parameters and retry */ }","preventionTips":["Only pass KeyParameter or ParametersWithSBox to Gost28147Engine","Do not reuse AES/CBC-style Init call shapes (ParametersWithIV) with GOST","Unwrap helper layers (ParametersWithRandom) before calling block-engine Init"],"tags":["csharp","cryptography","gost","wrong-parameter-type"],"backgroundTag":"invalid-cipher-parameters","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}