Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/analyzer/ConfigurationComposability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ ConfigurationComposability::execute(const Settings *settings, State *state) {
}
if(!var_included) extended_probes.push_back(reg);
}

if (extended_probes.size() > 63) throw std::logic_error("[COMPOSABILITY]: More than 63 extended probes detected (overflow)!");
}
else
{
Expand All @@ -131,6 +129,8 @@ ConfigurationComposability::execute(const Settings *settings, State *state) {
// Add "virtual" probes, e.g., abort signals
extended_probes.insert(extended_probes.end(), this->m_current_probes.second.begin(), this->m_current_probes.second.end());

if (extended_probes.size() > 63) throw std::logic_error("[COMPOSABILITY]: More than 63 extended probes detected (overflow)!");

/* Collect observation & support */
// This loop together with the next for-loop is used to generate all possible combinations of extended probes
for (uint64_t comb = 1; comb < (1ull << extended_probes.size()); comb++) {
Expand All @@ -139,7 +139,7 @@ ConfigurationComposability::execute(const Settings *settings, State *state) {

/* TODO: These loops check some combinations several times. Especially for higher order verifications some of the considered combinations are already checked in a previous test. */
for (uint64_t elem = 0; elem < extended_probes.size(); elem++) {
if (comb & (1 << elem)) {
if (comb & (1ull << elem)) {
observe &= extended_probes[elem]->functions(threadNum); // create cube of all selected extended probes
support.insert(extended_probes[elem]->variables(threadNum).begin(), extended_probes[elem]->variables(threadNum).end()); // track all influencing variables
}
Expand Down Expand Up @@ -182,12 +182,12 @@ ConfigurationComposability::execute(const Settings *settings, State *state) {
std::vector<std::vector<std::set<const verica::Wire*>>> intra(shares.size());
// Loop over all secret values
for (unsigned int idx = 0; idx < shares.size(); idx++) {
for (uint64_t comb = 0; comb < (uint64_t)(1 << shares[idx].size()); comb++) {
for (uint64_t comb = 0; comb < (1ull << shares[idx].size()); comb++) {
if (__builtin_popcount(comb) <= threshold) { // TODO: would == threshold also be valid since we always start with testing security for d=1?
std::set<const verica::Wire*> tmp;
intra[idx].push_back(tmp);
for (unsigned int elem = 0; elem < shares[idx].size(); elem++)
if (comb & (1 << elem)) intra[idx][intra[idx].size() - 1].insert(shares[idx][elem]);
if (comb & (1ull << elem)) intra[idx][intra[idx].size() - 1].insert(shares[idx][elem]);
}
}
}
Expand Down Expand Up @@ -249,13 +249,13 @@ ConfigurationComposability::execute(const Settings *settings, State *state) {


// This strategy seems to be faster
for(unsigned int s=0; s < (1 << combination_filtered.size()) && this->m_independent; ++s){
for(uint64_t s=0; s < (1ull << combination_filtered.size()) && this->m_independent; ++s){
BDD simulate = observe;
for(int elem=0; elem<combination_filtered.size(); ++elem) if(s & (1 << elem)) simulate &= combination_filtered[elem]->functions(threadNum);
for(int elem=0; elem<combination_filtered.size(); ++elem) if(s & (1ull << elem)) simulate &= combination_filtered[elem]->functions(threadNum);

for(unsigned int r=1; r<(1 << complement.size()) && this->m_independent; ++r){
for(uint64_t r=1; r<(1ull << complement.size()) && this->m_independent; ++r){
BDD free = state->m_managers[threadNum].bddOne();
for(int elem=0; elem<complement.size(); ++elem) if(r & (1 << elem)) free &= complement[elem]->functions(threadNum);
for(int elem=0; elem<complement.size(); ++elem) if(r & (1ull << elem)) free &= complement[elem]->functions(threadNum);

this->m_independent &= state->m_managers[threadNum].bdd_statindependence(simulate, free);
}
Expand Down
7 changes: 4 additions & 3 deletions src/analyzer/ConfigurationProbing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ ConfigurationProbing::execute(const Settings *settings, State *state)
if(!var_included) extended_probes.push_back(reg);
}

if (extended_probes.size() > 63) throw std::logic_error("PROBING: More than 63 extended probes detected (overflow)!");
}
else
{
Expand All @@ -111,13 +110,15 @@ ConfigurationProbing::execute(const Settings *settings, State *state)

this->m_independent = true;

if (extended_probes.size() > 63) throw std::logic_error("[PROBING]: More than 63 extended probes detected (overflow)!");

/* Check combinations & secrets for statistical independence */
for (uint64_t comb = 1; comb < (uint64_t)(1ull << extended_probes.size()) && this->m_independent; comb++)
for (uint64_t comb = 1; comb < (1ull << extended_probes.size()) && this->m_independent; comb++)
{
/* Generate probe observation */
BDD observation = state->m_managers[threadNum].bddOne();
for (uint64_t elem = 0; elem < extended_probes.size(); elem++){
if (comb & (1 << elem)) observation &= extended_probes[elem]->functions(threadNum);
if (comb & (1ull << elem)) observation &= extended_probes[elem]->functions(threadNum);
}

/* Statistical independence check */
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/ConfigurationUniformity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ConfigurationUniformity::execute(const Settings *settings, State *state)
for (uint64_t comb = 1; comb < ((1ull << output_shares_map.second.size()) - 1) && this->m_uniform; comb++) {
intra[share_cnt].push_back(state->m_managers[0].bddZero());
for (unsigned int elem = 0; elem < output_shares_map.second.size(); elem++) {
if (comb & (1 << elem)) intra[share_cnt].back() ^= output_shares_map.second[elem]->functions(0);
if (comb & (1ull << elem)) intra[share_cnt].back() ^= output_shares_map.second[elem]->functions(0);
}

if (abs(state->m_managers[0].bdd_satcountln(intra[share_cnt].back(), this->m_variable_count) - this->m_variable_count + 1) > DOUBLE_COMPARE_THRESHOLD) this->m_uniform = false;
Expand Down
4 changes: 2 additions & 2 deletions src/preprocessor/ConfigurationSCA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@ ConfigurationSCA::update_probe_combinations(State *state, const Settings *settin
for(auto d : domains) wires.insert(wires.end(), m_outputs_same_domain[d].begin(), m_outputs_same_domain[d].end());

// create combinations
for(unsigned int comb=1; comb <= ((1 << wires.size())-1); comb++){
for(uint64_t comb=1; comb <= ((1ull << wires.size())-1); comb++){
std::vector<const verica::Wire*> new_comb;
for(unsigned int bit=0; bit < wires.size(); bit++){
for(uint64_t bit=0; bit < wires.size(); bit++){
if((comb >> bit) & 1) new_comb.push_back(wires[bit]);
}
state->m_probe_combinations[thread_num].push_back(std::make_pair(probes, new_comb));
Expand Down