Skip to content

Commit f09d0b7

Browse files
committed
openssl2: Add locate_and_set_int_param() function
This patch adds a openssl support function which finds the desired param from the param array and sets it withe provided value. Signed-off-by: Gowtham Suresh Kumar <[email protected]>
1 parent 2fb177b commit f09d0b7

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

parsec-openssl2/src/lib.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,23 @@ pub unsafe fn locate_and_set_provider_status_param(
116116
openssl_returns_1(openssl_bindings::OSSL_PARAM_set_int(ptr, 1))?;
117117
Ok(())
118118
}
119+
120+
// Finds the OpenSSL parameter type in the parameter array "params" and sets the value
121+
// to the provider specific value
122+
pub unsafe fn locate_and_set_int_param(
123+
openssl_param: &[u8],
124+
value: usize,
125+
params: *mut openssl_bindings::OSSL_PARAM,
126+
) -> Result<(), Error> {
127+
if let Ok(ptr) = openssl_returns_nonnull(openssl_bindings::OSSL_PARAM_locate(
128+
params,
129+
openssl_param.as_ptr() as *const std::os::raw::c_char,
130+
)) {
131+
// OpenSSL returns OPENSSL_SUCCESS
132+
openssl_returns_1(openssl_bindings::OSSL_PARAM_set_int(
133+
ptr,
134+
value.try_into().unwrap(),
135+
))?;
136+
}
137+
Ok(())
138+
}

0 commit comments

Comments
 (0)