Generate a key-encryption key (KEK) from input keying material (IKM) using a key derivation function (KDF).
Namespace: CryptoSysPKIAssembly: diCrSysPKINet (in diCrSysPKINet.dll) Version: 23.0.0.25611 (23.0.0.0)
Syntaxpublic static byte[] Bytes(
int dkLen,
byte[] ikm,
KdfKdfAlg kdfAlg = KdfKdfAlg.X963,
KdfHashAlg hashAlg = KdfHashAlg.Sha1,
byte[] sharedInfo = null,
string paramString = ""
)
Public Shared Function Bytes (
dkLen As Integer,
ikm As Byte(),
Optional kdfAlg As KdfKdfAlg = KdfKdfAlg.X963,
Optional hashAlg As KdfHashAlg = KdfHashAlg.Sha1,
Optional sharedInfo As Byte() = Nothing,
Optional paramString As String = ""
) As Byte()
Parameters
- dkLen Int32
- Required length of output key material in bytes.
- ikm Byte
- Input key material/shared secret.
- kdfAlg KdfKdfAlg (Optional)
- Key derivation function to use.
- hashAlg KdfHashAlg (Optional)
- Hash algorithm to use with the key derivation function (default is SHA-1)
- sharedInfo Byte (Optional)
- SharedInfo (optional)
- paramString String (Optional)
- Optional parameters. Set as "" for defaults.
Pass attribute-value salt=<hex-digits> to set the optional salt parameter for the HKDF algorithm,
e.g. "salt=606162636465666768696a6b6c6d6e6f;"
Return Value
ByteOutput key material (KEK).
Example
int nbytes = 42;
byte[] zz = "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b".FromHex();
byte [] info = "f0f1f2f3f4f5f6f7f8f9".FromHex();
byte[] kek = Kdf.Bytes(nbytes, zz, Kdf.KdfAlg.Hkdf, Kdf.HashAlg.Sha256, info, "salt=000102030405060708090a0b0c");
Console.WriteLine("KEK={0}", Cnv.ToHex(kek));
See Also