{"record":{"id":"819e7ba110401948","repo":"peass-ng/PEASS-ng","slug":"invalid-digest-length-required-1-64","errorCode":null,"errorMessage":"Invalid digest length (required: 1 - 64)","messagePattern":"Invalid digest length \\(required: 1 - 64\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/Blake2bDigest.cs","lineNumber":189,"sourceCode":"            Init();\n        }\n\n        /**\n         * Blake2b with key, required digest length (in bytes), salt and personalization.\n         * After calling the doFinal() method, the key, the salt and the personal string\n         * will remain and might be used for further computations with this instance.\n         * The key can be overwritten using the clearKey() method, the salt (pepper)\n         * can be overwritten using the clearSalt() method.\n         *\n         * @param key             A key up to 64 bytes or null\n         * @param digestLength    from 1 up to 64 bytes\n         * @param salt            16 bytes or null\n         * @param personalization 16 bytes or null\n         */\n        public Blake2bDigest(byte[] key, int digestLength, byte[] salt, byte[] personalization)\n        {\n            if (digestLength < 1 || digestLength > 64)\n                throw new ArgumentException(\"Invalid digest length (required: 1 - 64)\");\n\n            this.digestLength = digestLength;\n            this.buffer = new byte[BLOCK_LENGTH_BYTES];\n\n            if (salt != null)\n            {\n                if (salt.Length != 16)\n                    throw new ArgumentException(\"salt length must be exactly 16 bytes\");\n\n                this.salt = new byte[16];\n                Array.Copy(salt, 0, this.salt, 0, salt.Length);\n            }\n            if (personalization != null)\n            {\n                if (personalization.Length != 16)\n                    throw new ArgumentException(\"personalization length must be exactly 16 bytes\");\n\n                this.personalization = new byte[16];","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/Blake2bDigest.cs#L171-L207","documentation":"The Blake2bDigest(byte[] key, int digestLength, byte[] salt, byte[] personalization) constructor requires digestLength (in BYTES) to be between 1 and 64; otherwise it throws this ArgumentException. Unlike the bits-based constructor, this parameter is bytes, and the bounds match BLAKE2b's 1-64 byte output range.","triggerScenarios":"new Blake2bDigest(key, digestLength, salt, personalization) with digestLength < 1 or > 64 (e.g. 0, 128, or a bit count like 512).","commonSituations":"Mixing the two constructors' units (passing 512 bits into the bytes-based constructor), zero/default-initialized length variables, ports from other BLAKE2 libraries that use bits.","solutions":["Pass a byte length between 1 and 64 (use 64 for the full digest)","If you have a bit size, divide by 8 before constructing","Use Blake2bDigest() default constructor when the standard 64-byte output is wanted"],"exampleFix":"// before\nvar d = new Blake2bDigest(key, 512, salt, pers); // bits passed\n// after\nvar d = new Blake2bDigest(key, 64, salt, pers); // bytes","handlingStrategy":"validation","validationCode":"bool IsValidBlake2bDigestBytes(int len) => len >= 1 && len <= 64;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["This overload takes BYTES (1-64), unlike the bits overload (8-512)","Never pass bit counts (e.g. 512) into the byte-based constructor","Default to 64 unless a truncated digest is intended"],"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"}