Safe Haskell | None |
---|
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.
- class Describable (Implementation p) => Primitive p where
- type Implementation p :: *
- blockSize :: p -> BYTES Int
- class Primitive prim => Symmetric prim where
- type Key prim
- class Asymmetric prim where
- type PublicKey prim
- type PrivateKey prim
- class Primitive p => Recommendation p where
- recommended :: p -> Implementation p
- data BLOCKS p
- blocksOf :: Int -> p -> BLOCKS p
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.
type Implementation p :: *Source
Associated type that captures an implementation of this primitive.
class Primitive prim => Symmetric prim Source
A symmetric primitive. An example would be primitives like Ciphers, HMACs etc.
class Asymmetric prim Source
An asymmetric primitive.
class Primitive p => Recommendation p whereSource
Primitives that have a recommended implementations.
recommended :: p -> Implementation pSource
The recommended implementation for the primitive.
Recommendation SHA1 | |
Recommendation SHA224 | |
Recommendation SHA256 | |
Recommendation SHA384 | |
Recommendation SHA512 | |
(Hash h, Recommendation h) => Recommendation (HMAC h) | |
Recommendation (AES 128 CBC) | |
Recommendation (AES 192 CBC) | |
Recommendation (AES 256 CBC) |
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.