- (*type HMACStream (buffer: byte[], output: Stream) =
- inherit Stream ()
- override this.CanRead with get () = false
- override this.CanSeek with get () = false
- override this.CanWrite with get () = true
- override this.Length with get () = raise <| new NotSupportedException ()
- override this.Position with get () = raise <| new NotSupportedException ()
- and set _ = raise <| new NotSupportedException ()
- override this.Flush () =
- output.Flush ()
- override this.Read (_: byte[], _: int, _: int) = raise <| new NotSupportedException ()*)
\ No newline at end of file
+ /// Compute HMAC-SHA256 for all the data in the input stream.
+ let ComputeHMAC (key: byte[]) (inputStream: Stream) : byte[] =
+ if key.Length <> 32 then raise KeySizeError
+ use hmac = new HMACSHA256 (key)
+ hmac.ComputeHash inputStream
\ No newline at end of file