Skip to content

Commit 4743852

Browse files
tuxxyalex
authored andcommitted
Expose OpenSSL constant time bignum arithmetic (pyca#4200)
* Expose BIGNUM constant time operations This commit exposes the following functions: BN_set_flags BN_get_flags BN_MONT_CTX_new BN_MONT_CTX_set BN_MONT_CTX_free BN_mod_exp_mont BN_mod_exp_mont_consttime This commit also exposes the BN_FLG_CONSTTIME flag. * Add myself to AUTHORS
1 parent c81df6b commit 4743852

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

AUTHORS.rst

+1
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ PGP key fingerprints are enclosed in parentheses.
4040
* Chris Wolfe <[email protected]>
4141
* Jeremy Lainé <[email protected]>
4242
* Denis Gladkikh <[email protected]>
43+
* John Pacific <[email protected]> (2CF6 0381 B5EF 29B7 D48C 2020 7BB9 71A0 E891 44D9)

src/_cffi_src/openssl/bignum.py

+14
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@
1010

1111
TYPES = """
1212
typedef ... BN_CTX;
13+
typedef ... BN_MONT_CTX;
1314
typedef ... BIGNUM;
1415
typedef int... BN_ULONG;
1516
"""
1617

1718
FUNCTIONS = """
19+
#define BN_FLG_CONSTTIME ...
20+
21+
void BN_set_flags(BIGNUM *, int);
22+
int BN_get_flags(const BIGNUM *, int);
23+
1824
BIGNUM *BN_new(void);
1925
void BN_free(BIGNUM *);
2026
void BN_clear_free(BIGNUM *);
@@ -29,6 +35,10 @@
2935
BIGNUM *BN_CTX_get(BN_CTX *);
3036
void BN_CTX_end(BN_CTX *);
3137
38+
BN_MONT_CTX *BN_MONT_CTX_new(void);
39+
int BN_MONT_CTX_set(BN_MONT_CTX *, BIGNUM *, BN_CTX *);
40+
void BN_MONT_CTX_free(BN_MONT_CTX *);
41+
3242
BIGNUM *BN_copy(BIGNUM *, const BIGNUM *);
3343
BIGNUM *BN_dup(const BIGNUM *);
3444
@@ -63,6 +73,10 @@
6373
int BN_exp(BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *);
6474
int BN_mod_exp(BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *,
6575
BN_CTX *);
76+
int BN_mod_exp_mont(BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *,
77+
BN_CTX *, BN_MONT_CTX *);
78+
int BN_mod_exp_mont_consttime(BIGNUM *, const BIGNUM *, const BIGNUM *,
79+
const BIGNUM *, BN_CTX *, BN_MONT_CTX *);
6680
int BN_gcd(BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *);
6781
BIGNUM *BN_mod_inverse(BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *);
6882

0 commit comments

Comments
 (0)