aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Cole <[email protected]>2014-11-29 19:40:48 -0500
committerChris Cole <[email protected]>2014-11-29 19:40:48 -0500
commitff0480549745403290f5cfdba5da3221982d42cf (patch)
tree9c0df5866978c83aed8a3d80cfd07e0a7e86fb44 /src
parentRemoved BN_sub_word signature for the time being. (diff)
downloadrust-openssl-ff0480549745403290f5cfdba5da3221982d42cf.tar.xz
rust-openssl-ff0480549745403290f5cfdba5da3221982d42cf.zip
Added mod_mul.
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 })