[Gnuk-users] [PATCH 4/7] polarssl: replace BIGNUM_C_IMPLEMENTATION check
Aurelien Jarno
aurelien at aurel32.net
Thu Oct 12 20:02:22 UTC 2017
Replace the BIGNUM_C_IMPLEMENTATION check by a check on POLARSSL_HAVE_ASM
and __arm__. This way it's possible to use this code on non arm, but
also to run the GNU/Linux emulation on an arm machine, which is useful
for debugging and profiling.
---
polarssl/library/bignum.c | 12 ++++++------
src/Makefile | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/polarssl/library/bignum.c b/polarssl/library/bignum.c
index cb1b345..2cf9bfb 100644
--- a/polarssl/library/bignum.c
+++ b/polarssl/library/bignum.c
@@ -1524,12 +1524,7 @@ static void mpi_montred( size_t n, const t_uint *np, t_uint mm, t_uint *d )
*/
static void mpi_montsqr( size_t n, const t_uint *np, t_uint mm, t_uint *d )
{
-#ifdef BIGNUM_C_IMPLEMENTATION
- t_uint a_input[n];
-
- memcpy (a_input, &d[n], sizeof (a_input));
- mpi_montmul (n, np, mm, d, a_input);
-#else
+#if defined(POLARSSL_HAVE_ASM) && defined(__arm__)
size_t i;
register t_uint c = 0;
@@ -1614,6 +1609,11 @@ static void mpi_montsqr( size_t n, const t_uint *np, t_uint mm, t_uint *d )
mpi_sub_hlp( n, np, d );
else
mpi_sub_hlp( n, d - n, d - n);
+#else
+ t_uint a_input[n];
+
+ memcpy (a_input, &d[n], sizeof (a_input));
+ mpi_montmul (n, np, mm, d, a_input);
#endif
}
diff --git a/src/Makefile b/src/Makefile
index 1a755a3..5c728e6 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -34,7 +34,7 @@ USE_EVENTFLAG = yes
ifeq ($(EMULATION),)
DEFS += -DFLASH_UPGRADE_SUPPORT
else
-DEFS += -DBN256_C_IMPLEMENTATION -DBIGNUM_C_IMPLEMENTATION
+DEFS += -DBN256_C_IMPLEMENTATION
endif
ifneq ($(ENABLE_DEBUG),)
--
2.14.2
More information about the gnuk-users
mailing list