tlslite.utils.rijndael module

A pure python (slow) implementation of rijndael with a decent interface

To include -

from rijndael import Rijndael

To do a key setup -

r = Rijndael(key, block_size = 16)

key must be a string of length 16, 24, or 32 blocksize must be 16, 24, or 32. Default is 16

To use -

ciphertext = r.encrypt(plaintext) plaintext = r.decrypt(ciphertext)

If any strings are of the wrong length a ValueError is thrown

class tlslite.utils.rijndael.Rijndael(key, block_size=16)[source]

Bases: object

Implementation of the AES (formely known as Rijndael) block cipher.

Supports key sizes of 128, 192 and 256 bits as well as the non standard block sizes of 192 and 256 bits (the standard 128 bit block size is the default).

Note: this is a pure python stright-forward implementation thus it is vulnerable against majority, if not all possible side channel attacks.

Can process data just one block at a time, does not perform block cipher chaining or plaintext padding.

Ival int block_size:

the size of the encrypted blocks, in bytes

Ival list Ke:

key schedule for encryption

Ival list Kd:

key schedule for decryption

__init__(key, block_size=16)[source]

Initialise the object, derive keys for encryption and decryption.

decrypt(ciphertext)[source]

Decrypt a block of ciphertext.

encrypt(plaintext)[source]

Encrypt a single block of plaintext.

tlslite.utils.rijndael.decrypt(key, block)[source]
tlslite.utils.rijndael.encrypt(key, block)[source]
tlslite.utils.rijndael.rijndael

alias of Rijndael

tlslite.utils.rijndael.test()[source]