tlslite.utils.chacha module

Pure Python implementation of ChaCha cipher

Implementation that follows RFC 7539 closely.

class tlslite.utils.chacha.ChaCha(key, nonce, counter=0, rounds=20)[source]

Bases: object

Pure python implementation of ChaCha cipher

__init__(key, nonce, counter=0, rounds=20)[source]

Set the initial state for the ChaCha cipher

static chacha_block(key, counter, nonce, rounds)[source]

Generate a state of a single block

constants = [1634760805, 857760878, 2036477234, 1797285236]
decrypt(ciphertext)[source]

Decrypt the data

classmethod double_round(x)[source]

Perform two rounds of ChaCha cipher

encrypt(plaintext)[source]

Encrypt the data

static quarter_round(x, a, b, c, d)[source]

Perform a ChaCha quarter round

static rotl32(v, c)[source]

Rotate left a 32 bit integer v by c bits

static word_to_bytearray(state)[source]

Convert state to little endian bytestream