cardano-crypto-class-2.0.0.0.0.0.0.2: Type classes abstracting over cryptography primitives for Cardano
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cardano.Crypto.Libsodium

Synopsis

Initialization

MLocked memory management

data MLockedForeignPtr a Source #

Foreign pointer to securely allocated memory.

withMLockedForeignPtr :: forall a b. MLockedForeignPtr a -> (Ptr a -> IO b) -> IO b Source #

traceMLockedForeignPtr :: (Storable a, Show a) => MLockedForeignPtr a -> IO () Source #

Deprecated: Don't leave traceMLockedForeignPtr in production

MLocked bytes

data MLockedSizedBytes n Source #

Instances

Instances details
KnownNat n => Show (MLockedSizedBytes n) Source # 
Instance details

Defined in Cardano.Crypto.Libsodium.MLockedBytes.Internal

NFData (MLockedSizedBytes n) Source # 
Instance details

Defined in Cardano.Crypto.Libsodium.MLockedBytes.Internal

Methods

rnf :: MLockedSizedBytes n -> () Source #

KnownNat n => Eq (MLockedSizedBytes n) Source # 
Instance details

Defined in Cardano.Crypto.Libsodium.MLockedBytes.Internal

KnownNat n => Ord (MLockedSizedBytes n) Source # 
Instance details

Defined in Cardano.Crypto.Libsodium.MLockedBytes.Internal

NoThunks (MLockedSizedBytes n) Source # 
Instance details

Defined in Cardano.Crypto.Libsodium.MLockedBytes.Internal

mlsbZero :: forall n. KnownNat n => MLockedSizedBytes n Source #

Note: this doesn't need to allocate mlocked memory, but we do that for consistency

mlsbToByteString :: forall n. KnownNat n => MLockedSizedBytes n -> ByteString Source #

Note: the resulting ByteString will still refer to secure memory, but the types don't prevent it from be exposed.

mlsbFinalize :: MLockedSizedBytes n -> IO () Source #

Calls finalizeMLockedForeignPtr on underlying pointer. This function invalidates argument.

Hashing

class HashAlgorithm h => SodiumHashAlgorithm h where Source #

Methods

naclDigestPtr Source #

Arguments

:: proxy h 
-> Ptr a

input

-> Int

input length

-> IO (MLockedSizedBytes (SizeHash h)) 

digestMLockedStorable :: forall h a proxy. (SodiumHashAlgorithm h, Storable a) => proxy h -> Ptr a -> MLockedSizedBytes (SizeHash h) Source #