Skip to content

Commit 4611888

Browse files
committed
Updated to use new message pack encoding from cipherstash-client
1 parent aeb558d commit 4611888

File tree

8 files changed

+24
-42
lines changed

8 files changed

+24
-42
lines changed

Cargo.lock

Lines changed: 12 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/crypto/attrs/flattened_encrypted_attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl FlattenedEncryptedAttributes {
6262
.into_iter()
6363
.map(|record| {
6464
record
65-
.to_vec()
65+
.to_mp_bytes()
6666
.map(|data| (FlattenedAttrName::parse(&record.descriptor), data))
6767
.map_err(|_| SealError::AssertionFailed("Decryption failed".to_string()))
6868
})

src/crypto/sealed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ mod tests {
242242
let cipher = get_cipher().await?;
243243
// TODO: Temporary obvs
244244
let dataset_id = Uuid::parse_str("93e10481-2692-4d65-a619-37e36a496e64").unwrap();
245-
let scoped_cipher = ScopedCipherWithCreds::init(cipher, dataset_id).await;
245+
let scoped_cipher = ScopedCipherWithCreds::init(cipher, dataset_id).await.unwrap();
246246

247247
let results = SealedTableEntry::unseal_all(vec![], spec, &scoped_cipher)
248248
.await

src/encrypted_table/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ impl<D> EncryptedTable<D> {
281281
{
282282
// TODO: Temporary obvs
283283
let dataset_id = Uuid::parse_str("93e10481-2692-4d65-a619-37e36a496e64").unwrap();
284-
let scoped_cipher = ScopedCipherWithCreds::init(self.cipher.clone(), dataset_id).await?;
284+
let scoped_cipher = ScopedCipherWithCreds::init(self.cipher.clone(), dataset_id).await.unwrap();
285285

286286
decrypt_all(&scoped_cipher, items).await
287287
}
@@ -292,7 +292,7 @@ impl<D> EncryptedTable<D> {
292292
) -> Result<DynamoRecordPatch, DeleteError> {
293293
// TODO: Temporary obvs
294294
let dataset_id = Uuid::parse_str("93e10481-2692-4d65-a619-37e36a496e64").unwrap();
295-
let scoped_cipher = ScopedCipherWithCreds::init(self.cipher.clone(), dataset_id).await;
295+
let scoped_cipher = ScopedCipherWithCreds::init(self.cipher.clone(), dataset_id).await.unwrap();
296296

297297
let PrimaryKeyParts { pk, sk } = encrypt_primary_key_parts(&scoped_cipher, delete.primary_key)?;
298298

@@ -330,7 +330,7 @@ impl<D> EncryptedTable<D> {
330330

331331
// TODO: Temporary obvs
332332
let dataset_id = Uuid::parse_str("93e10481-2692-4d65-a619-37e36a496e64").unwrap();
333-
let indexable_cipher = ScopedCipherWithCreds::init(self.cipher.clone(), dataset_id).await;
333+
let indexable_cipher = ScopedCipherWithCreds::init(self.cipher.clone(), dataset_id).await.unwrap();
334334

335335
let PreparedRecord {
336336
protected_attributes,
@@ -405,7 +405,7 @@ impl EncryptedTable<Dynamo> {
405405
{
406406
// TODO: Temporary obvs
407407
let dataset_id = Uuid::parse_str("93e10481-2692-4d65-a619-37e36a496e64").unwrap();
408-
let scoped_cipher = ScopedCipherWithCreds::init(self.cipher.clone(), dataset_id).await;
408+
let scoped_cipher = ScopedCipherWithCreds::init(self.cipher.clone(), dataset_id).await.unwrap();
409409

410410
let PrimaryKeyParts { pk, sk } =
411411
encrypt_primary_key_parts(&scoped_cipher, PreparedPrimaryKey::new::<T>(k))?;

src/encrypted_table/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ where
134134
{
135135
// TODO: Temporary obvs
136136
let dataset_id = Uuid::parse_str("93e10481-2692-4d65-a619-37e36a496e64").unwrap();
137-
let scoped_cipher = ScopedCipherWithCreds::init(self.storage.cipher.clone(), dataset_id).await;
137+
let scoped_cipher = ScopedCipherWithCreds::init(self.storage.cipher.clone(), dataset_id).await.unwrap();
138138

139139
let storage = self.storage;
140140
let query = self.build()?;

src/encrypted_table/table_attribute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl TableAttribute {
4141
descriptor: &str,
4242
) -> Result<EncryptedRecord, SealError> {
4343
if let TableAttribute::Bytes(s) = self {
44-
EncryptedRecord::from_slice(&s[..])
44+
EncryptedRecord::from_mp_bytes(&s[..])
4545
.map_err(|_| SealError::AssertionFailed("Could not parse EncryptedRecord".to_string()))
4646
.and_then(|record| {
4747
if record.descriptor == descriptor {

src/lib.rs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
pub mod crypto;
77
pub mod encrypted_table;
88
pub mod traits;
9-
use encrypted_table::DynamoRecordPatch;
109
pub use encrypted_table::{EncryptedTable, QueryBuilder};
1110
pub use traits::{
1211
Decryptable, Encryptable, Identifiable, IndexType, Pk, PkSk, PrimaryKey, Searchable,
@@ -21,31 +20,4 @@ pub use cipherstash_dynamodb_derive::{Decryptable, Encryptable, Identifiable, Se
2120

2221
// Re-exports
2322
pub use cipherstash_client::encryption;
24-
25-
pub type Key = [u8; 32];
26-
27-
28-
pub struct Put<T> {
29-
record: T,
30-
}
31-
32-
impl<T> Put<T> where T: Encryptable + Identifiable {
33-
pub fn new(record: T) -> Self {
34-
Self { record }
35-
}
36-
}
37-
38-
pub struct Cipher {}
39-
40-
impl Cipher {
41-
}
42-
43-
pub trait IntoPatch<Op> {
44-
fn seal(&self, op: Op) -> Result<DynamoRecordPatch, Error>;
45-
}
46-
47-
impl<T> IntoPatch<Put<T>> for Cipher {
48-
fn seal(&self, op: Put<T>) -> Result<DynamoRecordPatch, Error> {
49-
unimplemented!()
50-
}
51-
}
23+
pub type Key = [u8; 32];

tests/query_builder_direct.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ async fn test_query_single_exact() {
9090
.expect("failed to build query");
9191

9292
let dataset_id = Uuid::parse_str("93e10481-2692-4d65-a619-37e36a496e64").unwrap();
93-
let scoped_cipher = ScopedCipherWithCreds::init(table.cipher(), dataset_id).await;
93+
let scoped_cipher = ScopedCipherWithCreds::init(table.cipher(), dataset_id).await.unwrap();
9494

9595
let term = query
9696
.encrypt(&scoped_cipher)
@@ -133,7 +133,7 @@ async fn test_query_single_prefix() {
133133
.expect("failed to init table");
134134

135135
let dataset_id = Uuid::parse_str("93e10481-2692-4d65-a619-37e36a496e64").unwrap();
136-
let scoped_cipher = ScopedCipherWithCreds::init(table.cipher(), dataset_id).await;
136+
let scoped_cipher = ScopedCipherWithCreds::init(table.cipher(), dataset_id).await.unwrap();
137137

138138
let query = QueryBuilder::<User>::new()
139139
.starts_with("name", "Dan")
@@ -190,7 +190,7 @@ async fn test_query_compound() {
190190
.expect("failed to build query");
191191

192192
let dataset_id = Uuid::parse_str("93e10481-2692-4d65-a619-37e36a496e64").unwrap();
193-
let scoped_cipher = ScopedCipherWithCreds::init(table.cipher(), dataset_id).await;
193+
let scoped_cipher = ScopedCipherWithCreds::init(table.cipher(), dataset_id).await.unwrap();
194194

195195
let term = query
196196
.encrypt(&scoped_cipher)

0 commit comments

Comments
 (0)