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