Xuyi Wang / wolfSSL

Dependents:   OS

Committer:
wolfSSL
Date:
Sat Aug 18 22:20:43 2018 +0000
Revision:
15:117db924cf7c
wolfSSL 3.15.3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolfSSL 15:117db924cf7c 1 /* wolfmath.h
wolfSSL 15:117db924cf7c 2 *
wolfSSL 15:117db924cf7c 3 * Copyright (C) 2006-2017 wolfSSL Inc.
wolfSSL 15:117db924cf7c 4 *
wolfSSL 15:117db924cf7c 5 * This file is part of wolfSSL.
wolfSSL 15:117db924cf7c 6 *
wolfSSL 15:117db924cf7c 7 * wolfSSL is free software; you can redistribute it and/or modify
wolfSSL 15:117db924cf7c 8 * it under the terms of the GNU General Public License as published by
wolfSSL 15:117db924cf7c 9 * the Free Software Foundation; either version 2 of the License, or
wolfSSL 15:117db924cf7c 10 * (at your option) any later version.
wolfSSL 15:117db924cf7c 11 *
wolfSSL 15:117db924cf7c 12 * wolfSSL is distributed in the hope that it will be useful,
wolfSSL 15:117db924cf7c 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
wolfSSL 15:117db924cf7c 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wolfSSL 15:117db924cf7c 15 * GNU General Public License for more details.
wolfSSL 15:117db924cf7c 16 *
wolfSSL 15:117db924cf7c 17 * You should have received a copy of the GNU General Public License
wolfSSL 15:117db924cf7c 18 * along with this program; if not, write to the Free Software
wolfSSL 15:117db924cf7c 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
wolfSSL 15:117db924cf7c 20 */
wolfSSL 15:117db924cf7c 21
wolfSSL 15:117db924cf7c 22 #if defined(HAVE_WOLF_BIGINT) && !defined(WOLF_BIGINT_DEFINED)
wolfSSL 15:117db924cf7c 23 /* raw big integer */
wolfSSL 15:117db924cf7c 24 typedef struct WC_BIGINT {
wolfSSL 15:117db924cf7c 25 byte* buf;
wolfSSL 15:117db924cf7c 26 word32 len;
wolfSSL 15:117db924cf7c 27 void* heap;
wolfSSL 15:117db924cf7c 28 } WC_BIGINT;
wolfSSL 15:117db924cf7c 29
wolfSSL 15:117db924cf7c 30 #define WOLF_BIGINT_DEFINED
wolfSSL 15:117db924cf7c 31 #endif
wolfSSL 15:117db924cf7c 32
wolfSSL 15:117db924cf7c 33
wolfSSL 15:117db924cf7c 34 /* only define functions if mp_int has been declared */
wolfSSL 15:117db924cf7c 35 #ifdef MP_INT_DEFINED
wolfSSL 15:117db924cf7c 36
wolfSSL 15:117db924cf7c 37 #ifndef __WOLFMATH_H__
wolfSSL 15:117db924cf7c 38 #define __WOLFMATH_H__
wolfSSL 15:117db924cf7c 39
wolfSSL 15:117db924cf7c 40 /* timing resistance array */
wolfSSL 15:117db924cf7c 41 #if !defined(WC_NO_CACHE_RESISTANT) && \
wolfSSL 15:117db924cf7c 42 ((defined(HAVE_ECC) && defined(ECC_TIMING_RESISTANT)) || \
wolfSSL 15:117db924cf7c 43 (defined(USE_FAST_MATH) && defined(TFM_TIMING_RESISTANT)))
wolfSSL 15:117db924cf7c 44
wolfSSL 15:117db924cf7c 45 extern const wolfssl_word wc_off_on_addr[2];
wolfSSL 15:117db924cf7c 46 #endif
wolfSSL 15:117db924cf7c 47
wolfSSL 15:117db924cf7c 48 /* common math functions */
wolfSSL 15:117db924cf7c 49 int get_digit_count(mp_int* a);
wolfSSL 15:117db924cf7c 50 mp_digit get_digit(mp_int* a, int n);
wolfSSL 15:117db924cf7c 51 int get_rand_digit(WC_RNG* rng, mp_digit* d);
wolfSSL 15:117db924cf7c 52 int mp_rand(mp_int* a, int digits, WC_RNG* rng);
wolfSSL 15:117db924cf7c 53
wolfSSL 15:117db924cf7c 54
wolfSSL 15:117db924cf7c 55 #ifdef HAVE_WOLF_BIGINT
wolfSSL 15:117db924cf7c 56 void wc_bigint_init(WC_BIGINT* a);
wolfSSL 15:117db924cf7c 57 int wc_bigint_alloc(WC_BIGINT* a, word32 sz);
wolfSSL 15:117db924cf7c 58 int wc_bigint_from_unsigned_bin(WC_BIGINT* a, const byte* in, word32 inlen);
wolfSSL 15:117db924cf7c 59 int wc_bigint_to_unsigned_bin(WC_BIGINT* a, byte* out, word32* outlen);
wolfSSL 15:117db924cf7c 60 void wc_bigint_zero(WC_BIGINT* a);
wolfSSL 15:117db924cf7c 61 void wc_bigint_free(WC_BIGINT* a);
wolfSSL 15:117db924cf7c 62
wolfSSL 15:117db924cf7c 63 int wc_mp_to_bigint(mp_int* src, WC_BIGINT* dst);
wolfSSL 15:117db924cf7c 64 int wc_mp_to_bigint_sz(mp_int* src, WC_BIGINT* dst, word32 sz);
wolfSSL 15:117db924cf7c 65 int wc_bigint_to_mp(WC_BIGINT* src, mp_int* dst);
wolfSSL 15:117db924cf7c 66 #endif /* HAVE_WOLF_BIGINT */
wolfSSL 15:117db924cf7c 67
wolfSSL 15:117db924cf7c 68 #endif /* __WOLFMATH_H__ */
wolfSSL 15:117db924cf7c 69
wolfSSL 15:117db924cf7c 70 #endif /* MP_INT_DEFINED */
wolfSSL 15:117db924cf7c 71