Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- sodiumInit :: IO ()
- data MLockedForeignPtr a
- withMLockedForeignPtr :: forall a b. MLockedForeignPtr a -> ( Ptr a -> IO b) -> IO b
- allocMLockedForeignPtr :: Storable a => IO ( MLockedForeignPtr a)
- finalizeMLockedForeignPtr :: forall a. MLockedForeignPtr a -> IO ()
- traceMLockedForeignPtr :: ( Storable a, Show a) => MLockedForeignPtr a -> IO ()
- data MLockedSizedBytes n
- mlsbZero :: forall n. KnownNat n => MLockedSizedBytes n
- mlsbFromByteString :: forall n. KnownNat n => ByteString -> MLockedSizedBytes n
- mlsbFromByteStringCheck :: forall n. KnownNat n => ByteString -> Maybe ( MLockedSizedBytes n)
- mlsbToByteString :: forall n. KnownNat n => MLockedSizedBytes n -> ByteString
- mlsbFinalize :: MLockedSizedBytes n -> IO ()
-
class
HashAlgorithm
h =>
SodiumHashAlgorithm
h
where
- naclDigestPtr :: proxy h -> Ptr a -> Int -> IO ( MLockedSizedBytes ( SizeHash h))
- digestMLockedStorable :: forall h a proxy. ( SodiumHashAlgorithm h, Storable a) => proxy h -> Ptr a -> MLockedSizedBytes ( SizeHash h)
- digestMLockedBS :: forall h proxy. SodiumHashAlgorithm h => proxy h -> ByteString -> MLockedSizedBytes ( SizeHash h)
- expandHash :: forall h proxy. SodiumHashAlgorithm h => proxy h -> MLockedSizedBytes ( SizeHash h) -> ( MLockedSizedBytes ( SizeHash h), MLockedSizedBytes ( SizeHash h))
Initialization
sodiumInit :: IO () Source #
MLocked memory management
data MLockedForeignPtr a Source #
Foreign pointer to securely allocated memory.
Instances
NoThunks ( MLockedForeignPtr a) Source # | |
Defined in Cardano.Crypto.Libsodium.Memory.Internal |
withMLockedForeignPtr :: forall a b. MLockedForeignPtr a -> ( Ptr a -> IO b) -> IO b Source #
allocMLockedForeignPtr :: Storable a => IO ( MLockedForeignPtr a) Source #
Allocate secure memory using
c_sodium_malloc
.
finalizeMLockedForeignPtr :: forall a. MLockedForeignPtr a -> IO () Source #
traceMLockedForeignPtr :: ( Storable a, Show a) => MLockedForeignPtr a -> IO () Source #
Deprecated: Don't leave traceMLockedForeignPtr in production
MLocked bytes
data MLockedSizedBytes n Source #
Instances
mlsbZero :: forall n. KnownNat n => MLockedSizedBytes n Source #
Note: this doesn't need to allocate mlocked memory, but we do that for consistency
mlsbFromByteString :: forall n. KnownNat n => ByteString -> MLockedSizedBytes n Source #
mlsbFromByteStringCheck :: forall n. KnownNat n => ByteString -> Maybe ( MLockedSizedBytes n) Source #
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 #
:: proxy h | |
-> Ptr a |
input |
-> Int |
input length |
-> IO ( MLockedSizedBytes ( SizeHash h)) |
Instances
SodiumHashAlgorithm Blake2b_256 Source # | |
Defined in Cardano.Crypto.Libsodium.Hash naclDigestPtr :: proxy Blake2b_256 -> Ptr a -> Int -> IO ( MLockedSizedBytes ( SizeHash Blake2b_256 )) Source # |
|
SodiumHashAlgorithm SHA256 Source # | |
Defined in Cardano.Crypto.Libsodium.Hash naclDigestPtr :: proxy SHA256 -> Ptr a -> Int -> IO ( MLockedSizedBytes ( SizeHash SHA256 )) Source # |
digestMLockedStorable :: forall h a proxy. ( SodiumHashAlgorithm h, Storable a) => proxy h -> Ptr a -> MLockedSizedBytes ( SizeHash h) Source #
digestMLockedBS :: forall h proxy. SodiumHashAlgorithm h => proxy h -> ByteString -> MLockedSizedBytes ( SizeHash h) Source #
expandHash :: forall h proxy. SodiumHashAlgorithm h => proxy h -> MLockedSizedBytes ( SizeHash h) -> ( MLockedSizedBytes ( SizeHash h), MLockedSizedBytes ( SizeHash h)) Source #