Add option to adjust compiler optimization on RSA

Using -O3 optimization level rather than -Os results in a large speed-up
for a minor code size increase for the RSA code with our current GCC
toolchain.
Add the CONFIG_RSA_OPTIMIZED option to do it on platforms which are not
too size-constrained.

On cortex-M4 based STM32L432, I'm measuring a 37 to 40% speed increase
(depending on CPU frequency) for a 200 bytes code size delta.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=none
BUG=none
TEST=manual: benchmark RSA2048 with F4 exponent on STM32L432:
         -Os           -O3
@16Mhz 185163 us --> 111942 us
@80Mhz  39286 us -->  24582 us

Change-Id: I8c2e4b757f037f4f645fb73ba0faaaa471b24896
Reviewed-on: https://chromium-review.googlesource.com/445218
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
This commit is contained in:
Vincent Palatin
2017-02-21 09:10:19 +01:00
committed by chrome-bot
parent 7757a8e872
commit a1c8d50e9b
2 changed files with 11 additions and 0 deletions

View File

@@ -127,3 +127,8 @@ else
common-y+=test_util.o
endif
common-$(TEST_BUILD)+=sensor_common.o
ifneq ($(CONFIG_RSA_OPTIMIZED),)
$(out)/RW/common/rsa.o: CFLAGS+=-O3
$(out)/RO/common/rsa.o: CFLAGS+=-O3
endif

View File

@@ -1782,6 +1782,12 @@
/* Use RSA exponent 3 instead of F4 (65537) */
#undef CONFIG_RSA_EXPONENT_3
/*
* Adjust the compiler optimization flags for the RSA code to get a speed-up
* at the expense of a small code size delta.
*/
#undef CONFIG_RSA_OPTIMIZED
/*
* Verify the RW firmware using the RSA signature.
* (for accessories without software sync)