peass-ng/PEASS-ng · error · ArgumentException
BLAKE2s digest bit length must be a multiple of 8 and not gr
Error message
BLAKE2s digest bit length must be a multiple of 8 and not greater than 256
What it means
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.
Source
Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/Blake2sDigest.cs:158
{
this.bufferPos = digest.bufferPos;
this.buffer = Arrays.Clone(digest.buffer);
this.keyLength = digest.keyLength;
this.key = Arrays.Clone(digest.key);
this.digestLength = digest.digestLength;
this.chainValue = Arrays.Clone(digest.chainValue);
this.personalization = Arrays.Clone(digest.personalization);
}
/**
* BLAKE2s for hashing.
*
* @param digestBits the desired digest length in bits. Must be a multiple of 8 and less than 256.
*/
public Blake2sDigest(int digestBits)
{
if (digestBits < 8 || digestBits > 256 || digestBits % 8 != 0)
throw new ArgumentException("BLAKE2s digest bit length must be a multiple of 8 and not greater than 256");
buffer = new byte[BLOCK_LENGTH_BYTES];
keyLength = 0;
digestLength = digestBits / 8;
Init();
}
/**
* BLAKE2s for authentication ("Prefix-MAC mode").
* <p/>
* After calling the doFinal() method, the key will remain to be used for
* further computations of this instance. The key can be overwritten using
* the clearKey() method.
*
* @param key a key up to 32 bytes or null
*/
public Blake2sDigest(byte[] key)
{View on GitHub (pinned to 53fb989abc)
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
Example fix
// before var d = new Blake2sDigest(512); // copied from Blake2b code // after var d = new Blake2sDigest(256); // BLAKE2s max = 256 bits
Defensive patterns
Strategy: validation
Validate before calling
bool IsValidBlake2sBits(int bits) => bits >= 8 && bits <= 256 && bits % 8 == 0;
Prevention
- 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
When it happens
Trigger: new Blake2sDigest(bits) where bits < 8, bits > 256, or bits % 8 != 0 (e.g. Blake2sDigest(512), common when migrating from BLAKE2b).
Common situations: 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.
Related errors
- BLAKE2b digest bit length must be a multiple of 8 and not gr
- Invalid digest length (required: 1 - 64)
- Keys > 32 are not supported
- Invalid digest length (required: 1 - 32)
- Salt length must be exactly 8 bytes
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/a82f61b830594d1d.
Report an issue: GitHub.