diff options
author | Mary Ruthven <mruthven@chromium.org> | 2021-11-12 10:52:44 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-11-18 04:54:57 +0000 |
commit | 006f8a6f4a2fdcb236825d87b429be81a9695e2a (patch) | |
tree | a35b7b419fe29e67d513a46206aa38bf53a3e77b | |
parent | b46752dc210a5521a1782fd79e765596380c5a67 (diff) | |
download | chrome-ec-006f8a6f4a2fdcb236825d87b429be81a9695e2a.tar.gz |
Revert "rsa: Optimization of multiplications for Cortex-M0"
This reverts commit 49ff62bf0be5cfc88e092f987d77c18a0b21390a.
BUG=b:200823466
TEST=make buildall -j
Change-Id: I144e310c00d6490d278ca6215bf0a37d3cfc7d4f
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3285751
Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org>
-rw-r--r-- | common/rsa.c | 12 | ||||
-rw-r--r-- | include/config.h | 7 | ||||
-rw-r--r-- | include/util.h | 18 | ||||
-rw-r--r-- | test/utils.c | 27 |
4 files changed, 6 insertions, 58 deletions
diff --git a/common/rsa.c b/common/rsa.c index 9350f88554..891614bbfa 100644 --- a/common/rsa.c +++ b/common/rsa.c @@ -50,14 +50,14 @@ static void mont_mul_add(const struct rsa_public_key *key, const uint32_t a, const uint32_t *b) { - uint64_t A = mula32(a, b[0], c[0]); + uint64_t A = (uint64_t)a * b[0] + c[0]; uint32_t d0 = (uint32_t)A * key->n0inv; - uint64_t B = mula32(d0, key->n[0], A); + uint64_t B = (uint64_t)d0 * key->n[0] + (uint32_t)A; uint32_t i; for (i = 1; i < RSANUMWORDS; ++i) { - A = (A >> 32) + mula32(a, b[i], c[i]); - B = (B >> 32) + mula32(d0, key->n[i], A); + A = (A >> 32) + (uint64_t)a * b[i] + c[i]; + B = (B >> 32) + (uint64_t)d0 * key->n[i] + (uint32_t)A; c[i - 1] = (uint32_t)B; } @@ -78,11 +78,11 @@ static void mont_mul_add_0(const struct rsa_public_key *key, const uint32_t *b) { uint32_t d0 = c[0] * key->n0inv; - uint64_t B = mula32(d0, key->n[0], c[0]); + uint64_t B = (uint64_t)d0 * key->n[0] + c[0]; uint32_t i; for (i = 1; i < RSANUMWORDS; ++i) { - B = (B >> 32) + mula32(d0, key->n[i], c[i]); + B = (B >> 32) + (uint64_t)d0 * key->n[i] + c[i]; c[i - 1] = (uint32_t)B; } diff --git a/include/config.h b/include/config.h index 523bf2045b..aef1d301c5 100644 --- a/include/config.h +++ b/include/config.h @@ -276,13 +276,6 @@ /* Support AP Warm reset Interrupt. */ #undef CONFIG_AP_WARM_RESET_INTERRUPT -/* - * Defined if core/ code provides assembly optimized implementation of - * multiply-accumulate operations (32-bit operands, 64-bit result), for the - * cores that lack native instructions. - */ -#undef CONFIG_ASSEMBLY_MULA32 - /* Support audio codec. */ #undef CONFIG_AUDIO_CODEC /* Audio codec caps. */ diff --git a/include/util.h b/include/util.h index d05869305d..90e52dd2a5 100644 --- a/include/util.h +++ b/include/util.h @@ -222,24 +222,6 @@ int parse_offset_size(int argc, char **argv, int shift, */ void hexdump(const uint8_t *data, int len); -#ifdef CONFIG_ASSEMBLY_MULA32 -/* - * Compute (a*b)+c, where a, b, c are 32-bit integers, and the result is - * 64-bit long. - */ -uint64_t mula32(uint32_t a, uint32_t b, uint32_t c); -#else -static inline uint64_t mula32(uint32_t a, uint32_t b, uint32_t c) -{ - uint64_t ret = a; - - ret *= b; - ret += c; - - return ret; -} -#endif - #ifdef __cplusplus } #endif diff --git a/test/utils.c b/test/utils.c index 119ce98543..1cd86830ed 100644 --- a/test/utils.c +++ b/test/utils.c @@ -12,7 +12,6 @@ #include "test_util.h" #include "timer.h" #include "util.h" -#include "watchdog.h" static int test_memmove(void) { @@ -357,31 +356,6 @@ static int test_cond_t(void) return EC_SUCCESS; } -static int test_mula32(void) -{ - uint64_t r = 0x0; - uint32_t b = 0x1; - uint32_t c = 0x1; - uint32_t i; - timestamp_t t0, t1; - - t0 = get_time(); - for (i = 0; i < 5000000; i++) { - r = mula32(b, c, r + (r >> 32)); - b = (b << 13) ^ (b >> 2) ^ i; - c = (c << 16) ^ (c >> 7) ^ i; - watchdog_reload(); - } - t1 = get_time(); - - ccprintf("After %d iterations, r=%08x%08x (time: %d)\n", i, - (uint32_t)(r >> 32), (uint32_t)r, t1.le.lo-t0.le.lo); - TEST_ASSERT(r == 0x9df59b9fb0ab9d96L); - - /* well okay then */ - return EC_SUCCESS; -} - static int test_bytes_are_trivial(void) { static const uint8_t all0x00[] = { 0x00, 0x00, 0x00 }; @@ -416,7 +390,6 @@ void run_test(void) RUN_TEST(test_shared_mem); RUN_TEST(test_scratchpad); RUN_TEST(test_cond_t); - RUN_TEST(test_mula32); RUN_TEST(test_bytes_are_trivial); test_print_result(); |