-rw-r--r-- 975 cryptattacktester-20231020/aes128_enum_prob.cpp raw
#include "queue_prob.h"
#include "aes128_enum_prob.h"
using namespace std;
bigfloat aes128_enum_prob(const vector<bigint> ¶ms,const vector<bigint> &attackparams)
{
bigint K = params.at(0);
bigint C = params.at(1);
bigint I = attackparams.at(0);
bigint QX = attackparams.at(1);
bigint QU = attackparams.at(2);
bigint QF = attackparams.at(3);
bigint PE = QU*QF;
bigint searchspace = bigint(1)<<K;
for (bigint prec = 32;;prec *= 2) {
bigfloat::set_default_precision(prec);
bigfloat result = bigfloat(I)/bigfloat(searchspace);
if (QX && (I > 0)) {
bigint full_clears = I/PE;
bigint leftovers = I%PE;
bigfloat pr0 = exp2(bigfloat(-bigint(C)));
bigfloat survivors = full_clears*queue_average(PE,pr0,QU)+queue_average(leftovers,pr0,QU);
result *= survivors/(pr0*bigfloat(I));
}
result += bigfloat(1)/bigfloat(searchspace);
if (result.definitely_positive_and_reasonably_precise()) return result;
}
}