nettle-0.3.0: safe nettle binding

Copyright(c) 2013 Stefan Bühler
LicenseMIT-style (see the file COPYING)
Maintainerstbuehler@web.de
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Crypto.Nettle.ChaChaPoly1305

Contents

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

ChaCha-Poly1305

chaChaPoly1305Encrypt Source #

Arguments

:: B.ByteString

key (must be 32 bytes)

-> B.ByteString

nonce (must be 12 bytes)

-> B.ByteString

aad additional data to be verified

-> B.ByteString

plain data to encrypt

-> (B.ByteString, B.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 :: B.ByteString -> B.ByteString -> B.ByteString -> B.ByteString -> B.ByteString -> Maybe B.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.