peass-ng/PEASS-ng · error · ArgumentException

SBOX provided did not map to a known one

Error message

SBOX provided did not map to a known one

What it means

GetSBoxName performs the reverse mapping of GetSBox: it iterates the known S-Box tables and compares each against the provided bytes with Arrays.AreEqual. If no known table matches, it throws ArgumentException.

Source

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

				throw new ArgumentException("Unknown S-Box - possible types: "
					+ "\"Default\", \"E-Test\", \"E-A\", \"E-B\", \"E-C\", \"E-D\", \"D-Test\", \"D-A\".");
			}

			return Arrays.Clone(sBox);
		}

		public static string GetSBoxName(byte[] sBox)
		{
			foreach (string name in sBoxes.Keys)
			{
				byte[] sb = (byte[])sBoxes[name];
				if (Arrays.AreEqual(sb, sBox))
				{
					return name;
				}
			}

			throw new ArgumentException("SBOX provided did not map to a known one");
		}
	}
}

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Obtain the S-Box array from GetSBox() using a valid name instead of hand-built bytes
  2. Verify the byte array matches one of the standard tables exactly (same length, same order)
  3. If a custom/standard table is required, add it to the engine's sBoxes table (local modification) rather than expecting reverse lookup

Example fix

// before
byte[] custom = File.ReadAllBytes("my_sbox.bin");
string name = Gost28147Engine.GetSBoxName(custom);
// after
byte[] sbox = Gost28147Engine.GetSBox("D-A");
string name = Gost28147Engine.GetSBoxName(sbox);
Defensive patterns

Strategy: validation

Validate before calling

if (sBox == null || sBox.Length == 0) throw new ArgumentException("S-Box bytes missing");
// pre-verify against a table obtained from GetSBox(name)
if (!sBox.SequenceEqual(Gost28147Engine.GetSBox(expectedName))) throw new InvalidOperationException("S-Box not recognized");

Type guard

bool IsKnownSBox(byte[] sBox) => sBox != null && new[]{"Default","E-Test","E-A","E-B","E-C","E-D","D-Test","D-A"}.Any(n => Gost28147Engine.GetSBox(n).SequenceEqual(sBox));

Try / catch

try { string name = Gost28147Engine.GetSBoxName(sBox); }
catch (ArgumentException) { /* treat as unknown parameter set; require explicit name */ }

Prevention

When it happens

Trigger: Calling GetSBoxName with an S-Box byte array that does not byte-for-byte equal any of the eight built-in tables (wrong length, wrong ordering, or custom table).

Common situations: Loading S-Box bytes from an external config/file with different byte ordering; using S-Boxes from a newer GOST standard (TC 26) not in this library; a corrupted or truncated S-Box array.

Related errors


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