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 ()
| 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 ()
| 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 ()
| 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