raaz-0.3.1: indef/keyed/hash/Implementation.hsig
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE CPP #-}
-- | A keyed primitive is something that expects a key for it to
-- function. Examples include, encryption, encrypted-authentication
-- etc. This signature add additional constraints to an implementation
-- to make it a keyed cryptographic primitive.
signature Implementation
( Prim
, Internals
, BufferAlignment
) where
import Foreign.Storable (Storable)
import Raaz.Core
import Raaz.Primitive.Keyed.Internal (KeyedHash)
-- NOTE:
--
-- (This issue does not seem to be applicable any more)
--
-- With https://gitlab.haskell.org/ghc/ghc/issues/15138 and
-- https://gitlab.haskell.org/ghc/ghc/issues/15379 fixed I (ppk) had
-- expected that one can differ the assignment of Buffer
-- alignment. While this is indeed the case for other implementations,
-- for some reason it, does not seem to work for the Mac
-- implementation, probably because of being an indirect constraint;
-- Mac.Implementation -> Implementation but then is mixed as
-- Implementation in the auth case. Therefore, I am setting an
-- artificially large base number here.
--
# if MIN_VERSION_base(4,13,0)
import GHC.TypeLits
-- | The alignment requirements on the buffer.
data BufferAlignment :: Nat
instance KnownNat BufferAlignment
# else
-- | The alignment required for buffer (hack around bug
-- https://ghc.haskell.org/trac/ghc/ticket/15138)
type BufferAlignment = 32
#endif
-- | The primitive for which the implementation is given
data Prim
instance Primitive Prim
instance Storable Prim
instance KeyedHash Prim
-- | The internal memory used by the implementation.
data Internals
instance Memory Internals
instance Initialisable Internals Prim
instance Extractable Internals Prim