{"record":{"id":"a82f61b830594d1d","repo":"peass-ng/PEASS-ng","slug":"blake2s-digest-bit-length-must-be-a-multiple-of-8","errorCode":null,"errorMessage":"BLAKE2s digest bit length must be a multiple of 8 and not greater than 256","messagePattern":"BLAKE2s digest bit length must be a multiple of 8 and not greater than 256","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/Blake2sDigest.cs","lineNumber":158,"sourceCode":"        {\n            this.bufferPos = digest.bufferPos;\n            this.buffer = Arrays.Clone(digest.buffer);\n            this.keyLength = digest.keyLength;\n            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        }\n\n        /**\n         * BLAKE2s for hashing.\n         *\n         * @param digestBits the desired digest length in bits. Must be a multiple of 8 and less than 256.\n         */\n        public Blake2sDigest(int digestBits)\n        {\n            if (digestBits < 8 || digestBits > 256 || digestBits % 8 != 0)\n                throw new ArgumentException(\"BLAKE2s digest bit length must be a multiple of 8 and not greater than 256\");\n\n            buffer = new byte[BLOCK_LENGTH_BYTES];\n            keyLength = 0;\n            digestLength = digestBits / 8;\n            Init();\n        }\n\n        /**\n         * BLAKE2s for authentication (\"Prefix-MAC mode\").\n         * <p/>\n         * After calling the doFinal() method, the key will remain to be used for\n         * further computations of this instance. The key can be overwritten using\n         * the clearKey() method.\n         *\n         * @param key a key up to 32 bytes or null\n         */\n        public Blake2sDigest(byte[] key)\n        {","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/Blake2sDigest.cs#L140-L176","documentation":"The Blake2sDigest(int digestBits) constructor requires the digest size in BITS to be between 8 and 256 inclusive and a multiple of 8; anything else throws this ArgumentException. This enforces BLAKE2s's maximum 256-bit (32-byte) output, half of BLAKE2b's limit.","triggerScenarios":"new Blake2sDigest(bits) where bits < 8, bits > 256, or bits % 8 != 0 (e.g. Blake2sDigest(512), common when migrating from BLAKE2b).","commonSituations":"Confusing bits with bytes (passing 32 expecting 32-byte digest — that is only 32 bits, which is valid, but passing 512 after copying BLAKE2b code is invalid), copying BLAKE2b constructor calls.","solutions":["Pass a multiple of 8 between 8 and 256 (e.g. 256 for the default 32-byte digest)","Divide byte sizes by nothing but multiply bits: bytes * 8, capped at 256","Use the parameterless Blake2sDigest() for the standard 256-bit digest"],"exampleFix":"// before\nvar d = new Blake2sDigest(512); // copied from Blake2b code\n// after\nvar d = new Blake2sDigest(256); // BLAKE2s max = 256 bits","handlingStrategy":"validation","validationCode":"bool IsValidBlake2sBits(int bits) => bits >= 8 && bits <= 256 && bits % 8 == 0;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["BLAKE2s max is 256 bits (32 bytes), not 512 like BLAKE2b","Update constants when migrating code from BLAKE2b to BLAKE2s","Prefer the default constructor for the standard digest"],"tags":["csharp","bouncycastle","blake2s","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"}