projects
/
crypto_lab3.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implementation of Shamir's trick (working in progress).
[crypto_lab3.git]
/
src
/
RsaCrt.h
diff --git
a/src/RsaCrt.h
b/src/RsaCrt.h
index
87f9a11
..
adf6c72
100644
(file)
--- a/
src/RsaCrt.h
+++ b/
src/RsaCrt.h
@@
-2,6
+2,7
@@
#define RSACRT_H
#include <utility>
#define RSACRT_H
#include <utility>
+#include <exception>
#include <gmpxx.h>
#include <gmpxx.h>
@@
-11,20
+12,29
@@
class RsaCrt
{
public:
struct KeyPriv {
{
public:
struct KeyPriv {
- mpz_class n; // Modulus.
- uint e; // Exponent.
-
mpz_class p;
mpz_class q;
mpz_class dp;
mpz_class dq;
mpz_class qInv;
mpz_class p;
mpz_class q;
mpz_class dp;
mpz_class dq;
mpz_class qInv;
- mpz_class d;
};
};
+ /**
+ * Generate a pair of keys (public, private).
+ */
static std::pair<Rsa::KeyPub, KeyPriv> generateRSAKeys(uint exponent, uint keySizeBits);
static std::pair<Rsa::KeyPub, KeyPriv> generateRSAKeys(uint exponent, uint keySizeBits);
+ /**
+ * m must not be greater or equal than kPriv.n.
+ * @param m the message to sign. No padding is used.
+ */
static mpz_class sign(const mpz_class& m, const KeyPriv& kPriv);
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
};
#endif