@@ -10,7 +10,10 @@ use aws_db_esdk::aws_cryptography_dbEncryptionSdk_dynamoDb::types::DynamoDbTable
10
10
use aws_db_esdk:: aws_cryptography_dbEncryptionSdk_dynamoDb:: types:: EncryptedPart ;
11
11
use aws_db_esdk:: aws_cryptography_dbEncryptionSdk_dynamoDb:: types:: SearchConfig ;
12
12
use aws_db_esdk:: aws_cryptography_dbEncryptionSdk_dynamoDb:: types:: SignedPart ;
13
- use aws_db_esdk:: aws_cryptography_dbEncryptionSdk_dynamoDb:: types:: SingleKeyStore ;
13
+ use aws_db_esdk:: aws_cryptography_dbEncryptionSdk_dynamoDb:: types:: MultiKeyStore ;
14
+ use aws_db_esdk:: aws_cryptography_materialProviders:: types:: CacheType ;
15
+ use aws_db_esdk:: aws_cryptography_materialProviders:: types:: DefaultCache ;
16
+ use aws_db_esdk:: aws_cryptography_materialProviders:: types:: cryptographic_materials_cache:: CryptographicMaterialsCacheRef ;
14
17
use aws_db_esdk:: aws_cryptography_dbEncryptionSdk_dynamoDb:: types:: StandardBeacon ;
15
18
use aws_db_esdk:: aws_cryptography_dbEncryptionSdk_structuredEncryption:: types:: CryptoAction ;
16
19
use aws_db_esdk:: aws_cryptography_keyStore:: client as keystore_client;
@@ -463,25 +466,40 @@ pub async fn setup_beacon_config(
463
466
] ;
464
467
465
468
// 9. Create BeaconVersion
469
+ let mpl_config = MaterialProvidersConfig :: builder ( ) . build ( ) ?;
470
+ let mpl = mpl_client:: Client :: from_conf ( mpl_config) ?;
471
+ let cache: CacheType = CacheType :: Default (
472
+ DefaultCache :: builder ( )
473
+ . entry_capacity ( 100 )
474
+ . build ( ) ?,
475
+ ) ;
476
+
477
+ let shared_cryptographic_materials_cache: CryptographicMaterialsCacheRef = mpl.
478
+ create_cryptographic_materials_cache ( )
479
+ . cache ( cache)
480
+ . send ( )
481
+ . await ?;
482
+
483
+ let shared_cache: CacheType = CacheType :: Shared ( shared_cryptographic_materials_cache) ;
484
+
466
485
let beacon_versions = BeaconVersion :: builder ( )
467
486
. standard_beacons ( standard_beacon_list)
468
487
. compound_beacons ( compound_beacon_list)
469
488
. encrypted_parts ( encrypted_parts_list)
470
489
. signed_parts ( signed_parts_list)
471
490
. version ( 1 )
472
491
. key_store ( key_store. clone ( ) )
473
- . key_source ( BeaconKeySource :: Single (
474
- SingleKeyStore :: builder ( )
475
- . key_id ( branch_key_id)
492
+ . key_source ( BeaconKeySource :: Multi (
493
+ MultiKeyStore :: builder ( )
494
+ . cache ( shared_cache)
495
+ . key_field_name ( branch_key_id)
476
496
. cache_ttl ( 6000 )
477
497
. build ( ) ?,
478
498
) )
479
499
. build ( ) ?;
480
500
let beacon_versions = vec ! [ beacon_versions] ;
481
501
482
502
// 10. Create a Hierarchical Keyring
483
- let mpl_config = MaterialProvidersConfig :: builder ( ) . build ( ) ?;
484
- let mpl = mpl_client:: Client :: from_conf ( mpl_config) ?;
485
503
let kms_keyring = mpl
486
504
. create_aws_kms_hierarchical_keyring ( )
487
505
. branch_key_id ( branch_key_id)
0 commit comments