aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bn/mod.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/bn/mod.rs b/src/bn/mod.rs
index cc64d8cd..fddd5703 100644
--- a/src/bn/mod.rs
+++ b/src/bn/mod.rs
@@ -45,6 +45,7 @@ extern {
fn BN_exp(r: *mut BIGNUM, a: *mut BIGNUM, p: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int;
fn BN_mod_exp(r: *mut BIGNUM, a: *mut BIGNUM, p: *mut BIGNUM, m: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int;
fn BN_mod_inverse(r: *mut BIGNUM, a: *mut BIGNUM, n: *mut BIGNUM, ctx: *mut BN_CTX) -> *const BIGNUM;
+ fn BN_mod_word(r: *mut BIGNUM, w: c_ulong) -> c_ulong;
fn BN_gcd(r: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int;
/* Bit operations on BIGNUMs */
@@ -232,6 +233,12 @@ impl BigNum {
}
}
+ pub fn mod_word(&self, w: c_ulong) -> c_ulong {
+ unsafe {
+ return BN_mod_word(self.raw(), w);
+ }
+ }
+
pub fn checked_gcd(&self, a: &BigNum) -> Result<BigNum, SslError> {
unsafe {
with_bn_in_ctx!(r, ctx, { BN_gcd(r.raw(), self.raw(), a.raw(), ctx) == 1 })