wolfSSL 3.11.1 for TLS1.3 beta

Fork of wolfSSL by wolf SSL

Committer:
wolfSSL
Date:
Tue May 30 06:16:19 2017 +0000
Revision:
13:80fb167dafdf
Parent:
11:cee25a834751
wolfSSL 3.11.1: TLS1.3 Beta

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolfSSL 11:cee25a834751 1 /* bn.h for openssl */
wolfSSL 11:cee25a834751 2
wolfSSL 11:cee25a834751 3
wolfSSL 11:cee25a834751 4 #ifndef WOLFSSL_BN_H_
wolfSSL 11:cee25a834751 5 #define WOLFSSL_BN_H_
wolfSSL 11:cee25a834751 6
wolfSSL 11:cee25a834751 7 #include <wolfssl/wolfcrypt/settings.h>
wolfSSL 11:cee25a834751 8 #include <wolfssl/wolfcrypt/integer.h>
wolfSSL 11:cee25a834751 9
wolfSSL 11:cee25a834751 10 #ifdef __cplusplus
wolfSSL 11:cee25a834751 11 extern "C" {
wolfSSL 11:cee25a834751 12 #endif
wolfSSL 11:cee25a834751 13
wolfSSL 11:cee25a834751 14 typedef struct WOLFSSL_BIGNUM {
wolfSSL 11:cee25a834751 15 int neg; /* openssh deference */
wolfSSL 11:cee25a834751 16 void* internal; /* our big num */
wolfSSL 11:cee25a834751 17 } WOLFSSL_BIGNUM;
wolfSSL 11:cee25a834751 18
wolfSSL 11:cee25a834751 19
wolfSSL 11:cee25a834751 20 #define WOLFSSL_BN_ULONG mp_digit
wolfSSL 11:cee25a834751 21
wolfSSL 11:cee25a834751 22 typedef struct WOLFSSL_BN_CTX WOLFSSL_BN_CTX;
wolfSSL 11:cee25a834751 23 typedef struct WOLFSSL_BN_GENCB WOLFSSL_BN_GENCB;
wolfSSL 11:cee25a834751 24
wolfSSL 11:cee25a834751 25 WOLFSSL_API WOLFSSL_BN_CTX* wolfSSL_BN_CTX_new(void);
wolfSSL 11:cee25a834751 26 WOLFSSL_API void wolfSSL_BN_CTX_init(WOLFSSL_BN_CTX*);
wolfSSL 11:cee25a834751 27 WOLFSSL_API void wolfSSL_BN_CTX_free(WOLFSSL_BN_CTX*);
wolfSSL 11:cee25a834751 28
wolfSSL 11:cee25a834751 29 WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_BN_new(void);
wolfSSL 11:cee25a834751 30 WOLFSSL_API void wolfSSL_BN_free(WOLFSSL_BIGNUM*);
wolfSSL 11:cee25a834751 31 WOLFSSL_API void wolfSSL_BN_clear_free(WOLFSSL_BIGNUM*);
wolfSSL 11:cee25a834751 32
wolfSSL 11:cee25a834751 33
wolfSSL 11:cee25a834751 34 WOLFSSL_API int wolfSSL_BN_sub(WOLFSSL_BIGNUM*, const WOLFSSL_BIGNUM*,
wolfSSL 11:cee25a834751 35 const WOLFSSL_BIGNUM*);
wolfSSL 11:cee25a834751 36 WOLFSSL_API int wolfSSL_BN_mod(WOLFSSL_BIGNUM*, const WOLFSSL_BIGNUM*,
wolfSSL 11:cee25a834751 37 const WOLFSSL_BIGNUM*, const WOLFSSL_BN_CTX*);
wolfSSL 11:cee25a834751 38 WOLFSSL_API int wolfSSL_BN_mod_exp(WOLFSSL_BIGNUM *r, const WOLFSSL_BIGNUM *a,
wolfSSL 11:cee25a834751 39 const WOLFSSL_BIGNUM *p, const WOLFSSL_BIGNUM *m, WOLFSSL_BN_CTX *ctx);
wolfSSL 11:cee25a834751 40 WOLFSSL_API const WOLFSSL_BIGNUM* wolfSSL_BN_value_one(void);
wolfSSL 11:cee25a834751 41
wolfSSL 11:cee25a834751 42
wolfSSL 11:cee25a834751 43 WOLFSSL_API int wolfSSL_BN_num_bytes(const WOLFSSL_BIGNUM*);
wolfSSL 11:cee25a834751 44 WOLFSSL_API int wolfSSL_BN_num_bits(const WOLFSSL_BIGNUM*);
wolfSSL 11:cee25a834751 45
wolfSSL 11:cee25a834751 46 WOLFSSL_API int wolfSSL_BN_is_zero(const WOLFSSL_BIGNUM*);
wolfSSL 11:cee25a834751 47 WOLFSSL_API int wolfSSL_BN_is_one(const WOLFSSL_BIGNUM*);
wolfSSL 11:cee25a834751 48 WOLFSSL_API int wolfSSL_BN_is_odd(const WOLFSSL_BIGNUM*);
wolfSSL 11:cee25a834751 49
wolfSSL 11:cee25a834751 50 WOLFSSL_API int wolfSSL_BN_cmp(const WOLFSSL_BIGNUM*, const WOLFSSL_BIGNUM*);
wolfSSL 11:cee25a834751 51
wolfSSL 11:cee25a834751 52 WOLFSSL_API int wolfSSL_BN_bn2bin(const WOLFSSL_BIGNUM*, unsigned char*);
wolfSSL 11:cee25a834751 53 WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_BN_bin2bn(const unsigned char*, int len,
wolfSSL 11:cee25a834751 54 WOLFSSL_BIGNUM* ret);
wolfSSL 11:cee25a834751 55
wolfSSL 11:cee25a834751 56 WOLFSSL_API int wolfSSL_mask_bits(WOLFSSL_BIGNUM*, int n);
wolfSSL 11:cee25a834751 57
wolfSSL 11:cee25a834751 58 WOLFSSL_API int wolfSSL_BN_rand(WOLFSSL_BIGNUM*, int bits, int top, int bottom);
wolfSSL 11:cee25a834751 59 WOLFSSL_API int wolfSSL_BN_is_bit_set(const WOLFSSL_BIGNUM*, int n);
wolfSSL 11:cee25a834751 60 WOLFSSL_API int wolfSSL_BN_hex2bn(WOLFSSL_BIGNUM**, const char* str);
wolfSSL 11:cee25a834751 61
wolfSSL 11:cee25a834751 62 WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_BN_dup(const WOLFSSL_BIGNUM*);
wolfSSL 11:cee25a834751 63 WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_BN_copy(WOLFSSL_BIGNUM*,
wolfSSL 11:cee25a834751 64 const WOLFSSL_BIGNUM*);
wolfSSL 11:cee25a834751 65
wolfSSL 11:cee25a834751 66 WOLFSSL_API int wolfSSL_BN_dec2bn(WOLFSSL_BIGNUM**, const char* str);
wolfSSL 11:cee25a834751 67 WOLFSSL_API char* wolfSSL_BN_bn2dec(const WOLFSSL_BIGNUM*);
wolfSSL 11:cee25a834751 68
wolfSSL 11:cee25a834751 69 WOLFSSL_API int wolfSSL_BN_lshift(WOLFSSL_BIGNUM*, const WOLFSSL_BIGNUM*, int);
wolfSSL 11:cee25a834751 70 WOLFSSL_API int wolfSSL_BN_add_word(WOLFSSL_BIGNUM*, WOLFSSL_BN_ULONG);
wolfSSL 11:cee25a834751 71 WOLFSSL_API int wolfSSL_BN_set_bit(WOLFSSL_BIGNUM*, int);
wolfSSL 11:cee25a834751 72 WOLFSSL_API int wolfSSL_BN_set_word(WOLFSSL_BIGNUM*, WOLFSSL_BN_ULONG);
wolfSSL 11:cee25a834751 73
wolfSSL 11:cee25a834751 74 WOLFSSL_API int wolfSSL_BN_add(WOLFSSL_BIGNUM*, WOLFSSL_BIGNUM*,
wolfSSL 11:cee25a834751 75 WOLFSSL_BIGNUM*);
wolfSSL 11:cee25a834751 76 WOLFSSL_API char *wolfSSL_BN_bn2hex(const WOLFSSL_BIGNUM*);
wolfSSL 11:cee25a834751 77 WOLFSSL_API int wolfSSL_BN_is_prime_ex(const WOLFSSL_BIGNUM*, int,
wolfSSL 11:cee25a834751 78 WOLFSSL_BN_CTX*, WOLFSSL_BN_GENCB*);
wolfSSL 11:cee25a834751 79 WOLFSSL_API WOLFSSL_BN_ULONG wolfSSL_BN_mod_word(const WOLFSSL_BIGNUM*,
wolfSSL 11:cee25a834751 80 WOLFSSL_BN_ULONG);
wolfSSL 11:cee25a834751 81 #ifndef NO_FILESYSTEM
wolfSSL 11:cee25a834751 82 WOLFSSL_API int wolfSSL_BN_print_fp(FILE*, const WOLFSSL_BIGNUM*);
wolfSSL 11:cee25a834751 83 #endif
wolfSSL 11:cee25a834751 84 WOLFSSL_API int wolfSSL_BN_rshift(WOLFSSL_BIGNUM*, const WOLFSSL_BIGNUM*, int);
wolfSSL 11:cee25a834751 85 WOLFSSL_API WOLFSSL_BIGNUM *wolfSSL_BN_CTX_get(WOLFSSL_BN_CTX *ctx);
wolfSSL 11:cee25a834751 86 WOLFSSL_API void wolfSSL_BN_CTX_start(WOLFSSL_BN_CTX *ctx);
wolfSSL 11:cee25a834751 87
wolfSSL 11:cee25a834751 88 typedef WOLFSSL_BIGNUM BIGNUM;
wolfSSL 11:cee25a834751 89 typedef WOLFSSL_BN_CTX BN_CTX;
wolfSSL 11:cee25a834751 90 typedef WOLFSSL_BN_GENCB BN_GENCB;
wolfSSL 11:cee25a834751 91
wolfSSL 11:cee25a834751 92 #define BN_CTX_new wolfSSL_BN_CTX_new
wolfSSL 11:cee25a834751 93 #define BN_CTX_init wolfSSL_BN_CTX_init
wolfSSL 11:cee25a834751 94 #define BN_CTX_free wolfSSL_BN_CTX_free
wolfSSL 11:cee25a834751 95
wolfSSL 11:cee25a834751 96 #define BN_new wolfSSL_BN_new
wolfSSL 11:cee25a834751 97 #define BN_free wolfSSL_BN_free
wolfSSL 11:cee25a834751 98 #define BN_clear_free wolfSSL_BN_clear_free
wolfSSL 11:cee25a834751 99
wolfSSL 11:cee25a834751 100 #define BN_num_bytes wolfSSL_BN_num_bytes
wolfSSL 11:cee25a834751 101 #define BN_num_bits wolfSSL_BN_num_bits
wolfSSL 11:cee25a834751 102
wolfSSL 11:cee25a834751 103 #define BN_is_zero wolfSSL_BN_is_zero
wolfSSL 11:cee25a834751 104 #define BN_is_one wolfSSL_BN_is_one
wolfSSL 11:cee25a834751 105 #define BN_is_odd wolfSSL_BN_is_odd
wolfSSL 11:cee25a834751 106
wolfSSL 11:cee25a834751 107 #define BN_cmp wolfSSL_BN_cmp
wolfSSL 11:cee25a834751 108
wolfSSL 11:cee25a834751 109 #define BN_bn2bin wolfSSL_BN_bn2bin
wolfSSL 11:cee25a834751 110 #define BN_bin2bn wolfSSL_BN_bin2bn
wolfSSL 11:cee25a834751 111
wolfSSL 11:cee25a834751 112 #define BN_mod wolfSSL_BN_mod
wolfSSL 11:cee25a834751 113 #define BN_mod_exp wolfSSL_BN_mod_exp
wolfSSL 11:cee25a834751 114 #define BN_sub wolfSSL_BN_sub
wolfSSL 11:cee25a834751 115 #define BN_value_one wolfSSL_BN_value_one
wolfSSL 11:cee25a834751 116
wolfSSL 11:cee25a834751 117 #define BN_mask_bits wolfSSL_mask_bits
wolfSSL 11:cee25a834751 118
wolfSSL 11:cee25a834751 119 #define BN_rand wolfSSL_BN_rand
wolfSSL 11:cee25a834751 120 #define BN_is_bit_set wolfSSL_BN_is_bit_set
wolfSSL 11:cee25a834751 121 #define BN_hex2bn wolfSSL_BN_hex2bn
wolfSSL 11:cee25a834751 122
wolfSSL 11:cee25a834751 123 #define BN_dup wolfSSL_BN_dup
wolfSSL 11:cee25a834751 124 #define BN_copy wolfSSL_BN_copy
wolfSSL 11:cee25a834751 125
wolfSSL 11:cee25a834751 126 #define BN_set_word wolfSSL_BN_set_word
wolfSSL 11:cee25a834751 127
wolfSSL 11:cee25a834751 128 #define BN_dec2bn wolfSSL_BN_dec2bn
wolfSSL 11:cee25a834751 129 #define BN_bn2dec wolfSSL_BN_bn2dec
wolfSSL 11:cee25a834751 130 #define BN_bn2hex wolfSSL_BN_bn2hex
wolfSSL 11:cee25a834751 131
wolfSSL 11:cee25a834751 132 #define BN_lshift wolfSSL_BN_lshift
wolfSSL 11:cee25a834751 133 #define BN_add_word wolfSSL_BN_add_word
wolfSSL 11:cee25a834751 134 #define BN_add wolfSSL_BN_add
wolfSSL 11:cee25a834751 135 #define BN_set_word wolfSSL_BN_set_word
wolfSSL 11:cee25a834751 136 #define BN_set_bit wolfSSL_BN_set_bit
wolfSSL 11:cee25a834751 137
wolfSSL 11:cee25a834751 138
wolfSSL 11:cee25a834751 139 #define BN_is_prime_ex wolfSSL_BN_is_prime_ex
wolfSSL 11:cee25a834751 140 #define BN_print_fp wolfSSL_BN_print_fp
wolfSSL 11:cee25a834751 141 #define BN_rshift wolfSSL_BN_rshift
wolfSSL 11:cee25a834751 142 #define BN_mod_word wolfSSL_BN_mod_word
wolfSSL 11:cee25a834751 143
wolfSSL 11:cee25a834751 144 #define BN_CTX_get wolfSSL_BN_CTX_get
wolfSSL 11:cee25a834751 145 #define BN_CTX_start wolfSSL_BN_CTX_start
wolfSSL 11:cee25a834751 146
wolfSSL 11:cee25a834751 147 #ifdef __cplusplus
wolfSSL 11:cee25a834751 148 } /* extern "C" */
wolfSSL 11:cee25a834751 149 #endif
wolfSSL 11:cee25a834751 150
wolfSSL 11:cee25a834751 151
wolfSSL 11:cee25a834751 152 #endif /* WOLFSSL__H_ */
wolfSSL 11:cee25a834751 153