peass-ng/PEASS-ng · error · InvalidOperationException
AES engine not initialised
Error message
AES engine not initialised
What it means
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.
Source
Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/engines/AesEngine.cs:486
public virtual bool IsPartialBlockOkay
{
get { return false; }
}
public virtual int GetBlockSize()
{
return BLOCK_SIZE;
}
public virtual int ProcessBlock(
byte[] input,
int inOff,
byte[] output,
int outOff)
{
if (WorkingKey == null)
throw new InvalidOperationException("AES engine not initialised");
Check.DataLength(input, inOff, 16, "input buffer too short");
Check.OutputLength(output, outOff, 16, "output buffer too short");
UnPackBlock(input, inOff);
if (forEncryption)
{
EncryptBlock(WorkingKey);
}
else
{
DecryptBlock(WorkingKey);
}
PackBlock(output, outOff);
return BLOCK_SIZE;View on GitHub (pinned to 53fb989abc)
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
Example fix
// before var engine = new AesEngine(); engine.ProcessBlock(input, 0, output, 0); // after var engine = new AesEngine(); engine.Init(true, new KeyParameter(key)); engine.ProcessBlock(input, 0, output, 0);
Defensive patterns
Strategy: try-catch
Validate before calling
if (!initialized) cipher.Init(forEncryption, new KeyParameter(key));
Type guard
static bool IsAesReady(AesEngine e) => e != null; // WorkingKey is private; track init yourself
Try / catch
try { cipher.ProcessBlock(input, 0, output, 0); } catch (InvalidOperationException ex) { /* lazy-Init then retry */ } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Skein engine is not initialised.
- Key length not 128/192/256 bits.
- Should never get here
- invalid parameter passed to AES init -
- Gost28147 engine not initialised
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/126d7482ecef87bb.
Report an issue: GitHub.