peass-ng/PEASS-ng · error · ArgumentException

cannot be 384 use SHA384 instead

Error message

cannot be 384 use SHA384 instead

What it means

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.

Source

Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/Sha512tDigest.cs:28

        : LongDigest
    {
        private const ulong A5 = 0xa5a5a5a5a5a5a5a5UL;

        private readonly int digestLength;

        private ulong H1t, H2t, H3t, H4t, H5t, H6t, H7t, H8t;

        /**
         * Standard constructor
         */
        public Sha512tDigest(int bitLength)
        {
            if (bitLength >= 512)
                throw new ArgumentException("cannot be >= 512", "bitLength");
            if (bitLength % 8 != 0)
                throw new ArgumentException("needs to be a multiple of 8", "bitLength");
            if (bitLength == 384)
                throw new ArgumentException("cannot be 384 use SHA384 instead", "bitLength");

            this.digestLength = bitLength / 8;

            tIvGenerate(digestLength * 8);

            Reset();
        }

        /**
         * Copy constructor.  This will copy the state of the provided
         * message digest.
         */
        public Sha512tDigest(Sha512tDigest t)
            : base(t)
        {
            this.digestLength = t.digestLength;

			Reset(t);

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Use Sha384Digest for a 384-bit digest.
  2. Adjust factory logic to map 384 to Sha384Digest and other sizes to Sha512tDigest.
  3. Pick a different truncation length (e.g. 256) if SHA-384 semantics are not required.

Example fix

// before
var digest = new Sha512tDigest(384);
// after
var digest = new Sha384Digest();
Defensive patterns

Strategy: validation

Validate before calling

var digest = bitLength == 384 ? (IDigest)new Sha384Digest() : new Sha512tDigest(bitLength);

Type guard

bool RequiresSha384(int bits) => bits == 384;

Try / catch

try { d = new Sha512tDigest(bits); }
catch (ArgumentException ex) when (ex.ParamName == "bitLength" && bits == 384) { d = new Sha384Digest(); }

Prevention

When it happens

Trigger: new Sha512tDigest(384), often because code generically maps a digest size like 384 to Sha512tDigest.

Common situations: Factory code that selects a digest class by bit size without special-casing 384; users expecting SHA-512/384 to exist.

Related errors


AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02). Data as JSON: /api/errors/016bdde91bc338a9. Report an issue: GitHub.