File: bench.hs

package info (click to toggle)
haskell-cipher-aes128 0.7.0.6-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 220 kB
  • sloc: ansic: 1,696; haskell: 674; makefile: 2
file content (18 lines) | stat: -rw-r--r-- 516 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import qualified Crypto.Cipher.AES128 as AES128
import Crypto.Classes
import Crypto.Types
import Criterion
import Criterion.Main
import System.Entropy
import Data.Serialize
import qualified Data.ByteString as B

main = do
    let iv  = zeroIV
        ivV = B.replicate 16 0
    pt <- getEntropy (2^16)
    k  <- buildKeyIO :: IO AES128.AESKey128
    defaultMain
        [ bench "aes-ecb cipher-aes128" $ nf (AES128.encryptBlock k) pt
        , bench "aes-ctr cipher-aes128" $ nf (fst . AES128.ctr k iv) pt
        ]