| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
from __future__ import absolute_import, division, print_function |
| 6 |
|
| 7 |
INCLUDES = """ |
| 8 |
#include <openssl/bn.h> |
| 9 |
""" |
| 10 |
|
| 11 |
TYPES = """ |
| 12 |
typedef ... BN_CTX; |
| 13 |
typedef ... BN_MONT_CTX; |
| 14 |
typedef ... BIGNUM; |
| 15 |
typedef int... BN_ULONG; |
| 16 |
""" |
| 17 |
|
| 18 |
FUNCTIONS = """ |
| 19 |
#define BN_FLG_CONSTTIME ... |
| 20 |
|
| 21 |
void BN_set_flags(BIGNUM *, int); |
| 22 |
|
| 23 |
BIGNUM *BN_new(void); |
| 24 |
void BN_free(BIGNUM *); |
| 25 |
void BN_clear_free(BIGNUM *); |
| 26 |
|
| 27 |
int BN_rand_range(BIGNUM *, const BIGNUM *); |
| 28 |
|
| 29 |
BN_CTX *BN_CTX_new(void); |
| 30 |
void BN_CTX_free(BN_CTX *); |
| 31 |
|
| 32 |
void BN_CTX_start(BN_CTX *); |
| 33 |
BIGNUM *BN_CTX_get(BN_CTX *); |
| 34 |
void BN_CTX_end(BN_CTX *); |
| 35 |
|
| 36 |
BN_MONT_CTX *BN_MONT_CTX_new(void); |
| 37 |
int BN_MONT_CTX_set(BN_MONT_CTX *, const BIGNUM *, BN_CTX *); |
| 38 |
void BN_MONT_CTX_free(BN_MONT_CTX *); |
| 39 |
|
| 40 |
BIGNUM *BN_dup(const BIGNUM *); |
| 41 |
|
| 42 |
int BN_set_word(BIGNUM *, BN_ULONG); |
| 43 |
|
| 44 |
const BIGNUM *BN_value_one(void); |
| 45 |
|
| 46 |
char *BN_bn2hex(const BIGNUM *); |
| 47 |
int BN_hex2bn(BIGNUM **, const char *); |
| 48 |
|
| 49 |
int BN_bn2bin(const BIGNUM *, unsigned char *); |
| 50 |
BIGNUM *BN_bin2bn(const unsigned char *, int, BIGNUM *); |
| 51 |
|
| 52 |
int BN_num_bits(const BIGNUM *); |
| 53 |
|
| 54 |
int BN_cmp(const BIGNUM *, const BIGNUM *); |
| 55 |
int BN_is_negative(const BIGNUM *); |
| 56 |
int BN_add(BIGNUM *, const BIGNUM *, const BIGNUM *); |
| 57 |
int BN_sub(BIGNUM *, const BIGNUM *, const BIGNUM *); |
| 58 |
int BN_nnmod(BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); |
| 59 |
int BN_mod_add(BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, |
| 60 |
BN_CTX *); |
| 61 |
int BN_mod_sub(BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, |
| 62 |
BN_CTX *); |
| 63 |
int BN_mod_mul(BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, |
| 64 |
BN_CTX *); |
| 65 |
int BN_mod_exp(BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, |
| 66 |
BN_CTX *); |
| 67 |
int BN_mod_exp_mont(BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, |
| 68 |
BN_CTX *, BN_MONT_CTX *); |
| 69 |
int BN_mod_exp_mont_consttime(BIGNUM *, const BIGNUM *, const BIGNUM *, |
| 70 |
const BIGNUM *, BN_CTX *, BN_MONT_CTX *); |
| 71 |
BIGNUM *BN_mod_inverse(BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); |
| 72 |
|
| 73 |
int BN_num_bytes(const BIGNUM *); |
| 74 |
|
| 75 |
int BN_mod(BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); |
| 76 |
|
| 77 |
/* The following 3 prime methods are exposed for Tribler. */ |
| 78 |
int BN_generate_prime_ex(BIGNUM *, int, int, const BIGNUM *, |
| 79 |
const BIGNUM *, BN_GENCB *); |
| 80 |
int BN_is_prime_ex(const BIGNUM *, int, BN_CTX *, BN_GENCB *); |
| 81 |
const int BN_prime_checks_for_size(int); |
| 82 |
""" |
| 83 |
|
| 84 |
CUSTOMIZATIONS = """ |
| 85 |
""" |