@@ -12,6 +12,10 @@ use crate::providers::ProviderIdentity;
12
12
use derivative:: Derivative ;
13
13
use log:: { info, trace} ;
14
14
use parsec_interface:: operations:: list_providers:: Uuid ;
15
+ use parsec_interface:: operations:: psa_algorithm:: Algorithm ;
16
+ use parsec_interface:: operations:: psa_key_attributes:: {
17
+ Attributes , Lifetime , Policy , Type , UsageFlags ,
18
+ } ;
15
19
use parsec_interface:: operations:: {
16
20
attest_key, can_do_crypto, prepare_key_attestation, psa_asymmetric_decrypt,
17
21
psa_asymmetric_encrypt, psa_destroy_key, psa_export_public_key, psa_generate_key,
@@ -478,6 +482,45 @@ impl ProviderBuilder {
478
482
format_error ! ( "Error when verifying the Root Key's Name" , e) ;
479
483
return Err ( e) ;
480
484
}
485
+ } else {
486
+ let mut esapi_context = built_provider
487
+ . esapi_context
488
+ . lock ( )
489
+ . expect ( "ESAPI Context lock poisoned" ) ;
490
+
491
+ let root_key_name = esapi_context. get_root_key_name ( ) . map_err ( |e| {
492
+ format_error ! ( "Error getting the the Root Key's Name" , e) ;
493
+ std:: io:: Error :: new (
494
+ ErrorKind :: InvalidData ,
495
+ "failed getting Root Key's Name" ,
496
+ )
497
+ } ) ?;
498
+
499
+ let attributes = Attributes {
500
+ lifetime : Lifetime :: Persistent ,
501
+ key_type : Type :: RsaPublicKey ,
502
+ bits : ROOT_KEY_SIZE as usize ,
503
+ policy : Policy {
504
+ // Internal key, usage_flags information is not relevant
505
+ usage_flags : UsageFlags :: default ( ) ,
506
+ // Internal key, permitted_algorithms information is not relevant
507
+ permitted_algorithms : Algorithm :: None ,
508
+ } ,
509
+ } ;
510
+
511
+ built_provider
512
+ . key_info_store
513
+ . insert_key_info (
514
+ root_key_identity,
515
+ & ( root_key_name. value ( ) . to_vec ( ) ) ,
516
+ attributes,
517
+ )
518
+ . map_err ( |_| {
519
+ std:: io:: Error :: new (
520
+ ErrorKind :: InvalidData ,
521
+ "Failed to insert Key Info in the Key Store" ,
522
+ )
523
+ } ) ?;
481
524
}
482
525
483
526
Ok ( built_provider)
0 commit comments