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

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | Stable
Portability | GHC
Safe Haskell | Safe-Inferred
Language | Haskell98

Data.SecureMem

Contents

- Allocation and early termination
- Pointers manipulation
- convertion

Description

Synopsis

- data SecureMem
- secureMemGetSize :: SecureMem -> Int
- secureMemCopy :: SecureMem -> IO SecureMem
- class ToSecureMem a where
  - toSecureMem :: a -> SecureMem
- allocateSecureMem :: Int -> IO SecureMem
- createSecureMem :: Int -> (Ptr Word8 -> IO ()) -> IO SecureMem
- unsafeCreateSecureMem :: Int -> (Ptr Word8 -> IO ()) -> SecureMem
- finalizeSecureMem :: SecureMem -> IO ()
- withSecureMemPtr :: SecureMem -> (Ptr Word8 -> IO b) -> IO b
- withSecureMemPtrSz :: SecureMem -> (Int -> Ptr Word8 -> IO b) -> IO b
- withSecureMemCopy :: SecureMem -> (Ptr Word8 -> IO ()) -> IO SecureMem
- secureMemFromByteString :: ByteString -> SecureMem
- secureMemFromByteable :: Byteable b => b -> SecureMem

# 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

#### Instances

Instances details

Monoid SecureMem Source # |
Instance details Defined in Data.SecureMem Methods mempty :: SecureMem Source # mappend :: SecureMem -> SecureMem -> SecureMem Source # mconcat :: [SecureMem] -> SecureMem Source #
Semigroup SecureMem Source # |
Instance details Defined in Data.SecureMem Methods (<>) :: SecureMem -> SecureMem -> SecureMem Source # sconcat :: NonEmpty SecureMem -> SecureMem Source # stimes :: Integral b => b -> SecureMem -> SecureMem Source #
Show SecureMem Source # |
Instance details Defined in Data.SecureMem Methods showsPrec :: Int -> SecureMem -> ShowS Source # show :: SecureMem -> String Source # showList :: [SecureMem] -> ShowS Source #
Byteable SecureMem Source # |
Instance details Defined in Data.SecureMem Methods toBytes :: SecureMem -> ByteString Source # byteableLength :: SecureMem -> Int Source # withBytePtr :: SecureMem -> (Ptr Word8 -> IO b) -> IO b Source #
Eq SecureMem Source # |
Instance details Defined in Data.SecureMem Methods (==) :: SecureMem -> SecureMem -> Bool Source # (/=) :: SecureMem -> SecureMem -> Bool Source #
ToSecureMem SecureMem Source # |
Instance details Defined in Data.SecureMem Methods toSecureMem :: SecureMem -> SecureMem Source #

secureMemGetSize :: SecureMem -> Int Source #

secureMemCopy :: SecureMem -> IO SecureMem Source #

class ToSecureMem a where Source #

Types that can be converted to a secure mem object.

Methods

toSecureMem :: a -> SecureMem Source #

#### Instances

Instances details

ToSecureMem ByteString Source # |
Instance details Defined in Data.SecureMem Methods toSecureMem :: ByteString -> SecureMem Source #
ToSecureMem SecureMem Source # |
Instance details Defined in Data.SecureMem Methods toSecureMem :: SecureMem -> SecureMem Source #

# Allocation and early termination

allocateSecureMem :: Int -> IO SecureMem Source #

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 SecureMem Source #

Create a new secure mem and running an initializer function

unsafeCreateSecureMem :: Int -> (Ptr Word8 -> IO ()) -> SecureMem Source #

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 b Source #

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 b Source #

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

withSecureMemCopy :: SecureMem -> (Ptr Word8 -> IO ()) -> IO SecureMem Source #

# convertion

secureMemFromByteString :: ByteString -> SecureMem Source #

Create a SecureMem from a bytestring

secureMemFromByteable :: Byteable b => b -> SecureMem Source #

Create a SecureMem from any byteable object