-
Notifications
You must be signed in to change notification settings - Fork 9
Streams
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 post-processed by output modification stream.
The generalization of data generation allows higher customizability and code reduction due to re-usage of commonly used streams (like counter plaintext).
Specific streams are dedicated to cryptographical primitives as block ciphers, stream ciphers, and hash functions. These streams are described in dedicated pages.
-
Block ciphers with config keyword
block
. -
Stream ciphers with config keyword
stream-cipher
. -
Hash functions with config keyword
hash
. -
PRNGs with config keyword
prng
- CAESAR competition candidates are currently not supported.
-
dummy_stream
: a stream that does nothing. It is controlled externally usingset_data(vec_cview data)
function. -
tuple_stream
: a stream consisting of multiple streams printed in given order. The internal streams are defined as JSON array in argumentsources
("sources":[{source1},{source2}...]
).
-
file_stream
: containspath
to file, which is read as input. -
true_stream
andfalse_stream
: generate vectors of ones, zeros respectively. -
const_stream
provides a given vector from the hex-coded config{"value":"f0f1f2f3"}
on the output -
mt19937_stream
andpcg32-stream
: PRNG Mersenne Twister MT19937-64, PCG (faster and more statistically random, preferred)
-
counter
: generates increasing numbers. The first generated number vector is 1 (zero is omitted). -
random_start_counter
: same ascounter
, but starts with random initial value. -
sac
(Strict avalanche criterion): generates firstly random vector (source is PCG32); secondly the copy of the first vector 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 argumentposition
(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 flipped per copy. -
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 lengthl
with hamming weight at mosth
is (l
overh
). -
randomize_overflow
(Boolean) generates a new base random vector (from which is counted the target hamming weight) after generating all possible combinations. -
randomize_start
(Boolean). If set, randomly generates the underlying mask which is XORer with the HW coutner on each next() call. False by default, thus the mask is zeros. Therandomize_start
enables generate different sequences with fixed hamming distance from the origin block. -
initial_state
(array of integers). If set, specifies initial counter state. Has length of the Hamming weight, specifies indices of the enabled bits.- Helps with generating various different sequences with low hamming weight. User can control the starting offset and thus partition the combination space precisely.
- It forms strictly increasing sequence, with minimum index 0 and maximum index
(size * 8 - 1)
. - Initial state for HW4 is
[0, 1, 2, 3]
. - Example: the HW4 on
size=2
goes from state[0, 13, 14, 15]
to[1, 2, 3, 4]
-
-
bernoulli_distribution
biased stream, that generates a binary vector, where "0" has probability given by argumentp
. -
binomial_distribution
outputs vector of the binomial distribution. How many "1" flipped on a coin withp
probability andmax_value
trials? -
normal_distribution
similar tobinomial_distribution
using normal distribution withmean
andstd_dev
arguments. The generated real value is cut to 4 sigmas and this value is projected to the byte value. -
poisson_distribution
Poisson distribution has an argumentmean
. If an event occursmean
times a minute on average, how often is it that it occurs N times in one minute? Output N -
exponential_distribution
with argumentlambda
. If particles decaylambda
times per second on average, how much time, in seconds, until the next one?
-
pipe_in_stream
: the beginning of the pipe - passes data from the source vianext()
and allows the other end of pipe to read these data. Identification is by string in argumentid
. The sourceid
has to be unique, else the behavior is undefined. -
pipe_out_stream
: the end of pipe - copies data from the pipe source. Identified byid
, there can be multiplepipe_out_streams
with sameid
. Theid
of pipe output has to fit some input, else the behavior is undefined.
These stream modifiers always contain inner JSON subtree with usually some cipher.
-
single_value_stream
: passes repeatedly same value. Initialized by the internal stream. Useful for repeating passing single value of other random streams. -
repeating_stream
: repeats the same vector forperiod
of calls.
-
xor_stream
: splits the input into two halves and XOR these two parts. Fits for checkingsac
andrnd_plt_ctx_stream
. -
column
: the ciphertext is transposed, and vectors are created from thei
th bit of the ciphertext fori
in rangesize
. -
column_fixed_position
: every vector is created from theposition
th bit of the ciphertext. Theposition
is a number argument in interval (0,size
-1).
Getting started
Building notes
Running notes
Recommended scenarios
Configuration file structure
Developer notes
Framework components
Submodules
Third party libraries
Coding guide
Testing
Known bugs
User notes
List of streams
Block ciphers
Stream ciphers
Hash functions
PRNGs
WIP CAESAR
Useful links