pkcs7-1.0.0.0: PKCS #7 padding in Haskell

Copyright(c) K. Isom (2015)
LicenseBSD-style
Maintainercoder@kyleisom.net
Stabilitystable
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Crypto.Data.PKCS7

Description

This implements the PKCS #7 padding scheme for Strings. This scheme is defined in RFC 5652.

Strings will be padded out to multiples of the block size; for example, a 5-byte string with an 8-byte block size will have three bytes of padding added. If the length is already a multiple of the block size, an entire block size worth of padding is added.

The padding bytes are all set to the number of padding bytes. Returning to the previous example, the padding string would be three bytes of the byte 0x03.

Unpadding checks the length and padding, and if this is valid, strips off the padding.

Synopsis

Documentation

pad :: String -> String Source

pad applies the PKCS #7 padding scheme to the input string; it uses the AES block size of 16 bytes as its block size.

padN :: Int -> String -> String Source

padN applies the PKCS #7 padding scheme to the input string given the blockSize.

unpad :: String -> Maybe String Source

unpad attempts to remove the padding from the input String, assuming an AES block size of 16 bytes.

unpadN :: Int -> String -> Maybe String Source

unpadN attempts to remove the blockSize padding from its input String. If the padding is invalid, Nothing is returned.

padBytes :: ByteString -> ByteString Source

pad applies the PKCS #7 padding scheme to the input string; it uses the AES block size of 16 bytes as its block size.

padBytesN :: Int -> ByteString -> ByteString Source

padBytesN applies the PKCS #7 padding scheme to the input bytestring given the blockSize.

unpadBytes :: ByteString -> Maybe ByteString Source

unpadBytes attempts to remove the padding from the input ByteString, assuming an AES block size of 16 bytes.

unpadBytesN :: Int -> ByteString -> Maybe ByteString Source

unpadBytesN attempts to remove the blockSize padding from its input ByteString. If the padding is invalid, Nothing is returned.