From 1859a853508d080e335d30c39a0b3febf3d576c8 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 7 Oct 2013 14:00:21 -0500 Subject: [PATCH] libtommath: protect functions by tommath_class macros libtommath protects the inclusion of functions by wrapping their declarations by CPP #ifdef tests and defining the matching macros within libtommath_class.h. Add missing macros: BN_MP_FIND_PRIME_C BN_MP_ISPRIME_C Change-Id: Ic577300114f8e88d7a3af3d9f717a249d57f03b1 --- lib/hcrypto/libtommath/bn_mp_find_prime.c | 3 ++- lib/hcrypto/libtommath/bn_mp_isprime.c | 3 ++- lib/hcrypto/libtommath/tommath_class.h | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/hcrypto/libtommath/bn_mp_find_prime.c b/lib/hcrypto/libtommath/bn_mp_find_prime.c index ef7b6532c..d007acbef 100644 --- a/lib/hcrypto/libtommath/bn_mp_find_prime.c +++ b/lib/hcrypto/libtommath/bn_mp_find_prime.c @@ -5,7 +5,7 @@ * Love Hornquist Astrand */ #include - +#ifdef BN_MP_FIND_PRIME_C int mp_find_prime(mp_int *a) { int res; @@ -24,3 +24,4 @@ int mp_find_prime(mp_int *a) return res; } +#endif diff --git a/lib/hcrypto/libtommath/bn_mp_isprime.c b/lib/hcrypto/libtommath/bn_mp_isprime.c index d3678d5dc..f12358778 100644 --- a/lib/hcrypto/libtommath/bn_mp_isprime.c +++ b/lib/hcrypto/libtommath/bn_mp_isprime.c @@ -8,7 +8,7 @@ * Tom St Denis, tomstdenis@gmail.com */ #include - +#ifdef BN_MP_ISPRIME_C /* a few primes */ static const mp_digit primes[256] = { 0x0002, 0x0003, 0x0005, 0x0007, 0x000B, 0x000D, 0x0011, 0x0013, @@ -73,3 +73,4 @@ int mp_isprime(mp_int *a) } return MP_YES; } +#endif diff --git a/lib/hcrypto/libtommath/tommath_class.h b/lib/hcrypto/libtommath/tommath_class.h index fa95a0277..8fd0f52f4 100644 --- a/lib/hcrypto/libtommath/tommath_class.h +++ b/lib/hcrypto/libtommath/tommath_class.h @@ -42,6 +42,7 @@ #define BN_MP_EXPTMOD_C #define BN_MP_EXPTMOD_FAST_C #define BN_MP_EXTEUCLID_C +#define BN_MP_FIND_PRIME_C #define BN_MP_FREAD_C #define BN_MP_FWRITE_C #define BN_MP_GCD_C @@ -55,6 +56,7 @@ #define BN_MP_INIT_SIZE_C #define BN_MP_INVMOD_C #define BN_MP_INVMOD_SLOW_C +#define BN_MP_ISPRIME_C #define BN_MP_IS_SQUARE_C #define BN_MP_JACOBI_C #define BN_MP_KARATSUBA_MUL_C