peass-ng/PEASS-ng · error · ArgumentException

invalid parameter passed to Gost28147 init -

Error message

invalid parameter passed to Gost28147 init - 

What it means

Gost28147Engine.Init throws this ArgumentException when the parameters object is neither a KeyParameter nor ParametersWithSBox (nor null, which is tolerated for parameter-less re-init). The message appends the runtime type name of the unsupported parameter.

Source

Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/engines/Gost28147Engine.cs:185

				this.S = Arrays.Clone(sBox);

				//
				// set key if there is one
				//
				if (param.Parameters != null)
				{
					workingKey = generateWorkingKey(forEncryption,
							((KeyParameter)param.Parameters).GetKey());
				}
			}
			else if (parameters is KeyParameter)
			{
				workingKey = generateWorkingKey(forEncryption,
									((KeyParameter)parameters).GetKey());
			}
			else if (parameters != null)
			{
				throw new ArgumentException("invalid parameter passed to Gost28147 init - "
					+ Platform.GetTypeName(parameters));
			}
		}

		public virtual string AlgorithmName
		{
			get { return "Gost28147"; }
		}

		public virtual bool IsPartialBlockOkay
		{
			get { return false; }
		}

		public virtual int GetBlockSize()
		{
			return BlockSize;
		}

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Pass new KeyParameter(keyBytes), optionally wrapped in ParametersWithSBox
  2. Unwrap the extra ParametersWithIV/ParametersWithRandom layer before Init
  3. If parameters may be null intentionally, ensure it is actually null, not a wrong type

Example fix

// before
engine.Init(true, new ParametersWithIV(new KeyParameter(key), iv));
// after
engine.Init(true, new KeyParameter(key));
Defensive patterns

Strategy: type-guard

Validate before calling

if (parameters != null && parameters is not KeyParameter && parameters is not ParametersWithSBox) throw new ArgumentException("Unsupported GOST parameters");

Type guard

static bool IsGostParameter(ICipherParameters p) => p == null || p is KeyParameter || p is ParametersWithSBox;

Try / catch

try { engine.Init(forEncryption, parameters); } catch (ArgumentException ex) { /* unwrap/convert parameters and retry */ }

Prevention

When it happens

Trigger: Calling Init(forEncryption, parameters) with e.g. ParametersWithIV, ParametersWithRandom, or a custom ICipherParameters implementation; parameters != null but not one of the two supported types.

Common situations: Copy-pasting an AES-mode Init call (ParametersWithIV) into GOST code; wrapping parameters in an extra layer like ParametersWithRandom for no reason.

Related errors


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