In our last blog, the multi-precision math implementations in wolfCrypt were discussed with a feature comparison. In this blog we compare the performance of the SP Math All and Integer implementations.
The SP Math All library can be compiled with WOLFSSL_SP_SMALL (--enable-sp-math-all=small
) to be small in size, with lower performance, to suit embedded applications. The code is both smaller and faster than the Integer math library.
Let’s take a look at how much faster SP Math All is than Integer. (Note: SP Math All configured with –-enable-sp-math-all=small -–disable-asm C_EXTRA_FLAGS=-DWC_NO_HARDEN
, Integer configured with –-disable-fastmath
.)
x64 | Aarch64 | |
---|---|---|
RSA 2048 Sign | 81.43% | 50.46% |
RSA 2048 Verify | 993.81% | 522.14% |
DH 2048 Key Gen | 48.55% | 1.82% |
DH 2048 Agree | 65.16% | 12.71% |
ECC P-256 Key Gen | 45.22% | 112.74% |
ECC P-256 Agree | 43.74% | 111.60% |
ECC P-256 Sign | 55.01% | 118.90% |
ECC P-256 Verify | 62.54% | 127.31% |
The Elliptic Curve algorithms are consistently faster across the board – about 50% on x64 and 100% on Aarch64. The RSA and DH are variable but the RSA verify operation is much faster due to the optimized exponentiation implementation in SP Math All.
Now, code size is just as important if not more so! Let’s take ARM Cortex M4 as an example.
ARM Cortex-M4 (bytes) | Integer | SP Math All | |
---|---|---|---|
+RSA +DH +ECC | 23625 | 18672 | -20.97% |
+RSA +DH -ECC | 22492 | 16836 | -25.15% |
-RSA -DH +ECC | 21149 | 18232 | -13.79% |
All builds are smaller with a saving of up to 25% and the code is faster! Similar reductions are seen across all CPUs.
If you have any questions or run into any issues, contact us at facts@wolfssl.com, or call us at +1 425 245 8247.