nettle-0.3.1.1: 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 | Haskell2010

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 Source #

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 (losing security).

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

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.