diff options
author | Nicolas Boichat <drinkcat@google.com> | 2017-06-22 10:34:39 +0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2017-10-24 01:54:09 +0000 |
commit | 2bd35faa1dd123350026077cd61fb43aee690729 (patch) | |
tree | a0569b724550f5810e55298ab6cb982c02b55497 /include | |
parent | b628bbd3caad7893e32a60ca7c34c36998f7394f (diff) | |
download | chrome-ec-2bd35faa1dd123350026077cd61fb43aee690729.tar.gz |
core/cortex-m0/curve25519: Integrate fast curve25519 implementation
- Move generic implementation to curve25519-generic.o
- Always use optimized version on cortex-m0.
- Rename .s files to .S, remove unnecessary lines in assembly files.
- Rename crypto_scalarmult_curve25519 to x25519_scalar_mult to match
the signature provided by the generic implementation.
- Replace some handcoded memcpy with function calls
- Remove unnecessary "volatile" specifications in the code.
Conflicts:
common/build.mk
core/cortex-m0/curve25519/mpy121666.S
core/cortex-m0/curve25519/mul.S
core/cortex-m0/curve25519/reduce25519.S
core/cortex-m0/curve25519/scalarmult.c
core/cortex-m0/curve25519/sqr.S
BRANCH=none
BUG=b:62813194
TEST=To test old implementation only:
- Increase CONFIG_RO_SIZE to 60kb
- Increase console stack size to 2048
make BOARD=hammer PROJECT=x25519 TEST_BUILD=y
./util/flash_ec --board=hammer --image=build/hammer/x25519.bin
EC console: runtest, taskinfo
=> Used to takes ~4'17" to run (X25519 duration 256347 us).
1496/2048 stack size usage in CONSOLE task
=> Now takes ~1'25" to run (X25519 duration 84520 us)
732/2048 stack size usage in CONSOLE task
TEST=In test/x25519.c, uncomment #define TEST_X25519_1M_ITERATIONS
make BOARD=hammer PROJECT=x25519 TEST_BUILD=y
./util/flash_ec --board=hammer --image=build/hammer/x25519.bin
EC console: runtest, wait ~23 hours, test passes.
TEST=- Define CONFIG_CURVE25519_CORTEXM0 (next patch)
makes newsizes
build/hammer/RW/ec.RW.flat shrank by 1888 bytes: (52208 to 50320)
Change-Id: Icce38d3c32f431a85ac0f951cf34456b490dc665
Reviewed-on: https://chromium-review.googlesource.com/540962
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
(cherry picked from commit edc668ea6cca1d4f3e53c211406d6a8bf5fe6364)
Reviewed-on: https://chromium-review.googlesource.com/734797
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/curve25519.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/curve25519.h b/include/curve25519.h index 4b75373da1..8287c94466 100644 --- a/include/curve25519.h +++ b/include/curve25519.h @@ -59,4 +59,12 @@ int X25519(uint8_t out_shared_key[32], const uint8_t private_key[32], void X25519_public_from_private(uint8_t out_public_value[32], const uint8_t private_key[32]); +/* + * Low-level x25519 function, defined by either the generic or cortex-m0 + * implementation. Must not be called directly. + */ +void x25519_scalar_mult(uint8_t out[32], + const uint8_t scalar[32], + const uint8_t point[32]); + #endif /* __CROS_EC_CURVE25519_H */ |