cyassl re-port with cellular comms, PSK test

Dependencies:   VodafoneUSBModem_bleedingedge2 mbed-rtos mbed-src

Committer:
ashleymills
Date:
Fri Apr 26 16:54:58 2013 +0000
Revision:
0:e979170e02e7
Basic operation of SSL with PSK working for cellular.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ashleymills 0:e979170e02e7 1 /* integer.h
ashleymills 0:e979170e02e7 2 *
ashleymills 0:e979170e02e7 3 * Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
ashleymills 0:e979170e02e7 4 *
ashleymills 0:e979170e02e7 5 * This file is part of CyaSSL.
ashleymills 0:e979170e02e7 6 *
ashleymills 0:e979170e02e7 7 * CyaSSL is free software; you can redistribute it and/or modify
ashleymills 0:e979170e02e7 8 * it under the terms of the GNU General Public License as published by
ashleymills 0:e979170e02e7 9 * the Free Software Foundation; either version 2 of the License, or
ashleymills 0:e979170e02e7 10 * (at your option) any later version.
ashleymills 0:e979170e02e7 11 *
ashleymills 0:e979170e02e7 12 * CyaSSL is distributed in the hope that it will be useful,
ashleymills 0:e979170e02e7 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ashleymills 0:e979170e02e7 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ashleymills 0:e979170e02e7 15 * GNU General Public License for more details.
ashleymills 0:e979170e02e7 16 *
ashleymills 0:e979170e02e7 17 * You should have received a copy of the GNU General Public License
ashleymills 0:e979170e02e7 18 * along with this program; if not, write to the Free Software
ashleymills 0:e979170e02e7 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
ashleymills 0:e979170e02e7 20 */
ashleymills 0:e979170e02e7 21
ashleymills 0:e979170e02e7 22 /*
ashleymills 0:e979170e02e7 23 * Based on public domain LibTomMath 0.38 by Tom St Denis, tomstdenis@iahu.ca,
ashleymills 0:e979170e02e7 24 * http://math.libtomcrypt.com
ashleymills 0:e979170e02e7 25 */
ashleymills 0:e979170e02e7 26
ashleymills 0:e979170e02e7 27
ashleymills 0:e979170e02e7 28 #ifndef CTAO_CRYPT_INTEGER_H
ashleymills 0:e979170e02e7 29 #define CTAO_CRYPT_INTEGER_H
ashleymills 0:e979170e02e7 30
ashleymills 0:e979170e02e7 31 /* may optionally use fast math instead, not yet supported on all platforms and
ashleymills 0:e979170e02e7 32 may not be faster on all
ashleymills 0:e979170e02e7 33 */
ashleymills 0:e979170e02e7 34 #include <cyassl/ctaocrypt/types.h> /* will set MP_xxBIT if not default */
ashleymills 0:e979170e02e7 35 #ifdef USE_FAST_MATH
ashleymills 0:e979170e02e7 36 #include <cyassl/ctaocrypt/tfm.h>
ashleymills 0:e979170e02e7 37 #else
ashleymills 0:e979170e02e7 38
ashleymills 0:e979170e02e7 39 #ifndef CHAR_BIT
ashleymills 0:e979170e02e7 40 #include <limits.h>
ashleymills 0:e979170e02e7 41 #endif
ashleymills 0:e979170e02e7 42
ashleymills 0:e979170e02e7 43 #include <cyassl/ctaocrypt/mpi_class.h>
ashleymills 0:e979170e02e7 44
ashleymills 0:e979170e02e7 45 #ifndef MIN
ashleymills 0:e979170e02e7 46 #define MIN(x,y) ((x)<(y)?(x):(y))
ashleymills 0:e979170e02e7 47 #endif
ashleymills 0:e979170e02e7 48
ashleymills 0:e979170e02e7 49 #ifndef MAX
ashleymills 0:e979170e02e7 50 #define MAX(x,y) ((x)>(y)?(x):(y))
ashleymills 0:e979170e02e7 51 #endif
ashleymills 0:e979170e02e7 52
ashleymills 0:e979170e02e7 53 #ifdef __cplusplus
ashleymills 0:e979170e02e7 54 extern "C" {
ashleymills 0:e979170e02e7 55
ashleymills 0:e979170e02e7 56 /* C++ compilers don't like assigning void * to mp_digit * */
ashleymills 0:e979170e02e7 57 #define OPT_CAST(x) (x *)
ashleymills 0:e979170e02e7 58
ashleymills 0:e979170e02e7 59 #else
ashleymills 0:e979170e02e7 60
ashleymills 0:e979170e02e7 61 /* C on the other hand doesn't care */
ashleymills 0:e979170e02e7 62 #define OPT_CAST(x)
ashleymills 0:e979170e02e7 63
ashleymills 0:e979170e02e7 64 #endif
ashleymills 0:e979170e02e7 65
ashleymills 0:e979170e02e7 66
ashleymills 0:e979170e02e7 67 /* detect 64-bit mode if possible */
ashleymills 0:e979170e02e7 68 #if defined(__x86_64__)
ashleymills 0:e979170e02e7 69 #if !(defined(MP_64BIT) && defined(MP_16BIT) && defined(MP_8BIT))
ashleymills 0:e979170e02e7 70 #define MP_64BIT
ashleymills 0:e979170e02e7 71 #endif
ashleymills 0:e979170e02e7 72 #endif
ashleymills 0:e979170e02e7 73
ashleymills 0:e979170e02e7 74 /* some default configurations.
ashleymills 0:e979170e02e7 75 *
ashleymills 0:e979170e02e7 76 * A "mp_digit" must be able to hold DIGIT_BIT + 1 bits
ashleymills 0:e979170e02e7 77 * A "mp_word" must be able to hold 2*DIGIT_BIT + 1 bits
ashleymills 0:e979170e02e7 78 *
ashleymills 0:e979170e02e7 79 * At the very least a mp_digit must be able to hold 7 bits
ashleymills 0:e979170e02e7 80 * [any size beyond that is ok provided it doesn't overflow the data type]
ashleymills 0:e979170e02e7 81 */
ashleymills 0:e979170e02e7 82 #ifdef MP_8BIT
ashleymills 0:e979170e02e7 83 typedef unsigned char mp_digit;
ashleymills 0:e979170e02e7 84 typedef unsigned short mp_word;
ashleymills 0:e979170e02e7 85 #elif defined(MP_16BIT)
ashleymills 0:e979170e02e7 86 typedef unsigned short mp_digit;
ashleymills 0:e979170e02e7 87 typedef unsigned long mp_word;
ashleymills 0:e979170e02e7 88 #elif defined(MP_64BIT)
ashleymills 0:e979170e02e7 89 /* for GCC only on supported platforms */
ashleymills 0:e979170e02e7 90 #ifndef CRYPT
ashleymills 0:e979170e02e7 91 typedef unsigned long long ulong64;
ashleymills 0:e979170e02e7 92 typedef signed long long long64;
ashleymills 0:e979170e02e7 93 #endif
ashleymills 0:e979170e02e7 94
ashleymills 0:e979170e02e7 95 typedef unsigned long mp_digit;
ashleymills 0:e979170e02e7 96 typedef unsigned long mp_word __attribute__ ((mode(TI)));
ashleymills 0:e979170e02e7 97
ashleymills 0:e979170e02e7 98 #define DIGIT_BIT 60
ashleymills 0:e979170e02e7 99 #else
ashleymills 0:e979170e02e7 100 /* this is the default case, 28-bit digits */
ashleymills 0:e979170e02e7 101
ashleymills 0:e979170e02e7 102 /* this is to make porting into LibTomCrypt easier :-) */
ashleymills 0:e979170e02e7 103 #ifndef CRYPT
ashleymills 0:e979170e02e7 104 #if defined(_MSC_VER) || defined(__BORLANDC__)
ashleymills 0:e979170e02e7 105 typedef unsigned __int64 ulong64;
ashleymills 0:e979170e02e7 106 typedef signed __int64 long64;
ashleymills 0:e979170e02e7 107 #else
ashleymills 0:e979170e02e7 108 typedef unsigned long long ulong64;
ashleymills 0:e979170e02e7 109 typedef signed long long long64;
ashleymills 0:e979170e02e7 110 #endif
ashleymills 0:e979170e02e7 111 #endif
ashleymills 0:e979170e02e7 112
ashleymills 0:e979170e02e7 113 typedef unsigned int mp_digit; /* long could be 64 now, changed TAO */
ashleymills 0:e979170e02e7 114 typedef ulong64 mp_word;
ashleymills 0:e979170e02e7 115
ashleymills 0:e979170e02e7 116 #ifdef MP_31BIT
ashleymills 0:e979170e02e7 117 /* this is an extension that uses 31-bit digits */
ashleymills 0:e979170e02e7 118 #define DIGIT_BIT 31
ashleymills 0:e979170e02e7 119 #else
ashleymills 0:e979170e02e7 120 /* default case is 28-bit digits, defines MP_28BIT as a handy test macro */
ashleymills 0:e979170e02e7 121 #define DIGIT_BIT 28
ashleymills 0:e979170e02e7 122 #define MP_28BIT
ashleymills 0:e979170e02e7 123 #endif
ashleymills 0:e979170e02e7 124 #endif
ashleymills 0:e979170e02e7 125
ashleymills 0:e979170e02e7 126
ashleymills 0:e979170e02e7 127 /* otherwise the bits per digit is calculated automatically from the size of
ashleymills 0:e979170e02e7 128 a mp_digit */
ashleymills 0:e979170e02e7 129 #ifndef DIGIT_BIT
ashleymills 0:e979170e02e7 130 #define DIGIT_BIT ((int)((CHAR_BIT * sizeof(mp_digit) - 1)))
ashleymills 0:e979170e02e7 131 /* bits per digit */
ashleymills 0:e979170e02e7 132 #endif
ashleymills 0:e979170e02e7 133
ashleymills 0:e979170e02e7 134 #define MP_DIGIT_BIT DIGIT_BIT
ashleymills 0:e979170e02e7 135 #define MP_MASK ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1))
ashleymills 0:e979170e02e7 136 #define MP_DIGIT_MAX MP_MASK
ashleymills 0:e979170e02e7 137
ashleymills 0:e979170e02e7 138 /* equalities */
ashleymills 0:e979170e02e7 139 #define MP_LT -1 /* less than */
ashleymills 0:e979170e02e7 140 #define MP_EQ 0 /* equal to */
ashleymills 0:e979170e02e7 141 #define MP_GT 1 /* greater than */
ashleymills 0:e979170e02e7 142
ashleymills 0:e979170e02e7 143 #define MP_ZPOS 0 /* positive integer */
ashleymills 0:e979170e02e7 144 #define MP_NEG 1 /* negative */
ashleymills 0:e979170e02e7 145
ashleymills 0:e979170e02e7 146 #define MP_OKAY 0 /* ok result */
ashleymills 0:e979170e02e7 147 #define MP_MEM -2 /* out of mem */
ashleymills 0:e979170e02e7 148 #define MP_VAL -3 /* invalid input */
ashleymills 0:e979170e02e7 149 #define MP_RANGE MP_VAL
ashleymills 0:e979170e02e7 150
ashleymills 0:e979170e02e7 151 #define MP_YES 1 /* yes response */
ashleymills 0:e979170e02e7 152 #define MP_NO 0 /* no response */
ashleymills 0:e979170e02e7 153
ashleymills 0:e979170e02e7 154 /* Primality generation flags */
ashleymills 0:e979170e02e7 155 #define LTM_PRIME_BBS 0x0001 /* BBS style prime */
ashleymills 0:e979170e02e7 156 #define LTM_PRIME_SAFE 0x0002 /* Safe prime (p-1)/2 == prime */
ashleymills 0:e979170e02e7 157 #define LTM_PRIME_2MSB_ON 0x0008 /* force 2nd MSB to 1 */
ashleymills 0:e979170e02e7 158
ashleymills 0:e979170e02e7 159 typedef int mp_err;
ashleymills 0:e979170e02e7 160
ashleymills 0:e979170e02e7 161 /* define this to use lower memory usage routines (exptmods mostly) */
ashleymills 0:e979170e02e7 162 #define MP_LOW_MEM
ashleymills 0:e979170e02e7 163
ashleymills 0:e979170e02e7 164 /* default precision */
ashleymills 0:e979170e02e7 165 #ifndef MP_PREC
ashleymills 0:e979170e02e7 166 #ifndef MP_LOW_MEM
ashleymills 0:e979170e02e7 167 #define MP_PREC 32 /* default digits of precision */
ashleymills 0:e979170e02e7 168 #else
ashleymills 0:e979170e02e7 169 #define MP_PREC 1 /* default digits of precision */
ashleymills 0:e979170e02e7 170 #endif
ashleymills 0:e979170e02e7 171 #endif
ashleymills 0:e979170e02e7 172
ashleymills 0:e979170e02e7 173 /* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD -
ashleymills 0:e979170e02e7 174 BITS_PER_DIGIT*2) */
ashleymills 0:e979170e02e7 175 #define MP_WARRAY (1 << (sizeof(mp_word) * CHAR_BIT - 2 * DIGIT_BIT + 1))
ashleymills 0:e979170e02e7 176
ashleymills 0:e979170e02e7 177 /* the infamous mp_int structure */
ashleymills 0:e979170e02e7 178 typedef struct {
ashleymills 0:e979170e02e7 179 int used, alloc, sign;
ashleymills 0:e979170e02e7 180 mp_digit *dp;
ashleymills 0:e979170e02e7 181 } mp_int;
ashleymills 0:e979170e02e7 182
ashleymills 0:e979170e02e7 183 /* callback for mp_prime_random, should fill dst with random bytes and return
ashleymills 0:e979170e02e7 184 how many read [upto len] */
ashleymills 0:e979170e02e7 185 typedef int ltm_prime_callback(unsigned char *dst, int len, void *dat);
ashleymills 0:e979170e02e7 186
ashleymills 0:e979170e02e7 187
ashleymills 0:e979170e02e7 188 #define USED(m) ((m)->used)
ashleymills 0:e979170e02e7 189 #define DIGIT(m,k) ((m)->dp[(k)])
ashleymills 0:e979170e02e7 190 #define SIGN(m) ((m)->sign)
ashleymills 0:e979170e02e7 191
ashleymills 0:e979170e02e7 192
ashleymills 0:e979170e02e7 193 /* ---> Basic Manipulations <--- */
ashleymills 0:e979170e02e7 194 #define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO)
ashleymills 0:e979170e02e7 195 #define mp_iseven(a) \
ashleymills 0:e979170e02e7 196 (((a)->used > 0 && (((a)->dp[0] & 1) == 0)) ? MP_YES : MP_NO)
ashleymills 0:e979170e02e7 197 #define mp_isodd(a) \
ashleymills 0:e979170e02e7 198 (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? MP_YES : MP_NO)
ashleymills 0:e979170e02e7 199
ashleymills 0:e979170e02e7 200
ashleymills 0:e979170e02e7 201 /* number of primes */
ashleymills 0:e979170e02e7 202 #ifdef MP_8BIT
ashleymills 0:e979170e02e7 203 #define PRIME_SIZE 31
ashleymills 0:e979170e02e7 204 #else
ashleymills 0:e979170e02e7 205 #define PRIME_SIZE 256
ashleymills 0:e979170e02e7 206 #endif
ashleymills 0:e979170e02e7 207
ashleymills 0:e979170e02e7 208 #define mp_prime_random(a, t, size, bbs, cb, dat) \
ashleymills 0:e979170e02e7 209 mp_prime_random_ex(a, t, ((size) * 8) + 1, (bbs==1)?LTM_PRIME_BBS:0, cb, dat)
ashleymills 0:e979170e02e7 210
ashleymills 0:e979170e02e7 211 #define mp_read_raw(mp, str, len) mp_read_signed_bin((mp), (str), (len))
ashleymills 0:e979170e02e7 212 #define mp_raw_size(mp) mp_signed_bin_size(mp)
ashleymills 0:e979170e02e7 213 #define mp_toraw(mp, str) mp_to_signed_bin((mp), (str))
ashleymills 0:e979170e02e7 214 #define mp_read_mag(mp, str, len) mp_read_unsigned_bin((mp), (str), (len))
ashleymills 0:e979170e02e7 215 #define mp_mag_size(mp) mp_unsigned_bin_size(mp)
ashleymills 0:e979170e02e7 216 #define mp_tomag(mp, str) mp_to_unsigned_bin((mp), (str))
ashleymills 0:e979170e02e7 217
ashleymills 0:e979170e02e7 218 #define mp_tobinary(M, S) mp_toradix((M), (S), 2)
ashleymills 0:e979170e02e7 219 #define mp_tooctal(M, S) mp_toradix((M), (S), 8)
ashleymills 0:e979170e02e7 220 #define mp_todecimal(M, S) mp_toradix((M), (S), 10)
ashleymills 0:e979170e02e7 221 #define mp_tohex(M, S) mp_toradix((M), (S), 16)
ashleymills 0:e979170e02e7 222
ashleymills 0:e979170e02e7 223 #define s_mp_mul(a, b, c) s_mp_mul_digs(a, b, c, (a)->used + (b)->used + 1)
ashleymills 0:e979170e02e7 224
ashleymills 0:e979170e02e7 225 extern const char *mp_s_rmap;
ashleymills 0:e979170e02e7 226
ashleymills 0:e979170e02e7 227 /* 6 functions needed by Rsa */
ashleymills 0:e979170e02e7 228 int mp_init (mp_int * a);
ashleymills 0:e979170e02e7 229 void mp_clear (mp_int * a);
ashleymills 0:e979170e02e7 230 int mp_unsigned_bin_size(mp_int * a);
ashleymills 0:e979170e02e7 231 int mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c);
ashleymills 0:e979170e02e7 232 int mp_to_unsigned_bin (mp_int * a, unsigned char *b);
ashleymills 0:e979170e02e7 233 int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y);
ashleymills 0:e979170e02e7 234 /* end functions needed by Rsa */
ashleymills 0:e979170e02e7 235
ashleymills 0:e979170e02e7 236 /* functions added to support above needed, removed TOOM and KARATSUBA */
ashleymills 0:e979170e02e7 237 int mp_count_bits (mp_int * a);
ashleymills 0:e979170e02e7 238 int mp_init_copy (mp_int * a, mp_int * b);
ashleymills 0:e979170e02e7 239 int mp_copy (mp_int * a, mp_int * b);
ashleymills 0:e979170e02e7 240 int mp_grow (mp_int * a, int size);
ashleymills 0:e979170e02e7 241 void bn_reverse (unsigned char *s, int len);
ashleymills 0:e979170e02e7 242 int mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d);
ashleymills 0:e979170e02e7 243 void mp_zero (mp_int * a);
ashleymills 0:e979170e02e7 244 void mp_clamp (mp_int * a);
ashleymills 0:e979170e02e7 245 void mp_exch (mp_int * a, mp_int * b);
ashleymills 0:e979170e02e7 246 void mp_rshd (mp_int * a, int b);
ashleymills 0:e979170e02e7 247 int mp_mod_2d (mp_int * a, int b, mp_int * c);
ashleymills 0:e979170e02e7 248 int mp_mul_2d (mp_int * a, int b, mp_int * c);
ashleymills 0:e979170e02e7 249 int mp_lshd (mp_int * a, int b);
ashleymills 0:e979170e02e7 250 int mp_abs (mp_int * a, mp_int * b);
ashleymills 0:e979170e02e7 251 int mp_invmod (mp_int * a, mp_int * b, mp_int * c);
ashleymills 0:e979170e02e7 252 int fast_mp_invmod (mp_int * a, mp_int * b, mp_int * c);
ashleymills 0:e979170e02e7 253 int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c);
ashleymills 0:e979170e02e7 254 int mp_cmp_mag (mp_int * a, mp_int * b);
ashleymills 0:e979170e02e7 255 int mp_cmp (mp_int * a, mp_int * b);
ashleymills 0:e979170e02e7 256 int mp_cmp_d(mp_int * a, mp_digit b);
ashleymills 0:e979170e02e7 257 void mp_set (mp_int * a, mp_digit b);
ashleymills 0:e979170e02e7 258 int mp_mod (mp_int * a, mp_int * b, mp_int * c);
ashleymills 0:e979170e02e7 259 int mp_div(mp_int * a, mp_int * b, mp_int * c, mp_int * d);
ashleymills 0:e979170e02e7 260 int mp_div_2(mp_int * a, mp_int * b);
ashleymills 0:e979170e02e7 261 int mp_add (mp_int * a, mp_int * b, mp_int * c);
ashleymills 0:e979170e02e7 262 int s_mp_add (mp_int * a, mp_int * b, mp_int * c);
ashleymills 0:e979170e02e7 263 int s_mp_sub (mp_int * a, mp_int * b, mp_int * c);
ashleymills 0:e979170e02e7 264 int mp_sub (mp_int * a, mp_int * b, mp_int * c);
ashleymills 0:e979170e02e7 265 int mp_reduce_is_2k_l(mp_int *a);
ashleymills 0:e979170e02e7 266 int mp_reduce_is_2k(mp_int *a);
ashleymills 0:e979170e02e7 267 int mp_dr_is_modulus(mp_int *a);
ashleymills 0:e979170e02e7 268 int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int);
ashleymills 0:e979170e02e7 269 int mp_montgomery_setup (mp_int * n, mp_digit * rho);
ashleymills 0:e979170e02e7 270 int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho);
ashleymills 0:e979170e02e7 271 int mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho);
ashleymills 0:e979170e02e7 272 void mp_dr_setup(mp_int *a, mp_digit *d);
ashleymills 0:e979170e02e7 273 int mp_dr_reduce (mp_int * x, mp_int * n, mp_digit k);
ashleymills 0:e979170e02e7 274 int mp_reduce_2k(mp_int *a, mp_int *n, mp_digit d);
ashleymills 0:e979170e02e7 275 int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs);
ashleymills 0:e979170e02e7 276 int s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs);
ashleymills 0:e979170e02e7 277 int mp_reduce_2k_setup_l(mp_int *a, mp_int *d);
ashleymills 0:e979170e02e7 278 int mp_reduce_2k_l(mp_int *a, mp_int *n, mp_int *d);
ashleymills 0:e979170e02e7 279 int mp_reduce (mp_int * x, mp_int * m, mp_int * mu);
ashleymills 0:e979170e02e7 280 int mp_reduce_setup (mp_int * a, mp_int * b);
ashleymills 0:e979170e02e7 281 int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode);
ashleymills 0:e979170e02e7 282 int mp_montgomery_calc_normalization (mp_int * a, mp_int * b);
ashleymills 0:e979170e02e7 283 int s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs);
ashleymills 0:e979170e02e7 284 int s_mp_sqr (mp_int * a, mp_int * b);
ashleymills 0:e979170e02e7 285 int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs);
ashleymills 0:e979170e02e7 286 int fast_s_mp_sqr (mp_int * a, mp_int * b);
ashleymills 0:e979170e02e7 287 int mp_init_size (mp_int * a, int size);
ashleymills 0:e979170e02e7 288 int mp_div_3 (mp_int * a, mp_int *c, mp_digit * d);
ashleymills 0:e979170e02e7 289 int mp_mul_2(mp_int * a, mp_int * b);
ashleymills 0:e979170e02e7 290 int mp_mul (mp_int * a, mp_int * b, mp_int * c);
ashleymills 0:e979170e02e7 291 int mp_sqr (mp_int * a, mp_int * b);
ashleymills 0:e979170e02e7 292 int mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d);
ashleymills 0:e979170e02e7 293 int mp_mul_d (mp_int * a, mp_digit b, mp_int * c);
ashleymills 0:e979170e02e7 294 int mp_2expt (mp_int * a, int b);
ashleymills 0:e979170e02e7 295 int mp_reduce_2k_setup(mp_int *a, mp_digit *d);
ashleymills 0:e979170e02e7 296 int mp_add_d (mp_int* a, mp_digit b, mp_int* c);
ashleymills 0:e979170e02e7 297 int mp_set_int (mp_int * a, unsigned long b);
ashleymills 0:e979170e02e7 298 /* end support added functions */
ashleymills 0:e979170e02e7 299
ashleymills 0:e979170e02e7 300 /* added */
ashleymills 0:e979170e02e7 301 int mp_init_multi(mp_int* a, mp_int* b, mp_int* c, mp_int* d, mp_int* e,
ashleymills 0:e979170e02e7 302 mp_int* f);
ashleymills 0:e979170e02e7 303
ashleymills 0:e979170e02e7 304 #if defined(HAVE_ECC) || defined(CYASSL_KEY_GEN)
ashleymills 0:e979170e02e7 305 int mp_sqrmod(mp_int* a, mp_int* b, mp_int* c);
ashleymills 0:e979170e02e7 306 #endif
ashleymills 0:e979170e02e7 307 #ifdef HAVE_ECC
ashleymills 0:e979170e02e7 308 int mp_read_radix(mp_int* a, const char* str, int radix);
ashleymills 0:e979170e02e7 309 #endif
ashleymills 0:e979170e02e7 310
ashleymills 0:e979170e02e7 311 #ifdef CYASSL_KEY_GEN
ashleymills 0:e979170e02e7 312 int mp_prime_is_prime (mp_int * a, int t, int *result);
ashleymills 0:e979170e02e7 313 int mp_gcd (mp_int * a, mp_int * b, mp_int * c);
ashleymills 0:e979170e02e7 314 int mp_lcm (mp_int * a, mp_int * b, mp_int * c);
ashleymills 0:e979170e02e7 315 #endif
ashleymills 0:e979170e02e7 316
ashleymills 0:e979170e02e7 317 #if defined(CYASSL_KEY_GEN) || defined(HAVE_ECC) || !defined(NO_PWDBASED)
ashleymills 0:e979170e02e7 318 int mp_sub_d (mp_int * a, mp_digit b, mp_int * c);
ashleymills 0:e979170e02e7 319 #endif
ashleymills 0:e979170e02e7 320
ashleymills 0:e979170e02e7 321 #ifdef __cplusplus
ashleymills 0:e979170e02e7 322 }
ashleymills 0:e979170e02e7 323 #endif
ashleymills 0:e979170e02e7 324
ashleymills 0:e979170e02e7 325
ashleymills 0:e979170e02e7 326 #endif /* USE_FAST_MATH */
ashleymills 0:e979170e02e7 327
ashleymills 0:e979170e02e7 328 #endif /* CTAO_CRYPT_INTEGER_H */
ashleymills 0:e979170e02e7 329