diff options
author | noloader <noloader@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2015-07-02 21:35:21 +0000 |
---|---|---|
committer | noloader <noloader@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2015-07-02 21:35:21 +0000 |
commit | e29b709a97502ac919356f528d74ccdcdf66b651 (patch) | |
tree | 097263dd6e90e3c74326808bb5e2a8f4a98bd830 /rw.h | |
parent | 0fd98cb23b696c2bafc9255bd73ebbe5ce576f41 (diff) | |
download | cryptopp-e29b709a97502ac919356f528d74ccdcdf66b651.tar.gz |
Implmented Bernstein\'s Tweaked Roots for Rabin-Williams signatures. Thanks to Evgeny Sidorov for suggesting it
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@565 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'rw.h')
-rw-r--r-- | rw.h | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -48,8 +48,9 @@ class CRYPTOPP_DLL InvertibleRWFunction : public RWFunction, public TrapdoorFunc typedef InvertibleRWFunction ThisClass; public: - void Initialize(const Integer &n, const Integer &p, const Integer &q, const Integer &u) - {m_n = n; m_p = p; m_q = q; m_u = u;} + InvertibleRWFunction() : m_precompute(false) {} + + void Initialize(const Integer &n, const Integer &p, const Integer &q, const Integer &u); // generate a random private key void Initialize(RandomNumberGenerator &rng, unsigned int modulusBits) {GenerateRandomWithKeySize(rng, modulusBits);} @@ -79,8 +80,21 @@ public: void SetPrime2(const Integer &q) {m_q = q;} void SetMultiplicativeInverseOfPrime2ModPrime1(const Integer &u) {m_u = u;} + virtual bool SupportsPrecomputation() const {return true;} + virtual void Precompute(unsigned int unused = 0) {PrecomputeTweakedRoots();} + virtual void Precompute(unsigned int unused = 0) const {PrecomputeTweakedRoots();} + + virtual void LoadPrecomputation(BufferedTransformation &storedPrecomputation); + virtual void SavePrecomputation(BufferedTransformation &storedPrecomputation) const; + +protected: + void PrecomputeTweakedRoots() const; + protected: Integer m_p, m_q, m_u; + + mutable Integer m_pre_2_9p, m_pre_2_3q, m_pre_q_p; + mutable bool m_precompute; }; //! RW |