Crypto.Nettle.ChaChaPoly1305

nettle-0.2.0: safe nettle binding

Copyright | (c) 2013 Stefan Bühler
License | MIT-style (see the file COPYING)
Maintainer | stbuehler@web.de
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell98

Crypto.Nettle.ChaChaPoly1305

Contents

- ChaCha-Poly1305

Description

This module exports the ChaCha-Poly1305 AEAD cipher supported by nettle: http://www.lysator.liu.se/~nisse/nettle/

Both ChaCha (the underlying cipher) and Poly1305 (the keyed hash) were designed by D. J. Bernstein.

Synopsis

- chaChaPoly1305Encrypt :: ByteString -> ByteString -> ByteString -> ByteString -> (ByteString, ByteString)
- chaChaPoly1305Decrypt :: ByteString -> ByteString -> ByteString -> ByteString -> ByteString -> Maybe ByteString

# ChaCha-Poly1305

chaChaPoly1305Encrypt #

Arguments

:: ByteString | `key` (must be 32 bytes)
-> ByteString | `nonce` (must be 12 bytes)
-> ByteString | `aad` additional data to be verified
-> ByteString | `plain` data to encrypt
-> (ByteString, ByteString) | returns (`cipher`, `tag`) ciphertext and verification tag

Encrypt plain text and create a verification tag for the encrypted text and some additional data. `key` and `nonce` must not be reused together. The returned tag is 16 bytes long, but may be shortened for verification (loosing security).

chaChaPoly1305Decrypt :: ByteString -> ByteString -> ByteString -> ByteString -> ByteString -> Maybe ByteString #

Decrypt cipher text and verify a (possible shortened) tag for the encrypted text and some additional data. `key` and `nonce` must not be reused together.