Skip to content

Streams

Karel Kubicek edited this page Apr 12, 2018 · 14 revisions

Streams classes are used for managing test vectors, their generation, saving and loading.

Streams are identified by type in CryptoStreams configuration file. Every stream has to be inherited from abstract stream interface and provide implementation at least to method next() and osize(). Streams may be encapsulated to other streams, such as "plaintext generator" stream or postprocessed by output modification stream.

Generalisation of data generation allows higher customizability and code reduction due to reusage of commonly used streams (like counter plaintext).

Cryptographical function streams

Specific streams are dedicated to cryptographical primitives as block ciphers, stream ciphers, and hash functions. These streams are described in dedicated pages.

Streams for generation of the input (keys, plaintexts...)

  • file-stream: contains path to file, which is read as an input
  • true-stream and false-stream: generate vectors of ones, zeros respectively
  • mt19937-stream and pcg32-stream: use PRNG Mersenne Twister MT19937-64, PCG generation (faster and more statisticaly random, preferred)
  • single-value-stream: passes repeatedly same value. Initialized by internal stream. Useful for repeating passing single value of other random streams.
  • counter: generates increasing numbers. The first generated number vector is 1 (zero is omitted)
  • hw-counter: generates all vectors with given hamming weight.
    • hw (unsigned) sets-up target hamming weight.
    • increase_hw (Boolean) allows increase after generating all possible vectors (the number of vectors of length l with hamming weight at most h is (l over h).
    • randomize_overflow (Boolean) generates new base random vector (from which is counted the target hamming weight) after generating all possible combinations.
  • sac (Strict avalanche criterion): generates 2 times bigger vector than is the block size, first part is random (source is PCG32), second part is copy of the first part with exactly one bit flipped. The position of the flipped bit is random.
  • sac-fixed-position: similar to SAC, but the position of bit flip is given by argument position (requires number).
  • sac-2d-all-positions: the first vector is random and then follows (size * 8) - 1 copies of the original vector, with one bit flip per copy.

Streams for postprocessing of the output

These stream modifiers contains always inner JSON subtree with usually some cipher.

  • column-stream: the ciphertext is transposed and vectors are created from the ith bit of the ciphertext for i in range size (neber argument of block size of the inner stream).
  • column-fixed-position: every vector is created from the positionth bit of the ciphertext. The position is a number argument in interval (0, size-1).
  • xor-stream: splits input into two halves and XOR these 2 parts. Fits for checking SAC.
  • rnd-plt-ctx-stream: generates random plaintext and outputs pair plaintext and corresponding ciphertext.