Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of wolfSSL by
wolfmath.h
00001 /* wolfmath.h 00002 * 00003 * Copyright (C) 2006-2016 wolfSSL Inc. 00004 * 00005 * This file is part of wolfSSL. 00006 * 00007 * wolfSSL is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * wolfSSL is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 00020 */ 00021 00022 #if defined(HAVE_WOLF_BIGINT) && !defined(WOLF_BIGINT_DEFINED) 00023 /* raw big integer */ 00024 typedef struct WC_BIGINT { 00025 byte* buf; 00026 word32 len; 00027 void* heap; 00028 } WC_BIGINT; 00029 00030 #define WOLF_BIGINT_DEFINED 00031 #endif 00032 00033 00034 /* only define functions if mp_int has been declared */ 00035 #ifdef MP_INT_DEFINED 00036 00037 #ifndef __WOLFMATH_H__ 00038 #define __WOLFMATH_H__ 00039 00040 /* common math functions */ 00041 int get_digit_count(mp_int* a); 00042 mp_digit get_digit(mp_int* a, int n); 00043 int get_rand_digit(WC_RNG* rng, mp_digit* d); 00044 int mp_rand(mp_int* a, int digits, WC_RNG* rng); 00045 00046 00047 #ifdef HAVE_WOLF_BIGINT 00048 void wc_bigint_init(WC_BIGINT* a); 00049 int wc_bigint_alloc(WC_BIGINT* a, word32 sz); 00050 int wc_bigint_from_unsigned_bin(WC_BIGINT* a, const byte* in, word32 inlen); 00051 int wc_bigint_to_unsigned_bin(WC_BIGINT* a, byte* out, word32* outlen); 00052 void wc_bigint_zero(WC_BIGINT* a); 00053 void wc_bigint_free(WC_BIGINT* a); 00054 00055 int wc_mp_to_bigint(mp_int* src, WC_BIGINT* dst); 00056 int wc_bigint_to_mp(WC_BIGINT* src, mp_int* dst); 00057 #endif /* HAVE_WOLF_BIGINT */ 00058 00059 #endif /* __WOLFMATH_H__ */ 00060 00061 #endif /* MP_INT_DEFINED */ 00062
Generated on Tue Jul 12 2022 23:31:02 by
1.7.2
