--- /dev/null
+#ifndef RSACRT_SHAMIRS_TRICK_H
+#define RSACRT_SHAMIRS_TRICK_H
+
+#include <utility>
+#include <exception>
+
+#include <gmpxx.h>
+
+#include "Rsa.h"
+
+class RsaCrtShamirsTrick
+{
+public:
+ class UnableToSignWithShamirsTrick : public std::exception {};
+
+ struct KeyPriv {
+ mpz_class p;
+ mpz_class q;
+ mpz_class d;
+ mpz_class qInv;
+ };
+
+ /**
+ * Generate a pair of keys (public, private).
+ */
+ static std::pair<Rsa::KeyPub, KeyPriv> generateRSAKeys(uint exponent, uint keySizeBits);
+
+ /**
+ * m must not be greater or equal than kPriv.n.
+ * Use the Shamir's trick to test if a fault has been created during the computation of Sp and Sq.
+ * If so it throws 'UnableToSignWithShamirsTrick'.
+ * @param m the message to sign. No padding is used.
+ */
+ static mpz_class sign(const mpz_class& m, const KeyPriv& kPriv);
+
+ /**
+ * Sp is altered by flipping its 42nd bit.
+ * @param m the message to sign. No padding is used.
+ */
+ static mpz_class signWithFaultySp(const mpz_class& m, const KeyPriv& kPriv);
+};
+
+#endif