peass-ng/PEASS-ng · error · ArgumentException
must be one of 128, 224, 256, 288, 384, or 512.
Error message
must be one of 128, 224, 256, 288, 384, or 512.
What it means
KeccakDigest only supports fixed output lengths of 128, 224, 256, 288, 384, or 512 bits, because only those produce a valid sponge rate. Init() validates the bitLength passed to the constructor and throws ArgumentException (naming the bitLength parameter) for any other value.
Source
Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/KeccakDigest.cs:132
public virtual int GetByteLength()
{
return rate >> 3;
}
private void Init(int bitLength)
{
switch (bitLength)
{
case 128:
case 224:
case 256:
case 288:
case 384:
case 512:
InitSponge(1600 - (bitLength << 1));
break;
default:
throw new ArgumentException("must be one of 128, 224, 256, 288, 384, or 512.", "bitLength");
}
}
private void InitSponge(int rate)
{
if (rate <= 0 || rate >= 1600 || (rate & 63) != 0)
throw new InvalidOperationException("invalid rate value");
this.rate = rate;
Array.Clear(state, 0, state.Length);
Arrays.Fill(this.dataQueue, (byte)0);
this.bitsInQueue = 0;
this.squeezing = false;
this.fixedOutputLength = (1600 - rate) >> 1;
}
protected void Absorb(byte data)
{View on GitHub (pinned to 53fb989abc)
Solutions
- Pass one of the allowed bit lengths: 128, 224, 256, 288, 384, or 512.
- Convert byte-based configuration to bits (multiply by 8) before constructing.
- Whitelist the allowed sizes in config parsing and fail early with a clear message.
Example fix
// before var keccak = new KeccakDigest(32); // bytes given, bits expected // after var keccak = new KeccakDigest(256);
Defensive patterns
Strategy: validation
Validate before calling
int[] allowed = { 128, 224, 256, 288, 384, 512 };
if (Array.IndexOf(allowed, bitLength) < 0)
throw new ArgumentOutOfRangeException(nameof(bitLength), "Keccak supports 128/224/256/288/384/512 bits");
var keccak = new KeccakDigest(bitLength); Type guard
static bool IsValidKeccakLength(int bits) => bits == 128 || bits == 224 || bits == 256 || bits == 288 || bits == 384 || bits == 512;
Try / catch
try { var k = new KeccakDigest(bitLength); }
catch (ArgumentException ex) { /* map to nearest supported length or fail fast */ } Prevention
- Convert byte configs to bits before constructing
- Whitelist the six supported lengths
- Don't confuse SHA3 sizes with allowed Keccak custom sizes
When it happens
Trigger: Calling new KeccakDigest(bitLength) with bitLength not in {128, 224, 256, 288, 384, 512} — e.g. 384 vs 512 typos, 0, or SHA3 sizes like 256 passed to a custom subclass expecting bytes.
Common situations: Config-driven digest sizes including non-standard values; confusing SHA3-256 with Keccak-256 (both valid here, but e.g. 248 is not); passing byte sizes (32) instead of bits.
Related errors
- Keys > 32 are not supported
- Invalid digest length (required: 1 - 32)
- Salt length must be exactly 8 bytes
- Personalization length must be exactly 8 bytes
- Keys > 32 bytes are not supported
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/e5ef59e1990472ab.
Report an issue: GitHub.