{"record":{"id":"69cb6fb082df1e56","repo":"peass-ng/PEASS-ng","slug":"hash-size-is-not-recommended-use-256-384-512-inst","errorCode":null,"errorMessage":"Hash size is not recommended. Use 256/384/512 instead","messagePattern":"Hash size is not recommended\\. Use 256/384/512 instead","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/DSTU7564Digest.cs","lineNumber":71,"sourceCode":"                this.state = Arrays.Clone(digest.state);\n                this.tempState1 = new ulong[columns];\n                this.tempState2 = new ulong[columns];\n                this.buf = Arrays.Clone(digest.buf);\n            }\n\n            this.inputBlocks = digest.inputBlocks;\n            this.bufOff = digest.bufOff;\n        }\n\n        public Dstu7564Digest(int hashSizeBits)\n        {\n            if (hashSizeBits == 256 || hashSizeBits == 384 || hashSizeBits == 512)\n            {\n                this.hashSize = hashSizeBits / 8;\n            }\n            else\n            {\n                throw new ArgumentException(\"Hash size is not recommended. Use 256/384/512 instead\");\n            }\n\n            if (hashSizeBits > 256)\n            {\n                this.columns = NB_1024;\n                this.rounds = NR_1024;\n            }\n            else\n            {\n                this.columns = NB_512;\n                this.rounds = NR_512;\n            }\n\n            this.blockSize = columns << 3;\n\n            this.state = new ulong[columns];\n            this.state[0] = (ulong)blockSize;\n","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/DSTU7564Digest.cs#L53-L89","documentation":"DSTU 7564 (Ukrainian Kubeh hash) is only standardized for 256-, 384-, and 512-bit outputs; other sizes would require untested round/column parameters. The Dstu7564Digest(int hashSizeBits) constructor throws ArgumentException for any hashSizeBits other than 256, 384, or 512.","triggerScenarios":"Calling new Dstu7564Digest(hashSizeBits) with a value other than 256/384/512 — e.g. 128, 224, or a bit/byte confusion such as passing 32 instead of 256.","commonSituations":"Passing bit sizes from SHA-2 family configs (224); passing byte sizes (32/64) where bits are expected; guessing that smaller variants exist like in other hash families.","solutions":["Pass exactly 256, 384, or 512 (bits) to the constructor.","If a 128- or 224-bit output is needed, choose another algorithm (e.g. SHA-256 truncated, or a different digest).","Validate the configured hash size against the allowed set before constructing."],"exampleFix":"// before\nvar digest = new Dstu7564Digest(32); // bytes, not bits\n// after\nvar digest = new Dstu7564Digest(256); // bits: 256|384|512","handlingStrategy":"validation","validationCode":"int[] allowed = { 256, 384, 512 };\nif (Array.IndexOf(allowed, hashSizeBits) < 0)\n    throw new ArgumentOutOfRangeException(nameof(hashSizeBits), \"DSTU 7564 requires 256/384/512 bits\");\nvar digest = new Dstu7564Digest(hashSizeBits);","typeGuard":"static bool IsValidDstu7564Size(int bits) => bits == 256 || bits == 384 || bits == 512;","tryCatchPattern":"try { var d = new Dstu7564Digest(bits); }\ncatch (ArgumentException ex) { /* default to 512 or report config error */ }","preventionTips":["Pass sizes in bits, never bytes","Whitelist {256,384,512} in configuration","Check the algorithm spec before choosing non-standard sizes"],"tags":["csharp","cryptography","argument-validation","dstu7564"],"backgroundTag":"invalid-hash-size","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}