-rw-r--r-- 895 cryptattacktester-20231020/aes128_enum_cost.cpp raw
#include "bit_cost.h"
#include "bit_vector_cost.h"
#include "aes128_enum_cost.h"
using namespace std;
bigint aes128_enum_cost(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 xtime = 3;
  bigint byte_sub = 113;
  bigint byte_xor = 8;
  bigint keyexpand = 4*40*byte_xor+10*(4*byte_sub+byte_xor+xtime);
  bigint encrypt = keyexpand+11*16*byte_xor+160*byte_sub+9*4*(12*byte_xor+4*xtime);
  if (QX == 0)
    return I*(2*encrypt+4*C+(2+bit_mux_cost)*K);
  bigint clears = (I+PE-1)/PE;
  bigint periter = encrypt+2*C+2*K+1+bit_queue1_insert_cost(QU)+QU*K*bit_mux_cost;
  bigint perclear = QU*(encrypt+1+2*C+bit_mux_cost*K);
  return I*periter+clears*perclear;
}