{"record":{"id":"3458fdb77a25e436","repo":"peass-ng/PEASS-ng","slug":"gost28147-engine-not-initialised","errorCode":null,"errorMessage":"Gost28147 engine not initialised","messagePattern":"Gost28147 engine not initialised","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/engines/Gost28147Engine.cs","lineNumber":212,"sourceCode":"\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}\n\n\t\tpublic virtual int ProcessBlock(\n\t\t\tbyte[] input,\n\t\t\tint inOff,\n\t\t\tbyte[] output,\n\t\t\tint outOff)\n\t\t{\n\t\t\tif (workingKey == null)\n\t\t\t\tthrow new InvalidOperationException(\"Gost28147 engine not initialised\");\n\n\t\t\tCheck.DataLength(input, inOff, BlockSize, \"input buffer too short\");\n\t\t\tCheck.OutputLength(output, outOff, BlockSize, \"output buffer too short\");\n\n\t\t\tGost28147Func(workingKey, input, inOff, output, outOff);\n\n\t\t\treturn BlockSize;\n\t\t}\n\n\t\tpublic virtual void Reset()\n\t\t{\n\t\t}\n\n\t\tprivate int[] generateWorkingKey(\n\t\t\tbool forEncryption,\n\t\t\tbyte[] userKey)\n\t\t{\n\t\t\tthis.forEncryption = forEncryption;","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/engines/Gost28147Engine.cs#L194-L230","documentation":"Gost28147Engine.ProcessBlock throws this InvalidOperationException as a state guard because the block cipher's workingKey is null, i.e. Init() was never called (or was called with a null key) before attempting to encrypt or decrypt a block.","triggerScenarios":"Calling ProcessBlock before Init, after Init was called with null parameters only (no key), or after a prior Init threw (bad S-box or wrong parameter type).","commonSituations":"An earlier invalid-parameter ArgumentException swallowed by caller, a two-phase init where the key-setting branch never executed, or reuse across threads without initialization.","solutions":["Call engine.Init(forEncryption, new KeyParameter(key)) before ProcessBlock","Ensure the earlier Init actually reached the key-generation branch (valid KeyParameter/SBox params)","Re-create or re-Init the engine after any initialization failure"],"exampleFix":"// before\nvar gost = new Gost28147Engine();\ngost.ProcessBlock(input, 0, output, 0);\n// after\nvar gost = new Gost28147Engine();\ngost.Init(true, new KeyParameter(key));\ngost.ProcessBlock(input, 0, output, 0);","handlingStrategy":"try-catch","validationCode":"if (!initialized) engine.Init(forEncryption, new KeyParameter(key));","typeGuard":"static bool IsGostReady(Gost28147Engine e) => e != null; // workingKey is private; track init yourself","tryCatchPattern":"try { engine.ProcessBlock(input, 0, output, 0); } catch (InvalidOperationException ex) { /* Init then retry once */ }","preventionTips":["Initialize the engine before the first ProcessBlock in every code path","Check that Init consumed a KeyParameter branch (not just null)","Handle Init exceptions at the call site so a failed init is not silently ignored"],"tags":["csharp","cryptography","gost","state-machine"],"backgroundTag":"cipher-not-initialised","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}