Skip to content

Commit

Permalink
Display current time for relations order for progress monitoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
ph4r05 committed Jun 26, 2014
1 parent 78e17ef commit 36f9294
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
21 changes: 19 additions & 2 deletions Approximation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1641,6 +1641,7 @@ int Approximation::cubeAttack(uint wPlain, uint wKey, uint numRelations, uint su
const uint numKeyBits = cip->getKeyBlockSize() * 8;

// Function input/output for evaluation.
bool doProgressMonitoring = verboseLvl>0 && wPlain>12;
uchar * output = new uchar[cip->getOutputBlockSize()];
uchar * key = new uchar[cip->getKeyBlockSize()];
uchar * input = new uchar[byteWidth];
Expand Down Expand Up @@ -1735,8 +1736,11 @@ int Approximation::cubeAttack(uint wPlain, uint wKey, uint numRelations, uint su

// For each key, one plaintext cube has to be computed.
for(uint orderCtr=0; orderCtr <= (wKey+subCube); orderCtr++){ // TODO: subcube computation is not correct!
if (verboseLvl>0 && wPlain>12){
cout << " r=" << relationIdx << "; sub=" << subCube << "; orderCtr=" << orderCtr << endl;
if (doProgressMonitoring){
cout << " r=" << relationIdx
<< "; sub=" << subCube
<< "; orderCtr=" << orderCtr
<< "; time=" << currentDateTime() << endl;
}

// Current order to XOR is orderCtr.
Expand Down Expand Up @@ -2026,6 +2030,19 @@ long Approximation::cubeOnlineAttack(CubeRelations_vector & keyRelationsVector,
return rank;
}

const std::string Approximation::currentDateTime() const {
time_t now = time(0);
struct tm tstruct;
char buf[80];
tstruct = *localtime(&now);
// Visit http://en.cppreference.com/w/cpp/chrono/c/strftime
// for more information about date/time format
strftime(buf, sizeof(buf), "%Y-%m-%d %X", &tstruct);

return buf;
}


void Approximation::initFGb(uint numVariables) const {
fgb.initFGb(numVariables);
}
Expand Down
6 changes: 6 additions & 0 deletions Approximation.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,12 @@ class Approximation {
*/
long cubeOnlineAttack(CubeRelations_vector & keyRelationsVector, const uchar * input, uchar * solvedKey) const;

/**
* Returns current date time as a formatted string.
* @return
*/
const std::string currentDateTime() const;

/**
* Initializes FGb library.
* @param numVariables
Expand Down

0 comments on commit 36f9294

Please sign in to comment.