|
3 | 3 |
|
4 | 4 | use crate::openssl_binding::{ |
5 | 5 | 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, |
8 | 9 | }; |
9 | 10 | use crate::ParsecProviderContext; |
10 | 11 | use parsec_openssl2::types::VOID_PTR; |
@@ -111,25 +112,55 @@ pub unsafe extern "C" fn parsec_provider_kmgmt_import( |
111 | 112 | 1 |
112 | 113 | } |
113 | 114 |
|
| 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 | + |
114 | 136 | pub type KeyMgmtNewPtr = unsafe extern "C" fn(VOID_PTR) -> VOID_PTR; |
115 | 137 | pub type KeyMgmtFreePtr = unsafe extern "C" fn(VOID_PTR); |
116 | 138 | pub type KeyMgmtImportPtr = |
117 | 139 | 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; |
118 | 141 | pub type KeyMgmtSetParamsPtr = |
119 | 142 | unsafe extern "C" fn(VOID_PTR, *mut OSSL_PARAM) -> std::os::raw::c_int; |
120 | 143 | pub type KeyMgmtSettableParamsPtr = unsafe extern "C" fn(VOID_PTR) -> *const OSSL_PARAM; |
121 | 144 |
|
122 | 145 | const OSSL_FUNC_KEYMGMT_NEW_PTR: KeyMgmtNewPtr = parsec_provider_kmgmt_new; |
123 | 146 | const OSSL_FUNC_KEYMGMT_FREE_PTR: KeyMgmtFreePtr = parsec_provider_kmgmt_free; |
124 | 147 | 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; |
125 | 150 | const OSSL_FUNC_KEYMGMT_SET_PARAMS_PTR: KeyMgmtSetParamsPtr = parsec_provider_kmgmt_set_params; |
126 | 151 | const OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS_PTR: KeyMgmtSettableParamsPtr = |
127 | 152 | parsec_provider_kmgmt_settable_params; |
128 | 153 |
|
129 | | -const PARSEC_PROVIDER_RSA_KEYMGMT_IMPL: [OSSL_DISPATCH; 5] = [ |
| 154 | +const PARSEC_PROVIDER_RSA_KEYMGMT_IMPL: [OSSL_DISPATCH; 6] = [ |
130 | 155 | unsafe { ossl_dispatch!(OSSL_FUNC_KEYMGMT_NEW, OSSL_FUNC_KEYMGMT_NEW_PTR) }, |
131 | 156 | unsafe { ossl_dispatch!(OSSL_FUNC_KEYMGMT_FREE, OSSL_FUNC_KEYMGMT_FREE_PTR) }, |
132 | 157 | 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 | + }, |
133 | 164 | unsafe { |
134 | 165 | ossl_dispatch!( |
135 | 166 | OSSL_FUNC_KEYMGMT_SET_PARAMS, |
|
0 commit comments