requireSupportedVersion

fnvoid requireSupportedVersion(const(ubyte)[] versionBytes, string what) pure @safe

Validates a decoded key-structure version field.

Key containers such as PKCS#8 PrivateKeyInfo and PKCS#1 RSAPrivateKey start with a version INTEGER; only version zero (v1 / two-prime) is supported here. Silently accepting a higher version would reinterpret a structure with extra or different fields (multi-prime RSA, public-key-bearing PKCS#8) as the plain one.

Parameters

versionBytesThe raw INTEGER content bytes read from the structure.
whatA human-readable name of the structure for error messages.

Throws

CryptoException when the version is anything but zero.