gchq/CyberChef · error · OperationError

Size must be between 0 and 512

Error message

Size must be between 0 and 512

What it means

Thrown by the MD6 hash operation when the 'Size' argument (args[0]) is outside 0–512. MD6 produces a variable-length digest and the node-md6 library expects the bit length; run() rejects any size below 0 or above 512 at MD6.mjs:56. The default is 256. Size is measured in bits.

Source

Thrown at src/core/operations/MD6.mjs:56

            },
            {
                "name": "Key",
                "type": "string",
                "value": ""
            }
        ];
    }

    /**
     * @param {string} input
     * @param {Object[]} args
     * @returns {string}
     */
    run(input, args) {
        const [size, levels, key] = args;

        if (size < 0 || size > 512)
            throw new OperationError("Size must be between 0 and 512");
        if (levels < 0)
            throw new OperationError("Levels must be greater than 0");

        return NodeMD6.getHashOfText(input, size, key, levels);
    }

}

export default MD6;

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Set Size to a value between 0 and 512 inclusive, expressed in bits (common: 256, 224, 512).
  2. If you entered a byte count, multiply-check: MD6 size is in bits, so use e.g. 256 not 32.
  3. Validate 0 <= size <= 512 before running.

Example fix

// before
md6.run(input, [1024, 64, '']);   // size too large

// after
md6.run(input, [256, 64, '']);     // 256-bit digest
Defensive patterns

Strategy: validation

Validate before calling

function validMd6Size(s) {
  return Number.isInteger(s) && s >= 0 && s <= 512;
}
if (!validMd6Size(size)) throw new Error('MD6 size must be 0..512 bits');

Type guard

function isMd6Size(v: unknown): v is number {
  return typeof v === 'number' && Number.isInteger(v) && v >= 0 && v <= 512;
}

Prevention

When it happens

Trigger: Setting the Size argument to a negative number or any value greater than 512 — e.g. 1024, -1, 0 is allowed. Raised at MD6.mjs:55-56 before NodeMD6.getHashOfText is called.

Common situations: Confusing bit length with byte length (entering 2048 thinking bytes); copying a recipe that set a non-standard size; setting 0 expecting 'no hash' (0 is actually permitted and yields a zero-length digest).

Related errors


AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13). Data as JSON: /api/errors/30a3016acb785bd6. Report an issue: GitHub.