Skip to content

Commit 6a87a2c

Browse files
authored
Merge pull request #2454 from huwcbjones/huw/sys/encdec
sys: add encoder & decoder symbols
2 parents 24f9a7c + 5099dc8 commit 6a87a2c

File tree

6 files changed

+138
-1
lines changed

6 files changed

+138
-1
lines changed

openssl-sys/build/run_bindgen.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ const INCLUDES: &str = "
5858
#endif
5959
6060
#if OPENSSL_VERSION_NUMBER >= 0x30000000
61+
#include <openssl/decoder.h>
62+
#include <openssl/encoder.h>
6163
#include <openssl/provider.h>
6264
#include <openssl/params.h>
6365
#include <openssl/param_build.h>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
use super::super::*;
2+
use libc::*;
3+
4+
extern "C" {
5+
pub fn OSSL_DECODER_CTX_new() -> *mut OSSL_DECODER_CTX;
6+
pub fn OSSL_DECODER_CTX_free(ctx: *mut OSSL_DECODER_CTX);
7+
8+
pub fn OSSL_DECODER_CTX_new_for_pkey(
9+
pkey: *mut *mut EVP_PKEY,
10+
input_type: *const c_char,
11+
input_struct: *const c_char,
12+
keytype: *const c_char,
13+
selection: c_int,
14+
libctx: *mut OSSL_LIB_CTX,
15+
propquery: *const c_char,
16+
) -> *mut OSSL_DECODER_CTX;
17+
18+
pub fn OSSL_DECODER_CTX_set_selection(ctx: *mut OSSL_DECODER_CTX, selection: c_int) -> c_int;
19+
pub fn OSSL_DECODER_CTX_set_input_type(
20+
ctx: *mut OSSL_DECODER_CTX,
21+
input_type: *const c_char,
22+
) -> c_int;
23+
pub fn OSSL_DECODER_CTX_set_input_structure(
24+
ctx: *mut OSSL_DECODER_CTX,
25+
input_structure: *const c_char,
26+
) -> c_int;
27+
28+
pub fn OSSL_DECODER_CTX_set_passphrase(
29+
ctx: *mut OSSL_DECODER_CTX,
30+
kstr: *const c_uchar,
31+
klen: size_t,
32+
) -> c_int;
33+
pub fn OSSL_DECODER_CTX_set_pem_password_cb(
34+
ctx: *mut OSSL_DECODER_CTX,
35+
cb: pem_password_cb,
36+
cbarg: *mut c_void,
37+
) -> c_int;
38+
pub fn OSSL_DECODER_CTX_set_passphrase_cb(
39+
ctx: *mut OSSL_DECODER_CTX,
40+
cb: OSSL_PASSPHRASE_CALLBACK,
41+
cbarg: *mut c_void,
42+
) -> c_int;
43+
44+
pub fn OSSL_DECODER_from_bio(ctx: *mut OSSL_DECODER_CTX, b_in: *mut BIO) -> c_int;
45+
#[cfg(not(osslconf = "OPENSSL_NO_STDIO"))]
46+
pub fn OSSL_DECODER_from_fp(ctx: *mut OSSL_DECODER_CTX, fp: *mut FILE) -> c_int;
47+
pub fn OSSL_DECODER_from_data(
48+
ctx: *mut OSSL_DECODER_CTX,
49+
pdata: *mut *const c_uchar,
50+
pdata_len: *mut size_t,
51+
) -> c_int;
52+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
use super::super::*;
2+
use libc::*;
3+
4+
#[cfg(ossl300)]
5+
extern "C" {
6+
pub fn OSSL_ENCODER_CTX_new() -> *mut OSSL_ENCODER_CTX;
7+
pub fn OSSL_ENCODER_CTX_free(ctx: *mut OSSL_ENCODER_CTX);
8+
9+
pub fn OSSL_ENCODER_CTX_new_for_pkey(
10+
pkey: *const EVP_PKEY,
11+
selection: c_int,
12+
output_type: *const c_char,
13+
output_structure: *const c_char,
14+
propquery: *const c_char,
15+
) -> *mut OSSL_ENCODER_CTX;
16+
17+
pub fn OSSL_ENCODER_CTX_set_selection(ctx: *mut OSSL_ENCODER_CTX, selection: c_int) -> c_int;
18+
pub fn OSSL_ENCODER_CTX_set_output_type(
19+
ctx: *mut OSSL_ENCODER_CTX,
20+
output_type: *const c_char,
21+
) -> c_int;
22+
pub fn OSSL_ENCODER_CTX_set_output_structure(
23+
ctx: *mut OSSL_ENCODER_CTX,
24+
output_structure: *const c_char,
25+
) -> c_int;
26+
27+
pub fn OSSL_ENCODER_CTX_set_cipher(
28+
ctx: *mut OSSL_ENCODER_CTX,
29+
cipher_name: *const c_char,
30+
propquery: *const c_char,
31+
) -> c_int;
32+
pub fn OSSL_ENCODER_CTX_set_passphrase(
33+
ctx: *mut OSSL_ENCODER_CTX,
34+
kstr: *const c_uchar,
35+
klen: size_t,
36+
) -> c_int;
37+
pub fn OSSL_ENCODER_CTX_set_pem_password_cb(
38+
ctx: *mut OSSL_ENCODER_CTX,
39+
cb: pem_password_cb,
40+
cbarg: *mut c_void,
41+
) -> c_int;
42+
pub fn OSSL_ENCODER_CTX_set_passphrase_cb(
43+
ctx: *mut OSSL_ENCODER_CTX,
44+
cb: OSSL_PASSPHRASE_CALLBACK,
45+
cbarg: *mut c_void,
46+
) -> c_int;
47+
48+
pub fn OSSL_ENCODER_to_data(
49+
ctx: *mut OSSL_ENCODER_CTX,
50+
pdata: *mut *mut c_uchar,
51+
pdata_len: *mut size_t,
52+
) -> c_int;
53+
pub fn OSSL_ENCODER_to_bio(ctx: *mut OSSL_ENCODER_CTX, out: *mut BIO) -> c_int;
54+
#[cfg(not(osslconf = "OPENSSL_NO_STDIO"))]
55+
pub fn OSSL_ENCODER_to_fp(ctx: *mut OSSL_ENCODER_CTX, fp: *mut FILE) -> c_int;
56+
}

openssl-sys/src/handwritten/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ pub use self::cmac::*;
66
pub use self::cms::*;
77
pub use self::conf::*;
88
pub use self::crypto::*;
9+
#[cfg(ossl300)]
10+
pub use self::decoder::*;
911
pub use self::dh::*;
1012
pub use self::dsa::*;
1113
pub use self::ec::*;
14+
#[cfg(ossl300)]
15+
pub use self::encoder::*;
1216
pub use self::err::*;
1317
pub use self::evp::*;
1418
pub use self::hmac::*;
@@ -46,9 +50,13 @@ mod cmac;
4650
mod cms;
4751
mod conf;
4852
mod crypto;
53+
#[cfg(ossl300)]
54+
mod decoder;
4955
mod dh;
5056
mod dsa;
5157
mod ec;
58+
#[cfg(ossl300)]
59+
mod encoder;
5260
mod err;
5361
mod evp;
5462
mod hmac;

openssl-sys/src/handwritten/types.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,3 +1147,19 @@ pub enum OSSL_PARAM_BLD {}
11471147
pub enum EVP_KDF {}
11481148
#[cfg(ossl300)]
11491149
pub enum EVP_KDF_CTX {}
1150+
1151+
#[cfg(ossl300)]
1152+
pub enum OSSL_ENCODER_CTX {}
1153+
#[cfg(ossl300)]
1154+
pub enum OSSL_DECODER_CTX {}
1155+
1156+
#[cfg(ossl300)]
1157+
pub type OSSL_PASSPHRASE_CALLBACK = Option<
1158+
unsafe extern "C" fn(
1159+
pass: *mut c_char,
1160+
pass_size: size_t,
1161+
pass_len: *mut size_t,
1162+
params: *const OSSL_PARAM,
1163+
arg: *mut c_void,
1164+
) -> c_int,
1165+
>;

systest/build.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ fn main() {
8383
}
8484

8585
if version >= 0x30000000 {
86-
cfg.header("openssl/provider.h")
86+
cfg.header("openssl/decoder.h")
87+
.header("openssl/encoder.h")
88+
.header("openssl/provider.h")
8789
.header("openssl/params.h")
8890
.header("openssl/param_build.h")
8991
.header("openssl/ssl.h");
@@ -121,6 +123,7 @@ fn main() {
121123
s == "PasswordCallback"
122124
|| s == "pem_password_cb"
123125
|| s == "bio_info_cb"
126+
|| s == "OSSL_PASSPHRASE_CALLBACK"
124127
|| s.starts_with("CRYPTO_EX_")
125128
});
126129
cfg.skip_struct(|s| {

0 commit comments

Comments
 (0)