- const auto& keys = RsaStd::generateRSAKeys(RSA_PUBLIC_EXPONENT, KEY_SIZE_BITS);
- const auto& kPub = keys.first;
- const auto& kPriv = keys.second;
-
- mpz_class message = Rand::randSize(KEY_SIZE_BITS / 2);
- mpz_class signature = RsaStd::sign(message, kPriv);
-
- return Rsa::verifySignature(message, signature, kPub) && !Rsa::verifySignature(message + 1, signature, kPub);
-}
-
-bool testRsaCrt()
-{
- const auto& keys = RsaCrt::generateRSAKeys(RSA_PUBLIC_EXPONENT, KEY_SIZE_BITS);
- const auto& kPub = keys.first;
- const auto& kPriv = keys.second;
-
- mpz_class message = Rand::randSize(KEY_SIZE_BITS / 2);
- mpz_class signature = RsaCrt::sign(message, kPriv);
-
- return Rsa::verifySignature(message, signature, kPub) && !Rsa::verifySignature(message + 1, signature, kPub);
-}
-
-int timeSignRsaStd(int N)
-{
- Timer timer;
- const auto& keys = RsaStd::generateRSAKeys(RSA_PUBLIC_EXPONENT, KEY_SIZE_BITS);
-
- for (int i = 0; i < N; i++)
- {
- mpz_class message = Rand::randSize(KEY_SIZE_BITS / 2);
- RsaStd::sign(message, keys.second);
- }
-
- return timer.ms();
-}
-
-int timeSignRsaCRT(int N)
-{
- Timer timer;
- const auto& keys = RsaCrt::generateRSAKeys(RSA_PUBLIC_EXPONENT, KEY_SIZE_BITS);
-
- for (int i = 0; i < N; i++)
- {
- mpz_class message = Rand::randSize(KEY_SIZE_BITS / 2);
- RsaCrt::sign(message, keys.second);
- }
-
- return timer.ms();
-}
-
-void measuresRsaDurations()
-{
- const int N = 10000;
- int timeRsaStd = timeSignRsaStd(N);
- int timeRsaCRT = timeSignRsaCRT(N);
-
- cout << N << " x RSA standard: " << timeRsaStd << " ms" << endl;
- cout << N << " x RSA CRT: " << timeRsaCRT << " ms" << endl;
- cout << "Speedup: " << (double(timeRsaStd) / double(timeRsaCRT)) << endl;
+ 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 << " * tests-with-shamirs-trick: Do some tests for RSA-CRT with Shamir's trick" << 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: Try the attack with the Shamir's trick version" << endl;