public byte[] TestHMac(HandshakeHashType algorithm, byte[] key, byte[] data) { var hmac = HMac.Create(algorithm, SecureBuffer.CreateCopy(key)); hmac.Reset(); hmac.TransformBlock(data, 0, data.Length); var output = new byte [hmac.MacSize]; hmac.TransformFinalBlock(output, 0, output.Length); return(output); }