35static void approx(
const char* label,
double got,
double want,
double tol) {
36 if (fabs(got - want) > tol) {
37 n_log(
LOG_ERR,
"%s: got %.4f, expected %.4f", label, got, want);
43 unsigned char uni[256];
44 unsigned char same[64];
47 unsigned char half[8];
48 unsigned char two[4] = {
'A',
'B',
'A',
'B'};
53 for (i = 0; i < 256; i++)
54 uni[i] = (
unsigned char)i;
60 memset(same,
'A',
sizeof(same));
68 memset(z, 0x00,
sizeof(z));
69 memset(f, 0xFF,
sizeof(f));
70 memset(half, 0x0F,
sizeof(half));
static void approx(const char *label, double got, double want, double tol)
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_ERR
error conditions
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL )
#define LOG_NOTICE
normal but significant condition
double n_entropy_shannon(const unsigned char *data, size_t len)
Shannon entropy of the byte sample, in bits per byte (0.0 .
double n_entropy_monobit(const unsigned char *data, size_t len)
Fraction of set bits in the sample (0.0 .
double n_entropy_chi_square(const unsigned char *data, size_t len)
Chi-square statistic of the byte histogram against a uniform distribution over 256 values.
Randomness/entropy metrics for byte samples (token-randomness analysis)