Skip to content

Commit 0c29f40

Browse files
committed
chore: update client for 0.27
1 parent 167a4dc commit 0c29f40

File tree

4 files changed

+24
-18
lines changed

4 files changed

+24
-18
lines changed

src/crypto/attrs/flattened_encrypted_attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl FlattenedEncryptedAttributes {
4141
.collect_vec();
4242

4343
cipher
44-
.decrypt(self.attrs.into_iter())
44+
.decrypt(self.attrs.into_iter(), None, None, None)
4545
.await
4646
.map(|records| {
4747
records

src/encrypted_table/mod.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ use aws_sdk_dynamodb::types::{AttributeValue, Delete, Put, TransactWriteItem};
2020
use cipherstash_client::{
2121
config::{
2222
console_config::ConsoleConfig, cts_config::CtsConfig, zero_kms_config::ZeroKMSConfig,
23+
EnvSource,
2324
},
24-
credentials::{auto_refresh::AutoRefresh, service_credentials::ServiceCredentials},
25+
credentials::{auto_refresh::AutoRefresh, ServiceCredentials},
2526
encryption::ScopedCipher,
26-
zerokms::{ClientKey, ZeroKMS, ZeroKMSWithClientKey},
27+
zerokms::{ClientKey, ZeroKMSWithClientKey},
28+
IdentifiedBy,
2729
};
2830
use log::info;
2931
use std::{
@@ -73,7 +75,7 @@ impl EncryptedTable<Headless> {
7375

7476
let zerokms_config = ZeroKMSConfig::builder()
7577
.decryption_log(true)
76-
.with_env()
78+
.add_source(EnvSource::default())
7779
.console_config(&console_config)
7880
.cts_config(&cts_config)
7981
.build_with_client_key()?;
@@ -86,12 +88,8 @@ impl EncryptedTable<Headless> {
8688
) -> Result<Self, InitError> {
8789
info!("Initializing...");
8890

89-
let cipher = ZeroKMS::new_with_client_key(
90-
&zerokms_config.base_url(),
91-
AutoRefresh::new(zerokms_config.credentials()),
92-
zerokms_config.decryption_log_path().as_deref(),
93-
zerokms_config.client_key(),
94-
);
91+
let cipher = zerokms_config
92+
.create_client_with_credentials(AutoRefresh::new(zerokms_config.credentials()));
9593

9694
info!("Ready!");
9795

@@ -312,7 +310,8 @@ impl<D> EncryptedTable<D> {
312310
delete: PreparedDelete,
313311
dataset_id: Option<DatasetId>,
314312
) -> Result<DynamoRecordPatch, DeleteError> {
315-
let scoped_cipher = ScopedZeroKmsCipher::init(self.cipher.clone(), dataset_id).await?;
313+
let keyset_id = dataset_id.map(|id| IdentifiedBy::Uuid(id));
314+
let scoped_cipher = ScopedZeroKmsCipher::init(self.cipher.clone(), keyset_id).await?;
316315

317316
let PrimaryKeyParts { pk, sk } =
318317
encrypt_primary_key_parts(&scoped_cipher, delete.primary_key)?;
@@ -352,7 +351,8 @@ impl<D> EncryptedTable<D> {
352351
) -> Result<DynamoRecordPatch, PutError> {
353352
let mut seen_sk = HashSet::new();
354353

355-
let indexable_cipher = ScopedZeroKmsCipher::init(self.cipher.clone(), dataset_id).await?;
354+
let keyset_id = dataset_id.map(|id| IdentifiedBy::Uuid(id));
355+
let indexable_cipher = ScopedZeroKmsCipher::init(self.cipher.clone(), keyset_id).await?;
356356

357357
let PreparedRecord {
358358
protected_attributes,
@@ -463,7 +463,8 @@ impl EncryptedTable<Dynamo> {
463463
where
464464
T: Decryptable + Identifiable,
465465
{
466-
let cipher = ScopedZeroKmsCipher::init(self.cipher.clone(), dataset_id).await?;
466+
let keyset_id = dataset_id.map(|id| IdentifiedBy::Uuid(id));
467+
let cipher = ScopedZeroKmsCipher::init(self.cipher.clone(), keyset_id).await?;
467468

468469
let PrimaryKeyParts { pk, sk } =
469470
encrypt_primary_key_parts(&cipher, PreparedPrimaryKey::new::<T>(k))?;

src/encrypted_table/query.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use aws_sdk_dynamodb::{primitives::Blob, types::AttributeValue};
2-
use cipherstash_client::encryption::{
3-
compound_indexer::{ComposableIndex, ComposablePlaintext},
4-
Plaintext,
2+
use cipherstash_client::{
3+
encryption::{
4+
compound_indexer::{ComposableIndex, ComposablePlaintext},
5+
Plaintext,
6+
},
7+
IdentifiedBy,
58
};
69
use itertools::Itertools;
710
use std::{borrow::Cow, collections::HashMap, marker::PhantomData};
@@ -151,8 +154,10 @@ where
151154
where
152155
T: Decryptable + Identifiable,
153156
{
157+
let keyset_id = self.dataset_id.map(|id| IdentifiedBy::Uuid(id));
158+
154159
let scoped_cipher =
155-
ScopedZeroKmsCipher::init(self.storage.cipher.clone(), self.dataset_id).await?;
160+
ScopedZeroKmsCipher::init(self.storage.cipher.clone(), keyset_id).await?;
156161

157162
let storage = self.storage;
158163
let query = self.build()?;

src/traits/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::crypto::{SealError, Unsealed};
22
pub use crate::encrypted_table::{TableAttribute, TryFromTableAttr};
33
use cipherstash_client::encryption::EncryptionError;
44
pub use cipherstash_client::{
5-
credentials::{service_credentials::ServiceToken, Credentials},
5+
credentials::{Credentials, ServiceToken},
66
encryption::{
77
compound_indexer::{
88
ComposableIndex, ComposablePlaintext, CompoundIndex, ExactIndex, PrefixIndex,

0 commit comments

Comments
 (0)