Copyright | (c) Dominic Steinitz 2003 |
---|---|
License | BSD-style (see the file ReadMe.tex) |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Padding algorithms for use with block ciphers.
This module currently supports:
- PKCS5 padding and unpadding.
- Null padding and unpadding.
Function types
pkcs5 :: (Integral a, Bits a) => [Octet] -> [a] Source #
When the last block of plaintext is shorter than the block size then it must be padded. PKCS5 specifies that the padding octets should each contain the number of octets which must be stripped off. So, for example, with a block size of 8, "0a0b0c" will be padded with "05" resulting in "0a0b0c0505050505". If the final block is a full block of 8 octets then a whole block of "0808080808080808" is appended.
unPkcs5 :: (Bits a, Integral a) => [a] -> [Octet] Source #
Take a list of blocks padded using the method described in PKCS5 (see http://www.rsasecurity.com/rsalabs/pkcs/pkcs-5) and return the list of unpadded octets. NB this function does not currently check that the padded block is correctly formed and should only be used for blocks that have been padded correctly.
padNulls :: (Integral a, Bits a) => [Octet] -> [a] Source #
When the last block of plaintext is shorter than the block size then it must be padded. Nulls padding specifies that the padding octets should each contain a null. So, for example, with a block size of 8, "0a0b0c" will be padded to "0a0b0c0000000000". If the final block is a full block of 8 octets then a whole block of "0000000000000000" is appended. NB this is only suitable for data which does not contain nulls, for example, ASCII.