{-# LANGUAGE DataKinds #-}
module ChaCha20.Random.CPortable
  ( name, description, RandomBufferSize, reseedAfter, randomBlocks
  , module ChaCha20.CPortable
  ) where

import           Raaz.Core
import qualified ChaCha20.CPortable as Base
import           ChaCha20.CPortable (Prim, Internals, BufferAlignment, BufferPtr, additionalBlocks)
import           Raaz.Verse.ChaCha20.C.Portable

name :: String
name :: String
name = String
"chacha20-libverse-csprg"

description :: String
description :: String
description = String
"ChaCha20 based CSPRG written in C exposed by libverse"


-------------------- CSPRG related stuff -------------------------------
-- | The number of blocks of the cipher that is generated in one go
-- encoded as a type level nat.
type RandomBufferSize = 16


-- | How many blocks of the primitive to generated before re-seeding.
reseedAfter :: BlockCount Prim
reseedAfter :: BlockCount Prim
reseedAfter = Int -> Proxy Prim -> BlockCount Prim
forall p. Int -> Proxy p -> BlockCount p
blocksOf (Int
1024 Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
1024 Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
1024) (Proxy Prim
forall k (t :: k). Proxy t
Proxy :: Proxy Prim)



randomBlocks :: BufferPtr
             -> BlockCount Prim
             -> Internals
             -> IO ()
randomBlocks :: BufferPtr -> BlockCount Prim -> Internals -> IO ()
randomBlocks = (Ptr (Tuple 16 Word32)
 -> Word64
 -> Ptr (Tuple 8 Word32)
 -> Ptr (Tuple 3 Word32)
 -> Ptr Word32
 -> IO ())
-> BufferPtr -> BlockCount Prim -> Internals -> IO ()
forall buf a b c.
(Ptr buf -> Word64 -> Ptr a -> Ptr b -> Ptr c -> IO ())
-> BufferPtr -> BlockCount Prim -> Internals -> IO ()
Base.runBlockProcess Ptr (Tuple 16 Word32)
-> Word64
-> Ptr (Tuple 8 Word32)
-> Ptr (Tuple 3 Word32)
-> Ptr Word32
-> IO ()
verse_chacha20csprg_c_portable