YAARX: Yet Another ARX Toolkit  0.1
 All Data Structures Files Functions Variables Macros Pages
common.cc File Reference

Common functions used accross all YAARX programs. More...

#include "common.hh"

Functions

timestamp_t get_timestamp ()
 
uint32_t random32 ()
 
uint64_t random64 ()
 
WORD_T xrandom ()
 
uint32_t hw8 (const uint32_t x)
 
uint32_t hw32_slow (const uint32_t x)
 
uint32_t hw32 (const uint32_t w)
 
uint64_t hw64 (const uint64_t w)
 
uint32_t hamming_weight (const WORD_T w)
 
uint32_t parity32 (const uint32_t x)
 
uint64_t parity64 (const uint64_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 x, differential_t y)
 
bool operator< (difference_t x, difference_t y)
 
bool operator== (differential_t a, differential_t b)
 
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_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)
 
void yaarx_alloc_matrices_3d (WORD_T ****A, uint32_t A_dim)
 
void yaarx_free_matrices_3d (WORD_T ***A, uint32_t A_dim)
 
void yaarx_alloc_matrices_3d (gsl_matrix *A[2][2][2], uint32_t A_dim)
 
void yaarx_free_matrices_3d (gsl_matrix *A[2][2][2], uint32_t A_dim)
 
void matrix_matrix_multiply_bool (std::array< std::array< bool, WORD_SIZE >, WORD_SIZE > *res, const std::array< std::array< bool, WORD_SIZE >, WORD_SIZE > mat1, const std::array< std::array< bool, WORD_SIZE >, WORD_SIZE > mat2)
 

Detailed Description

Common functions used accross all YAARX programs.

Author
V.Velichkov, vesse.nosp@m.lin..nosp@m.velic.nosp@m.hkov.nosp@m.@uni..nosp@m.lu
Date
2012-2013

Function Documentation

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 ( )
uint32_t hamming_weight ( const WORD_T  w)

Hamming weight of a WORD-bit word (efficient).

uint32_t hw32 ( const uint32_t  w)

Hamming weight of a 32-bit word (efficient).

uint32_t hw32_slow ( const uint32_t  x)

Hamming weight of a 32-bit word (inefficient).

uint64_t hw64 ( const uint64_t  w)

Hamming weight of a 64-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.

void matrix_matrix_multiply_bool ( std::array< std::array< bool, WORD_SIZE >, WORD_SIZE > *  res,
const std::array< std::array< bool, WORD_SIZE >, WORD_SIZE mat1,
const std::array< std::array< bool, WORD_SIZE >, WORD_SIZE mat2 
)
inline

Basic matrix multiplication over F_2 See: http://www.joux.biz/algcrypt/PROGRAMS/Matmul3_1.html

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)

Compute parity of the word x with a multiply

See Also
parity32, parity64
uint32_t parity32 ( const uint32_t  x)

Compute parity of 32-bit word with a multiply Credit: https://graphics.stanford.edu/~seander/bithacks.html

uint64_t parity64 ( const uint64_t  x)

Compute parity of 64-bit word with a multiply Credit: https://graphics.stanford.edu/~seander/bithacks.html

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.

uint32_t random32 ( )

Generate a random 32-bit value.

uint64_t random64 ( )

Generate a random 64-bit value.

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.