4.1 Crypto.Protocol.AllOrNothing

This module implements all-or-nothing package transformations. An all-or-nothing package transformation is one in which some text is transformed into message blocks, such that all blocks must be obtained before the reverse transformation can be applied. Thus, if any blocks are corrupted or lost, the original message cannot be reproduced.

An all-or-nothing package transformation is not encryption, although a block cipher algorithm is used. The encryption key is randomly generated and is extractable from the message blocks.

class AllOrNothing(ciphermodule, mode=None, IV=None)
Class implementing the All-or-Nothing package transform.

ciphermodule is a module implementing the cipher algorithm to use. Optional arguments mode and IV are passed directly through to the ciphermodule.new() method; they are the feedback mode and initialization vector to use. All three arguments must be the same for the object used to create the digest, and to undigest'ify the message blocks.

The module passed as ciphermodule must provide the PEP 272 interface. An encryption key is randomly generated automatically when needed.

The methods of the AllOrNothing class are:

digest(text)
Perform the All-or-Nothing package transform on the string text. Output is a list of message blocks describing the transformed text, where each block is a string of bit length equal to the cipher module's block_size.

undigest(mblocks)
Perform the reverse package transformation on a list of message blocks. Note that the cipher module used for both transformations must be the same. mblocks is a list of strings of bit length equal to ciphermodule's block_size. The output is a string object.