rncryptor-0.0.1.0: Haskell implementation of the RNCryptor file format

Safe HaskellNone
LanguageHaskell2010

Crypto.RNCryptor.V3

Synopsis

Documentation

pkcs7Padding Source

Arguments

:: Int

The block size (e.g. 16 bytes)

-> Int

The input size

-> ByteString

The resulting padding

Computes the padding as per PKCS#7. The specification can be found here: http:/tools.ietf.orghtml/rfc5652#section-6.3

parseHeader :: ByteString -> RNCryptorHeader Source

Parse the input ByteString to extract the RNCryptorHeader, as defined in the V3 spec. The incoming ByteString is expected to have at least 34 bytes available. As the HMAC can be found only at the very end of an encrypted file, RNCryptorHeader provides by default a function to parse the HMAC, callable at the right time during streaming/parsing.

decrypt :: ByteString -> ByteString -> ByteString Source

Decrypt an encrypted message. Please be aware that this is a user-friendly but dangerous function, in the sense that it will load the *ENTIRE* input in memory. It's mostly suitable for small inputs like passwords. For large inputs, where size exceeds the available memory, please use decryptStream.

decryptBlock :: RNCryptorContext -> ByteString -> (RNCryptorContext, ByteString) Source

Decrypt a raw Bytestring block. The function returns the clear text block plus a new RNCryptorContext, which is needed because the IV needs to be set to the last 16 bytes of the previous cipher text. (Thanks to Rob Napier for the insight).