{"record":{"id":"de5d2555ba65b8eb","repo":"peass-ng/PEASS-ng","slug":"personalization-length-must-be-exactly-16-bytes","errorCode":null,"errorMessage":"personalization length must be exactly 16 bytes","messagePattern":"personalization length must be exactly 16 bytes","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/Blake2bDigest.cs","lineNumber":205,"sourceCode":"        {\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];\n                Array.Copy(personalization, 0, this.personalization, 0, personalization.Length);\n            }\n            if (key != null)\n            {\n                if (key.Length > 64)\n                    throw new ArgumentException(\"Keys > 64 are not supported\");\n\n                this.key = new byte[key.Length];\n                Array.Copy(key, 0, this.key, 0, key.Length);\n\n                keyLength = key.Length;\n                Array.Copy(key, 0, buffer, 0, key.Length);\n                bufferPos = BLOCK_LENGTH_BYTES; // zero padding\n            }\n            Init();\n        }","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/Blake2bDigest.cs#L187-L223","documentation":"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).","triggerScenarios":"new Blake2bDigest(key, digestLength, salt, personalization) where personalization != null and personalization.Length != 16.","commonSituations":"Using application-name strings longer or shorter than 16 bytes, passing empty arrays instead of null, reusing 32-byte personalization constants from BLAKE2s configs.","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"],"exampleFix":"// before\nvar d = new Blake2bDigest(key, 64, null, Encoding.UTF8.GetBytes(\"MyApp\"));\n// after\nbyte[] pers = new byte[16];\nArray.Copy(Encoding.UTF8.GetBytes(\"MyApp\"), pers, 5);\nvar d = new Blake2bDigest(key, 64, null, pers);","handlingStrategy":"validation","validationCode":"byte[] NormalizePersonalization(byte[] pers) {\n    if (pers == null) return null;\n    if (pers.Length == 16) return pers;\n    var p = new byte[16];\n    Array.Copy(pers, p, Math.Min(pers.Length, 16));\n    return p;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["csharp","bouncycastle","blake2b","personalization-length"],"backgroundTag":"invalid-salt-length","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}