public void Test_Extract_SHA256_Ok(string ikmStr, string saltStr, string prkStr) { byte[] ikm = ConvertHexStringToBytes(ikmStr); byte[] salt = ConvertHexStringToBytes(saltStr); NuniToolbox.Cryptography.HKDF hkdf = new NuniToolbox.Cryptography.HKDF(() => new HMACSHA256()); byte[] prk = hkdf.Extract(ikm, salt); Assert.NotNull(prk); Assert.Equal(prkStr, ConvertBytesToHexString(prk)); }
public void Test_Expand_SHA256_Ok(string prkStr, string infoStr, int length, string okmStr) { byte[] prk = ConvertHexStringToBytes(prkStr); byte[] info = ConvertHexStringToBytes(infoStr); NuniToolbox.Cryptography.HKDF hkdf = new NuniToolbox.Cryptography.HKDF(() => new HMACSHA256()); byte[] okm = hkdf.Expand(prk, info, length); Assert.NotNull(okm); Assert.Equal(length, okm.Length); Assert.Equal(okmStr, ConvertBytesToHexString(okm)); }
public void Test_DeriveKey_SHA256_Ok(string ikmStr, string saltStr, string infoStr, int length, string okmStr) { byte[] ikm = ConvertHexStringToBytes(ikmStr); byte[] salt = ConvertHexStringToBytes(saltStr); byte[] info = ConvertHexStringToBytes(infoStr); NuniToolbox.Cryptography.HKDF hkdf = new NuniToolbox.Cryptography.HKDF(() => new HMACSHA256()); byte[] okm = hkdf.DeriveKey(ikm, salt, info, length); Assert.NotNull(okm); Assert.Equal(length, okm.Length); Assert.Equal(okmStr, ConvertBytesToHexString(okm)); }