-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed-key AES garbling #8
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't checked the actual cryptography, just the Rust code style. In general it looks good to me, but maybe we should wait with the merge until we have the benchmarks, to be able to see the performance difference between the current encryption scheme and this one?
src/garble.rs
Outdated
bincode::deserialize(&plaintext).map_err(|e| Error::Serde(format!("{e:?}"))) | ||
let mut triple: (bool, Vec<Option<Mac>>, Label) = (false, vec![], Label(0)); | ||
let hash = hash_aes(garbling_key, party_num + 1, cipher)?; | ||
let mut decrypted = xor_dec(&hash[0], &bytes[0])?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bytes[0]
access will panic if bytes is empty, which could be the case if an attacker sends an empty message, correct? I would suggest to rewrite the function in such a way the length of any Vec is checked before we attempt to decrypt, so that the function either errors out or succeeds, but never panics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very true, thank you, I added a check on the length of the bytes for decryption.
src/garble.rs
Outdated
let hash = hash_aes(garbling_key, party_num + 1, cipher)?; | ||
let mut result: Vec<Vec<u8>> = vec![]; | ||
result.push(xor_enc(&hash[0], triple.0 as u128)?); | ||
for (i, h) in hash.iter().enumerate().take(party_num + 1).skip(1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can keep it as it is, but I'm wondering if this can be simplified, in two ways:
for (i, h) in hash.iter().skip(1).take(party_num).enumerate()
, so you don't have to doi - 1
- should
hash[0]
andhash[1..]
instead be a tuple(hash, hashes)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I included these, also the suggestion to have a tuple. It also made resolving the next comment easier (to serialize/deserialize only once).
src/garble.rs
Outdated
triple.1.push(None); | ||
} else { | ||
decrypted = xor_dec(&hash[i], &bytes[i])?; | ||
mac = bincode::deserialize(&(decrypted).to_le_bytes()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of serializing / deserializing multiple times inside a function, maybe we could just serialize / deserialize once?
Let's maybe close this one for now? We don't know whether we want to keep this and even if we do we would need to update the branch. |
No description provided.