Skip to content

Commit 3493780

Browse files
committed
try complex beacon example
1 parent 7b45929 commit 3493780

File tree

1 file changed

+24
-6
lines changed
  • DynamoDbEncryption/runtimes/rust/examples/searchableencryption/complexexample

1 file changed

+24
-6
lines changed

DynamoDbEncryption/runtimes/rust/examples/searchableencryption/complexexample/beacon_config.rs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ use aws_db_esdk::aws_cryptography_dbEncryptionSdk_dynamoDb::types::DynamoDbTable
1010
use aws_db_esdk::aws_cryptography_dbEncryptionSdk_dynamoDb::types::EncryptedPart;
1111
use aws_db_esdk::aws_cryptography_dbEncryptionSdk_dynamoDb::types::SearchConfig;
1212
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;
1417
use aws_db_esdk::aws_cryptography_dbEncryptionSdk_dynamoDb::types::StandardBeacon;
1518
use aws_db_esdk::aws_cryptography_dbEncryptionSdk_structuredEncryption::types::CryptoAction;
1619
use aws_db_esdk::aws_cryptography_keyStore::client as keystore_client;
@@ -463,25 +466,40 @@ pub async fn setup_beacon_config(
463466
];
464467

465468
// 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+
466485
let beacon_versions = BeaconVersion::builder()
467486
.standard_beacons(standard_beacon_list)
468487
.compound_beacons(compound_beacon_list)
469488
.encrypted_parts(encrypted_parts_list)
470489
.signed_parts(signed_parts_list)
471490
.version(1)
472491
.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)
476496
.cache_ttl(6000)
477497
.build()?,
478498
))
479499
.build()?;
480500
let beacon_versions = vec![beacon_versions];
481501

482502
// 10. Create a Hierarchical Keyring
483-
let mpl_config = MaterialProvidersConfig::builder().build()?;
484-
let mpl = mpl_client::Client::from_conf(mpl_config)?;
485503
let kms_keyring = mpl
486504
.create_aws_kms_hierarchical_keyring()
487505
.branch_key_id(branch_key_id)

0 commit comments

Comments
 (0)