-- 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.9


module Data.SecureMem

-- | SecureMem is a memory chunk which have the properties of:
--   
--   <ul>
--   <li>Being scrubbed after its goes out of scope.</li>
--   <li>A Show instance that doesn't actually show any content</li>
--   <li>A Eq instance that is constant time</li>
--   </ul>
data SecureMem
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

-- | Create a SecureMem from any byteable object
secureMemFromByteable :: Byteable b => b -> SecureMem
instance GHC.Show.Show Data.SecureMem.SecureMem
instance Data.Byteable.Byteable Data.SecureMem.SecureMem
instance GHC.Classes.Eq Data.SecureMem.SecureMem
instance GHC.Base.Monoid Data.SecureMem.SecureMem
instance Data.SecureMem.ToSecureMem Data.SecureMem.SecureMem
instance Data.SecureMem.ToSecureMem Data.ByteString.Internal.ByteString
