diff options
| author | Steven Fackler <[email protected]> | 2016-08-09 23:13:56 -0700 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2016-08-09 23:13:56 -0700 |
| commit | 35c79d176811af9e5cb0c012fe8daecbf7b0cdd4 (patch) | |
| tree | ddd891b25817a3bfbc67a466ccaf2668d2de2400 /openssl/src | |
| parent | Test hmac features (diff) | |
| download | rust-openssl-35c79d176811af9e5cb0c012fe8daecbf7b0cdd4.tar.xz rust-openssl-35c79d176811af9e5cb0c012fe8daecbf7b0cdd4.zip | |
Fix build
Diffstat (limited to 'openssl/src')
| -rw-r--r-- | openssl/src/c_helpers.c | 12 | ||||
| -rw-r--r-- | openssl/src/c_helpers.rs | 1 | ||||
| -rw-r--r-- | openssl/src/dh/mod.rs | 5 |
3 files changed, 17 insertions, 1 deletions
diff --git a/openssl/src/c_helpers.c b/openssl/src/c_helpers.c index 4a2021e4..13041956 100644 --- a/openssl/src/c_helpers.c +++ b/openssl/src/c_helpers.c @@ -15,6 +15,18 @@ STACK_OF(X509_EXTENSION) *rust_X509_get_extensions(X509 *x) { return x->cert_info ? x->cert_info->extensions : NULL; } +DH *rust_DH_new_from_params(BIGNUM *p, BIGNUM *g, BIGNUM *q) { + DH *dh; + + if ((dh = DH_new()) == NULL) { + return NULL; + } + dh->p = p; + dh->g = g; + dh->q = q; + return dh; +} + #if OPENSSL_VERSION_NUMBER < 0x10000000L int rust_HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int key_len, const EVP_MD *md, ENGINE *impl) { HMAC_Init_ex(ctx, key, key_len, md, impl); diff --git a/openssl/src/c_helpers.rs b/openssl/src/c_helpers.rs index a195d88f..90fcf877 100644 --- a/openssl/src/c_helpers.rs +++ b/openssl/src/c_helpers.rs @@ -10,4 +10,5 @@ extern "C" { pub fn rust_HMAC_Init_ex(ctx: *mut ffi::HMAC_CTX, key: *const c_void, keylen: c_int, md: *const ffi::EVP_MD, impl_: *mut ffi::ENGINE) -> c_int; pub fn rust_HMAC_Final(ctx: *mut ffi::HMAC_CTX, output: *mut c_uchar, len: *mut c_uint) -> c_int; pub fn rust_HMAC_Update(ctx: *mut ffi::HMAC_CTX, input: *const c_uchar, len: c_uint) -> c_int; + pub fn rust_DH_new_from_params(p: *mut ffi::BIGNUM, g: *mut ffi::BIGNUM, q: *mut ffi::BIGNUM) -> *mut ffi::DH; } diff --git a/openssl/src/dh/mod.rs b/openssl/src/dh/mod.rs index c0122d44..b9613a1d 100644 --- a/openssl/src/dh/mod.rs +++ b/openssl/src/dh/mod.rs @@ -7,9 +7,11 @@ use std::ptr; pub struct DH(*mut ffi::DH); impl DH { + /// Requires the `dh_from_params` feature. + #[cfg(feature = "dh_from_params")] pub fn from_params(p: BigNum, g: BigNum, q: BigNum) -> Result<DH, ErrorStack> { let dh = unsafe { - try_ssl_null!(ffi::DH_new_from_params(p.into_raw(), g.into_raw(), q.into_raw())) + try_ssl_null!(::c_helpers::rust_DH_new_from_params(p.into_raw(), g.into_raw(), q.into_raw())) }; Ok(DH(dh)) } @@ -75,6 +77,7 @@ mod tests { } #[test] + #[cfg(feature = "dh_from_params")] fn test_dh() { let mut ctx = SslContext::new(Sslv23).unwrap(); let p = BigNum::from_hex_str("87A8E61DB4B6663CFFBBD19C651959998CEEF608660DD0F25D2CEED4435\ |