diff options
author | Nicolas Boichat <drinkcat@chromium.org> | 2018-05-24 14:33:06 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-05-29 06:02:19 -0700 |
commit | ecd0d1b5767c829f4c73a79a9eb6abae343284fb (patch) | |
tree | 72be322444b05435927078bf9ac16f810c35d06e /include/util.h | |
parent | cc7889bfaec9243ff35b6a366f6f2c7c65c33a13 (diff) | |
download | chrome-ec-ecd0d1b5767c829f4c73a79a9eb6abae343284fb.tar.gz |
rsa: Further optimization of multiplications for Cortex-M0
In RSA, we often need to actually compute (a*b)+c+d: provide some
assembly optimized functions for that.
With -O3, 3072-bit exponent, lower verification time from 104 ms to
88 ms on STM32F072 @48Mhz.
BRANCH=poppy
BUG=b:35647963
BUG=b:77608104
TEST=On staff, flash, verification successful
TEST=make test-rsa, make test-rsa3
TEST=make BOARD=hammer test-utils test-rsa3, test on board
Change-Id: I80e8a7258d091e4f6adea11797729ac657dfd85d
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1071411
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'include/util.h')
-rw-r--r-- | include/util.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/include/util.h b/include/util.h index 2670d4e5ad..c8ae09db93 100644 --- a/include/util.h +++ b/include/util.h @@ -184,10 +184,11 @@ int parse_offset_size(int argc, char **argv, int shift, #ifdef CONFIG_ASSEMBLY_MULA32 /* - * Compute (a*b)+c, where a, b, c are 32-bit integers, and the result is - * 64-bit long. + * Compute (a*b)+c[+d], where a, b, c[, d] are 32-bit integers, and the result + * is 64-bit long. */ uint64_t mula32(uint32_t a, uint32_t b, uint32_t c); +uint64_t mulaa32(uint32_t a, uint32_t b, uint32_t c, uint32_t d); #else static inline uint64_t mula32(uint32_t a, uint32_t b, uint32_t c) { @@ -198,6 +199,17 @@ static inline uint64_t mula32(uint32_t a, uint32_t b, uint32_t c) return ret; } + +static inline uint64_t mulaa32(uint32_t a, uint32_t b, uint32_t c, uint32_t d) +{ + uint64_t ret = a; + + ret *= b; + ret += c; + ret += d; + + return ret; +} #endif #endif /* __CROS_EC_UTIL_H */ |