From 087e0379c5619d6fc9e366b5288dd94b49b68029 Mon Sep 17 00:00:00 2001 From: Paul Bakker Date: Mon, 14 Jan 2013 17:57:13 +0100 Subject: [PATCH] Moved mpi_inv_mod() outside POLARSSL_GENPRIME (cherry picked from commit d9374b05d67ca1abcfe0f6b289b6583b6257eee3) Conflicts: ChangeLog --- ChangeLog | 1 + library/bignum.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1872991631..587f686d9c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ Bugfix * Handle existence of OpenSSL Trust Extensions at end of X.509 DER blob * mpi_add_abs() now correctly handles adding short numbers to long numbers with carry rollover + * Moved mpi_inv_mod() outside POLARSSL_GENPRIME Security * Fixed potential memory zeroization on miscrafted RSA key (found by Eloi diff --git a/library/bignum.c b/library/bignum.c index 508730882a..052cc2513a 100644 --- a/library/bignum.c +++ b/library/bignum.c @@ -1627,8 +1627,6 @@ cleanup: return( ret ); } -#if defined(POLARSSL_GENPRIME) - /* * Modular inverse: X = A^-1 mod N (HAC 14.61 / 14.64) */ @@ -1724,6 +1722,8 @@ cleanup: return( ret ); } +#if defined(POLARSSL_GENPRIME) + static const int small_prime[] = { 3, 5, 7, 11, 13, 17, 19, 23,