Skip to content

Commit 0305f11

Browse files
committed
sys/dh: add EVP_PKEY_CTX set dh prime_len & generator
1 parent 93f9e02 commit 0305f11

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

openssl-sys/src/dh.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use libc::*;
2+
use std::ptr;
3+
4+
use super::super::*;
5+
6+
cfg_if! {
7+
if #[cfg(not(ossl300))] {
8+
pub unsafe fn EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx: *mut EVP_PKEY_CTX, len: c_int) -> c_int {
9+
EVP_PKEY_CTX_ctrl(
10+
ctx,
11+
EVP_PKEY_DH,
12+
EVP_PKEY_OP_PARAMGEN,
13+
EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN,
14+
len,
15+
ptr::null_mut(),
16+
)
17+
}
18+
pub unsafe fn EVP_PKEY_CTX_set_dh_paramgen_generator(ctx: *mut EVP_PKEY_CTX, gen: c_int) -> c_int {
19+
EVP_PKEY_CTX_ctrl(
20+
ctx,
21+
EVP_PKEY_DH,
22+
EVP_PKEY_OP_PARAMGEN,
23+
EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR,
24+
gen,
25+
ptr::null_mut(),
26+
)
27+
}
28+
}
29+
}
30+
31+
pub const EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN: c_int = EVP_PKEY_ALG_CTRL + 1;
32+
pub const EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR: c_int = EVP_PKEY_ALG_CTRL + 2;

openssl-sys/src/handwritten/dh.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
use super::super::*;
22

3+
#[cfg(ossl300)]
4+
extern "C" {
5+
pub fn EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx: *mut EVP_PKEY_CTX, len: c_int) -> c_int;
6+
pub fn EVP_PKEY_CTX_set_dh_paramgen_generator(ctx: *mut EVP_PKEY_CTX, gen: c_int) -> c_int;
7+
}
8+
39
extern "C" {
410
pub fn DH_new() -> *mut DH;
511
pub fn DH_free(dh: *mut DH);

openssl-sys/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ mod openssl {
7373
pub use self::bn::*;
7474
pub use self::cms::*;
7575
pub use self::crypto::*;
76+
pub use self::dh::*;
7677
pub use self::dsa::*;
7778
pub use self::dtls1::*;
7879
pub use self::ec::*;
@@ -104,6 +105,7 @@ mod openssl {
104105
mod bn;
105106
mod cms;
106107
mod crypto;
108+
mod dh;
107109
mod dsa;
108110
mod dtls1;
109111
mod ec;

0 commit comments

Comments
 (0)