-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | abstraction to an auto scrubbing and const time eq, memory chunk.
--   
--   SecureMem is similar to ByteString, except that it provides a memory
--   chunk that will be auto-scrubbed after it run out of scope.
@package securemem
@version 0.1.3


module Data.SecureMem

-- | SecureMem is a memory chunk which have the properties of:
--   
--   <ul>
--   <li>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</li>
--   </ul>
data SecureMem

-- | Return the size of the memory allocated by this secure mem.
secureMemGetSize :: SecureMem -> Int
secureMemCopy :: SecureMem -> IO SecureMem

-- | Types that can be converted to a secure mem object.
class ToSecureMem a
toSecureMem :: ToSecureMem a => a -> SecureMem

-- | Allocate a new SecureMem
--   
--   The memory is allocated on the haskell heap, and will be scrubed
--   before being released.
allocateSecureMem :: Int -> IO SecureMem

-- | Create a new secure mem and running an initializer function
createSecureMem :: Int -> (Ptr Word8 -> IO ()) -> IO SecureMem

-- | Create a new secure mem using inline perform IO to create a pure
--   result.
unsafeCreateSecureMem :: Int -> (Ptr Word8 -> IO ()) -> SecureMem

-- | Finalize a SecureMem early
finalizeSecureMem :: SecureMem -> IO ()

-- | 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
withSecureMemPtr :: SecureMem -> (Ptr Word8 -> IO b) -> IO b

-- | similar to withSecureMem but also include the size of the pointed
--   memory.
withSecureMemPtrSz :: SecureMem -> (Int -> Ptr Word8 -> IO b) -> IO b
withSecureMemCopy :: SecureMem -> (Ptr Word8 -> IO ()) -> IO SecureMem

-- | Create a SecureMem from a bytestring
secureMemFromByteString :: ByteString -> SecureMem
instance ToSecureMem ByteString
instance ToSecureMem SecureMem
instance Monoid SecureMem
instance Eq SecureMem
instance Byteable SecureMem
instance Show SecureMem
