<PackageReference Include="BouncyCastle.Cryptography" Version="2.7.0" />

Org.BouncyCastle.Security.ParameterUtilities

public static class ParameterUtilities
Helpers for building ICipherParameters values: creating algorithm-appropriate KeyParameter instances, decoding ASN.1 algorithm parameters into IV-bearing ICipherParameters, generating random IV/parameter blocks, and wrapping/unwrapping ParametersWithRandom / ParametersWithContext envelopes.
namespace Org.BouncyCastle.Security { public static class ParameterUtilities { public static string GetCanonicalAlgorithmName(string algorithm); public static KeyParameter CreateKeyParameter(DerObjectIdentifier algOid, byte[] keyBytes); public static KeyParameter CreateKeyParameter(string algorithm, byte[] keyBytes); public static KeyParameter CreateKeyParameter(DerObjectIdentifier algOid, byte[] keyBytes, int offset, int length); public static KeyParameter CreateKeyParameter(string algorithm, byte[] keyBytes, int offset, int length); public static ICipherParameters GetCipherParameters(DerObjectIdentifier algOid, ICipherParameters key, Asn1Object asn1Params); public static ICipherParameters GetCipherParameters(string algorithm, ICipherParameters key, Asn1Object asn1Params); public static Asn1Encodable GenerateParameters(DerObjectIdentifier algID, SecureRandom random); public static Asn1Encodable GenerateParameters(string algorithm, SecureRandom random); public static ICipherParameters GetContext(ICipherParameters cipherParameters, int minLen, int maxLen, out byte[] context); public static ICipherParameters GetRandom(ICipherParameters cipherParameters, out SecureRandom random); public static ICipherParameters IgnoreRandom(ICipherParameters cipherParameters); public static ICipherParameters WithContext(ICipherParameters cp, byte[] context); public static ICipherParameters WithRandom(ICipherParameters cp, SecureRandom random); } }