securemem-0.1.3: abstraction to an auto scrubbing and const time eq, memory chunk.

PortabilityGHC
StabilityStable
MaintainerVincent Hanquez <vincent@snarc.org>
Safe HaskellNone

Data.SecureMem

Contents

Description

 

Synopsis

Documentation

data SecureMem Source

SecureMem is a memory chunk which have the properties of:

  • Being scrubbed after its goes out of scope. * A Show instance that doesn't actually show any content * A Eq instance that is constant time

secureMemGetSize :: SecureMem -> IntSource

Return the size of the memory allocated by this secure mem.

class ToSecureMem a whereSource

Types that can be converted to a secure mem object.

Allocation and early termination

allocateSecureMem :: Int -> IO SecureMemSource

Allocate a new SecureMem

The memory is allocated on the haskell heap, and will be scrubed before being released.

createSecureMem :: Int -> (Ptr Word8 -> IO ()) -> IO SecureMemSource

Create a new secure mem and running an initializer function

unsafeCreateSecureMem :: Int -> (Ptr Word8 -> IO ()) -> SecureMemSource

Create a new secure mem using inline perform IO to create a pure result.

finalizeSecureMem :: SecureMem -> IO ()Source

Finalize a SecureMem early

Pointers manipulation

withSecureMemPtr :: SecureMem -> (Ptr Word8 -> IO b) -> IO bSource

This is a way to look at the pointer living inside a foreign object. This function takes a function which is applied to that pointer. The resulting IO action is then executed

this is similary to withForeignPtr for a ForeignPtr

withSecureMemPtrSz :: SecureMem -> (Int -> Ptr Word8 -> IO b) -> IO bSource

similar to withSecureMem but also include the size of the pointed memory.

convertion

secureMemFromByteString :: ByteString -> SecureMemSource

Create a SecureMem from a bytestring