Skip to content

Commit 0cb8faf

Browse files
committed
Fixed warnings and removed legacy code
1 parent 37bd5b6 commit 0cb8faf

14 files changed

Lines changed: 30 additions & 351 deletions

src/async_map_somes.rs

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/crypto/attrs/flattened_encrypted_attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use cipherstash_client::{credentials::{service_credentials::ServiceToken, Credentials}, encryption::{Encryption, EncryptionError}, zero_kms::EncryptedRecord};
22
use itertools::Itertools;
3-
use crate::{crypto::{attrs::flattened_protected_attributes::FlattenedKey, SealError}, encrypted_table::{TableAttributes, TableEntry}, traits::TableAttribute};
3+
use crate::{crypto::{attrs::flattened_protected_attributes::FlattenedKey, SealError}, encrypted_table::TableAttributes, traits::TableAttribute};
44

55
use super::FlattenedProtectedAttributes;
66

src/crypto/attrs/flattened_protected_attributes.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::{
2-
flattened_encrypted_attributes::FlattenedEncryptedAttributes, normalized_protected_attributes::NormalizedKey, NormalizedProtectedAttributes
2+
flattened_encrypted_attributes::FlattenedEncryptedAttributes, normalized_protected_attributes::NormalizedKey
33
};
44
use crate::crypto::SealError;
55
use cipherstash_client::{
@@ -160,10 +160,6 @@ impl FlattenedKey {
160160
}
161161
}
162162

163-
pub(crate) fn has_subkey(&self) -> bool {
164-
self.subkey.is_some()
165-
}
166-
167163
/// Consume and return the parts of the key (not including the prefix).
168164
pub fn into_key_parts(self) -> (String, Option<String>) {
169165
(self.key, self.subkey)

src/crypto/attrs/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,3 @@ mod normalized_protected_attributes;
44
pub(crate) use flattened_protected_attributes::FlattenedProtectedAttributes;
55
pub(crate) use normalized_protected_attributes::NormalizedProtectedAttributes;
66
pub(crate) use flattened_encrypted_attributes::FlattenedEncryptedAttributes;
7-
8-
pub(crate) enum ProtectedAttributes {
9-
Normalized(NormalizedProtectedAttributes),
10-
Flattened(FlattenedProtectedAttributes),
11-
}

src/crypto/attrs/normalized_protected_attributes.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use std::collections::{hash_map, HashMap};
1+
use std::collections::HashMap;
22
use cipherstash_client::encryption::Plaintext;
3-
use itertools::{Chunk, Chunks, IntoChunks, Itertools};
43
use super::flattened_protected_attributes::{
54
FlattenedKey, FlattenedProtectedAttribute, FlattenedProtectedAttributes,
65
};

src/crypto/sealed.rs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
use crate::{
2-
async_map_somes::async_map_somes, crypto::attrs::FlattenedEncryptedAttributes, encrypted_table::TableEntry, traits::{ReadConversionError, TableAttribute, WriteConversionError}, Decryptable
2+
crypto::attrs::FlattenedEncryptedAttributes, encrypted_table::TableEntry, traits::{ReadConversionError, WriteConversionError}, Decryptable
33
};
44
use aws_sdk_dynamodb::{primitives::Blob, types::AttributeValue};
55
use cipherstash_client::{
66
credentials::{service_credentials::ServiceToken, Credentials},
7-
encryption::{Encryption, Plaintext},
7+
encryption::Encryption,
88
};
99
use itertools::Itertools;
10-
use std::{borrow::Cow, collections::HashMap, ops::Deref};
10+
use std::{borrow::Cow, collections::HashMap};
1111

12-
use super::{attrs::NormalizedProtectedAttributes, sealer::Sealed, SealError, Unsealed};
12+
use super::{attrs::NormalizedProtectedAttributes, SealError, Unsealed};
1313

1414
// FIXME: Remove this (only used for debugging)
1515
#[derive(Debug)]
@@ -61,25 +61,13 @@ impl SealedTableEntry {
6161
spec: UnsealSpec<'_>,
6262
cipher: &Encryption<impl Credentials<Token = ServiceToken>>,
6363
) -> Result<Vec<Unsealed>, SealError> {
64-
//let items = items.as_ref();
6564

6665
let UnsealSpec {
6766
protected_attributes,
67+
// TODO: Why is this here?
6868
plaintext_attributes,
6969
} = spec;
7070

71-
72-
// FIXME: The following issues remain:
73-
// 1. The pk and sk are not being added to the unsealed
74-
// 2. We don't handle the case where protected_attributes is empty
75-
// 3. We don't handle the case where plaintext_attributes is empty
76-
// 4. The zipped iterator is misaligned
77-
// Unsealed item: Unsealed { descriptor: None, protected: {"name": (SmallInt(Some(42)), "/name"), "age": (Utf8Str(Some("value-a")), "/age"), "attrs": (Utf8Str(Some("value-c")), "/attrs")}, unprotected: TableAttributes({"tag": String("sk")}) }
78-
// 5. (Minor) The Unsealed is not given a descriptor after decryption
79-
// 6. Ciphertexts are unexpectedly large
80-
// 7. Determine if pk and sk should be underscored (check the bahaviour in main or tests)
81-
82-
//let mut plaintext_items: Vec<Vec<Option<&TableAttribute>>> =
8371
let mut unprotected_items = Vec::with_capacity(items.len());
8472
let mut protected_items = FlattenedEncryptedAttributes::with_capacity(items.len() * protected_attributes.len());
8573

src/crypto/sealer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ impl Sealed {
412412
mut index_predicate: impl FnMut(&str, &TableAttribute) -> bool,
413413
) -> (SealedTableEntry, Vec<SealedTableEntry>) {
414414
// TODO: Is this normalization necessary? - try removing it
415-
let root_attributes = self.attributes.normalize();
415+
let root_attributes = self.attributes;
416416

417417
let index_attributes: TableAttributes = root_attributes
418418
.clone()

src/crypto/unsealed.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,14 @@ impl Unsealed {
4242

4343
// TODO: Change this to take_unprotected
4444
pub fn get_plaintext(&self, name: &str) -> TableAttribute {
45-
println!("Getting plaintext for {}", name);
46-
println!("unprotected: {:?}", self.unprotected);
47-
let r = self.unprotected
48-
.get(name);
49-
println!("Got plaintext for {}: {:?}", name, r);
50-
r
45+
self.unprotected
46+
.get(name)
5147
.cloned()
5248
.unwrap_or(TableAttribute::Null)
5349
}
5450

55-
pub fn add_protected(&mut self, name: impl Into<String>, plaintext: Plaintext) {
56-
self.protected.insert(name, plaintext);
51+
pub fn add_protected(&mut self, name: impl Into<String>, plaintext: impl Into<Plaintext>) {
52+
self.protected.insert(name, plaintext.into());
5753
}
5854

5955
pub fn add_protected_map(&mut self, name: impl Into<String>, map: HashMap<String, Plaintext>) {
@@ -64,11 +60,11 @@ impl Unsealed {
6460
/// If the map does not exist, it will be created.
6561
/// If the map exists, the key-value pair will be updated.
6662
/// If an attribute called `name` already exists but is not a map, this will panic.
67-
pub fn add_protected_map_field(&mut self, name: impl Into<String>, subkey: impl Into<String>, value: Plaintext) {
68-
self.protected.insert_and_update_map(name, subkey, value);
63+
pub fn add_protected_map_field(&mut self, name: impl Into<String>, subkey: impl Into<String>, value: impl Into<Plaintext>) {
64+
self.protected.insert_and_update_map(name, subkey, value.into());
6965
}
7066

71-
pub fn add_unprotected(&mut self, name: impl Into<String>, attribute: TableAttribute) {
67+
pub fn add_unprotected(&mut self, name: impl Into<String>, attribute: impl Into<TableAttribute>) {
7268
self.unprotected.insert(name.into(), attribute);
7369
}
7470

src/encrypted_table/dynamo.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/encrypted_table/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
mod dynamo;
21
pub mod query;
32
mod table_attribute;
43
mod table_attributes;
@@ -23,7 +22,7 @@ use cipherstash_client::{
2322
service_credentials::{ServiceCredentials, ServiceToken},
2423
Credentials,
2524
},
26-
encryption::{Encryption, Plaintext},
25+
encryption::Encryption,
2726
zero_kms::ZeroKMS,
2827
};
2928
use log::info;
@@ -32,8 +31,8 @@ use std::{
3231
collections::{HashMap, HashSet},
3332
ops::Deref,
3433
};
35-
pub use dynamo::DynamoItem;
3634

35+
/// Index terms are truncated to this length
3736
const DEFAULT_TERM_SIZE: usize = 12;
3837

3938
pub struct Headless;

0 commit comments

Comments
 (0)