peass-ng/PEASS-ng · error · ArgumentException

Invalid value for MAC size:

Error message

Invalid value for MAC size: 

What it means

A parameter validation in GcmBlockCipher.Init: when initialized from AeadParameters, the requested MAC size in bits must be between 32 and 128 inclusive and a multiple of 8 (GCM tags are truncated 128-bit tags). It fires when MacSize is set outside that range or is not byte-aligned; the message prints the offending bit count.

Source

Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/modes/GcmBlockCipher.cs:106

        {
            this.forEncryption = forEncryption;
            this.macBlock = null;
            this.initialised = true;

            KeyParameter keyParam;
            byte[] newNonce = null;

            if (parameters is AeadParameters)
            {
                AeadParameters param = (AeadParameters)parameters;

                newNonce = param.GetNonce();
                initialAssociatedText = param.GetAssociatedText();

                int macSizeBits = param.MacSize;
                if (macSizeBits < 32 || macSizeBits > 128 || macSizeBits % 8 != 0)
                {
                    throw new ArgumentException("Invalid value for MAC size: " + macSizeBits);
                }

                macSize = macSizeBits / 8;
                keyParam = param.Key;
            }
            else if (parameters is ParametersWithIV)
            {
                ParametersWithIV param = (ParametersWithIV)parameters;

                newNonce = param.GetIV();
                initialAssociatedText = null;
                macSize = 16;
                keyParam = (KeyParameter)param.Parameters;
            }
            else
            {
                throw new ArgumentException("invalid parameters passed to GCM");
            }

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Use a standard GCM tag size: 128 bits (16 bytes), or 120/112/104/96 bits per NIST SP 800-38D
  2. Construct AeadParameters with a MacSize that is a multiple of 8 within 32..128
  3. Prefer the common 12-byte IV / 16-byte tag defaults unless truncation is intentionally accepted
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/modes/GcmBlockCipher.cs:106 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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