Org.BouncyCastle.Security.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.
Build a KeyParameter for the algorithm identified by algOid.
Build a KeyParameter for the named algorithm.
public static KeyParameter CreateKeyParameter(DerObjectIdentifier algOid, byte[] keyBytes, int offset, int length)
Build a KeyParameter from a slice of keyBytes.
public static KeyParameter CreateKeyParameter(string algorithm, byte[] keyBytes, int offset, int length)
Build a KeyParameter from a slice of keyBytes. DES / DES-EDE / RC2
keys are returned as their dedicated parameter subclasses; all other algorithms get a plain
KeyParameter.
Generate a fresh ASN.1-encoded algorithm parameters block (typically a random IV) for the
algorithm identified by algID.
Generate a fresh ASN.1-encoded algorithm parameters block for the named algorithm. CAST5, IDEA and
RC2 receive their dedicated parameter structures; other IV-based algorithms get a plain
Asn1OctetString containing the IV.
Returns the canonical algorithm name for the given alias or OID string, or null if the
algorithm is not recognised.
public static ICipherParameters GetCipherParameters(DerObjectIdentifier algOid, ICipherParameters key, Asn1Object asn1Params)
Combine a key with ASN.1-encoded algorithm parameters, returning the appropriate
ICipherParameters envelope (e.g. ParametersWithIV or
AeadParameters for AES-GCM/CCM).
public static ICipherParameters GetCipherParameters(string algorithm, ICipherParameters key, Asn1Object asn1Params)
Combine a key with ASN.1-encoded algorithm parameters for the named algorithm. See the OID
overload.
public static ICipherParameters GetContext(ICipherParameters cipherParameters, int minLen, int maxLen, out byte context)
Unwrap a ParametersWithContext envelope, returning the inner parameters and copying the
context bytes out via context. If the envelope is absent, context
is set to null and the input is returned unchanged.
public static ICipherParameters GetRandom(ICipherParameters cipherParameters, out SecureRandom random)
Unwrap a ParametersWithRandom envelope, returning the inner parameters and exposing the
attached SecureRandom via random. If the envelope is absent,
random is set to null and the input is returned unchanged.
Strip any ParametersWithRandom envelope and return the inner parameters; otherwise return
the input unchanged.
Wrap cp in a ParametersWithContext envelope when context
is non-null; otherwise return cp unchanged.