wolfSSL SSL/TLS library, support up to TLS1.3

Dependents:   CyaSSL-Twitter-OAuth4Tw Example-client-tls-cert TwitterReader TweetTest ... more

Committer:
wolfSSL
Date:
Tue Aug 22 10:48:22 2017 +0000
Revision:
13:f67a6c6013ca
wolfSSL3.12.0 with TLS1.3

Who changed what in which revision?

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