gnunet-android

GNUnet for Android
Log | Files | Refs | README

mpi_superclass.h (3003B)


      1 /* mpi_superclass.h
      2  *
      3  * Copyright (C) 2006-2025 wolfSSL Inc.
      4  *
      5  * This file is part of wolfSSL.
      6  *
      7  * wolfSSL is free software; you can redistribute it and/or modify
      8  * it under the terms of the GNU General Public License as published by
      9  * the Free Software Foundation; either version 3 of the License, or
     10  * (at your option) any later version.
     11  *
     12  * wolfSSL is distributed in the hope that it will be useful,
     13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15  * GNU General Public License for more details.
     16  *
     17  * You should have received a copy of the GNU General Public License
     18  * along with this program; if not, write to the Free Software
     19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
     20  */
     21 
     22 
     23 
     24 /* super class file for PK algos */
     25 
     26 /* default ... include all MPI */
     27 #define LTM_ALL
     28 
     29 /* RSA only (does not support DH/DSA/ECC) */
     30 /* #define SC_RSA_1 */
     31 
     32 /* For reference.... On an Athlon64 optimizing for speed...
     33 
     34    LTM's mpi.o with all functions [striped] is 142KiB in size.
     35 
     36 */
     37 
     38 /* Works for RSA only, mpi.o is 68KiB */
     39 #ifdef SC_RSA_1
     40    #define BN_MP_SHRINK_C
     41    #define BN_MP_LCM_C
     42    #define BN_MP_PRIME_RANDOM_EX_C
     43    #define BN_MP_INVMOD_C
     44    #define BN_MP_GCD_C
     45    #define BN_MP_MOD_C
     46    #define BN_MP_MULMOD_C
     47    #define BN_MP_ADDMOD_C
     48    #define BN_MP_EXPTMOD_C
     49    #define BN_MP_SET_INT_C
     50    #define BN_MP_INIT_MULTI_C
     51    #define BN_MP_CLEAR_MULTI_C
     52    #define BN_MP_UNSIGNED_BIN_SIZE_C
     53    #define BN_MP_TO_UNSIGNED_BIN_C
     54    #define BN_MP_MOD_D_C
     55    #define BN_MP_PRIME_RABIN_MILLER_TRIALS_C
     56    #define BN_REVERSE_C
     57    #define BN_PRIME_TAB_C
     58 
     59    /* other modifiers */
     60    #define BN_MP_DIV_SMALL                    /* Slower division, not critical */
     61 
     62    /* here we are on the last pass so we turn things off.  The functions classes are still there
     63     * but we remove them specifically from the build.  This also invokes tweaks in functions
     64     * like removing support for even moduli, etc...
     65     */
     66 #ifdef LTM_LAST
     67    #undef  BN_MP_TOOM_MUL_C
     68    #undef  BN_MP_TOOM_SQR_C
     69    #undef  BN_MP_KARATSUBA_MUL_C
     70    #undef  BN_MP_KARATSUBA_SQR_C
     71    #undef  BN_MP_REDUCE_C
     72    #undef  BN_MP_REDUCE_SETUP_C
     73    #undef  BN_MP_DR_IS_MODULUS_C
     74    #undef  BN_MP_DR_SETUP_C
     75    #undef  BN_MP_DR_REDUCE_C
     76    #undef  BN_MP_REDUCE_IS_2K_C
     77    #undef  BN_MP_REDUCE_2K_SETUP_C
     78    #undef  BN_MP_REDUCE_2K_C
     79    #undef  BN_S_MP_EXPTMOD_C
     80    #undef  BN_MP_DIV_3_C
     81    #undef  BN_S_MP_MUL_HIGH_DIGS_C
     82    #undef  BN_FAST_S_MP_MUL_HIGH_DIGS_C
     83    #undef  BN_FAST_MP_INVMOD_C
     84 
     85    /* To safely undefine these you have to make sure your RSA key won't exceed the Comba threshold
     86     * which is roughly 255 digits [7140 bits for 32-bit machines, 15300 bits for 64-bit machines]
     87     * which means roughly speaking you can handle up to 2536-bit RSA keys with these defined without
     88     * trouble.
     89     */
     90    #undef  BN_S_MP_MUL_DIGS_C
     91    #undef  BN_S_MP_SQR_C
     92    #undef  BN_MP_MONTGOMERY_REDUCE_C
     93 #endif
     94 
     95 #endif
     96