add Scrypt placeholder

This commit is contained in:
Vincent Hanquez 2014-07-27 11:09:45 -07:00
parent 04912a180a
commit c84acf079e
2 changed files with 42 additions and 0 deletions

41
Crypto/KDF/Scrypt.hs Normal file
View File

@ -0,0 +1,41 @@
-- |
-- Module : Crypto.KDF.Scrypt
-- License : BSD-style
-- Maintainer : Vincent Hanquez <vincent@snarc.org>
-- Stability : experimental
-- Portability : unknown
--
-- Scrypt key derivation function as defined in Colin Percival's paper "Stronger Key Derivation via Sequential Memory-Hard Functions" <http://www.tarsnap.com/scrypt/scrypt.pdf>.
--
{-# LANGUAGE BangPatterns #-}
module Crypto.KDF.Scrypt
( Parameters(..)
, generate
) where
import Data.Word
import Data.Bits
import Data.ByteString (ByteString)
import qualified Data.ByteString as B
import qualified Data.ByteString.Internal as B (unsafeCreate, memset)
import Data.Byteable
import Foreign.Storable
import Foreign.Ptr (Ptr, plusPtr)
import Control.Applicative
import Control.Monad (forM_, void)
import qualified Crypto.KDF.PBKDF2 as PBKDF2
-- | Parameters for Scrypt
data Parameters = Parameters
{ password :: ByteString -- ^ Password (bytes encoded)
, salt :: ByteString -- ^ Salt (bytes encoded)
, n :: Int -- ^ Cpu/Memory cost ratio. must be a power of 2 greater than 1
, r :: Int -- ^ Must satisfy r * p < 2^30
, p :: Int -- ^ Must satisfy r * p < 2^30
, outputLength :: Int -- ^ the number of bytes to generate out of Scrypt
}
-- | Generate the scrypt key derivation data
generate :: Parameters -> B.ByteString
generate params = undefined

View File

@ -48,6 +48,7 @@ Library
Other-modules: Crypto.Hash.Internal
, Crypto.Hash.Utils
, Crypto.Hash.Types
, Crypto.KDF.Scrypt
, Crypto.Random.Entropy.Source
Build-depends: base >= 4 && < 5
, bytestring