packages feed

saltine-quickcheck 0.1.0.0 → 0.1.0.1

raw patch · 2 files changed

+30/−8 lines, 2 files

Files

saltine-quickcheck.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                saltine-quickcheck-version:             0.1.0.0+version:             0.1.0.1 synopsis:            Quickcheck implementations for some NaCl data homepage:            https://github.com/tsuraan/saltine-quickcheck license:             MIT
src/Crypto/Saltine/QuickCheck.hs view
@@ -1,3 +1,10 @@+-- |+-- Module    : Crypto.Saltine.QuickCheck+-- Copyright : Jeremy Groven+-- License   : BSD3+--+-- This module provides newtype/data wrappers that provide Arbitrary instances+-- for Crypto.Saltine types. module Crypto.Saltine.QuickCheck ( DeterministicBoxPair(..) , DeterministicBoxNonce(..)@@ -15,7 +22,6 @@ import qualified Data.ByteString                   as ByteString  import Crypto.Saltine.Class      ( IsEncoding(..) )-import Crypto.Saltine.Core.Box   ( SecretKey, PublicKey ) import Data.ByteString           ( ByteString ) import Data.ByteString.Arbitrary ( fastRandBs ) import Data.ByteString.Unsafe    ( unsafeUseAsCString )@@ -26,28 +32,38 @@ import System.IO.Unsafe          ( unsafePerformIO ) import Test.QuickCheck           ( Arbitrary(..) ) -boxSeedBytes :: Int-boxSeedBytes = fromIntegral c_crypto_box_seedbytes--signSeedBytes :: Int-signSeedBytes = fromIntegral c_crypto_sign_seedbytes-+-- |Wrapper around Saltine's Box.Keypair data DeterministicBoxPair = DBP   { boxSecret :: !Box.SecretKey   , boxPublic :: !Box.PublicKey } +-- |Wrapper around Saltine's Box.Nonce newtype DeterministicBoxNonce = DBN { fromDBN :: Box.Nonce } +-- |Wrapper around Saltine's Sign.Keypair data DeterministicSignPair = DSP   { signSecret :: !Sign.SecretKey   , signPublic :: !Sign.PublicKey } +-- |Wrapper around Saltine's SecretBox.Key newtype DeterministicSecretKey   = DSK { fromDSK :: Secret.Key }++-- |Wrapper around Saltine's SecretBox.Nonce newtype DeterministicSecretNonce = DSN { fromDSN :: Secret.Nonce } +-- |Convenience function for getting a Box.Keypair; can be used in a test as+--+-- @+--     (boxSecret, boxPublic) <- toBoxPair \`fmap\` arbitrary+-- @ toBoxPair :: DeterministicBoxPair -> Box.Keypair toBoxPair (DBP s p) = (s,p) +-- |Convenience function for getting a Sign.Keypair; can be used in a test as+--+-- @+--     (signSecret, signPublic) <- toSignPair \`fmap\` arbitrary+-- @ toSignPair :: DeterministicSignPair -> Sign.Keypair toSignPair (DSP s p) = (s,p) @@ -132,4 +148,10 @@  foreign import ccall "crypto_sign_seedbytes"   c_crypto_sign_seedbytes :: CSize++boxSeedBytes :: Int+boxSeedBytes = fromIntegral c_crypto_box_seedbytes++signSeedBytes :: Int+signSeedBytes = fromIntegral c_crypto_sign_seedbytes