@@ -21,7 +21,7 @@ use cipherstash_client::{
2121 config:: { console_config:: ConsoleConfig , cts_config:: CtsConfig , zero_kms_config:: ZeroKMSConfig } , credentials:: {
2222 auto_refresh:: AutoRefresh ,
2323 service_credentials:: ServiceCredentials ,
24- } , encryption:: ScopedZeroKMSCipher , zerokms:: { ZeroKMS , ZeroKMSWithClientKey }
24+ } , encryption:: ScopedCipher , zerokms:: { ZeroKMS , ZeroKMSWithClientKey }
2525} ;
2626use log:: info;
2727use uuid:: Uuid ;
@@ -50,13 +50,11 @@ impl Deref for Dynamo {
5050}
5151
5252pub type Cipher = ZeroKMSWithClientKey < AutoRefresh < ServiceCredentials > > ;
53- pub type ScopedCipher = ScopedZeroKMSCipher < AutoRefresh < ServiceCredentials > > ;
53+ pub type ScopedCipherWithCreds = ScopedCipher < AutoRefresh < ServiceCredentials > > ;
5454
5555pub struct EncryptedTable < D = Dynamo > {
5656 db : D ,
5757 cipher : Arc < Cipher > ,
58- // FIXME: This is temporary
59- dataset_root_key : [ u8 ; 32 ] ,
6058}
6159
6260impl < D > EncryptedTable < D > {
@@ -92,7 +90,6 @@ impl EncryptedTable<Headless> {
9290 Ok ( Self {
9391 db : Headless ,
9492 cipher : Arc :: new ( cipher) ,
95- dataset_root_key : [ 0 ; 32 ] , // TODO
9693 } )
9794 }
9895}
@@ -284,7 +281,7 @@ impl<D> EncryptedTable<D> {
284281 {
285282 // TODO: Temporary obvs
286283 let dataset_id = Uuid :: parse_str ( "93e10481-2692-4d65-a619-37e36a496e64" ) . unwrap ( ) ;
287- let scoped_cipher = ScopedCipher :: init ( self . cipher . clone ( ) , dataset_id) . await ;
284+ let scoped_cipher = ScopedCipherWithCreds :: init ( self . cipher . clone ( ) , dataset_id) . await ? ;
288285
289286 decrypt_all ( & scoped_cipher, items) . await
290287 }
@@ -295,7 +292,7 @@ impl<D> EncryptedTable<D> {
295292 ) -> Result < DynamoRecordPatch , DeleteError > {
296293 // TODO: Temporary obvs
297294 let dataset_id = Uuid :: parse_str ( "93e10481-2692-4d65-a619-37e36a496e64" ) . unwrap ( ) ;
298- let scoped_cipher = ScopedCipher :: init ( self . cipher . clone ( ) , dataset_id) . await ;
295+ let scoped_cipher = ScopedCipherWithCreds :: init ( self . cipher . clone ( ) , dataset_id) . await ;
299296
300297 let PrimaryKeyParts { pk, sk } = encrypt_primary_key_parts ( & scoped_cipher, delete. primary_key ) ?;
301298
@@ -333,7 +330,7 @@ impl<D> EncryptedTable<D> {
333330
334331 // TODO: Temporary obvs
335332 let dataset_id = Uuid :: parse_str ( "93e10481-2692-4d65-a619-37e36a496e64" ) . unwrap ( ) ;
336- let indexable_cipher = ScopedCipher :: init ( self . cipher . clone ( ) , dataset_id) . await ;
333+ let indexable_cipher = ScopedCipherWithCreds :: init ( self . cipher . clone ( ) , dataset_id) . await ;
337334
338335 let PreparedRecord {
339336 protected_attributes,
@@ -354,8 +351,6 @@ impl<D> EncryptedTable<D> {
354351
355352 let PrimaryKeyParts { pk, sk } = sealed. primary_key ( ) ;
356353
357- println ! ( "IN CREATE_PUT_PATCH {:?} {:?}" , pk, sk) ;
358-
359354 let ( root, index_entries) = sealed. into_table_entries ( index_predicate) ;
360355
361356 seen_sk. insert ( root. inner ( ) . sk . clone ( ) ) ;
@@ -401,8 +396,6 @@ impl EncryptedTable<Dynamo> {
401396 db,
402397 } ,
403398 cipher : table. cipher ,
404- // FIXME: This is temporary
405- dataset_root_key : table. dataset_root_key ,
406399 } )
407400 }
408401
@@ -412,14 +405,12 @@ impl EncryptedTable<Dynamo> {
412405 {
413406 // TODO: Temporary obvs
414407 let dataset_id = Uuid :: parse_str ( "93e10481-2692-4d65-a619-37e36a496e64" ) . unwrap ( ) ;
415- let scoped_cipher = ScopedCipher :: init ( self . cipher . clone ( ) , dataset_id) . await ;
408+ let scoped_cipher = ScopedCipherWithCreds :: init ( self . cipher . clone ( ) , dataset_id) . await ;
416409
417410 let PrimaryKeyParts { pk, sk } =
418411 encrypt_primary_key_parts ( & scoped_cipher, PreparedPrimaryKey :: new :: < T > ( k) ) ?;
419412
420413
421- println ! ( "IN GET {:?} {:?}" , pk, sk) ;
422-
423414 let result = self
424415 . db
425416 . get_item ( )
@@ -493,7 +484,7 @@ impl EncryptedTable<Dynamo> {
493484/// Take a prepared primary key and encrypt it to get the [`PrimaryKeyParts`] which can be used
494485/// for retrieval.
495486fn encrypt_primary_key_parts (
496- scoped_cipher : & ScopedCipher ,
487+ scoped_cipher : & ScopedCipherWithCreds ,
497488 prepared_primary_key : PreparedPrimaryKey ,
498489) -> Result < PrimaryKeyParts , PrimaryKeyError > {
499490 let PrimaryKeyParts { mut pk, mut sk } = prepared_primary_key. primary_key_parts ;
@@ -509,7 +500,7 @@ fn encrypt_primary_key_parts(
509500 Ok ( PrimaryKeyParts { pk, sk } )
510501}
511502
512- async fn decrypt < T > ( scoped_cipher : & ScopedCipher , item : HashMap < String , AttributeValue > ) -> Result < T , DecryptError >
503+ async fn decrypt < T > ( scoped_cipher : & ScopedCipherWithCreds , item : HashMap < String , AttributeValue > ) -> Result < T , DecryptError >
513504where
514505 T : Decryptable + Identifiable ,
515506{
@@ -521,7 +512,7 @@ where
521512}
522513
523514async fn decrypt_all < T > (
524- scoped_cipher : & ScopedCipher ,
515+ scoped_cipher : & ScopedCipherWithCreds ,
525516 items : impl IntoIterator < Item = HashMap < String , AttributeValue > > ,
526517) -> Result < Vec < T > , DecryptError >
527518where
0 commit comments