peass-ng/PEASS-ng · error · ArgumentException
personalization length must be exactly 16 bytes
Error message
personalization length must be exactly 16 bytes
What it means
BLAKE2b's personalization parameter must be exactly 16 bytes per the specification; a non-null personalization of any other length throws this ArgumentException. Passing null is allowed (no personalization).
Source
Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/Blake2bDigest.cs:205
{
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];
Array.Copy(personalization, 0, this.personalization, 0, personalization.Length);
}
if (key != null)
{
if (key.Length > 64)
throw new ArgumentException("Keys > 64 are not supported");
this.key = new byte[key.Length];
Array.Copy(key, 0, this.key, 0, key.Length);
keyLength = key.Length;
Array.Copy(key, 0, buffer, 0, key.Length);
bufferPos = BLOCK_LENGTH_BYTES; // zero padding
}
Init();
}View on GitHub (pinned to 53fb989abc)
Solutions
- Ensure the personalization string is exactly 16 bytes (pad/truncate as needed)
- Pass null when no personalization is needed
- Constant-fold and validate personalization constants at startup
Example fix
// before
var d = new Blake2bDigest(key, 64, null, Encoding.UTF8.GetBytes("MyApp"));
// after
byte[] pers = new byte[16];
Array.Copy(Encoding.UTF8.GetBytes("MyApp"), pers, 5);
var d = new Blake2bDigest(key, 64, null, pers); Defensive patterns
Strategy: validation
Validate before calling
byte[] NormalizePersonalization(byte[] pers) {
if (pers == null) return null;
if (pers.Length == 16) return pers;
var p = new byte[16];
Array.Copy(pers, p, Math.Min(pers.Length, 16));
return p;
} Prevention
- Personalization must be exactly 16 bytes or null
- Pad ASCII personalization strings to 16 bytes with Array.Copy into new byte[16]
- Validate constants at startup with a debug assert
When it happens
Trigger: new Blake2bDigest(key, digestLength, salt, personalization) where personalization != null and personalization.Length != 16.
Common situations: Using application-name strings longer or shorter than 16 bytes, passing empty arrays instead of null, reusing 32-byte personalization constants from BLAKE2s configs.
Related errors
- BLAKE2b digest bit length must be a multiple of 8 and not gr
- Keys > 64 are not supported
- Invalid digest length (required: 1 - 64)
- salt length must be exactly 16 bytes
- data
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/de5d2555ba65b8eb.
Report an issue: GitHub.