mpi_superclass.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* super class file for PK algos */
  2. /* default ... include all MPI */
  3. #define LTM_ALL
  4. /* RSA only (does not support DH/DSA/ECC) */
  5. /* #define SC_RSA_1 */
  6. /* For reference.... On an Athlon64 optimizing for speed...
  7. LTM's mpi.o with all functions [striped] is 142KiB in size.
  8. */
  9. /* Works for RSA only, mpi.o is 68KiB */
  10. #ifdef SC_RSA_1
  11. #define BN_MP_SHRINK_C
  12. #define BN_MP_LCM_C
  13. #define BN_MP_PRIME_RANDOM_EX_C
  14. #define BN_MP_INVMOD_C
  15. #define BN_MP_GCD_C
  16. #define BN_MP_MOD_C
  17. #define BN_MP_MULMOD_C
  18. #define BN_MP_ADDMOD_C
  19. #define BN_MP_EXPTMOD_C
  20. #define BN_MP_SET_INT_C
  21. #define BN_MP_INIT_MULTI_C
  22. #define BN_MP_CLEAR_MULTI_C
  23. #define BN_MP_UNSIGNED_BIN_SIZE_C
  24. #define BN_MP_TO_UNSIGNED_BIN_C
  25. #define BN_MP_MOD_D_C
  26. #define BN_MP_PRIME_RABIN_MILLER_TRIALS_C
  27. #define BN_REVERSE_C
  28. #define BN_PRIME_TAB_C
  29. /* other modifiers */
  30. #define BN_MP_DIV_SMALL /* Slower division, not critical */
  31. /* here we are on the last pass so we turn things off. The functions classes are still there
  32. * but we remove them specifically from the build. This also invokes tweaks in functions
  33. * like removing support for even moduli, etc...
  34. */
  35. #ifdef LTM_LAST
  36. #undef BN_MP_TOOM_MUL_C
  37. #undef BN_MP_TOOM_SQR_C
  38. #undef BN_MP_KARATSUBA_MUL_C
  39. #undef BN_MP_KARATSUBA_SQR_C
  40. #undef BN_MP_REDUCE_C
  41. #undef BN_MP_REDUCE_SETUP_C
  42. #undef BN_MP_DR_IS_MODULUS_C
  43. #undef BN_MP_DR_SETUP_C
  44. #undef BN_MP_DR_REDUCE_C
  45. #undef BN_MP_REDUCE_IS_2K_C
  46. #undef BN_MP_REDUCE_2K_SETUP_C
  47. #undef BN_MP_REDUCE_2K_C
  48. #undef BN_S_MP_EXPTMOD_C
  49. #undef BN_MP_DIV_3_C
  50. #undef BN_S_MP_MUL_HIGH_DIGS_C
  51. #undef BN_FAST_S_MP_MUL_HIGH_DIGS_C
  52. #undef BN_FAST_MP_INVMOD_C
  53. /* To safely undefine these you have to make sure your RSA key won't exceed the Comba threshold
  54. * which is roughly 255 digits [7140 bits for 32-bit machines, 15300 bits for 64-bit machines]
  55. * which means roughly speaking you can handle upto 2536-bit RSA keys with these defined without
  56. * trouble.
  57. */
  58. #undef BN_S_MP_MUL_DIGS_C
  59. #undef BN_S_MP_SQR_C
  60. #undef BN_MP_MONTGOMERY_REDUCE_C
  61. #endif
  62. #endif