-rw-r--r-- 1810 cryptattacktester-20231020/aes128_enum_params.cpp raw
#include "selection.h"
#include "aes128_enum_params.h"
using namespace std;
bool aes128_enum_params_valid(const vector<bigint> ¶ms,const vector<bigint> &attackparams)
{
bigint K = params.at(0);
bigint C = params.at(1);
bigint pos = 0;
bigint ITERS = attackparams.at(pos++);
bigint QX = attackparams.at(pos++);
bigint QUEUE_SIZE = attackparams.at(pos++);
bigint QF = attackparams.at(pos++); auto PERIOD = QF*QUEUE_SIZE;
if (ITERS < 0) return 0;
bigint searchspace = bigint(1)<<K;
if (ITERS >= searchspace) return 0;
if (QX < 0) return 0;
if (QX > 1) return 0;
if (QUEUE_SIZE < 1) return 0;
if (PERIOD < 1) return 0;
return 1;
}
void aes128_enum_params(const vector<bigint> ¶ms,map<string,string> &S,int (*callback)(const vector<bigint> &))
{
bigint K = params.at(0);
bigint Imin = 0;
bigint Imax = (bigint(1)<<K)-1;
selection_constrain(S,"I",Imin,Imax);
if (Imin < 0) return;
for (bigint I = Imin;I <= Imax;I = I ? I*2 : bigint(1)) {
bigint QXmin = 0;
bigint QXmax = 1;
selection_constrain(S,"QX",QXmin,QXmax);
for (bigint QX = 0;QX <= 1;++QX) {
if (QX < QXmin) continue;
if (QX > QXmax) continue;
bigint QFmin = 1;
bigint QFmax = 1024;
selection_constrain(S,"QF",QFmin,QFmax);
if (QFmin < 1) continue;
for (bigint QF = QFmin;QF <= QFmax;QF *= 2) {
if (QF < 1) break;
bigint QUEUE_SIZEmin = 1;
bigint QUEUE_SIZEmax = 8;
selection_constrain(S,"QU",QUEUE_SIZEmin,QUEUE_SIZEmax);
if (QUEUE_SIZEmin < 1) continue;
for (bigint QUEUE_SIZE = QUEUE_SIZEmin;QUEUE_SIZE <= QUEUE_SIZEmax;QUEUE_SIZE *= 2) {
if (QUEUE_SIZE < 1) break;
vector<bigint> Q{I,QX,QUEUE_SIZE,QF};
if (callback(Q) < 0) return;
}
}
}
}
}