Esempio n. 1
0
        public static byte[] HKDF(byte[] salt, byte[] prk, byte[] info, int length)
        {
            var hmac = new HmacSha256(salt);
            var key  = hmac.ComputeHash(prk);

            return(HKDFSecondStep(key, info, length));
        }
Esempio n. 2
0
        public static byte[] HKDFSecondStep(byte[] key, byte[] info, int length)
        {
            var hmac       = new HmacSha256(key);
            var infoAndOne = info.Concat(new byte[] { 0x01 }).ToArray();
            var result     = hmac.ComputeHash(infoAndOne);

            if (result.Length > length)
            {
                Array.Resize(ref result, length);
            }
            return(result);
        }