This is the heart of the crypto-api package. By making (or having) an instance of Hash, AsymCipher, BlockCipher or StreamCipher you provide (or obtain) access to any infrastructure built on these primitives include block cipher modes of operation, hashing, hmac, signing, etc. These classes allow users to build routines that are agnostic to the algorithm used so changing algorithms is as simple as changing a type signature.
- class (Serialize d, Eq d, Ord d) => Hash ctx d | d -> ctx, ctx -> d where
- class Serialize k => BlockCipher k where
- blockSizeBytes :: BlockCipher k => Tagged k ByteLength
- class Serialize k => StreamCipher k iv | k -> iv where
- class (Serialize p, Serialize v) => AsymCipher p v where
- class (Serialize p, Serialize v) => Signing p v | p -> v, v -> p where
- for :: Tagged a b -> a -> b
- (.::.) :: Tagged a b -> a -> b
- hash :: Hash ctx d => ByteString -> d
- hash' :: Hash ctx d => ByteString -> d
- hashFunc :: Hash c d => d -> ByteString -> d
- hashFunc' :: Hash c d => d -> ByteString -> d
The Hash class is intended as the generic interface
targeted by maintainers of Haskell digest implementations.
Using this generic interface, higher level functions
hash' provide a useful API
for comsumers of hash implementations.
Any instantiated implementation must handle unaligned data
An initial context, provided with the first call to
Used to update a context, repeatedly called until all data is exhausted
must operate correctly for imputs of
Finializing a context, plus any message data less than the block size, into a digest
The BlockCipher class is intended as the generic interface
targeted by maintainers of Haskell cipher implementations.
Using this generic interface higher level functions
cbc, and other functions from Data.Crypto.Modes, provide a useful API
for comsumers of cipher implementations.
Instances must handle unaligned data
encrypt data of size
decrypt data of size
A stream cipher class. Instance are expected to work on messages as small as one byte The length of the resulting cipher text should be equal to the length of the input message.
Asymetric ciphers (common ones being RSA or EC based)
|:: CryptoRandomGen g|
|-> Either GenError ((p, v), g)|
build a public/private key pair using the provided generator
A class for signing operations which inherently can not be as generic as asymetric ciphers (ex: DSA).