File tree Expand file tree Collapse file tree 4 files changed +57
-0
lines changed Expand file tree Collapse file tree 4 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -236,3 +236,15 @@ shim_PSA_KEY_TYPE_DH_PUBLIC_KEY(psa_dh_group_t group)
236
236
{
237
237
return PSA_KEY_TYPE_DH_PUBLIC_KEY (group );
238
238
}
239
+
240
+ size_t
241
+ shim_PSA_SIGN_OUTPUT_SIZE (psa_key_type_t key_type , size_t key_bits , psa_algorithm_t alg )
242
+ {
243
+ return PSA_SIGN_OUTPUT_SIZE (key_type , key_bits , alg );
244
+ }
245
+
246
+ size_t
247
+ shim_PSA_KEY_EXPORT_MAX_SIZE (psa_key_type_t key_type , size_t key_bits )
248
+ {
249
+ return PSA_KEY_EXPORT_MAX_SIZE (key_type , key_bits );
250
+ }
Original file line number Diff line number Diff line change @@ -115,3 +115,5 @@ psa_key_type_t shim_PSA_KEY_TYPE_ECC_KEY_PAIR(psa_ecc_curve_t curve);
115
115
psa_key_type_t shim_PSA_KEY_TYPE_ECC_PUBLIC_KEY (psa_ecc_curve_t curve );
116
116
psa_key_type_t shim_PSA_KEY_TYPE_DH_KEY_PAIR (psa_dh_group_t group );
117
117
psa_key_type_t shim_PSA_KEY_TYPE_DH_PUBLIC_KEY (psa_dh_group_t group );
118
+ size_t shim_PSA_SIGN_OUTPUT_SIZE (psa_key_type_t key_type , size_t key_bits , psa_algorithm_t alg );
119
+ size_t shim_PSA_KEY_EXPORT_MAX_SIZE (psa_key_type_t key_type , size_t key_bits );
Original file line number Diff line number Diff line change @@ -171,3 +171,15 @@ pub fn PSA_KEY_TYPE_DH_KEY_PAIR(group: psa_dh_group_t) -> psa_key_type_t {
171
171
pub fn PSA_KEY_TYPE_DH_PUBLIC_KEY ( group : psa_dh_group_t ) -> psa_key_type_t {
172
172
unsafe { psa_crypto_binding:: shim_PSA_KEY_TYPE_DH_PUBLIC_KEY ( group) }
173
173
}
174
+
175
+ pub fn PSA_SIGN_OUTPUT_SIZE (
176
+ key_type : psa_key_type_t ,
177
+ key_bits : usize ,
178
+ alg : psa_algorithm_t ,
179
+ ) -> usize {
180
+ unsafe { psa_crypto_binding:: shim_PSA_SIGN_OUTPUT_SIZE ( key_type, key_bits, alg) }
181
+ }
182
+
183
+ pub fn PSA_EXPORT_KEY_OUTPUT_SIZE ( key_type : psa_key_type_t , key_bits : usize ) -> usize {
184
+ unsafe { psa_crypto_binding:: shim_PSA_KEY_EXPORT_MAX_SIZE ( key_type, key_bits) }
185
+ }
Original file line number Diff line number Diff line change @@ -305,6 +305,37 @@ impl Attributes {
305
305
get_attributes_res?;
306
306
Ok ( attributes?)
307
307
}
308
+
309
+ /// Sufficient size for a buffer to export the key, if supported
310
+ #[ cfg( feature = "with-mbed-crypto" ) ]
311
+ pub fn export_key_output_size ( self ) -> Result < usize > {
312
+ match self . key_type {
313
+ Type :: RsaKeyPair
314
+ | Type :: RsaPublicKey
315
+ | Type :: EccKeyPair { .. }
316
+ | Type :: EccPublicKey { .. } => Ok ( psa_crypto_sys:: PSA_EXPORT_KEY_OUTPUT_SIZE (
317
+ self . key_type . try_into ( ) ?,
318
+ self . bits ,
319
+ ) ) ,
320
+ _ => Err ( Error :: NotSupported ) ,
321
+ }
322
+ }
323
+
324
+ /// Sufficient buffer size for a signature using the given key, if the key is supported
325
+ #[ cfg( feature = "with-mbed-crypto" ) ]
326
+ pub fn sign_output_size ( self ) -> Result < usize > {
327
+ match self . key_type {
328
+ Type :: RsaPublicKey
329
+ | Type :: RsaKeyPair
330
+ | Type :: EccPublicKey { .. }
331
+ | Type :: EccKeyPair { .. } => Ok ( psa_crypto_sys:: PSA_SIGN_OUTPUT_SIZE (
332
+ self . key_type . try_into ( ) ?,
333
+ self . bits ,
334
+ self . policy . permitted_algorithms . try_into ( ) ?,
335
+ ) ) ,
336
+ _ => Err ( Error :: NotSupported ) ,
337
+ }
338
+ }
308
339
}
309
340
310
341
/// The lifetime of a key indicates where it is stored and which application and system actions
You can’t perform that action at this time.
0 commit comments