Permalink
Browse files

Remove System.Crypto.Random entirely. Bump version.

  • Loading branch information...
1 parent dcf30cb commit d696f5d3d5156cf62b2853e67a3821b57ddee67b @TomMD committed Oct 3, 2011
Showing with 5 additions and 118 deletions.
  1. +0 −92 Benchmark/Crypto.hs
  2. +0 −14 System/Crypto/Random.hs
  3. +5 −12 crypto-api.cabal
View
92 Benchmark/Crypto.hs
@@ -1,92 +0,0 @@
-{- |
- Maintainer: Thomas.DuBuisson@gmail.com
- Stability: beta
- Portability: portable
-
-
- Criterion benchmarks for hash and block ciphers.
- Example hash benchmark:
-
-> import Data.Digest.Pure.MD5
-> import Benchmark.Crypto
-> import Criterion.Main
-> main = defaultMain [benchmarkHash (undefined :: MD5Digest) "pureMD5"]
-
- example block cipher benchmark:
-
-> main = do
-> let (Just k128) = buildKey (B.pack [0..15]) :: Maybe AESKey
-> (Just k192) = buildKey (B.pack [0..23]) :: Maybe AESKey
-> (Just k256) = buildKey (B.pack [0..31]) :: Maybe AESKey
-> defaultMain [ benchmarkBlockCipher k128 "SimpleAES-128"
-> , benchmarkBlockCipher k192 "SimpleAES-192"
-> , benchmarkBlockCipher k256 "SimpleAES-256"]
--}
-module Benchmark.Crypto
- ( benchmarkHash
- , benchmarkBlockCipher
- , benchmarkRNG
- , benchmarkCryptoRandomGen
- ) where
-
-import Crypto.Classes
-import Crypto.Modes (ecb', unEcb')
-import Crypto.Random
-import qualified Data.Serialize as Ser
-import qualified Data.ByteString as B
-import qualified Data.ByteString.Lazy as L
-import Data.Serialize as Ser
-import Criterion
-import Control.Monad (liftM)
-import Data.IORef
-
--- 128KB strings
-ps = B.replicate (2^17) 0
-lps = L.replicate (2^17) 0
-
--- 4MB strings
-ps4MB = B.replicate (2^22) 0
-lps4MB = B.replicate (2^22) 0
-
--- |Benchmark a hash by calling the 'hash' and 'hash'' functions
--- on 128KB bytestrings.
-benchmarkHash :: Hash c d => d -> String -> Benchmark
-benchmarkHash h name =
- let benchs = bgroup name [ bench "lazy" (whnf (hashFunc h) lps)
- , bench "strict" (whnf (hashFunc' h) ps)] :: Benchmark
- in benchs
-
-op :: Ser.Serialize d => (a -> d) -> a -> Pure
-op f str = whnf (B.unpack . Ser.encode . f) str
-
--- |Benchmark a block cipher by calling the 'ecb'' and 'unEcb'' functions
--- on 128KB strings
-benchmarkBlockCipher :: BlockCipher k => k -> String -> Benchmark
-benchmarkBlockCipher k name =
- let benchs = bgroup name [ bench "enc" (whnf (ecb' k) ps)
- , bench "dec" (whnf (unEcb' k) ps)] :: Benchmark
- in benchs
-
--- |Benchmark an RNG by requesting 256K of random data
-benchmarkRNG :: (Int -> IO B.ByteString) -> String -> Benchmark
-benchmarkRNG rng name = bench name (nfIO $ liftM B.head (rng (2^18)))
-
--- | Benchmark a CryptoRandomGen by storing it in a IORef, and generating
--- 256k per call.
-benchmarkCryptoRandomGen :: CryptoRandomGen g => g -> String -> IO Benchmark
-benchmarkCryptoRandomGen g name = do
- g' <- useGenIO g
- return $ bench name (nfIO $ liftM B.head (g' (2^18)))
-
-useGenIO :: CryptoRandomGen g => g -> IO (Int -> IO B.ByteString)
-useGenIO g = do
- gRef <- newIORef g
- return $ \i -> do
- gen <- readIORef gRef
- let v = genBytes i gen
- case v of
- Left _ -> error "blah"
- Right (b,gen') -> do
- writeIORef gRef gen'
- return b
-
View
14 System/Crypto/Random.hs
@@ -1,14 +0,0 @@
-{-# LANGUAGE CPP, ForeignFunctionInterface, BangPatterns #-}
-{-|
- Maintainer: Thomas.DuBuisson@gmail.com
- Stability: beta
- Portability: portable
-
- Obtain entropy from system sources. This module is rather untested on Windows (or testers never provided feedback),
- though testing was requested from the community - please e-mail the maintainer with test results.
--}
-
-module System.Crypto.Random {-# DEPRECATED "Use the 'entropy' package module System.Entropy instead" #-}
- (module System.Entropy) where
-
-import System.Entropy
View
17 crypto-api.cabal
@@ -1,13 +1,12 @@
name: crypto-api
-version: 0.6.4
+version: 0.7.1
license: BSD3
license-file: LICENSE
copyright: Thomas DuBuisson <thomas.dubuisson@gmail.com>, Francisco Blas Izquierdo Riera (klondike) (see AUTHORS)
author: Thomas DuBuisson <thomas.dubuisson@gmail.com>, Francisco Blas Izquierdo Riera (klondike)
maintainer: Thomas DuBuisson <thomas.dubuisson@gmail.com>
description: A generic interface for cryptographic operations,
- platform independent quality RNG
- and a basic benchmark infrastructure.
+ and a platform independent quality RNG.
Maintainers of hash and cipher implementations are
encouraged to add instances for the classes defined
@@ -28,10 +27,6 @@ cabal-version: >= 1.6
tested-with: GHC == 7.0.3
-flag benchmarks
- description: Include benchmarking tools for cryptographic operations
- default: False
-
Library
Build-Depends: base == 4.*,
bytestring >= 0.9 && < 0.10,
@@ -42,9 +37,7 @@ Library
hs-source-dirs:
exposed-modules: Crypto.Classes, Crypto.Types, Crypto.HMAC, Crypto.Modes, Crypto.Random, Crypto.Padding, System.Crypto.Random
other-modules: Crypto.Util, Crypto.CPoly
- if flag(benchmarks)
- exposed-modules: Benchmark.Crypto
- build-depends: criterion >= 0.5, deepseq
+
source-repository head
- type: darcs
- location: http://code.haskell.org/crypto-api
+ type: git
+ location: https://github.com/TomMD/crypto-api

0 comments on commit d696f5d

Please sign in to comment.