raaz-0.0.2: The raaz cryptographic library.

Safe HaskellNone

Raaz.Core.Primitives

Contents

Description

Generic cryptographic block primtives and their implementations. This module exposes low-level generic code used in the raaz system. Most likely, one would not need to stoop so low and it might be better to use a more high level interface.

Synopsis

Primtives and their implementations.

class Describable (Implementation p) => Primitive p whereSource

The type class that captures an abstract block cryptographic primitive. Bulk cryptographic primitives like hashes, ciphers etc often acts on blocks of data. The size of the block is captured by the member blockSize.

As a library, raaz believes in providing multiple implementations for a given primitive. The associated type Implementation captures implementations of the primitive.

There is a reference implementation where the emphasis is on correctness rather than speed or security. They are used to verify the correctness of the other implementations for the same primitive. Apart from this, for production use, we have a recommended implementation.

Associated Types

type Implementation p :: *Source

Associated type that captures an implementation of this primitive.

Methods

blockSize :: p -> BYTES IntSource

The block size.

Instances

Primitive SHA1 
Primitive SHA224 
Primitive SHA256 
Primitive SHA384 
Primitive SHA512 
Hash h => Primitive (HMAC h) 
Primitive (AES 128 CBC)

The 128-bit aes cipher in cbc mode.

Primitive (AES 192 CBC)

The 192-bit aes cipher in cbc mode.

Primitive (AES 256 CBC)

The 256-bit aes cipher in cbc mode.

class Primitive prim => Symmetric prim Source

A symmetric primitive. An example would be primitives like Ciphers, HMACs etc.

Associated Types

type Key prim Source

The key for the primitive.

Instances

Hash h => Symmetric (HMAC h) 
Symmetric (AES 128 CBC)

Key is (KEY128,IV) pair.

Symmetric (AES 192 CBC)

Key is (KEY192,IV) pair.

Symmetric (AES 256 CBC)

Key is (KEY256,IV) pair.

class Asymmetric prim Source

An asymmetric primitive.

Associated Types

type PublicKey prim Source

The public key

type PrivateKey prim Source

The private key

class Primitive p => Recommendation p whereSource

Primitives that have a recommended implementations.

Methods

recommended :: p -> Implementation pSource

The recommended implementation for the primitive.

data BLOCKS p Source

Type safe message length in units of blocks of the primitive. When dealing with buffer lengths for a primitive, it is often better to use the type safe units BLOCKS. Functions in the raaz package that take lengths usually allow any type safe length as long as they can be converted to bytes. This can avoid a lot of tedious and error prone length calculations.

Instances

blocksOf :: Int -> p -> BLOCKS pSource

The expression n blocksOf p specifies the message lengths in units of the block length of the primitive p. This expression is sometimes required to make the type checker happy.