summaryrefslogtreecommitdiff
path: root/nbtheory.cpp
diff options
context:
space:
mode:
authorweidai <weidai11@users.noreply.github.com>2007-04-16 00:13:05 +0000
committerweidai <weidai11@users.noreply.github.com>2007-04-16 00:13:05 +0000
commit3f68f7d55cf754b09385920af27916b093ac1d73 (patch)
treee00fe9aacfc5598e4d72ba1597a07b8805ab611a /nbtheory.cpp
parent33e9f55cdb441fa9800019f66fa0a5a05077fad1 (diff)
downloadcryptopp-git-3f68f7d55cf754b09385920af27916b093ac1d73.tar.gz
OpenMP
Diffstat (limited to 'nbtheory.cpp')
-rw-r--r--nbtheory.cpp35
1 files changed, 30 insertions, 5 deletions
diff --git a/nbtheory.cpp b/nbtheory.cpp
index 75edc148..fdc6e8f5 100644
--- a/nbtheory.cpp
+++ b/nbtheory.cpp
@@ -11,6 +11,11 @@
#include <math.h>
#include <vector>
+#ifdef _OPENMP
+// needed in MSVC 2005 to generate correct manifest
+#include <omp.h>
+#endif
+
NAMESPACE_BEGIN(CryptoPP)
const word s_lastSmallPrime = 32719;
@@ -647,8 +652,15 @@ bool SolveModularQuadraticEquation(Integer &r1, Integer &r2, const Integer &a, c
Integer ModularRoot(const Integer &a, const Integer &dp, const Integer &dq,
const Integer &p, const Integer &q, const Integer &u)
{
- Integer p2 = ModularExponentiation((a % p), dp, p);
- Integer q2 = ModularExponentiation((a % q), dq, q);
+ Integer p2, q2;
+ #pragma omp parallel
+ #pragma omp sections
+ {
+ #pragma omp section
+ p2 = ModularExponentiation((a % p), dp, p);
+ #pragma omp section
+ q2 = ModularExponentiation((a % q), dq, q);
+ }
return CRT(p2, p, q2, q, u);
}
@@ -992,9 +1004,22 @@ Integer Lucas(const Integer &n, const Integer &P, const Integer &modulus)
Integer InverseLucas(const Integer &e, const Integer &m, const Integer &p, const Integer &q, const Integer &u)
{
Integer d = (m*m-4);
- Integer p2 = p-Jacobi(d,p);
- Integer q2 = q-Jacobi(d,q);
- return CRT(Lucas(EuclideanMultiplicativeInverse(e,p2), m, p), p, Lucas(EuclideanMultiplicativeInverse(e,q2), m, q), q, u);
+ Integer p2, q2;
+ #pragma omp parallel
+ #pragma omp sections
+ {
+ #pragma omp section
+ {
+ p2 = p-Jacobi(d,p);
+ p2 = Lucas(EuclideanMultiplicativeInverse(e,p2), m, p);
+ }
+ #pragma omp section
+ {
+ q2 = q-Jacobi(d,q);
+ q2 = Lucas(EuclideanMultiplicativeInverse(e,q2), m, q);
+ }
+ }
+ return CRT(p2, p, q2, q, u);
}
Integer InverseLucas(const Integer &e, const Integer &m, const Integer &p, const Integer &q)