YAARX: Yet Another ARX Toolkit
0.1
|
Header file for common.cc. More...
#include <iostream>
#include <cassert>
#include <sstream>
#include <sys/time.h>
#include <map>
#include <unordered_map>
#include <boost/functional/hash.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/unordered_map.hpp>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <gsl/gsl_blas.h>
#include <algorithm>
#include <vector>
#include <array>
#include <set>
#include <gmp.h>
#include <gmpxx.h>
#include <chrono>
Go to the source code of this file.
Data Structures | |
struct | difference_t |
struct | differential_3d_t |
struct | differential_t |
struct | set_t |
struct | struct_comp_diff_3d_p |
struct | struct_comp_diff_3d_dx_dy_dz |
struct | struct_comp_diff_p |
struct | struct_comp_diff_hw |
struct | struct_comp_diff_dx_dy |
Macros | |
#define | IOSTREAM_H |
#define | CASSERT_H |
#define | SSTREAM_H |
#define | SYS_TIME_H |
#define | MAP_H |
#define | UNORDERED_MAP_H |
#define | BOOST_FUNCTIONAL_HASH_H |
#define | BOOST_ALGORITHM_STRING_PREDICATE_H |
#define | BOOST_UNORDERED_MAP_H |
#define | MATH_H |
#define | STRING_H |
#define | IOMANIP_H |
#define | GSL_BLAS_H |
#define | STL_ALGORITHM_H |
#define | STL_VECTOR_H |
#define | STL_ARRAY_H |
#define | STL_SET_H |
#define | GMP_H |
#define | GMPXX_H |
#define | CHRONO_H |
#define | NROUNDS_MAX 10 |
#define | WORD_SIZE 3 |
#define | NROUNDS 4 |
#define | ALL_WORDS (1ULL << WORD_SIZE) |
#define | MASK (0xffffffffUL >> (32 - WORD_SIZE)) |
#define | MASK_NO_MSB (0xffffffffUL >> (32 - (WORD_SIZE - 1))) |
#define | MOD (1ULL << WORD_SIZE) |
#define | TEA_LSH_CONST 4 |
#define | TEA_RSH_CONST 5 |
#define | DELTA_INIT 0x9e3779b9 |
#define | NPAIRS (1ULL << 15) |
#define | NDELTA (NROUNDS / 2) |
#define | WORD_T uint32_t |
#define | WORD_MAX_T long long unsigned int |
#define | LOG0 -10000 |
#define | XOR(x, y) ((x ^ y) & MASK) |
#define | ADD(x, y) ((x + y) & MASK) |
#define | SUB(x, y) ((WORD_T)(x - y + MOD) & MASK) |
#define | LSH(x, r) ((x << r) & MASK) |
#define | RSH(x, r) ((x >> r) & MASK) |
#define | LROT(x, r) (((x << r) | (x >> (WORD_SIZE - r))) & MASK) |
#define | RROT(x, r) (((x >> r) | (x << (WORD_SIZE - r))) & MASK) |
#define | MUL(x, y) ((x * y) & MASK) |
#define | ARX(r, x, y, z) XOR(z,LROT(ADD(x,y),r)) |
#define | DEBUG_XDP_ADD_TESTS 1 |
#define | DEBUG_MAX_XDP_ADD_TESTS 0 |
#define | DEBUG_ADP_XOR_TESTS 1 |
#define | DEBUG_ADP_XOR3_TESTS 0 |
#define | DEBUG_MAX_ADP_XOR_TESTS 1 |
#define | DEBUG_ADP_XOR_FI_TESTS 0 |
#define | DEBUG_MAX_ADP_XOR_FI_TESTS 0 |
#define | DEBUG_MAX_ADP_XOR3_TESTS 0 |
#define | DEBUG_MAX_ADP_XOR3_SET_TESTS 0 |
#define | DEBUG_ADP_RSH_XOR_TESTS 0 |
#define | DEBUG_ADP_SHIFT_TESTS 0 |
#define | DEBUG_EADP_TEA_F_TESTS 0 |
#define | DEBUG_ADP_TEA_F_FK_TESTS 0 |
#define | DEBUG_XDP_TEA_F_FK_TESTS 0 |
#define | DEBUG_XDP_XTEA_F_FK_TESTS 0 |
#define | DEBUG_ADP_XTEA_F_FK_TESTS 0 |
#define | DEBUG_ADP_RSH_XOR 0 |
#define | DEBUG_ADP_TEA_F_FK 0 |
#define | DEBUG_XDP_TEA_F_FK 0 |
Typedefs | |
typedef unsigned long long | timestamp_t |
Functions | |
uint32_t | hamming_weight (const WORD_T w) |
timestamp_t | get_timestamp () |
WORD_T | xrandom () |
uint32_t | hw8 (const uint32_t x) |
WORD_T | parity (const WORD_T x) |
bool | is_even (uint32_t i) |
WORD_T | gen_sparse (uint32_t hw, uint32_t n) |
void | print_binary (const uint64_t n) |
void | print_binary (const uint64_t n, const uint32_t word_size) |
bool | operator== (differential_t a, differential_t b) |
bool | operator< (differential_t x, differential_t y) |
bool | operator< (difference_t x, difference_t y) |
void | print_set (const std::set< differential_t, struct_comp_diff_dx_dy > diff_set_dx_dy) |
void | print_mset (const std::multiset< differential_t, struct_comp_diff_p > diff_mset_p) |
bool | sort_comp_diff_3d_p (differential_3d_t a, differential_3d_t b) |
void | yaarx_alloc_matrices_3d (WORD_T ****A, uint32_t A_len) |
void | yaarx_free_matrices_3d (WORD_T ***A, uint32_t A_len) |
void | yaarx_alloc_matrices_3d (gsl_matrix *A[2][2][2], uint32_t A_len) |
void | yaarx_free_matrices_3d (gsl_matrix *A[2][2][2], uint32_t A_len) |
void | yaarx_alloc_matrices_2d (WORD_T ***A, uint32_t A_rows, uint32_t A_cols) |
void | yaarx_free_matrices_2d (WORD_T **A, uint32_t A_rows, uint32_t A_cols) |
void | yaarx_alloc_matrices_4d (WORD_T *****A, uint32_t A_dim) |
void | yaarx_free_matrices_4d (WORD_T ****A, uint32_t A_dim) |
Header file for common.cc.
#define ALL_WORDS (1ULL << WORD_SIZE) |
Total number of words of size WORD_SIZE.
#define BOOST_ALGORITHM_STRING_PREDICATE_H |
C++ STL Boost algorithm
#define BOOST_FUNCTIONAL_HASH_H |
C++ STL Boost hash
#define BOOST_UNORDERED_MAP_H |
C++ STL Boost unordered map
#define CASSERT_H |
C++ cassert
#define CHRONO_H |
GMPXX library
#define DEBUG_ADP_RSH_XOR 0 |
DEBUG flags for source files.
#define DEBUG_XDP_ADD_TESTS 1 |
DEBUG flags for test files.
#define DELTA_INIT 0x9e3779b9 |
Initial round constant of TEA/XTEA.
#define GMPXX_H |
GMP library
#define GSL_BLAS_H |
GSL gsl/gsl_blas.h
#define IOMANIP_H |
C++ iomanip
#define IOSTREAM_H |
C++ iostream
Rotate x
by r
positions to the left; x
is of size WORD_SIZE
#define MAP_H |
C++ map
#define MASK (0xffffffffUL >> (32 - WORD_SIZE)) |
A mask for the WORD_SIZE LS bits of a 32-bit word.
#define MATH_H |
math.h
#define MOD (1ULL << WORD_SIZE) |
The value 2^{WORD_SIZE}.
#define NDELTA (NROUNDS / 2) |
Number round constants in TEA/XTEA.
#define NPAIRS (1ULL << 15) |
Number of chosen plaintext pairs used in experimentally verifying differential probabilities.
#define NROUNDS 4 |
Number of rounds in reduced-round versions of target ciphers.
#define NROUNDS_MAX 10 |
Max. number of rounds
Rotate x
by r
positions to the right; x
is of size WORD_SIZE
#define SSTREAM_H |
C++ sstream
#define STL_ALGORITHM_H |
STL algorithm
#define STL_ARRAY_H |
STL array
#define STL_SET_H |
STL set
#define STL_VECTOR_H |
STL vector
#define STRING_H |
string.h
The modular subtraction (SUB) operation on words of size WORD_SIZE
#define SYS_TIME_H |
C time header
#define UNORDERED_MAP_H |
C++ unordered_map
#define WORD_SIZE 3 |
Word size in bits.
WORD_T gen_sparse | ( | uint32_t | hw, |
uint32_t | n | ||
) |
Generate a random sparse n-bit difference with Hamming weight at most hw.
timestamp_t get_timestamp | ( | ) |
Measure item in milliseconds see: http://stackoverflow.com/questions/1861294/how-to-calculate-execution-time-of-a-code-snippet-in-c
uint32_t hamming_weight | ( | const WORD_T | w | ) |
Hamming weight of a WORD-bit word (efficient).
uint32_t hw8 | ( | const uint32_t | x | ) |
Hamming weight of a byte.
bool is_even | ( | uint32_t | i | ) |
Returns true if the argument is an even number.
bool operator< | ( | differential_t | x, |
differential_t | y | ||
) |
Compare two differentials by probability.
bool operator< | ( | difference_t | x, |
difference_t | y | ||
) |
Compare two differences by probability.
bool operator== | ( | differential_t | a, |
differential_t | b | ||
) |
Evaluate if two differentials are identical. Returns TRUE if they are.
WORD_T parity | ( | const WORD_T | x | ) |
void print_binary | ( | const uint64_t | n | ) |
Print a value in binary.
void print_binary | ( | const uint64_t | n, |
const uint32_t | word_size | ||
) |
Print a value in binary.
void print_mset | ( | const std::multiset< differential_t, struct_comp_diff_p > | diff_mset_p | ) |
Print the list of 2d differentials stored represented as an STL multiset and ordered by probability.
void print_set | ( | const std::set< differential_t, struct_comp_diff_dx_dy > | diff_set_dx_dy | ) |
Print the list of 2d differentials stored represented as an STL set and ordered by index idx = ((2^n dx) + dy), where n is the word size.
bool sort_comp_diff_3d_p | ( | differential_3d_t | a, |
differential_3d_t | b | ||
) |
Compare differential_3d_t structs for use with std::sort
WORD_T xrandom | ( | ) |
Generate a random WORD-bit value.