private static byte [] HMACSHA1HashForData(byte [] buf, byte [] modifier, int start, int length) { ExtendedHMACSHA1 hmac = ExtendedHMACSHA1.GetHMACSHA1(); // Pick up an ExtendedHMACSHA1 off the pool HMACBuffer [] hbufs; if (modifier != null) { hbufs = new HMACBuffer[2]; hbufs[1].buffer = modifier; hbufs[1].start = 0; hbufs[1].length = modifier.Length; } else { hbufs = new HMACBuffer[1]; } hbufs[0].buffer = buf; hbufs[0].start = start; hbufs[0].length = length; byte [] ret = hmac.ComputeHash(hbufs); ExtendedHMACSHA1.ReturnHMACSHA1(hmac); return(ret); }
internal /*public*/ byte[] ComputeHash(HMACBuffer[] buffers) { for (int i = 0; i < buffers.Length; i++) { HMACBuffer hb = buffers[i]; HashCore(hb.buffer, hb.start, hb.length); } byte[] ret = (byte [])HashFinal().Clone(); Initialize(); return(ret); }