* Author: Grégory Burri
*/
+#include <vector>
#include <iostream>
using namespace std;
#include <gmpxx.h>
-#include "Rsa.h"
-#include "RsaCrt.h"
+#include "Tests.h"
const uint KEY_SIZE_BITS = 1024;
const uint RSA_PUBLIC_EXPONENT = 65537;
+void printUsage(const string& progName)
+{
+ cout << "Usage: " << progName << " <command>" << endl;
+ cout << " <command> can be one of the following:" << endl;
+ cout << " * tests: Do some tests for RSA and RSA-CRT" << endl;
+ cout << " * time-measures: Compute the ratio between RSA and RSA-CRT" << endl;
+ cout << " * attack: Simulate the Boneh-DeMillo-Lipton attack against RSA-CRT" << endl;
+ cout << " * attack-fixed: [TODO]" << endl;
+}
+
int main(int argc, char** argv)
{
vector<string> args;
for (int i = 0; i < argc; i++)
args.push_back(string(argv[i]));
- const auto& keys = Rsa::generateRSAKeys(RSA_PUBLIC_EXPONENT, KEY_SIZE_BITS);
- const auto& kPub = keys.first;
- const auto& kPriv = keys.second;
-
- mpz_class message(42);
- mpz_class signature = Rsa::sign(message, kPriv);
-
- mpz_class message2(42);
- cout << "verify: " << Rsa::verifySignature(message2, signature, kPub) << endl;
-
- mpz_class message3(43);
- cout << "verify: " << Rsa::verifySignature(message3, signature, kPub) << endl;
+ if (args.size() >= 2 && args[1] == "tests")
+ Tests(KEY_SIZE_BITS, RSA_PUBLIC_EXPONENT).runTests();
+ else if (args.size() >= 2 && args[1] == "time-measures")
+ Tests(KEY_SIZE_BITS, RSA_PUBLIC_EXPONENT).runTimeMeasures();
+ else if (args.size() >= 2 && args[1] == "attack")
+ Tests(KEY_SIZE_BITS, RSA_PUBLIC_EXPONENT).doAttack();
+ else
+ printUsage(args[0]);
return 0;
}