| Version 3 (modified by TomMD, 3 years ago) |
|---|
Crypto-API
A generic interface for cryptographic operations, platform independent quality RNG, property tests and known-answer tests (KATs) for common algorithms, and a basic benchmark infrastructure.
Hackage: http://hackage.haskell.org/package/crypto-api
Testing
Using crypto-api for testing is absurdly simple and particularly useful if you are implementing one of the algorithms for which NIST CAVP provides known answer tests (KATs). For example:
import Test.SHA
import Test.HMAC
import Test.Crypto
import Data.CryptoHash.SHA512
import Data.CryptoHash.SHA384
main = do
t1 <- makeSHA512Tests (undefined :: SHA512)
t2 <- makeSHA384Tests (undefined :: SHA384)
runTests (concat [t1,t2])
h1 <- makeSHA512HMACTests (undefined :: SHA512)
h2 <- makeSHA384HMACTests (undefined :: SHA384)
runTests $ concat [h1,h2]
And the run:
[tommd@Mavlo Test]$ ghc --make sha.hs
[1 of 1] Compiling Main ( sha.hs, sha.o )
Linking sha ...
[tommd@Mavlo Test]$ ./sha | grep True | wc -l
844
[tommd@Mavlo Test]$ ./sha | grep False | wc -l
0
