peass-ng/PEASS-ng · error · ArgumentException
Invalid digest length (required: 1 - 64)
Error message
Invalid digest length (required: 1 - 64)
What it means
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.
Source
Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/Blake2bDigest.cs:189
Init();
}
/**
* Blake2b with key, required digest length (in bytes), salt and personalization.
* After calling the doFinal() method, the key, the salt and the personal string
* will remain and might be used for further computations with this instance.
* The key can be overwritten using the clearKey() method, the salt (pepper)
* can be overwritten using the clearSalt() method.
*
* @param key A key up to 64 bytes or null
* @param digestLength from 1 up to 64 bytes
* @param salt 16 bytes or null
* @param personalization 16 bytes or null
*/
public Blake2bDigest(byte[] key, int digestLength, byte[] salt, byte[] personalization)
{
if (digestLength < 1 || digestLength > 64)
throw new ArgumentException("Invalid digest length (required: 1 - 64)");
this.digestLength = digestLength;
this.buffer = new byte[BLOCK_LENGTH_BYTES];
if (salt != null)
{
if (salt.Length != 16)
throw new ArgumentException("salt length must be exactly 16 bytes");
this.salt = new byte[16];
Array.Copy(salt, 0, this.salt, 0, salt.Length);
}
if (personalization != null)
{
if (personalization.Length != 16)
throw new ArgumentException("personalization length must be exactly 16 bytes");
this.personalization = new byte[16];View on GitHub (pinned to 53fb989abc)
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
Example fix
// before var d = new Blake2bDigest(key, 512, salt, pers); // bits passed // after var d = new Blake2bDigest(key, 64, salt, pers); // bytes
Defensive patterns
Strategy: validation
Validate before calling
bool IsValidBlake2bDigestBytes(int len) => len >= 1 && len <= 64;
Prevention
- 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
When it happens
Trigger: new Blake2bDigest(key, digestLength, salt, personalization) with digestLength < 1 or > 64 (e.g. 0, 128, or a bit count like 512).
Common situations: 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.
Related errors
- BLAKE2b digest bit length must be a multiple of 8 and not gr
- Keys > 64 are not supported
- salt length must be exactly 16 bytes
- personalization length must be exactly 16 bytes
- BLAKE2s digest bit length must be a multiple of 8 and not gr
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/819e7ba110401948.
Report an issue: GitHub.