8c4ec7e52bdeaa17bf7c4915b24a9e4d3df846d1
3 * It uses GMPxx lib and C++11.
4 * It needs the RNG file "/dev/urandom".
6 * Author: Grégory Burri
17 const uint KEY_SIZE_BITS
= 1024;
18 const uint RSA_PUBLIC_EXPONENT
= 65537;
20 void printUsage(const string
& progName
)
22 cout
<< "Usage: " << progName
<< " <command>" << endl
;
23 cout
<< " <command> can be one of the following:" << endl
;
24 cout
<< " * tests: Do some tests for RSA and RSA-CRT" << endl
;
25 cout
<< " * tests-with-shamirs-trick: Do some tests for RSA-CRT with Shamir's trick" << endl
;
26 cout
<< " * time-measures: Compute the ratio between RSA and RSA-CRT" << endl
;
27 cout
<< " * attack: Simulate the Boneh-DeMillo-Lipton attack against RSA-CRT" << endl
;
28 cout
<< " * attack-fixed: Try the attack with the Shamir's trick version" << endl
;
31 int main(int argc
, char** argv
)
34 for (int i
= 0; i
< argc
; i
++)
35 args
.push_back(string(argv
[i
]));
37 if (args
.size() >= 2 && args
[1] == "tests")
38 Tests(KEY_SIZE_BITS
, RSA_PUBLIC_EXPONENT
).runTests();
39 else if (args
.size() >= 2 && args
[1] == "tests-with-shamirs-trick")
40 Tests(KEY_SIZE_BITS
, RSA_PUBLIC_EXPONENT
).runTestsWithShamirsTrick();
41 else if (args
.size() >= 2 && args
[1] == "time-measures")
42 Tests(KEY_SIZE_BITS
, RSA_PUBLIC_EXPONENT
).runTimeMeasures();
43 else if (args
.size() >= 2 && args
[1] == "attack")
44 Tests(KEY_SIZE_BITS
, RSA_PUBLIC_EXPONENT
).doAttack();
45 else if (args
.size() >= 2 && args
[1] == "attack-fixed")
46 Tests(KEY_SIZE_BITS
, RSA_PUBLIC_EXPONENT
).doAttackFixed();