Skip to content

Commit eacc74f

Browse files
keymgmt: Add Key Objects import types
Implement: 1. OSSL_FUNC_KEYMGMT_IMPORT_TYPES for key objects as indicated by https://www.openssl.org/docs/man3.0/man7/provider-keymgmt.html Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com>
1 parent 4e75a16 commit eacc74f

File tree

2 files changed

+35
-3
lines changed
  • parsec-openssl-provider/src/keymgmt
  • parsec-openssl-sys2/src/c

2 files changed

+35
-3
lines changed

parsec-openssl-provider/src/keymgmt/mod.rs

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
use crate::openssl_binding::{
55
OSSL_ALGORITHM, OSSL_DISPATCH, OSSL_FUNC_KEYMGMT_FREE, OSSL_FUNC_KEYMGMT_IMPORT,
6-
OSSL_FUNC_KEYMGMT_NEW, OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS, OSSL_FUNC_KEYMGMT_SET_PARAMS,
7-
OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS, OSSL_PARAM, OSSL_PARAM_UTF8_PTR,
6+
OSSL_FUNC_KEYMGMT_IMPORT_TYPES, OSSL_FUNC_KEYMGMT_NEW, OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS,
7+
OSSL_FUNC_KEYMGMT_SET_PARAMS, OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS, OSSL_PARAM,
8+
OSSL_PARAM_UTF8_PTR,
89
};
910
use crate::ParsecProviderContext;
1011
use parsec_openssl2::types::VOID_PTR;
@@ -111,25 +112,55 @@ pub unsafe extern "C" fn parsec_provider_kmgmt_import(
111112
1
112113
}
113114

115+
/*
116+
should return an array of descriptor OSSL_PARAM for data indicated by selection, for parameters that
117+
OSSL_FUNC_keymgmt_import() can handle
118+
*/
119+
pub unsafe extern "C" fn parsec_provider_kmgmt_import_types(
120+
selection: std::os::raw::c_int,
121+
) -> *const OSSL_PARAM {
122+
if selection & OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS as std::os::raw::c_int != 0 {
123+
static ONCE_INIT: std::sync::Once = std::sync::Once::new();
124+
static mut IMPORT_TYPES_TABLE: [OSSL_PARAM; 1] = [parsec_openssl2::ossl_param!(); 1];
125+
126+
ONCE_INIT.call_once(|| {
127+
IMPORT_TYPES_TABLE = [ossl_param!(PARSEC_PROVIDER_KEY_NAME, OSSL_PARAM_UTF8_PTR)];
128+
});
129+
130+
IMPORT_TYPES_TABLE.as_ptr()
131+
} else {
132+
std::ptr::null_mut()
133+
}
134+
}
135+
114136
pub type KeyMgmtNewPtr = unsafe extern "C" fn(VOID_PTR) -> VOID_PTR;
115137
pub type KeyMgmtFreePtr = unsafe extern "C" fn(VOID_PTR);
116138
pub type KeyMgmtImportPtr =
117139
unsafe extern "C" fn(VOID_PTR, std::os::raw::c_int, *mut OSSL_PARAM) -> std::os::raw::c_int;
140+
pub type KeyMgmtImportTypesPtr = unsafe extern "C" fn(std::os::raw::c_int) -> *const OSSL_PARAM;
118141
pub type KeyMgmtSetParamsPtr =
119142
unsafe extern "C" fn(VOID_PTR, *mut OSSL_PARAM) -> std::os::raw::c_int;
120143
pub type KeyMgmtSettableParamsPtr = unsafe extern "C" fn(VOID_PTR) -> *const OSSL_PARAM;
121144

122145
const OSSL_FUNC_KEYMGMT_NEW_PTR: KeyMgmtNewPtr = parsec_provider_kmgmt_new;
123146
const OSSL_FUNC_KEYMGMT_FREE_PTR: KeyMgmtFreePtr = parsec_provider_kmgmt_free;
124147
const OSSL_FUNC_KEYMGMT_IMPORT_PTR: KeyMgmtImportPtr = parsec_provider_kmgmt_import;
148+
const OSSL_FUNC_KEYMGMT_IMPORT_TYPES_PTR: KeyMgmtImportTypesPtr =
149+
parsec_provider_kmgmt_import_types;
125150
const OSSL_FUNC_KEYMGMT_SET_PARAMS_PTR: KeyMgmtSetParamsPtr = parsec_provider_kmgmt_set_params;
126151
const OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS_PTR: KeyMgmtSettableParamsPtr =
127152
parsec_provider_kmgmt_settable_params;
128153

129-
const PARSEC_PROVIDER_RSA_KEYMGMT_IMPL: [OSSL_DISPATCH; 5] = [
154+
const PARSEC_PROVIDER_RSA_KEYMGMT_IMPL: [OSSL_DISPATCH; 6] = [
130155
unsafe { ossl_dispatch!(OSSL_FUNC_KEYMGMT_NEW, OSSL_FUNC_KEYMGMT_NEW_PTR) },
131156
unsafe { ossl_dispatch!(OSSL_FUNC_KEYMGMT_FREE, OSSL_FUNC_KEYMGMT_FREE_PTR) },
132157
unsafe { ossl_dispatch!(OSSL_FUNC_KEYMGMT_IMPORT, OSSL_FUNC_KEYMGMT_IMPORT_PTR) },
158+
unsafe {
159+
ossl_dispatch!(
160+
OSSL_FUNC_KEYMGMT_IMPORT_TYPES,
161+
OSSL_FUNC_KEYMGMT_IMPORT_TYPES_PTR
162+
)
163+
},
133164
unsafe {
134165
ossl_dispatch!(
135166
OSSL_FUNC_KEYMGMT_SET_PARAMS,

parsec-openssl-sys2/src/c/openssl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
/* Import and export functions, with discovery */
2828
#define OSSL_FUNC_KEYMGMT_IMPORT 40
29+
#define OSSL_FUNC_KEYMGMT_IMPORT_TYPES 41
2930
#define OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS 12
3031
#define OSSL_FUNC_KEYMGMT_SET_PARAMS 13
3132
#define OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS 14

0 commit comments

Comments
 (0)