aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-06-19 10:51:17 -0400
committerJack Lloyd <[email protected]>2018-06-19 10:51:17 -0400
commitfc5156247ac9152fbe6f20f2ab6d1b09a9751652 (patch)
treeb09afcf6fc56c7f028626677109dc0c5c6d0d520 /src/lib/utils
parent7a13623a1ebf9ca289b0e4f5e5f08d1f415c0891 (diff)
Use masked table lookup in ECC base point multiplication
Diffstat (limited to 'src/lib/utils')
-rw-r--r--src/lib/utils/ct_utils.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lib/utils/ct_utils.h b/src/lib/utils/ct_utils.h
index f67fb8f10..013267874 100644
--- a/src/lib/utils/ct_utils.h
+++ b/src/lib/utils/ct_utils.h
@@ -108,6 +108,18 @@ inline T select(T mask, T from0, T from1)
return static_cast<T>((from0 & mask) | (from1 & ~mask));
}
+template<typename T>
+inline T select2(T mask0, T val0, T mask1, T val1, T val2)
+ {
+ return select<T>(mask0, val0, select<T>(mask1, val1, val2));
+ }
+
+template<typename T>
+inline T select3(T mask0, T val0, T mask1, T val1, T mask2, T val2, T val3)
+ {
+ return select2<T>(mask0, val0, mask1, val1, select<T>(mask2, val2, val3));
+ }
+
template<typename PredT, typename ValT>
inline ValT val_or_zero(PredT pred_val, ValT val)
{