From 2ccaf2ef1d78727194b59d986b491e717c508917 Mon Sep 17 00:00:00 2001 From: weidai Date: Tue, 25 Mar 2003 02:11:53 +0000 Subject: [PATCH] minor changes --- nbtheory.cpp | 2 +- rsa.cpp | 8 ++++++-- wait.cpp | 9 +++++++++ wait.h | 2 ++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/nbtheory.cpp b/nbtheory.cpp index 852beb57..8689cea7 100644 --- a/nbtheory.cpp +++ b/nbtheory.cpp @@ -440,7 +440,7 @@ bool FirstPrime(Integer &p, const Integer &max, const Integer &equiv, const Inte else pItr = primeTable; - while (pItr < primeTable+primeTableSize && *pItr%mod != equiv) + while (pItr < primeTable+primeTableSize && !(*pItr%mod == equiv && (!pSelector || pSelector->IsAcceptable(*pItr)))) ++pItr; if (pItr < primeTable+primeTableSize) diff --git a/rsa.cpp b/rsa.cpp index 62e95921..76d4aa9a 100644 --- a/rsa.cpp +++ b/rsa.cpp @@ -217,13 +217,17 @@ Integer InvertibleRSAFunction::CalculateInverse(RandomNumberGenerator &rng, cons { DoQuickSanityCheck(); ModularArithmetic modn(m_n); - Integer r(rng, Integer::One(), m_n - Integer::One()); + Integer r, rInv; + do { // do this loop for people using small numbers for testing + r.Randomize(rng, Integer::One(), m_n - Integer::One()); + rInv = modn.MultiplicativeInverse(r); + } while (rInv.IsZero()); Integer re = modn.Exponentiate(r, m_e); re = modn.Multiply(re, x); // blind // here we follow the notation of PKCS #1 and let u=q inverse mod p // but in ModRoot, u=p inverse mod q, so we reverse the order of p and q Integer y = ModularRoot(re, m_dq, m_dp, m_q, m_p, m_u); - y = modn.Divide(y, r); // unblind + y = modn.Multiply(y, rInv); // unblind if (modn.Exponentiate(y, m_e) != x) // check throw Exception(Exception::OTHER_ERROR, "InvertibleRSAFunction: computational error during private key operation"); return y; diff --git a/wait.cpp b/wait.cpp index 05d485b5..dfcb60c4 100644 --- a/wait.cpp +++ b/wait.cpp @@ -15,6 +15,15 @@ NAMESPACE_BEGIN(CryptoPP) +unsigned int WaitObjectContainer::MaxWaitObjects() +{ +#ifdef USE_WINDOWS_STYLE_SOCKETS + return MAXIMUM_WAIT_OBJECTS * (MAXIMUM_WAIT_OBJECTS-1); +#else + return FD_SETSIZE; +#endif +} + WaitObjectContainer::WaitObjectContainer() { Clear(); diff --git a/wait.h b/wait.h index 46193980..c1435221 100644 --- a/wait.h +++ b/wait.h @@ -29,6 +29,8 @@ public: Err(const std::string& s) : Exception(IO_ERROR, s) {} }; + static unsigned int MaxWaitObjects(); + WaitObjectContainer(); void Clear();