aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/math/numbertheory/nistp_redc.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-04-18 11:41:46 -0400
committerJack Lloyd <[email protected]>2018-04-18 11:41:46 -0400
commit3716327e26a9298cf4d09ed7703074ed4e4d5a37 (patch)
treef97a16faef10e7ca2aefada5010eb8cb5f9c4ddb /src/lib/math/numbertheory/nistp_redc.cpp
parent7e4e69629d61307c0366a3fc7aae675b3a947ca3 (diff)
Add early exit for P-192 reduce
Diffstat (limited to 'src/lib/math/numbertheory/nistp_redc.cpp')
-rw-r--r--src/lib/math/numbertheory/nistp_redc.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/lib/math/numbertheory/nistp_redc.cpp b/src/lib/math/numbertheory/nistp_redc.cpp
index 9ceb7c167..33e77562e 100644
--- a/src/lib/math/numbertheory/nistp_redc.cpp
+++ b/src/lib/math/numbertheory/nistp_redc.cpp
@@ -198,6 +198,11 @@ void redc_p192(BigInt& x, secure_vector<word>& ws)
#endif
};
+ if(S == 0 && x.word_at(p192_limbs-1) < p192_mults[0][p192_limbs-1])
+ {
+ return;
+ }
+
word borrow = bigint_sub2(x.mutable_data(), x.size(), p192_mults[S], p192_limbs);
BOTAN_ASSERT(borrow == 0 || borrow == 1, "Expected borrow during P-192 reduction");