Added mod_mul.
This commit is contained in:
parent
7cbe372ce1
commit
ff04805497
|
|
@ -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_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_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_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;
|
fn BN_gcd(r: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int;
|
||||||
|
|
||||||
/* Bit operations on BIGNUMs */
|
/* 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> {
|
pub fn checked_gcd(&self, a: &BigNum) -> Result<BigNum, SslError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
with_bn_in_ctx!(r, ctx, { BN_gcd(r.raw(), self.raw(), a.raw(), ctx) == 1 })
|
with_bn_in_ctx!(r, ctx, { BN_gcd(r.raw(), self.raw(), a.raw(), ctx) == 1 })
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue