peass-ng/PEASS-ng · error · ArgumentException

not supported for SHAKE

Error message

 not supported for SHAKE

What it means

ShakeDigest only supports the standardized XOF sizes 128 and 256 bits (SHAKE128/SHAKE256 as defined in FIPS 202). CheckBitLength throws ArgumentException for any other value, appending the unsupported bitLength to the message.

Source

Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/ShakeDigest.cs:24

{
    /// <summary>
    /// Implementation of SHAKE based on following KeccakNISTInterface.c from http://keccak.noekeon.org/
    /// </summary>
    /// <remarks>
    /// Following the naming conventions used in the C source code to enable easy review of the implementation.
    /// </remarks>
    public class ShakeDigest
        : KeccakDigest, IXof
    {
        private static int CheckBitLength(int bitLength)
        {
            switch (bitLength)
            {
            case 128:
            case 256:
                return bitLength;
            default:
                throw new ArgumentException(bitLength + " not supported for SHAKE", "bitLength");
            }
        }

        public ShakeDigest()
            : this(128)
        {
        }

        public ShakeDigest(int bitLength)
            : base(CheckBitLength(bitLength))
        {
        }

        public ShakeDigest(ShakeDigest source)
            : base(source)
        {
        }

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Use new ShakeDigest() (SHAKE128) or new ShakeDigest(256) (SHAKE256).
  2. Restrict config parsing to the values 128 and 256.
  3. For other output sizes, use SHAKE128/256 and call DoFinal with your desired output length.

Example fix

// before
var digest = new ShakeDigest(224);
// after
var digest = new ShakeDigest(256);
Defensive patterns

Strategy: validation

Validate before calling

bool IsValidShakeBitLength(int bits) => bits == 128 || bits == 256;

Type guard

int? NormalizeShakeBits(int bits) => (bits == 128 || bits == 256) ? bits : (int?)null;

Try / catch

try { var d = new ShakeDigest(bits); }
catch (ArgumentException ex) when (ex.ParamName == "bitLength") { d = new ShakeDigest(256); }

Prevention

When it happens

Trigger: new ShakeDigest(bitLength) with values like 64, 224, 512, or a parsed size from an algorithm string such as 'SHAKE-224'.

Common situations: Migrating from SHA3Digest sizes to SHAKE; assuming SHAKE supports arbitrary truncation lengths like fixed digests do.

Related errors


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