X-Git-Url: http://git.euphorik.ch/?p=crypto_lab2.git;a=blobdiff_plain;f=labo2-fsharp%2FCryptoFileTests%2FTests.fs;fp=labo2-fsharp%2FCryptoFileTests%2FTests.fs;h=aeea186d2bf60bc064f754017161ae09c4510313;hp=458b1beeb1bde578d5d931034a399762d1ab0615;hb=57d7ae8d75a854296718cb1056efbeb476309908;hpb=5682c6a31f9a56142007447eadc6ad5045da905e diff --git a/labo2-fsharp/CryptoFileTests/Tests.fs b/labo2-fsharp/CryptoFileTests/Tests.fs index 458b1be..aeea186 100644 --- a/labo2-fsharp/CryptoFileTests/Tests.fs +++ b/labo2-fsharp/CryptoFileTests/Tests.fs @@ -36,7 +36,7 @@ let doSomeTests () = decrypt () assert (File.ReadAllText plainFilename = fileContent) - printfn "== Altering the MAC..." + printfn "== Altering the MAC... (%d bytes)" (API.hmacSize - 1) for i in 0 .. API.hmacSize - 1 do printf "." encrypt () @@ -48,7 +48,7 @@ let doSomeTests () = | error -> assert (error :? IntegrityError) printfn "" - printfn "== Altering the signature..." + printfn "== Altering the signature... (%d bytes)" (API.signatureSize - 1) for i in 0 .. API.signatureSize - 1 do printf "." encrypt () @@ -60,7 +60,7 @@ let doSomeTests () = | error -> assert (error :? SignatureMismatch) printfn "" - printfn "== Altering the keys..." + printfn "== Altering the keys... (%d bytes)" (API.keysSize - 1) for i in 0 .. API.keysSize - 1 do printf "." encrypt () @@ -72,14 +72,18 @@ let doSomeTests () = | error -> assert (error :? UnableToDecryptKeys) printfn "" - printfn "== Altering the cyphertext..." - encrypt () - incrementByteCipherFileAt (int64 <| API.hmacSize + API.signatureSize + API.keysSize) - try - decrypt () - assert false - with - | error -> assert (error :? IntegrityError) + let cyphertextLength = (int (FileInfo (cipherFilename)).Length) + API.hmacSize + API.signatureSize + API.keysSize + printfn "== Altering the cyphertext... (%d bytes)" cyphertextLength + for i in 0 .. cyphertextLength do + printf "." + encrypt () + incrementByteCipherFileAt (int64 <| API.hmacSize + API.signatureSize + API.keysSize + i) + try + decrypt () + assert false + with + | error -> assert (error :? IntegrityError) + printfn "" File.Delete cipherFilename File.Delete plainFilename