@@ -49,16 +49,16 @@ impl Deref for Dynamo {
4949 }
5050}
5151
52- pub type Cipher = ZeroKMSWithClientKey < AutoRefresh < ServiceCredentials > > ;
53- pub type ScopedCipherWithCreds = ScopedCipher < AutoRefresh < ServiceCredentials > > ;
52+ pub type ZeroKmsCipher = ZeroKMSWithClientKey < AutoRefresh < ServiceCredentials > > ;
53+ pub type ScopedZeroKmsCipher = ScopedCipher < AutoRefresh < ServiceCredentials > > ;
5454
5555pub struct EncryptedTable < D = Dynamo > {
5656 db : D ,
57- cipher : Arc < Cipher > ,
57+ cipher : Arc < ZeroKmsCipher > ,
5858}
5959
6060impl < D > EncryptedTable < D > {
61- pub fn cipher ( & self ) -> Arc < Cipher > {
61+ pub fn cipher ( & self ) -> Arc < ZeroKmsCipher > {
6262 self . cipher . clone ( )
6363 }
6464}
@@ -279,9 +279,10 @@ impl<D> EncryptedTable<D> {
279279 ) -> Result < Vec < T > , DecryptError >
280280 where T : Decryptable + Identifiable ,
281281 {
282+ // TODO: Decryption _may_ not need to be scoped
282283 // TODO: Temporary obvs
283284 let dataset_id = Uuid :: parse_str ( "93e10481-2692-4d65-a619-37e36a496e64" ) . unwrap ( ) ;
284- let scoped_cipher = ScopedCipherWithCreds :: init ( self . cipher . clone ( ) , dataset_id) . await . unwrap ( ) ;
285+ let scoped_cipher = ScopedZeroKmsCipher :: init ( self . cipher . clone ( ) , dataset_id) . await . unwrap ( ) ;
285286
286287 decrypt_all ( & scoped_cipher, items) . await
287288 }
@@ -292,7 +293,7 @@ impl<D> EncryptedTable<D> {
292293 ) -> Result < DynamoRecordPatch , DeleteError > {
293294 // TODO: Temporary obvs
294295 let dataset_id = Uuid :: parse_str ( "93e10481-2692-4d65-a619-37e36a496e64" ) . unwrap ( ) ;
295- let scoped_cipher = ScopedCipherWithCreds :: init ( self . cipher . clone ( ) , dataset_id) . await . unwrap ( ) ;
296+ let scoped_cipher = ScopedZeroKmsCipher :: init ( self . cipher . clone ( ) , dataset_id) . await . unwrap ( ) ;
296297
297298 let PrimaryKeyParts { pk, sk } = encrypt_primary_key_parts ( & scoped_cipher, delete. primary_key ) ?;
298299
@@ -323,14 +324,15 @@ impl<D> EncryptedTable<D> {
323324 pub async fn create_put_patch (
324325 & self ,
325326 record : PreparedRecord ,
327+ dataset_id : Uuid ,
326328 // TODO: Make sure the index_predicate is used correctly
327329 index_predicate : impl FnMut ( & AttributeName , & TableAttribute ) -> bool ,
328330 ) -> Result < DynamoRecordPatch , PutError > {
329331 let mut seen_sk = HashSet :: new ( ) ;
330332
331333 // TODO: Temporary obvs
332334 let dataset_id = Uuid :: parse_str ( "93e10481-2692-4d65-a619-37e36a496e64" ) . unwrap ( ) ;
333- let indexable_cipher = ScopedCipherWithCreds :: init ( self . cipher . clone ( ) , dataset_id) . await . unwrap ( ) ;
335+ let indexable_cipher = ScopedZeroKmsCipher :: init ( self . cipher . clone ( ) , dataset_id) . await . unwrap ( ) ;
334336
335337 let PreparedRecord {
336338 protected_attributes,
@@ -405,7 +407,7 @@ impl EncryptedTable<Dynamo> {
405407 {
406408 // TODO: Temporary obvs
407409 let dataset_id = Uuid :: parse_str ( "93e10481-2692-4d65-a619-37e36a496e64" ) . unwrap ( ) ;
408- let scoped_cipher = ScopedCipherWithCreds :: init ( self . cipher . clone ( ) , dataset_id) . await . unwrap ( ) ;
410+ let scoped_cipher = ScopedZeroKmsCipher :: init ( self . cipher . clone ( ) , dataset_id) . await . unwrap ( ) ;
409411
410412 let PrimaryKeyParts { pk, sk } =
411413 encrypt_primary_key_parts ( & scoped_cipher, PreparedPrimaryKey :: new :: < T > ( k) ) ?;
@@ -484,7 +486,7 @@ impl EncryptedTable<Dynamo> {
484486/// Take a prepared primary key and encrypt it to get the [`PrimaryKeyParts`] which can be used
485487/// for retrieval.
486488fn encrypt_primary_key_parts (
487- scoped_cipher : & ScopedCipherWithCreds ,
489+ scoped_cipher : & ScopedZeroKmsCipher ,
488490 prepared_primary_key : PreparedPrimaryKey ,
489491) -> Result < PrimaryKeyParts , PrimaryKeyError > {
490492 let PrimaryKeyParts { mut pk, mut sk } = prepared_primary_key. primary_key_parts ;
@@ -500,7 +502,7 @@ fn encrypt_primary_key_parts(
500502 Ok ( PrimaryKeyParts { pk, sk } )
501503}
502504
503- async fn decrypt < T > ( scoped_cipher : & ScopedCipherWithCreds , item : HashMap < String , AttributeValue > ) -> Result < T , DecryptError >
505+ async fn decrypt < T > ( scoped_cipher : & ScopedZeroKmsCipher , item : HashMap < String , AttributeValue > ) -> Result < T , DecryptError >
504506where
505507 T : Decryptable + Identifiable ,
506508{
@@ -512,7 +514,7 @@ where
512514}
513515
514516async fn decrypt_all < T > (
515- scoped_cipher : & ScopedCipherWithCreds ,
517+ scoped_cipher : & ScopedZeroKmsCipher ,
516518 items : impl IntoIterator < Item = HashMap < String , AttributeValue > > ,
517519) -> Result < Vec < T > , DecryptError >
518520where
0 commit comments