tlslite.utils.chacha20_poly1305 module

Pure Python implementation of ChaCha20/Poly1305 AEAD cipher

Implementation that follows RFC 7539 and draft-ietf-tls-chacha20-poly1305-00

class tlslite.utils.chacha20_poly1305.CHACHA20_POLY1305(key, implementation)[source]

Bases: object

Pure python implementation of ChaCha20/Poly1305 AEAD cipher

__init__(key, implementation)[source]

Set the initial state for the ChaCha20 AEAD

open(nonce, ciphertext, data)[source]

Decrypts and authenticates ciphertext using nonce and data. If the tag is valid, the plaintext is returned. If the tag is invalid, returns None.

static pad16(data)[source]

Return padding for the Associated Authenticated Data

static poly1305_key_gen(key, nonce)[source]

Generate the key for the Poly1305 authenticator

seal(nonce, plaintext, data)[source]

Encrypts and authenticates plaintext using nonce and data. Returns the ciphertext, consisting of the encrypted plaintext and tag concatenated.