{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving, DeriveGeneric, ForeignFunctionInterface #-}
module Crypto.Saltine.Internal.Stream (
stream_keybytes
, stream_noncebytes
, c_stream
, c_stream_xor
, Key(..)
, Nonce(..)
) where
import Control.DeepSeq (NFData)
import Crypto.Saltine.Class
import Crypto.Saltine.Core.Hash (shorthash)
import Crypto.Saltine.Internal.Hash (nullShKey)
import Crypto.Saltine.Internal.Util as U
import Data.ByteString (ByteString)
import Data.Data (Data, Typeable)
import Data.Hashable (Hashable)
import Data.Monoid
import Foreign.C
import Foreign.Ptr
import GHC.Generics (Generic)
import qualified Data.ByteString as S
newtype Key = Key { Key -> ByteString
unKey :: ByteString } deriving (Eq Key
Eq Key
-> (Key -> Key -> Ordering)
-> (Key -> Key -> Bool)
-> (Key -> Key -> Bool)
-> (Key -> Key -> Bool)
-> (Key -> Key -> Bool)
-> (Key -> Key -> Key)
-> (Key -> Key -> Key)
-> Ord Key
Key -> Key -> Bool
Key -> Key -> Ordering
Key -> Key -> Key
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Key -> Key -> Ordering
compare :: Key -> Key -> Ordering
$c< :: Key -> Key -> Bool
< :: Key -> Key -> Bool
$c<= :: Key -> Key -> Bool
<= :: Key -> Key -> Bool
$c> :: Key -> Key -> Bool
> :: Key -> Key -> Bool
$c>= :: Key -> Key -> Bool
>= :: Key -> Key -> Bool
$cmax :: Key -> Key -> Key
max :: Key -> Key -> Key
$cmin :: Key -> Key -> Key
min :: Key -> Key -> Key
Ord, Eq Key
Eq Key -> (Int -> Key -> Int) -> (Key -> Int) -> Hashable Key
Int -> Key -> Int
Key -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> Key -> Int
hashWithSalt :: Int -> Key -> Int
$chash :: Key -> Int
hash :: Key -> Int
Hashable, Typeable Key
Typeable Key
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Key -> c Key)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Key)
-> (Key -> Constr)
-> (Key -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Key))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Key))
-> ((forall b. Data b => b -> b) -> Key -> Key)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Key -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Key -> r)
-> (forall u. (forall d. Data d => d -> u) -> Key -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Key -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Key -> m Key)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Key -> m Key)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Key -> m Key)
-> Data Key
Key -> Constr
Key -> DataType
(forall b. Data b => b -> b) -> Key -> Key
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Key -> u
forall u. (forall d. Data d => d -> u) -> Key -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Key -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Key -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Key -> m Key
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Key -> m Key
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Key
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Key -> c Key
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Key)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Key)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Key -> c Key
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Key -> c Key
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Key
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Key
$ctoConstr :: Key -> Constr
toConstr :: Key -> Constr
$cdataTypeOf :: Key -> DataType
dataTypeOf :: Key -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Key)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Key)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Key)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Key)
$cgmapT :: (forall b. Data b => b -> b) -> Key -> Key
gmapT :: (forall b. Data b => b -> b) -> Key -> Key
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Key -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Key -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Key -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Key -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Key -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Key -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Key -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Key -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Key -> m Key
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Key -> m Key
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Key -> m Key
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Key -> m Key
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Key -> m Key
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Key -> m Key
Data, Typeable, (forall x. Key -> Rep Key x)
-> (forall x. Rep Key x -> Key) -> Generic Key
forall x. Rep Key x -> Key
forall x. Key -> Rep Key x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Key -> Rep Key x
from :: forall x. Key -> Rep Key x
$cto :: forall x. Rep Key x -> Key
to :: forall x. Rep Key x -> Key
Generic, Key -> ()
(Key -> ()) -> NFData Key
forall a. (a -> ()) -> NFData a
$crnf :: Key -> ()
rnf :: Key -> ()
NFData)
instance Eq Key where
Key ByteString
a == :: Key -> Key -> Bool
== Key ByteString
b = ByteString -> ByteString -> Bool
U.compare ByteString
a ByteString
b
instance Show Key where
show :: Key -> String
show Key
k = String
"Stream.Key {hashesTo = \"" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> (ByteString -> String
bin2hex (ByteString -> String)
-> (ByteString -> ByteString) -> ByteString -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShorthashKey -> ByteString -> ByteString
shorthash ShorthashKey
nullShKey (ByteString -> String) -> ByteString -> String
forall a b. (a -> b) -> a -> b
$ Key -> ByteString
forall a. IsEncoding a => a -> ByteString
encode Key
k) String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"\"}"
instance IsEncoding Key where
decode :: ByteString -> Maybe Key
decode ByteString
v = if ByteString -> Int
S.length ByteString
v Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
stream_keybytes
then Key -> Maybe Key
forall a. a -> Maybe a
Just (ByteString -> Key
Key ByteString
v)
else Maybe Key
forall a. Maybe a
Nothing
{-# INLINE decode #-}
encode :: Key -> ByteString
encode (Key ByteString
v) = ByteString
v
{-# INLINE encode #-}
newtype Nonce = Nonce { Nonce -> ByteString
unNonce :: ByteString } deriving (Nonce -> Nonce -> Bool
(Nonce -> Nonce -> Bool) -> (Nonce -> Nonce -> Bool) -> Eq Nonce
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Nonce -> Nonce -> Bool
== :: Nonce -> Nonce -> Bool
$c/= :: Nonce -> Nonce -> Bool
/= :: Nonce -> Nonce -> Bool
Eq, Eq Nonce
Eq Nonce
-> (Nonce -> Nonce -> Ordering)
-> (Nonce -> Nonce -> Bool)
-> (Nonce -> Nonce -> Bool)
-> (Nonce -> Nonce -> Bool)
-> (Nonce -> Nonce -> Bool)
-> (Nonce -> Nonce -> Nonce)
-> (Nonce -> Nonce -> Nonce)
-> Ord Nonce
Nonce -> Nonce -> Bool
Nonce -> Nonce -> Ordering
Nonce -> Nonce -> Nonce
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Nonce -> Nonce -> Ordering
compare :: Nonce -> Nonce -> Ordering
$c< :: Nonce -> Nonce -> Bool
< :: Nonce -> Nonce -> Bool
$c<= :: Nonce -> Nonce -> Bool
<= :: Nonce -> Nonce -> Bool
$c> :: Nonce -> Nonce -> Bool
> :: Nonce -> Nonce -> Bool
$c>= :: Nonce -> Nonce -> Bool
>= :: Nonce -> Nonce -> Bool
$cmax :: Nonce -> Nonce -> Nonce
max :: Nonce -> Nonce -> Nonce
$cmin :: Nonce -> Nonce -> Nonce
min :: Nonce -> Nonce -> Nonce
Ord, Eq Nonce
Eq Nonce
-> (Int -> Nonce -> Int) -> (Nonce -> Int) -> Hashable Nonce
Int -> Nonce -> Int
Nonce -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> Nonce -> Int
hashWithSalt :: Int -> Nonce -> Int
$chash :: Nonce -> Int
hash :: Nonce -> Int
Hashable, Typeable Nonce
Typeable Nonce
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Nonce -> c Nonce)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Nonce)
-> (Nonce -> Constr)
-> (Nonce -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Nonce))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Nonce))
-> ((forall b. Data b => b -> b) -> Nonce -> Nonce)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Nonce -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Nonce -> r)
-> (forall u. (forall d. Data d => d -> u) -> Nonce -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Nonce -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Nonce -> m Nonce)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Nonce -> m Nonce)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Nonce -> m Nonce)
-> Data Nonce
Nonce -> Constr
Nonce -> DataType
(forall b. Data b => b -> b) -> Nonce -> Nonce
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Nonce -> u
forall u. (forall d. Data d => d -> u) -> Nonce -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Nonce -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Nonce -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Nonce -> m Nonce
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Nonce -> m Nonce
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Nonce
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Nonce -> c Nonce
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Nonce)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Nonce)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Nonce -> c Nonce
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Nonce -> c Nonce
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Nonce
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Nonce
$ctoConstr :: Nonce -> Constr
toConstr :: Nonce -> Constr
$cdataTypeOf :: Nonce -> DataType
dataTypeOf :: Nonce -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Nonce)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Nonce)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Nonce)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Nonce)
$cgmapT :: (forall b. Data b => b -> b) -> Nonce -> Nonce
gmapT :: (forall b. Data b => b -> b) -> Nonce -> Nonce
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Nonce -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Nonce -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Nonce -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Nonce -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Nonce -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Nonce -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Nonce -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Nonce -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Nonce -> m Nonce
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Nonce -> m Nonce
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Nonce -> m Nonce
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Nonce -> m Nonce
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Nonce -> m Nonce
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Nonce -> m Nonce
Data, Typeable, (forall x. Nonce -> Rep Nonce x)
-> (forall x. Rep Nonce x -> Nonce) -> Generic Nonce
forall x. Rep Nonce x -> Nonce
forall x. Nonce -> Rep Nonce x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Nonce -> Rep Nonce x
from :: forall x. Nonce -> Rep Nonce x
$cto :: forall x. Rep Nonce x -> Nonce
to :: forall x. Rep Nonce x -> Nonce
Generic, Nonce -> ()
(Nonce -> ()) -> NFData Nonce
forall a. (a -> ()) -> NFData a
$crnf :: Nonce -> ()
rnf :: Nonce -> ()
NFData)
instance Show Nonce where
show :: Nonce -> String
show Nonce
k = String
"Stream.Nonce " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> ByteString -> String
bin2hex (Nonce -> ByteString
forall a. IsEncoding a => a -> ByteString
encode Nonce
k)
instance IsNonce Nonce where
zero :: Nonce
zero = ByteString -> Nonce
Nonce (Int -> Word8 -> ByteString
S.replicate Int
stream_noncebytes Word8
0)
nudge :: Nonce -> Nonce
nudge (Nonce ByteString
n) = ByteString -> Nonce
Nonce (ByteString -> ByteString
nudgeBS ByteString
n)
instance IsEncoding Nonce where
decode :: ByteString -> Maybe Nonce
decode ByteString
v = if ByteString -> Int
S.length ByteString
v Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
stream_noncebytes
then Nonce -> Maybe Nonce
forall a. a -> Maybe a
Just (ByteString -> Nonce
Nonce ByteString
v)
else Maybe Nonce
forall a. Maybe a
Nothing
{-# INLINE decode #-}
encode :: Nonce -> ByteString
encode (Nonce ByteString
v) = ByteString
v
{-# INLINE encode #-}
stream_keybytes, stream_noncebytes :: Int
stream_keybytes :: Int
stream_keybytes = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_stream_keybytes
stream_noncebytes :: Int
stream_noncebytes = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_stream_noncebytes
foreign import ccall "crypto_stream_keybytes"
c_crypto_stream_keybytes :: CSize
foreign import ccall "crypto_stream_noncebytes"
c_crypto_stream_noncebytes :: CSize
foreign import ccall "crypto_stream"
c_stream :: Ptr CChar
-> CULLong
-> Ptr CChar
-> Ptr CChar
-> IO CInt
foreign import ccall "crypto_stream_xor"
c_stream_xor :: Ptr CChar
-> Ptr CChar
-> CULLong
-> Ptr CChar
-> Ptr CChar
-> IO CInt