4cfdb9c6887434df844508da2d5e3097e15b4409
[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 << " [tests|time-measures]" << endl;
23
24 // mpz_class n = 10;
25 // mpz_class d = 3;
26 // mpz_class q;
27 // mpz_fdiv_q(q.get_mpz_t(), n.get_mpz_t(), d.get_mpz_t());
28
29 // cout << "q: " << q << endl;
30 // cout << "q: " << (n / d) << endl;
31 }
32
33 int main(int argc, char** argv)
34 {
35 vector<string> args;
36 for (int i = 0; i < argc; i++)
37 args.push_back(string(argv[i]));
38
39 if (args.size() >= 2 && args[1] == "tests")
40 Tests(KEY_SIZE_BITS, RSA_PUBLIC_EXPONENT).runTests();
41 else if (args.size() >= 2 && args[1] == "time-measures")
42 Tests(KEY_SIZE_BITS, RSA_PUBLIC_EXPONENT).runTimeMeasures();
43 else
44 printUsage(args[0]);
45
46 return 0;
47 }