Browse Source

Combined internal LibTomMath configuration into one option

CONFIG_INTERNAL_LIBTOMMATH_FAST=y in .config can now be used to enable all
optimized routines at a cost of about 4 kB. This is small enough increase
in size to justify simplified configuration.
Jouni Malinen 17 years ago
parent
commit
b95394c66f
4 changed files with 21 additions and 30 deletions
  1. 11 11
      src/tls/libtommath.c
  2. 3 0
      wpa_supplicant/ChangeLog
  3. 2 8
      wpa_supplicant/Makefile
  4. 5 11
      wpa_supplicant/defconfig

+ 11 - 11
src/tls/libtommath.c

@@ -26,29 +26,29 @@
 #define BN_S_MP_SQR_C
 #define BN_S_MP_MUL_HIGH_DIGS_C /* Note: #undef in tommath_superclass.h; this
 				 * would require other than mp_reduce */
-#ifdef LTM_FAST_DIV
+
+#ifdef LTM_FAST
+
 /* Use faster div at the cost of about 1 kB */
 #define BN_MP_MUL_D_C
-#else /* LTM_FAST_DIV */
-#define BN_MP_DIV_SMALL
-#define BN_MP_INIT_MULTI_C
-#define BN_MP_CLEAR_MULTI_C
-#define BN_MP_ABS_C
-#endif /* LTM_FAST_DIV */
 
-#ifdef LTM_FAST_EXPTMOD
 /* Include faster exptmod (Montgomery) at the cost of about 2.5 kB in code */
 #define BN_MP_EXPTMOD_FAST_C
 #define BN_MP_MONTGOMERY_SETUP_C
 #define BN_FAST_MP_MONTGOMERY_REDUCE_C
 #define BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
 #define BN_MP_MUL_2_C
-#endif /* LTM_FAST_EXPTMOD */
 
-#ifdef LTM_FAST_SQR
 /* Include faster sqr at the cost of about 0.5 kB in code */
 #define BN_FAST_S_MP_SQR_C
-#endif /* LTM_FAST_SQR */
+
+#else /* LTM_FAST */
+
+#define BN_MP_DIV_SMALL
+#define BN_MP_INIT_MULTI_C
+#define BN_MP_CLEAR_MULTI_C
+#define BN_MP_ABS_C
+#endif /* LTM_FAST */
 
 /* Current uses do not require support for negative exponent in exptmod, so we
  * can save about 1.5 kB in leaving out invmod. */

+ 3 - 0
wpa_supplicant/ChangeLog

@@ -11,6 +11,9 @@ ChangeLog for wpa_supplicant
 	* added support for parsing PKCS #8 formatted private keys into the
 	  internal TLS implementation (both PKCS #1 RSA key and PKCS #8
 	  encapsulated RSA key can now be used)
+	* added option of using faster, but larger, routines in the internal
+	  LibTomMath (for internal TLS implementation) to speed up DH and RSA
+	  calculations (CONFIG_INTERNAL_LIBTOMMATH_FAST=y)
 
 2008-02-22 - v0.6.3
 	* removed 'nai' and 'eappsk' network configuration variables that were

+ 2 - 8
wpa_supplicant/Makefile

@@ -621,14 +621,8 @@ CFLAGS += -DCONFIG_TLS_INTERNAL_CLIENT
 ifeq ($(CONFIG_CRYPTO), internal)
 ifdef CONFIG_INTERNAL_LIBTOMMATH
 CFLAGS += -DCONFIG_INTERNAL_LIBTOMMATH
-ifdef CONFIG_INTERNAL_LIBTOMMATH_FAST_EXPTMOD
-CFLAGS += -DLTM_FAST_EXPTMOD
-endif
-ifdef CONFIG_INTERNAL_LIBTOMMATH_FAST_SQR
-CFLAGS += -DLTM_FAST_SQR
-endif
-ifdef CONFIG_INTERNAL_LIBTOMMATH_FAST_DIV
-CFLAGS += -DLTM_FAST_DIV
+ifdef CONFIG_INTERNAL_LIBTOMMATH_FAST
+CFLAGS += -DLTM_FAST
 endif
 else
 LIBS += -ltommath

+ 5 - 11
wpa_supplicant/defconfig

@@ -307,17 +307,11 @@ CONFIG_PEERKEY=y
 #LIBS += -L$(LTM_PATH)
 #LIBS_p += -L$(LTM_PATH)
 #endif
-# At the cost of about 2.5 kB of additional binarysize, the internal LibTomMath
-# can be configured to include fast exptmod routine to speed up DH and RSA.
-#CONFIG_INTERNAL_LIBTOMMATH_FAST_EXPTMOD=y
-# At the cost of about 0.5 kB of additional binary size, the internal
-# LibTomMath can be configured to include faster sqr routine to speed up DH and
-# RSA.
-#CONFIG_INTERNAL_LIBTOMMATH_FAST_SQR=y
-# At the cost of about 1 kB of additional binary size, the internal
-# LibTomMath can be configured to include faster div routine to speed up DH and
-# RSA.
-#CONFIG_INTERNAL_LIBTOMMATH_FAST_DIV=y
+# At the cost of about 4 kB of additional binary size, the internal LibTomMath
+# can be configured to include faster routines for exptmod, sqr, and div to
+# speed up DH and RSA calculation considerably (around 20% time removed on
+# Pentium 4)
+#CONFIG_INTERNAL_LIBTOMMATH_FAST=y
 
 # Include NDIS event processing through WMI into wpa_supplicant/wpasvc.
 # This is only for Windows builds and requires WMI-related header files and