aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/math/bigint
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-12-03 06:40:20 -0500
committerJack Lloyd <[email protected]>2018-12-03 06:40:20 -0500
commitd506b715c51cf3c609d5f61d47f025c050462c92 (patch)
tree45f3264a499004c44a8047cff7143e07c5b42b95 /src/lib/math/bigint
parent6c3eef4013e7da971ae884fd4dcb8318fbfcc05b (diff)
Use const time reductions in Barrett and LCM computations
Diffstat (limited to 'src/lib/math/bigint')
-rw-r--r--src/lib/math/bigint/divide.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/lib/math/bigint/divide.h b/src/lib/math/bigint/divide.h
index ac9c43e81..e365dabb3 100644
--- a/src/lib/math/bigint/divide.h
+++ b/src/lib/math/bigint/divide.h
@@ -48,6 +48,23 @@ void BOTAN_PUBLIC_API(2,9) ct_divide(const BigInt& x,
*
* @param x an integer
* @param y a non-zero integer
+* @return x/y with remainder discarded
+*/
+inline BigInt ct_divide(const BigInt& x, const BigInt& y)
+ {
+ BigInt q, r;
+ ct_divide(x, y, q, r);
+ return q;
+ }
+
+/**
+* BigInt division, const time variant
+*
+* This runs with control flow independent of the values of x/y.
+* Warning: the loop bounds still leak the sizes of x and y.
+*
+* @param x an integer
+* @param y a non-zero integer
* @param q will be set to x / y
* @param r will be set to x % y
*/