PROLEAD
A Probing-Based Leakage Detection Tool for Hardware and Software
Loading...
Searching...
No Matches
Util.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <time.h>
4#include <vector>
5#include <cmath>
6#include <numeric>
7
8#include <boost/math/distributions/chi_squared.hpp>
9#include <boost/math/distributions/inverse_chi_squared.hpp>
10#include <boost/math/distributions/non_central_chi_squared.hpp>
11
15namespace Util{
23 std::vector<unsigned char> Key;
24 std::vector<unsigned int> Count;
25
34 TableEntryStruct(unsigned int);
35
48 TableEntryStruct(unsigned int, std::vector<unsigned char>&, unsigned int, unsigned int);
49 };
50
59 std::vector<TableEntryStruct> Entries;
60
71 std::vector<std::vector<std::vector<std::vector<unsigned char>>>> OnlyOneEntry;
72 double Probability;
73 unsigned int Traces;
74
85 void CalculateTraces(int, double, double);
86 };
87
99 double GetGValue(unsigned int, unsigned int, ContingencyTableStruct&, std::vector<double>, unsigned int, unsigned int&);
100
114 void GTest(unsigned int, unsigned int, ContingencyTableStruct&, std::vector<double>);
115
116 void StartClock(timespec&);
117 double EndClock(timespec&);
118}
Definition: Util.hpp:15
double EndClock(timespec &)
void GTest(unsigned int, unsigned int, ContingencyTableStruct &, std::vector< double >)
Computes the p-value.
void StartClock(timespec &)
double GetGValue(unsigned int, unsigned int, ContingencyTableStruct &, std::vector< double >, unsigned int, unsigned int &)
Computes the G-value.
Defines a contingency table.
Definition: Util.hpp:58
double Probability
The false-positive probability computed with the G-test.
Definition: Util.hpp:72
unsigned int Traces
The number of traces required to achieve a desired confidence level computed via statistical power an...
Definition: Util.hpp:73
std::vector< std::vector< std::vector< std::vector< unsigned char > > > > OnlyOneEntry
Stores all entires that occurred only once.
Definition: Util.hpp:71
std::vector< TableEntryStruct > Entries
Different entries of a contingency table, i.e. one entry per sample.
Definition: Util.hpp:59
void CalculateTraces(int, double, double)
Computes the required number of traces.
Defines one entry of a contingency table.
Definition: Util.hpp:22
TableEntryStruct(unsigned int)
Initializes a new entry without fixed state and zero counts.
std::vector< unsigned char > Key
The probed state of the cell, i.e. a byte-wise n-bit value recorded by n probes of a probing set.
Definition: Util.hpp:23
std::vector< unsigned int > Count
Counts how often state state was probed for each user-defined group.
Definition: Util.hpp:24
TableEntryStruct(unsigned int, std::vector< unsigned char > &, unsigned int, unsigned int)
Initializes a new entry with fixed state and counts.