cyassl re-port with cellular comms, PSK test

Dependencies:   VodafoneUSBModem_bleedingedge2 mbed-rtos mbed-src

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mpi_superclass.h Source File

mpi_superclass.h

00001 /* mpi_superclass.h
00002  *
00003  * Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
00004  *
00005  * This file is part of CyaSSL.
00006  *
00007  * CyaSSL is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * CyaSSL is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
00020  */
00021 
00022 
00023 /* super class file for PK algos */
00024 
00025 /* default ... include all MPI */
00026 #define LTM_ALL
00027 
00028 /* RSA only (does not support DH/DSA/ECC) */
00029 /* #define SC_RSA_1 */
00030 
00031 /* For reference.... On an Athlon64 optimizing for speed...
00032 
00033    LTM's mpi.o with all functions [striped] is 142KiB in size.
00034 
00035 */
00036 
00037 /* Works for RSA only, mpi.o is 68KiB */
00038 #ifdef SC_RSA_1
00039    #define BN_MP_SHRINK_C
00040    #define BN_MP_LCM_C
00041    #define BN_MP_PRIME_RANDOM_EX_C
00042    #define BN_MP_INVMOD_C
00043    #define BN_MP_GCD_C
00044    #define BN_MP_MOD_C
00045    #define BN_MP_MULMOD_C
00046    #define BN_MP_ADDMOD_C
00047    #define BN_MP_EXPTMOD_C
00048    #define BN_MP_SET_INT_C
00049    #define BN_MP_INIT_MULTI_C
00050    #define BN_MP_CLEAR_MULTI_C
00051    #define BN_MP_UNSIGNED_BIN_SIZE_C
00052    #define BN_MP_TO_UNSIGNED_BIN_C
00053    #define BN_MP_MOD_D_C
00054    #define BN_MP_PRIME_RABIN_MILLER_TRIALS_C
00055    #define BN_REVERSE_C
00056    #define BN_PRIME_TAB_C
00057 
00058    /* other modifiers */
00059    #define BN_MP_DIV_SMALL                    /* Slower division, not critical */
00060 
00061    /* here we are on the last pass so we turn things off.  The functions classes are still there
00062     * but we remove them specifically from the build.  This also invokes tweaks in functions
00063     * like removing support for even moduli, etc...
00064     */
00065 #ifdef LTM_LAST
00066    #undef  BN_MP_TOOM_MUL_C
00067    #undef  BN_MP_TOOM_SQR_C
00068    #undef  BN_MP_KARATSUBA_MUL_C
00069    #undef  BN_MP_KARATSUBA_SQR_C
00070    #undef  BN_MP_REDUCE_C
00071    #undef  BN_MP_REDUCE_SETUP_C
00072    #undef  BN_MP_DR_IS_MODULUS_C
00073    #undef  BN_MP_DR_SETUP_C
00074    #undef  BN_MP_DR_REDUCE_C
00075    #undef  BN_MP_REDUCE_IS_2K_C
00076    #undef  BN_MP_REDUCE_2K_SETUP_C
00077    #undef  BN_MP_REDUCE_2K_C
00078    #undef  BN_S_MP_EXPTMOD_C
00079    #undef  BN_MP_DIV_3_C
00080    #undef  BN_S_MP_MUL_HIGH_DIGS_C
00081    #undef  BN_FAST_S_MP_MUL_HIGH_DIGS_C
00082    #undef  BN_FAST_MP_INVMOD_C
00083 
00084    /* To safely undefine these you have to make sure your RSA key won't exceed the Comba threshold
00085     * which is roughly 255 digits [7140 bits for 32-bit machines, 15300 bits for 64-bit machines] 
00086     * which means roughly speaking you can handle upto 2536-bit RSA keys with these defined without
00087     * trouble.  
00088     */
00089    #undef  BN_S_MP_MUL_DIGS_C
00090    #undef  BN_S_MP_SQR_C
00091    #undef  BN_MP_MONTGOMERY_REDUCE_C
00092 #endif
00093 
00094 #endif
00095