-rw-r--r-- 1268 cryptattacktester-20231020/attack_scan.cpp raw
#include "bigint.h"
#include "selection.h"
#include "problem.h"
#include "attack.h"
using namespace std;
selection_type attack_selection;
static problem E;
static vector<bigint> P;
static attack A;
int callback(const vector<bigint> &Q)
{
if (A.params_valid) assert(A.params_valid(P,Q));
for (bigint j = 0;j < Q.size();++j)
if (!selection_allows(attack_selection,A.paramnames.at(j),Q.at(j).get_str()))
return 0;
return attack_handle(E,P,A,Q);
}
int main(int argc,char **argv)
{
attack_selection = selection_parse(argv+1,argc-1);
for (auto E_local : problem_list) {
E = E_local;
if (!selection_allows(attack_selection,"problem",E.name)) continue;
vector<vector<bigint>> Plist = E.params(attack_selection);
for (auto P_local : Plist) {
P = P_local;
bool selected = 1;
for (bigint j = 0;j < P.size();++j)
selected &= selection_allows(attack_selection,E.paramnames.at(j),P.at(j).get_str());
if (!selected) continue;
for (auto A_local : attack_list) {
A = A_local;
if (string(A.problemname) != string(E.name)) continue;
if (!selection_allows(attack_selection,"attack",A.name)) continue;
A.params(P,attack_selection,callback);
}
}
}
return 0;
}