{"record":{"id":"8c115e7fda497912","repo":"peass-ng/PEASS-ng","slug":"needs-to-be-a-multiple-of-8","errorCode":null,"errorMessage":"needs to be a multiple of 8","messagePattern":"needs to be a multiple of 8","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/Sha512tDigest.cs","lineNumber":26,"sourceCode":"     */\n    public class Sha512tDigest\n        : LongDigest\n    {\n        private const ulong A5 = 0xa5a5a5a5a5a5a5a5UL;\n\n        private readonly int digestLength;\n\n        private ulong H1t, H2t, H3t, H4t, H5t, H6t, H7t, H8t;\n\n        /**\n         * Standard constructor\n         */\n        public Sha512tDigest(int bitLength)\n        {\n            if (bitLength >= 512)\n                throw new ArgumentException(\"cannot be >= 512\", \"bitLength\");\n            if (bitLength % 8 != 0)\n                throw new ArgumentException(\"needs to be a multiple of 8\", \"bitLength\");\n            if (bitLength == 384)\n                throw new ArgumentException(\"cannot be 384 use SHA384 instead\", \"bitLength\");\n\n            this.digestLength = bitLength / 8;\n\n            tIvGenerate(digestLength * 8);\n\n            Reset();\n        }\n\n        /**\n         * Copy constructor.  This will copy the state of the provided\n         * message digest.\n         */\n        public Sha512tDigest(Sha512tDigest t)\n            : base(t)\n        {\n            this.digestLength = t.digestLength;","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/Sha512tDigest.cs#L8-L44","documentation":"Sha512tDigest truncates SHA-512 to bitLength bits, and truncation is only well-defined on byte boundaries, so the constructor requires bitLength % 8 == 0. The library throws ArgumentException('needs to be a multiple of 8') otherwise.","triggerScenarios":"new Sha512tDigest(bitLength) with a bitLength not divisible by 8, e.g. 253 or 511.","commonSituations":"Parsing a bit size from a string like 'SHA-512/254' or computing bitLength from bytes incorrectly (multiplying by 4 instead of 8).","solutions":["Pass a bitLength that is a multiple of 8 (e.g. 8, 16, ..., 504) and also < 512 and != 384.","If you have a byte length, multiply by 8 before passing it.","Validate input before constructing if the value comes from external config."],"exampleFix":"// before\nvar digest = new Sha512tDigest(254);\n// after\nvar digest = new Sha512tDigest(256);","handlingStrategy":"validation","validationCode":"if (bitLength % 8 != 0 || bitLength >= 512 || bitLength == 384) throw new ArgumentOutOfRangeException(nameof(bitLength));","typeGuard":"bool IsByteAligned(int bits) => bits % 8 == 0;","tryCatchPattern":"try { var d = new Sha512tDigest(bits); }\ncatch (ArgumentException ex) when (ex.ParamName == \"bitLength\") { bits = (bits / 8 + 1) * 8; d = new Sha512tDigest(bits); }","preventionTips":["Convert byte lengths to bits with * 8 before passing.","Reject user-supplied bit sizes that are not byte-aligned at config load time.","Add unit tests covering boundary sizes (0, 8, 504, 511)."],"tags":["csharp","argument-validation","bouncycastle","hash"],"backgroundTag":"invalid-hash-parameter","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}