X-Git-Url: http://git.euphorik.ch/?p=crypto_lab2.git;a=blobdiff_plain;f=labo2-fsharp%2FCryptoFile%2FCrypto.fs;fp=labo2-fsharp%2FCryptoFile%2FCrypto.fs;h=3ed1c5dcc2387aadb69d51879d9945f7c3f0b9ea;hp=4b893b0bfeba9b6985508998432d00ae946e1aa5;hb=57d7ae8d75a854296718cb1056efbeb476309908;hpb=5682c6a31f9a56142007447eadc6ad5045da905e diff --git a/labo2-fsharp/CryptoFile/Crypto.fs b/labo2-fsharp/CryptoFile/Crypto.fs index 4b893b0..3ed1c5d 100644 --- a/labo2-fsharp/CryptoFile/Crypto.fs +++ b/labo2-fsharp/CryptoFile/Crypto.fs @@ -62,12 +62,13 @@ module internal Crypto = use aes = new AesCryptoServiceProvider (KeySize = aesKeySize) new CryptoStream (inputStream, aes.CreateDecryptor (key, iv), CryptoStreamMode.Read) - // Create a stream to compute the HMAC-SHA256 against all data being written. + /// Create a stream to compute HMAC-SHA256 against all data being written. let HMACStream (key: byte[]) (outputStream: Stream) : Stream * HMACSHA256 = if key.Length <> 32 then raise KeySizeError let hmac = new HMACSHA256 (key) new CryptoStream (outputStream, hmac, CryptoStreamMode.Write) :> Stream, hmac + /// 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)