Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added RSA_METHOD Bindings #2219

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
4 changes: 4 additions & 0 deletions openssl-sys/src/handwritten/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ pub use self::poly1305::*;
pub use self::provider::*;
pub use self::rand::*;
pub use self::rsa::*;
#[cfg(ossl110)]
pub use self::rsa_meth::*;
pub use self::safestack::*;
pub use self::sha::*;
pub use self::srtp::*;
Expand Down Expand Up @@ -61,6 +63,8 @@ mod poly1305;
mod provider;
mod rand;
mod rsa;
#[cfg(ossl110)]
mod rsa_meth;
mod safestack;
mod sha;
mod srtp;
Expand Down
165 changes: 165 additions & 0 deletions openssl-sys/src/handwritten/rsa_meth.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
use super::super::*;
use libc::*;

#[cfg(ossl110)]
extern "C" {
pub fn RSA_meth_new(name: *const c_char, flags: i32) -> *mut RSA_METHOD;

pub fn RSA_meth_free(meth: *mut RSA_METHOD);

pub fn RSA_meth_dup(meth: *const RSA_METHOD) -> *mut RSA_METHOD;

pub fn RSA_meth_get0_name(meth: *const RSA_METHOD) -> *const c_char;
pub fn RSA_meth_set1_name(meth: *mut RSA_METHOD, name: *const c_char) -> i32;

pub fn RSA_meth_get_flags(meth: *const RSA_METHOD) -> i32;
pub fn RSA_meth_set_flags(meth: *mut RSA_METHOD, flags: i32) -> i32;

pub fn RSA_meth_get0_app_data(meth: *const RSA_METHOD) -> *mut c_void;
pub fn RSA_meth_set0_app_data(meth: *mut RSA_METHOD, app_data: *mut c_void) -> i32;

pub fn RSA_meth_set_pub_enc(
rsa: *mut RSA_METHOD,
pub_enc: Option<
unsafe extern "C" fn(
flen: i32,
from: *const u8,
to: *mut u8,
rsa: *mut RSA,
padding: i32,
) -> i32,
>,
) -> i32;

pub fn RSA_meth_set_pub_dec(
rsa: *mut RSA_METHOD,
pub_dec: Option<
unsafe extern "C" fn(
flen: i32,
from: *const u8,
to: *mut u8,
rsa: *mut RSA,
padding: i32,
) -> i32,
>,
) -> i32;

pub fn RSA_meth_set_priv_enc(
rsa: *mut RSA_METHOD,
priv_enc: Option<
unsafe extern "C" fn(
flen: i32,
from: *const u8,
to: *mut u8,
rsa: *mut RSA,
padding: i32,
) -> i32,
>,
) -> i32;
pub fn RSA_meth_set_priv_dec(
rsa: *mut RSA_METHOD,
priv_dec: Option<
unsafe extern "C" fn(
flen: i32,
from: *const u8,
to: *mut u8,
rsa: *mut RSA,
padding: i32,
) -> i32,
>,
) -> i32;

/// Notes from OpenSSL documentation: Can be null.
pub fn RSA_meth_set_mod_exp(
rsa: *mut RSA_METHOD,
mod_exp: Option<
unsafe extern "C" fn(
r0: *mut BIGNUM,
i: *const BIGNUM,
rsa: *mut RSA,
ctx: *mut BN_CTX,
) -> i32,
>,
) -> i32;

/// Notes from OpenSSL documentation: Can be null.
pub fn RSA_meth_set_bn_mod_exp(
rsa: *mut RSA_METHOD,
bn_mod_exp: Option<
unsafe extern "C" fn(
r: *mut BIGNUM,
a: *const BIGNUM,
p: *const BIGNUM,
m: *const BIGNUM,
ctx: *mut BN_CTX,
m_ctx: *mut BN_MONT_CTX,
) -> i32,
>,
) -> i32;

/// Notes from OpenSSL documentation: Can be null.
pub fn RSA_meth_set_init(
rsa: *mut RSA_METHOD,
init: Option<unsafe extern "C" fn(rsa: *mut RSA) -> i32>,
) -> i32;

/// Notes from OpenSSL documentation: Can be null.
pub fn RSA_meth_set_finish(
rsa: *mut RSA_METHOD,
finish: Option<unsafe extern "C" fn(rsa: *mut RSA) -> i32>,
) -> i32;

pub fn RSA_meth_set_sign(
rsa: *mut RSA_METHOD,
sign: Option<
unsafe extern "C" fn(
_type: i32,
m: *const u8,
m_length: u32,
sigret: *mut u8,
siglen: *mut u32,
rsa: *const RSA,
) -> i32,
>,
) -> i32;

pub fn RSA_meth_set_verify(
rsa: *mut RSA_METHOD,
verify: Option<
unsafe extern "C" fn(
dtype: i32,
m: *const u8,
m_length: u32,
sigbuf: *const u8,
siglen: u32,
rsa: *const RSA,
) -> i32,
>,
) -> i32;

pub fn RSA_meth_set_keygen(
rsa: *mut RSA_METHOD,
keygen: Option<
unsafe extern "C" fn(
rsa: *mut RSA,
bits: i32,
e: *mut BIGNUM,
cb: *mut BN_GENCB,
) -> i32,
>,
) -> i32;

#[cfg(ossl111)]
pub fn RSA_meth_set_multi_prime_keygen(
meth: *mut RSA_METHOD,
keygen: Option<
unsafe extern "C" fn(
rsa: *mut RSA,
bits: i32,
primes: i32,
e: *mut BIGNUM,
cb: *mut BN_GENCB,
) -> i32,
>,
) -> i32;
}
2 changes: 2 additions & 0 deletions openssl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ pub mod pkey_ctx;
pub mod provider;
pub mod rand;
pub mod rsa;
#[cfg(ossl110)]
pub mod rsa_meth;
pub mod sha;
pub mod sign;
pub mod srtp;
Expand Down
Loading