From: Ummon Date: Thu, 4 Dec 2014 21:32:01 +0000 (+0100) Subject: Clean up. X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=a29300558755d533aff12a6fb668c7e985ca4617;p=crypto_lab2.git Clean up. --- diff --git a/labo2-fsharp/CryptoFile/API.fs b/labo2-fsharp/CryptoFile/API.fs index 886b0d9..2f80c07 100644 --- a/labo2-fsharp/CryptoFile/API.fs +++ b/labo2-fsharp/CryptoFile/API.fs @@ -93,12 +93,12 @@ module API = // Decrypt metadata. inputStream.Position <- 32L + 256L + 256L use cryptoStream = Crypto.decryptAES keyAES iv inputStream - let metadata = Metadata (cryptoStream) + let metadata = Metadata cryptoStream // Create the file and write its content and metadata. let filePath = Path.Combine (targetDirPath, metadata.get MetadataKeys.filename) let modificationTime = DateTime (metadata.get MetadataKeys.modificationTime |> int64) - let fileInfo = FileInfo (filePath) + let fileInfo = FileInfo filePath using (fileInfo.Create ()) <| fun outputStream -> cryptoStream.CopyTo outputStream fileInfo.LastWriteTimeUtc <- modificationTime \ No newline at end of file diff --git a/labo2-fsharp/CryptoFile/Crypto.fs b/labo2-fsharp/CryptoFile/Crypto.fs index e74409d..a7ba53c 100644 --- a/labo2-fsharp/CryptoFile/Crypto.fs +++ b/labo2-fsharp/CryptoFile/Crypto.fs @@ -21,7 +21,7 @@ module internal Crypto = generator.GetBytes result result - /// Generate a new RSA key pair: (public * private). + /// Generates a new RSA key pair: (public * private). let generateRSAKeysPair : Key * Key = use rsa = new RSACryptoServiceProvider (rsaKeySize) rsa.ToXmlString false, rsa.ToXmlString true @@ -62,7 +62,7 @@ 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. + // Creates a stream to compute the 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)