A library for setting up Secure Socket Layer (SSL) connections and verifying remote hosts using certificates. Contains only the source files for mbed platform implementation of the library.

Dependents:   HTTPClient-SSL HTTPClient-SSL HTTPClient-SSL HTTPClient-SSL

Committer:
Vanger
Date:
Mon Jan 19 21:45:42 2015 +0000
Revision:
0:b86d15c6ba29
Updated CyaSSL Library to 3.3.0. Changed Settings and functions to be implemented for mbed platforms

Who changed what in which revision?

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