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