{"record":{"id":"e1a1cdb57af9cf84","repo":"peass-ng/PEASS-ng","slug":"cannot-be-512","errorCode":null,"errorMessage":"cannot be >= 512","messagePattern":"cannot be >= 512","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/Sha512tDigest.cs","lineNumber":24,"sourceCode":"    /**\n     * FIPS 180-4 implementation of SHA-512/t\n     */\n    public class Sha512tDigest\n        : LongDigest\n    {\n        private const ulong A5 = 0xa5a5a5a5a5a5a5a5UL;\n\n        private readonly int digestLength;\n\n        private ulong H1t, H2t, H3t, H4t, H5t, H6t, H7t, H8t;\n\n        /**\n         * Standard constructor\n         */\n        public Sha512tDigest(int bitLength)\n        {\n            if (bitLength >= 512)\n                throw new ArgumentException(\"cannot be >= 512\", \"bitLength\");\n            if (bitLength % 8 != 0)\n                throw new ArgumentException(\"needs to be a multiple of 8\", \"bitLength\");\n            if (bitLength == 384)\n                throw new ArgumentException(\"cannot be 384 use SHA384 instead\", \"bitLength\");\n\n            this.digestLength = bitLength / 8;\n\n            tIvGenerate(digestLength * 8);\n\n            Reset();\n        }\n\n        /**\n         * Copy constructor.  This will copy the state of the provided\n         * message digest.\n         */\n        public Sha512tDigest(Sha512tDigest t)\n            : base(t)","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/Sha512tDigest.cs#L6-L42","documentation":"Sha512tDigest implements SHA-512/t, a truncated variant of SHA-512. The constructor validates bitLength and rejects any value >= 512 because the whole point of this digest is a truncated output shorter than 512 bits; for 512 you should use the plain Sha512Digest. BouncyCastle throws ArgumentException with the parameter name to signal an invalid constructor argument.","triggerScenarios":"Calling new Sha512tDigest(bitLength) with bitLength >= 512 (e.g. 512, 1024) or a value read from config that equals a full SHA-512 size.","commonSituations":"Configuring the algorithm name as 'SHA-512' and parsing the number to pass as bitLength; confusing SHA-512 with SHA-512/t when migrating code between digest classes.","solutions":["Pass a bitLength strictly less than 512 and a multiple of 8 that is not 384 (e.g. 224, 256).","If you need a full 512-bit digest, use Sha512Digest instead of Sha512tDigest.","If the value comes from user config, clamp or map it before constructing."],"exampleFix":"// before\nvar digest = new Sha512tDigest(512);\n// after\nvar digest = new Sha512Digest(); // or new Sha512tDigest(256);","handlingStrategy":"validation","validationCode":"bool IsValidSha512tBitLength(int bitLength) => bitLength < 512 && bitLength % 8 == 0 && bitLength != 384;","typeGuard":"bool IsValidSha512tBitLength(int bitLength) => bitLength is < 512 and not 384 && bitLength % 8 == 0;","tryCatchPattern":"try { var d = new Sha512tDigest(bits); }\ncatch (ArgumentException ex) when (ex.ParamName == \"bitLength\") { /* fall back to Sha512Digest or a default size */ }","preventionTips":["Never pass 512 or 384 to Sha512tDigest; use Sha512Digest/Sha384Digest for those sizes.","Assert bitLength is a multiple of 8 before constructing.","Centralize digest construction in one factory that validates sizes."],"tags":["csharp","argument-validation","bouncycastle","hash"],"backgroundTag":"invalid-hash-parameter","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}