{"record":{"id":"016bdde91bc338a9","repo":"peass-ng/PEASS-ng","slug":"cannot-be-384-use-sha384-instead","errorCode":null,"errorMessage":"cannot be 384 use SHA384 instead","messagePattern":"cannot be 384 use SHA384 instead","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/Sha512tDigest.cs","lineNumber":28,"sourceCode":"        : 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)\n        {\n            this.digestLength = t.digestLength;\n\n\t\t\tReset(t);","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/Sha512tDigest.cs#L10-L46","documentation":"SHA-512/384 is intentionally forbidden because SHA-512 truncated to 384 bits uses a different IV than the standard SHA-384 digest. To avoid two ways of producing the same output, the constructor rejects bitLength == 384 and directs you to Sha384Digest.","triggerScenarios":"new Sha512tDigest(384), often because code generically maps a digest size like 384 to Sha512tDigest.","commonSituations":"Factory code that selects a digest class by bit size without special-casing 384; users expecting SHA-512/384 to exist.","solutions":["Use Sha384Digest for a 384-bit digest.","Adjust factory logic to map 384 to Sha384Digest and other sizes to Sha512tDigest.","Pick a different truncation length (e.g. 256) if SHA-384 semantics are not required."],"exampleFix":"// before\nvar digest = new Sha512tDigest(384);\n// after\nvar digest = new Sha384Digest();","handlingStrategy":"validation","validationCode":"var digest = bitLength == 384 ? (IDigest)new Sha384Digest() : new Sha512tDigest(bitLength);","typeGuard":"bool RequiresSha384(int bits) => bits == 384;","tryCatchPattern":"try { d = new Sha512tDigest(bits); }\ncatch (ArgumentException ex) when (ex.ParamName == \"bitLength\" && bits == 384) { d = new Sha384Digest(); }","preventionTips":["Map 384 to Sha384Digest in any digest factory.","Never construct SHA-512/t variants generically from raw bit sizes without a whitelist.","Prefer DigestUtilities.GetDigest(\"SHA-384\") over manual construction."],"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"}