{"record":{"id":"a3dfc70dfb774a78","repo":"peass-ng/PEASS-ng","slug":"blake2b-digest-bit-length-must-be-a-multiple-of-8","errorCode":null,"errorMessage":"BLAKE2b digest bit length must be a multiple of 8 and not greater than 512","messagePattern":"BLAKE2b digest bit length must be a multiple of 8 and not greater than 512","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/Blake2bDigest.cs","lineNumber":138,"sourceCode":"            this.key = Arrays.Clone(digest.key);\n            this.digestLength = digest.digestLength;\n            this.chainValue = Arrays.Clone(digest.chainValue);\n            this.personalization = Arrays.Clone(digest.personalization);\n            this.salt = Arrays.Clone(digest.salt);\n            this.t0 = digest.t0;\n            this.t1 = digest.t1;\n            this.f0 = digest.f0;\n        }\n\n        /**\n         * Basic sized constructor - size in bits.\n         *\n         * @param digestSize size of the digest in bits\n         */\n        public Blake2bDigest(int digestSize)\n        {\n            if (digestSize < 8 || digestSize > 512 || digestSize % 8 != 0)\n                throw new ArgumentException(\"BLAKE2b digest bit length must be a multiple of 8 and not greater than 512\");\n\n            buffer = new byte[BLOCK_LENGTH_BYTES];\n            keyLength = 0;\n            this.digestLength = digestSize / 8;\n            Init();\n        }\n\n        /**\n         * Blake2b for authentication (\"Prefix-MAC mode\").\n         * After calling the doFinal() method, the key will\n         * remain to be used for further computations of\n         * this instance.\n         * The key can be overwritten using the clearKey() method.\n         *\n         * @param key A key up to 64 bytes or null\n         */\n        public Blake2bDigest(byte[] key)\n        {","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/Blake2bDigest.cs#L120-L156","documentation":"The Blake2bDigest(int digestSize) constructor requires the digest size in BITS to be between 8 and 512 inclusive and a multiple of 8; anything else throws this ArgumentException immediately. This enforces the BLAKE2b specification's allowable output lengths (8-512 bits, byte-aligned).","triggerScenarios":"new Blake2bDigest(bits) where bits < 8, bits > 512, or bits % 8 != 0 (e.g. Blake2bDigest(520), Blake2bDigest(100)).","commonSituations":"Confusing bits with bytes (passing 64 expecting 64-byte digest when max is 512 bits; passing 0 or negative defaults), porting configs that store byte sizes (32/64) into a bits parameter.","solutions":["Pass a multiple of 8 between 8 and 512 (e.g. 512 for the default 64-byte digest)","If your config stores bytes, multiply by 8 before constructing","Use the parameterless Blake2bDigest() for the standard 512-bit digest"],"exampleFix":"// before\nvar d = new Blake2bDigest(64); // 64 bits, likely meant bytes\n// after\nvar d = new Blake2bDigest(64 * 8); // 512 bits = 64-byte digest","handlingStrategy":"validation","validationCode":"bool IsValidBlake2bBits(int bits) => bits >= 8 && bits <= 512 && bits % 8 == 0;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember the parameter is BITS (8-512), not bytes","Convert byte sizes with bytes * 8","Prefer the default constructor unless a custom length is required"],"tags":["csharp","bouncycastle","blake2b","argument-validation"],"backgroundTag":"invalid-digest-size","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}