{"record":{"id":"b838156c37ea7cce","repo":"peass-ng/PEASS-ng","slug":"unsupported-state-size-only-512-1024-are-allowed","errorCode":null,"errorMessage":"unsupported state size: only 512/1024 are allowed","messagePattern":"unsupported state size: only 512/1024 are allowed","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/DSTU7564Digest.cs","lineNumber":412,"sourceCode":"\n                d = (c00 ^ c01) & 0xFF00FF00FF00FF00UL; c00 ^= d; c01 ^= d;\n                d = (c02 ^ c03) & 0xFF00FF00FF00FF00UL; c02 ^= d; c03 ^= d;\n                d = (c04 ^ c05) & 0xFF00FF00FF00FF00UL; c04 ^= d; c05 ^= d;\n                d = (c06 ^ c07) & 0xFF00FF00FF00FF00UL; c06 ^= d; c07 ^= d;\n                d = (c08 ^ c09) & 0xFF00FF00FF00FF00UL; c08 ^= d; c09 ^= d;\n                d = (c10 ^ c11) & 0xFF00FF00FF00FF00UL; c10 ^= d; c11 ^= d;\n                d = (c12 ^ c13) & 0xFF00FF00FF00FF00UL; c12 ^= d; c13 ^= d;\n                d = (c14 ^ c15) & 0xFF00FF00FF00FF00UL; c14 ^= d; c15 ^= d;\n\n                s[0] = c00; s[1] = c01; s[2] = c02; s[3] = c03;\n                s[4] = c04; s[5] = c05; s[6] = c06; s[7] = c07;\n                s[8] = c08; s[9] = c09; s[10] = c10; s[11] = c11;\n                s[12] = c12; s[13] = c13; s[14] = c14; s[15] = c15;\n                break;\n            }\n            default:\n            {\n                throw new InvalidOperationException(\"unsupported state size: only 512/1024 are allowed\");\n            }\n            }\n        }\n\n        private void SubBytes(ulong[] s)\n        {\n            for (int i = 0; i < columns; ++i)\n            {\n                ulong u = s[i];\n                uint lo = (uint)u, hi = (uint)(u >> 32);\n                byte t0 = S0[lo & 0xFF];\n                byte t1 = S1[(lo >> 8) & 0xFF];\n                byte t2 = S2[(lo >> 16) & 0xFF];\n                byte t3 = S3[lo >> 24];\n                lo = (uint)t0 | ((uint)t1 << 8) | ((uint)t2 << 16) | ((uint)t3 << 24);\n                byte t4 = S0[hi & 0xFF];\n                byte t5 = S1[(hi >> 8) & 0xFF];\n                byte t6 = S2[(hi >> 16) & 0xFF];","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/DSTU7564Digest.cs#L394-L430","documentation":"ShiftRows performs the AES-like row-shuffle on the internal state, which is sized 512 or 1024 bits (8 or 16 ulongs). The switch has cases only for those sizes; any other state size falls into the default and throws InvalidOperationException. In normal use the constructor guarantees a valid size, so this signals corrupted/internal misuse.","triggerScenarios":"ShiftRows invoked (via P or Q permutation rounds) on a state array that is neither 8 nor 16 ulongs long — practically only when a Dstu7564Digest instance was built with an invalid size bypassing the constructor check, via reflection/serialization of a hand-modified object, or a patched library.","commonSituations":"Deserializing a Dstu7564Digest instance from untrusted/partial data; custom subclasses or modified forks that change columns/rounds; state corruption from concurrent use of one digest instance across threads.","solutions":["Only create Dstu7564Digest via its constructor with hashSizeBits of 256, 384, or 512; never hand-construct or deserialize digest instances.","Use one digest instance per thread (IDigest instances are not thread-safe) and call Reset() between hashes.","If seen in a modified build, restore the stock BouncyCastle source or verify the size passed to the constructor."],"exampleFix":"// before\nvar digest = Activator.CreateInstance(typeof(Dstu7564Digest)); // default/uninitialized state\n// after\nvar digest = new Dstu7564Digest(512); // valid size, state arrays sized correctly","handlingStrategy":"try-catch","validationCode":"// construct only through the constructor with a valid size\nvar digest = hashBits == 256 || hashBits == 384 || hashBits == 512\n    ? new Dstu7564Digest(hashBits)\n    : new Dstu7564Digest(512);","typeGuard":"static bool HasValidState(Dstu7564Digest d) => d != null; // size is fixed at construction; use only constructor-built instances","tryCatchPattern":"try { digest.BlockUpdate(data, 0, data.Length); }\ncatch (InvalidOperationException ex) { /* replace instance: var d = new Dstu7564Digest(512); */ }","preventionTips":["Never deserialize or reflect-construct digest instances","One digest instance per thread","Call Reset() between hashes on the same instance"],"tags":["csharp","cryptography","invalid-operation","dstu7564"],"backgroundTag":"unsupported-state-size","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}