{"record":{"id":"126d7482ecef87bb","repo":"peass-ng/PEASS-ng","slug":"aes-engine-not-initialised","errorCode":null,"errorMessage":"AES engine not initialised","messagePattern":"AES engine not initialised","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/engines/AesEngine.cs","lineNumber":486,"sourceCode":"\n        public virtual bool IsPartialBlockOkay\n        {\n            get { return false; }\n        }\n\n        public virtual int GetBlockSize()\n        {\n            return BLOCK_SIZE;\n        }\n\n        public virtual int ProcessBlock(\n            byte[] input,\n            int inOff,\n            byte[] output,\n            int outOff)\n        {\n            if (WorkingKey == null)\n                throw new InvalidOperationException(\"AES engine not initialised\");\n\n            Check.DataLength(input, inOff, 16, \"input buffer too short\");\n            Check.OutputLength(output, outOff, 16, \"output buffer too short\");\n\n            UnPackBlock(input, inOff);\n\n            if (forEncryption)\n            {\n                EncryptBlock(WorkingKey);\n            }\n            else\n            {\n                DecryptBlock(WorkingKey);\n            }\n\n            PackBlock(output, outOff);\n\n            return BLOCK_SIZE;","sourceCodeStart":468,"sourceCodeEnd":504,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/engines/AesEngine.cs#L468-L504","documentation":"ProcessBlock throws this InvalidOperationException when WorkingKey is null, i.e. EncryptBlock/DecryptBlock is attempted before Init was called successfully. AES requires the key schedule before any block can be processed.","triggerScenarios":"Calling ProcessBlock on a new AesEngine without Init, after Init threw (e.g. bad key length), or after the engine was reset without re-initializing.","commonSituations":"Deferred initialization logic that skips Init, an earlier Init exception swallowed by logging code, or sharing an engine instance across threads before it's initialized.","solutions":["Call engine.Init(forEncryption, new KeyParameter(key)) before ProcessBlock","Verify the earlier Init did not throw (it leaves WorkingKey null)","Re-create or re-Init the engine after any failure"],"exampleFix":"// before\nvar engine = new AesEngine();\nengine.ProcessBlock(input, 0, output, 0);\n// after\nvar engine = new AesEngine();\nengine.Init(true, new KeyParameter(key));\nengine.ProcessBlock(input, 0, output, 0);","handlingStrategy":"try-catch","validationCode":"if (!initialized) cipher.Init(forEncryption, new KeyParameter(key));","typeGuard":"static bool IsAesReady(AesEngine e) => e != null; // WorkingKey is private; track init yourself","tryCatchPattern":"try { cipher.ProcessBlock(input, 0, output, 0); } catch (InvalidOperationException ex) { /* lazy-Init then retry */ }","preventionTips":["Always Init immediately after constructing the engine","Let Init exceptions propagate — swallowing them leads to not-initialised errors later","Create a fresh engine per operation instead of sharing uninitialized instances"],"tags":["csharp","cryptography","aes","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"}