raaz-0.0.2: The raaz cryptographic library.

Safe HaskellNone

Raaz.Core.Util

Description

Some useful utility functions and combinators.

Synopsis

Documentation

length :: ByteString -> BYTES IntSource

A typesafe length for Bytestring

replicate :: LengthUnit l => l -> Word8 -> ByteStringSource

A type safe version of replicate

fromByteStringStorable :: Storable k => ByteString -> kSource

Get the value from the bytestring using peek.

createFrom :: LengthUnit l => l -> Pointer -> IO ByteStringSource

The IO action createFrom n cptr creates a bytestring by copying n bytes from the pointer cptr.

withByteString :: ByteString -> (Pointer -> IO a) -> IO aSource

Works directly on the pointer associated with the ByteString. This function should only read and not modify the contents of the pointer.

unsafeCopyToPointerSource

Arguments

:: ByteString

The source.

-> Pointer

The destination.

-> IO () 

Copy the bytestring to the crypto buffer. This operation leads to undefined behaviour if the crypto pointer points to an area smaller than the size of the byte string.

unsafeNCopyToPointerSource

Arguments

:: LengthUnit n 
=> n

length of data to be copied

-> ByteString

The source byte string

-> Pointer

The buffer

-> IO () 

Similar to unsafeCopyToPointer but takes an additional input n which is the number of bytes (expressed in type safe length units) to transfer. This operation leads to undefined behaviour if either the bytestring is shorter than n or the crypto pointer points to an area smaller than n.