summaryrefslogtreecommitdiff
path: root/rw.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2019-05-17 15:18:17 -0400
committerGitHub <noreply@github.com>2019-05-17 15:18:17 -0400
commitc51f0ecbfd21b1eb29cfd26ea870b175d92db6c6 (patch)
tree87f0f2dbe92e25d2816ab6077e93714b2e69d863 /rw.cpp
parentb25b6f0892ebab5cc8a5e8c494c0db69057e1ba8 (diff)
downloadcryptopp-git-c51f0ecbfd21b1eb29cfd26ea870b175d92db6c6.tar.gz
Make config.h more Autoconf friendly (GH #835, PR #836)
Diffstat (limited to 'rw.cpp')
-rw-r--r--rw.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/rw.cpp b/rw.cpp
index d7287fad..ab79358c 100644
--- a/rw.cpp
+++ b/rw.cpp
@@ -126,6 +126,8 @@ void InvertibleRWFunction::PrecomputeTweakedRoots() const
{
ModularArithmetic modp(m_p), modq(m_q);
+ // GCC warning bug, https://stackoverflow.com/q/12842306/608639
+#ifdef _OPENMP
#pragma omp parallel sections if(CRYPTOPP_RW_USE_OMP)
{
#pragma omp section
@@ -135,6 +137,11 @@ void InvertibleRWFunction::PrecomputeTweakedRoots() const
#pragma omp section
m_pre_q_p = modp.Exponentiate(m_q, m_p - 2);
}
+#else
+ m_pre_2_9p = modp.Exponentiate(2, (9 * m_p - 11)/8);
+ m_pre_2_3q = modq.Exponentiate(2, (3 * m_q - 5)/8);
+ m_pre_q_p = modp.Exponentiate(m_q, m_p - 2);
+#endif
m_precompute = true;
}
@@ -223,6 +230,7 @@ Integer InvertibleRWFunction::CalculateInverse(RandomNumberGenerator &rng, const
else
f = 2;
+#ifdef _OPENMP
Integer W, X;
#pragma omp parallel sections if(CRYPTOPP_RW_USE_OMP)
{
@@ -236,6 +244,12 @@ Integer InvertibleRWFunction::CalculateInverse(RandomNumberGenerator &rng, const
X = (f.IsUnit() ? t : modp.Multiply(m_pre_2_9p, t));
}
}
+#else
+ const Integer W = (f.IsUnit() ? U : modq.Multiply(m_pre_2_3q, U));
+ const Integer t = modp.Multiply(modp.Exponentiate(V, 3), eh);
+ const Integer X = (f.IsUnit() ? t : modp.Multiply(m_pre_2_9p, t));
+#endif
+
const Integer Y = W + q * modp.Multiply(m_pre_q_p, (X - W));
// Signature