@@ -100,6 +100,59 @@ pub unsafe extern "C" fn parsec_provider_kmgmt_settable_params(
100
100
KEYMGMT_TABLE . as_ptr ( )
101
101
}
102
102
103
+ /*
104
+ should return a constant array of descriptor OSSL_PARAM, for parameters that OSSL_FUNC_keymgmt_get_params() can handle
105
+ */
106
+ pub unsafe extern "C" fn parsec_provider_kmgmt_gettable_params (
107
+ _provctx : VOID_PTR ,
108
+ ) -> * const OSSL_PARAM {
109
+ static ONCE_INIT : std:: sync:: Once = std:: sync:: Once :: new ( ) ;
110
+ static mut KEYMGMT_GETTABLE_TABLE : [ OSSL_PARAM ; 4 ] = [ ossl_param ! ( ) ; 4 ] ;
111
+
112
+ ONCE_INIT . call_once ( || {
113
+ KEYMGMT_GETTABLE_TABLE = [
114
+ ossl_param ! ( OSSL_PKEY_PARAM_BITS , OSSL_PARAM_INTEGER ) ,
115
+ ossl_param ! ( OSSL_PKEY_PARAM_SECURITY_BITS , OSSL_PARAM_INTEGER ) ,
116
+ ossl_param ! ( OSSL_PKEY_PARAM_MAX_SIZE , OSSL_PARAM_INTEGER ) ,
117
+ ossl_param ! ( ) ,
118
+ ] ;
119
+ } ) ;
120
+ KEYMGMT_GETTABLE_TABLE . as_ptr ( )
121
+ }
122
+
123
+ /*
124
+ should extract information data associated with the given keydata
125
+ */
126
+ pub unsafe extern "C" fn parsec_provider_kmgmt_get_params (
127
+ keydata : VOID_PTR ,
128
+ params : * mut OSSL_PARAM ,
129
+ ) -> std:: os:: raw:: c_int {
130
+ let result = super :: r#catch ( Some ( || super :: Error :: PROVIDER_KEYMGMT_GET_PARAMS ) , || {
131
+ if keydata. is_null ( ) || params. is_null ( ) {
132
+ Err ( "Null pointer received as parameter" . into ( ) )
133
+ } else {
134
+ Arc :: increment_strong_count ( keydata as * const RwLock < ParsecProviderKeyObject > ) ;
135
+ let key_data = Arc :: from_raw ( keydata as * const RwLock < ParsecProviderKeyObject > ) ;
136
+ let reader_key_data = key_data. read ( ) . unwrap ( ) ;
137
+
138
+ if let Some ( public_key) = reader_key_data. get_rsa_key ( ) {
139
+ let modulus = public_key. modulus . as_unsigned_bytes_be ( ) ;
140
+
141
+ locate_and_set_int_param ( OSSL_PKEY_PARAM_BITS , modulus. len ( ) * 8 , params) ?;
142
+ locate_and_set_int_param ( OSSL_PKEY_PARAM_SECURITY_BITS , 112 , params) ?;
143
+ locate_and_set_int_param ( OSSL_PKEY_PARAM_MAX_SIZE , modulus. len ( ) , params) ?;
144
+ }
145
+
146
+ Ok ( OPENSSL_SUCCESS )
147
+ }
148
+ } ) ;
149
+
150
+ match result {
151
+ Ok ( result) => result,
152
+ Err ( ( ) ) => OPENSSL_ERROR ,
153
+ }
154
+ }
155
+
103
156
// should update information data associated with the given keydata
104
157
pub unsafe extern "C" fn parsec_provider_kmgmt_set_params (
105
158
keydata : VOID_PTR ,
@@ -384,7 +437,11 @@ pub type KeyMgmtImportPtr =
384
437
pub type KeyMgmtImportTypesPtr = unsafe extern "C" fn ( std:: os:: raw:: c_int ) -> * const OSSL_PARAM ;
385
438
pub type KeyMgmtSetParamsPtr =
386
439
unsafe extern "C" fn ( VOID_PTR , * mut OSSL_PARAM ) -> std:: os:: raw:: c_int ;
440
+ pub type KeyMgmtGetParamsPtr =
441
+ unsafe extern "C" fn ( VOID_PTR , * mut OSSL_PARAM ) -> std:: os:: raw:: c_int ;
387
442
pub type KeyMgmtSettableParamsPtr = unsafe extern "C" fn ( VOID_PTR ) -> * const OSSL_PARAM ;
443
+ pub type KeyMgmtGettableParamsPtr = unsafe extern "C" fn ( VOID_PTR ) -> * const OSSL_PARAM ;
444
+
388
445
pub type KeyMgmtMatchPtr =
389
446
unsafe extern "C" fn ( VOID_PTR , VOID_PTR , std:: os:: raw:: c_int ) -> std:: os:: raw:: c_int ;
390
447
@@ -396,11 +453,15 @@ const OSSL_FUNC_KEYMGMT_IMPORT_PTR: KeyMgmtImportPtr = parsec_provider_kmgmt_imp
396
453
const OSSL_FUNC_KEYMGMT_IMPORT_TYPES_PTR : KeyMgmtImportTypesPtr =
397
454
parsec_provider_kmgmt_import_types;
398
455
const OSSL_FUNC_KEYMGMT_SET_PARAMS_PTR : KeyMgmtSetParamsPtr = parsec_provider_kmgmt_set_params;
456
+ const OSSL_FUNC_KEYMGMT_GET_PARAMS_PTR : KeyMgmtGetParamsPtr = parsec_provider_kmgmt_get_params;
399
457
const OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS_PTR : KeyMgmtSettableParamsPtr =
400
458
parsec_provider_kmgmt_settable_params;
459
+ const OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS_PTR : KeyMgmtGettableParamsPtr =
460
+ parsec_provider_kmgmt_gettable_params;
461
+
401
462
const OSSL_FUNC_KEYMGMT_MATCH_PTR : KeyMgmtMatchPtr = parsec_provider_kmgmt_match;
402
463
403
- const PARSEC_PROVIDER_KEYMGMT_IMPL : [ OSSL_DISPATCH ; 10 ] = [
464
+ const PARSEC_PROVIDER_KEYMGMT_IMPL : [ OSSL_DISPATCH ; 13 ] = [
404
465
unsafe { ossl_dispatch ! ( OSSL_FUNC_KEYMGMT_DUP , OSSL_FUNC_KEYMGMT_DUP_PTR ) } ,
405
466
unsafe { ossl_dispatch ! ( OSSL_FUNC_KEYMGMT_NEW , OSSL_FUNC_KEYMGMT_NEW_PTR ) } ,
406
467
unsafe { ossl_dispatch ! ( OSSL_FUNC_KEYMGMT_FREE , OSSL_FUNC_KEYMGMT_FREE_PTR ) } ,
@@ -430,6 +491,18 @@ const PARSEC_PROVIDER_KEYMGMT_IMPL: [OSSL_DISPATCH; 10] = [
430
491
OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS_PTR
431
492
)
432
493
} ,
494
+ unsafe {
495
+ ossl_dispatch ! (
496
+ OSSL_FUNC_KEYMGMT_GET_PARAMS ,
497
+ OSSL_FUNC_KEYMGMT_GET_PARAMS_PTR
498
+ )
499
+ } ,
500
+ unsafe {
501
+ ossl_dispatch ! (
502
+ OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS ,
503
+ OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS_PTR
504
+ )
505
+ } ,
433
506
unsafe { ossl_dispatch ! ( OSSL_FUNC_KEYMGMT_MATCH , OSSL_FUNC_KEYMGMT_MATCH_PTR ) } ,
434
507
ossl_dispatch ! ( ) ,
435
508
] ;
0 commit comments