Add conf module

This commit is contained in:
Steven Fackler 2016-11-06 14:49:26 -08:00
parent b83edbad0d
commit 1939e6fd78
3 changed files with 34 additions and 0 deletions

View File

@ -24,6 +24,7 @@ pub enum ASN1_TYPE {}
pub enum BN_CTX {}
pub enum BN_GENCB {}
pub enum CONF {}
pub enum CONF_METHOD {}
pub enum COMP_METHOD {}
pub enum EC_KEY {}
pub enum ENGINE {}
@ -1329,6 +1330,10 @@ extern {
pub fn BN_bn2hex(a: *const BIGNUM) -> *mut c_char;
pub fn BN_to_ASN1_INTEGER(bn: *const BIGNUM, ai: *mut ASN1_INTEGER) -> *mut ASN1_INTEGER;
pub fn NCONF_default() -> *mut CONF_METHOD;
pub fn NCONF_new(meth: *mut CONF_METHOD) -> *mut CONF;
pub fn NCONF_free(conf: *mut CONF);
pub fn CRYPTO_memcmp(a: *const c_void, b: *const c_void,
len: size_t) -> c_int;

28
openssl/src/conf.rs Normal file
View File

@ -0,0 +1,28 @@
use ffi;
use cvt_p;
use error::ErrorStack;
pub struct ConfMethod(*mut ffi::CONF_METHOD);
impl ConfMethod {
pub fn default() -> ConfMethod {
unsafe { ConfMethod(ffi::NCONF_default()) }
}
pub unsafe fn from_ptr(ptr: *mut ffi::CONF_METHOD) -> ConfMethod {
ConfMethod(ptr)
}
pub fn as_ptr(&self) -> *mut ffi::CONF_METHOD {
self.0
}
}
type_!(Conf, ConfRef, ffi::CONF, ffi::NCONF_free);
impl Conf {
pub fn new(method: ConfMethod) -> Result<Conf, ErrorStack> {
unsafe { cvt_p(ffi::NCONF_new(method.as_ptr())).map(Conf) }
}
}

View File

@ -65,6 +65,7 @@ mod bio;
mod util;
pub mod asn1;
pub mod bn;
pub mod conf;
pub mod crypto;
pub mod dh;
pub mod dsa;