| 3 | | http://hackage.haskell.org/package/crypto-api |
| | 4 | Hackage: http://hackage.haskell.org/package/crypto-api |
| | 5 | |
| | 6 | = Testing = |
| | 7 | 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: |
| | 8 | |
| | 9 | {{{ |
| | 10 | import Test.SHA |
| | 11 | import Test.HMAC |
| | 12 | import Test.Crypto |
| | 13 | import Data.CryptoHash.SHA512 |
| | 14 | import Data.CryptoHash.SHA384 |
| | 15 | |
| | 16 | main = do |
| | 17 | t1 <- makeSHA512Tests (undefined :: SHA512) |
| | 18 | t2 <- makeSHA384Tests (undefined :: SHA384) |
| | 19 | runTests (concat [t1,t2]) |
| | 20 | |
| | 21 | h1 <- makeSHA512HMACTests (undefined :: SHA512) |
| | 22 | h2 <- makeSHA384HMACTests (undefined :: SHA384) |
| | 23 | runTests $ concat [h1,h2] |
| | 24 | }}} |
| | 25 | |
| | 26 | And the run: |
| | 27 | |
| | 28 | {{{ |
| | 29 | [tommd@Mavlo Test]$ ghc --make sha.hs |
| | 30 | [1 of 1] Compiling Main ( sha.hs, sha.o ) |
| | 31 | Linking sha ... |
| | 32 | [tommd@Mavlo Test]$ ./sha | grep True | wc -l |
| | 33 | 844 |
| | 34 | [tommd@Mavlo Test]$ ./sha | grep False | wc -l |
| | 35 | 0 |
| | 36 | }}} |