peass-ng/PEASS-ng · error · ArgumentException

Skein key must be at least 128 bits.

Error message

Skein key must be at least 128 bits.

What it means

SkeinEngine requires a key of at least 16 bytes (128 bits) when initialized with a SkeinParameters object. The library enforces this minimum because Skein's UBI chaining needs a non-trivial key for the key-absorb block; shorter keys would produce a degenerate hash. Thrown as ArgumentException during Init.

Source

Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/SkeinEngine.cs:610

        /// <summary>
        /// Initialises the Skein engine with the provided parameters. See <see cref="Org.BouncyCastle.Crypto.Parameters.SkeinParameters"/> for
        /// details on the parameterisation of the Skein hash function.
        /// </summary>
        /// <param name="parameters">the parameters to apply to this engine, or <code>null</code> to use no parameters.</param>
        public void Init(SkeinParameters parameters)
        {
            this.chain = null;
            this.key = null;
            this.preMessageParameters = null;
            this.postMessageParameters = null;

            if (parameters != null)
            {
                byte[] key = parameters.GetKey();
                if (key.Length < 16)
                {
                    throw new ArgumentException("Skein key must be at least 128 bits.");
                }
                InitParams(parameters.GetParameters());
            }
            CreateInitialState();

            // Initialise message block
            UbiInit(PARAM_TYPE_MESSAGE);
        }

        private void InitParams(IDictionary parameters)
        {
            IEnumerator keys = parameters.Keys.GetEnumerator();
            IList pre = Platform.CreateArrayList();
            IList post = Platform.CreateArrayList();

            while (keys.MoveNext())
            {
                int type = (int)keys.Current;

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Provide a key byte[] of at least 16 bytes in SkeinParameters
  2. If a smaller key must be accepted, pad/hash it to >= 16 bytes before building parameters
  3. Use SetKey with the full 32/64-byte key recommended by your Skein parameter choice

Example fix

// before
var p = new SkeinParameters.Builder().SetKey(shortKeyBytes).Build();
engine.Init(p);
// after
if (shortKeyBytes.Length < 16) shortKeyBytes = new byte[16]; // or stretch via KDF
var p = new SkeinParameters.Builder().SetKey(shortKeyBytes).Build();
engine.Init(p);
Defensive patterns

Strategy: validation

Validate before calling

if (keyBytes == null || keyBytes.Length < 16) throw new ArgumentException("Skein key must be >= 16 bytes");

Type guard

static bool IsValidSkeinKey(byte[] key) => key != null && key.Length >= 16;

Try / catch

try { engine.Init(skeinParams); } catch (ArgumentException ex) { /* handle key-size error: ex.Message.Contains("at least 128 bits") */ }

Prevention

When it happens

Trigger: Calling Init(SkeinParameters) whose key byte[] has length < 16, e.g. built via SkeinParameters.Builder().SetKey(shortKey).Build().

Common situations: Passing a 64-bit or 96-bit key from a config file, truncating a key to fewer than 16 bytes, or using a legacy stored key that predates the 128-bit minimum.

Related errors


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