peass-ng/PEASS-ng · error · InvalidOperationException
Should never get here
Error message
Should never get here
What it means
GenerateWorkingKey's key-schedule switch has cases only for the valid key control-word counts; the default case throws InvalidOperationException("Should never get here"). It is unreachable through the public API because key length is validated earlier, but signals internal corruption if hit.
Solutions
- Use the library unmodified and validate key length (16/24/32) before Init
- Restore the original AesEngine.cs from the official BouncyCastle source
- If you patched the code, re-add the length guard before the switch
Defensive patterns
Strategy: try-catch
Validate before calling
// unreachable via public API; just ensure key length is 16/24/32 before Init
Type guard
static bool IsValidAesKey(byte[] key) => key != null && (key.Length == 16 || key.Length == 24 || key.Length == 32);
Try / catch
try { cipher.Init(forEncryption, new KeyParameter(key)); } catch (InvalidOperationException ex) { /* treat as library integrity failure: ex.Message == "Should never get here" */ } Prevention
- Use unmodified official BouncyCastle sources
- Do not call private key-schedule methods from subclasses
- Pin and verify third-party crypto library versions
When it happens
Trigger: Only reachable if the key-length guard at the top of GenerateWorkingKey was bypassed or modified, producing a KC value outside {4,6,8}.
Common situations: A patched/modified BouncyCastle build, memory corruption, or custom subclassing that calls GenerateWorkingKey directly with unvalidated key lengths.
Related errors
- AES engine not initialised
- invalid parameter passed to AES init -
- Key length not 128/192/256 bits.
- attempt to absorb with odd length queue
- Decryption failed due to MAC mismatch
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/17e22b3cb7cbe0cb.
Report an issue: GitHub.
Appendix: source
Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/engines/AesEngine.cs:405
t3 ^= t2; W[i][3] = t3;
u = SubWord(t3);
t4 ^= u; W[i + 1][0] = t4;
t5 ^= t4; W[i + 1][1] = t5;
t6 ^= t5; W[i + 1][2] = t6;
t7 ^= t6; W[i + 1][3] = t7;
}
u = SubWord(Shift(t7, 8)) ^ rcon;
t0 ^= u; W[14][0] = t0;
t1 ^= t0; W[14][1] = t1;
t2 ^= t1; W[14][2] = t2;
t3 ^= t2; W[14][3] = t3;
break;
}
default:
{
throw new InvalidOperationException("Should never get here");
}
}
if (!forEncryption)
{
for (int j = 1; j < ROUNDS; j++)
{
uint[] w = W[j];
for (int i = 0; i < 4; i++)
{
w[i] = Inv_Mcol(w[i]);
}
}
}
return W;
}
View on GitHub (pinned to 53fb989abc)