Attack implementation.
[crypto_lab3.git] / src / main.cpp
1 /**
2 * ICR - Labo 3.
3 * It uses GMPxx lib and C++11.
4 * It needs the RNG file "/dev/urandom".
5 *
6 * Author: Grégory Burri
7 */
8
9 #include <vector>
10 #include <iostream>
11 using namespace std;
12
13 #include <gmpxx.h>
14
15 #include "Tests.h"
16
17 const uint KEY_SIZE_BITS = 1024;
18 const uint RSA_PUBLIC_EXPONENT = 65537;
19
20 void printUsage(const string& progName)
21 {
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 << " * time-measures: Compute the ratio between RSA and RSA-CRT" << endl;
26 cout << " * attack: Simulate the Boneh-DeMillo-Lipton attack against RSA-CRT" << endl;
27 cout << " * attack-fixed: [TODO]" << endl;
28 }
29
30 int main(int argc, char** argv)
31 {
32 vector<string> args;
33 for (int i = 0; i < argc; i++)
34 args.push_back(string(argv[i]));
35
36 if (args.size() >= 2 && args[1] == "tests")
37 Tests(KEY_SIZE_BITS, RSA_PUBLIC_EXPONENT).runTests();
38 else if (args.size() >= 2 && args[1] == "time-measures")
39 Tests(KEY_SIZE_BITS, RSA_PUBLIC_EXPONENT).runTimeMeasures();
40 else if (args.size() >= 2 && args[1] == "attack")
41 Tests(KEY_SIZE_BITS, RSA_PUBLIC_EXPONENT).doAttack();
42 else
43 printUsage(args[0]);
44
45 return 0;
46 }