{"record":{"id":"17e22b3cb7cbe0cb","repo":"peass-ng/PEASS-ng","slug":"should-never-get-here","errorCode":null,"errorMessage":"Should never get here","messagePattern":"Should never get here","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/engines/AesEngine.cs","lineNumber":405,"sourceCode":"                            t3 ^= t2; W[i][3] = t3;\n                            u = SubWord(t3);\n                            t4 ^= u; W[i + 1][0] = t4;\n                            t5 ^= t4; W[i + 1][1] = t5;\n                            t6 ^= t5; W[i + 1][2] = t6;\n                            t7 ^= t6; W[i + 1][3] = t7;\n                        }\n\n                        u = SubWord(Shift(t7, 8)) ^ rcon;\n                        t0 ^= u; W[14][0] = t0;\n                        t1 ^= t0; W[14][1] = t1;\n                        t2 ^= t1; W[14][2] = t2;\n                        t3 ^= t2; W[14][3] = t3;\n\n                        break;\n                    }\n                default:\n                    {\n                        throw new InvalidOperationException(\"Should never get here\");\n                    }\n            }\n\n            if (!forEncryption)\n            {\n                for (int j = 1; j < ROUNDS; j++)\n                {\n                    uint[] w = W[j];\n                    for (int i = 0; i < 4; i++)\n                    {\n                        w[i] = Inv_Mcol(w[i]);\n                    }\n                }\n            }\n\n            return W;\n        }\n","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/engines/AesEngine.cs#L387-L423","documentation":"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.","triggerScenarios":"Only reachable if the key-length guard at the top of GenerateWorkingKey was bypassed or modified, producing a KC value outside {4,6,8}.","commonSituations":"A patched/modified BouncyCastle build, memory corruption, or custom subclassing that calls GenerateWorkingKey directly with unvalidated key lengths.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// unreachable via public API; just ensure key length is 16/24/32 before Init","typeGuard":"static bool IsValidAesKey(byte[] key) => key != null && (key.Length == 16 || key.Length == 24 || key.Length == 32);","tryCatchPattern":"try { cipher.Init(forEncryption, new KeyParameter(key)); } catch (InvalidOperationException ex) { /* treat as library integrity failure: ex.Message == \"Should never get here\" */ }","preventionTips":["Use unmodified official BouncyCastle sources","Do not call private key-schedule methods from subclasses","Pin and verify third-party crypto library versions"],"tags":["csharp","cryptography","aes","internal-invariant"],"backgroundTag":"unreachable-default-case","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}