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 (Binary d, Serialize d, Eq d, Ord d) => Hash ctx d | d -> ctx, ctx -> d where
- class (Binary k, Serialize k) => BlockCipher k where
- class (Binary k, Serialize k) => StreamCipher k iv | k -> iv where
- class (Binary p, Serialize p) => AsymCipher 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
keyLength may inspect its argument to return the length
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.
|:: CryptoRandomGen g|
|-> Maybe ((p, p), g)|
build a public/private key pair using the provided generator