Skip to content
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

Bump chacha20 and salsa20 #402

Merged
merged 4 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
appease clippy 1.56 needless_borrow
  • Loading branch information
trevyn committed Mar 17, 2022
commit 486d8b4a809971204147426f2ef14a42d0f74bfd
2 changes: 1 addition & 1 deletion aes-gcm-siv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ where
let expected_tag = self.finish_tag(associated_data.len(), buffer.len());

use subtle::ConstantTimeEq;
if expected_tag.ct_eq(&tag).unwrap_u8() == 1 {
if expected_tag.ct_eq(tag).unwrap_u8() == 1 {
Ok(())
} else {
// On MAC verify failure, re-encrypt the plaintext buffer to
Expand Down
2 changes: 1 addition & 1 deletion aes-gcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ where
ctr.apply_keystream(expected_tag.as_mut_slice());

use subtle::ConstantTimeEq;
if expected_tag.ct_eq(&tag).unwrap_u8() == 1 {
if expected_tag.ct_eq(tag).unwrap_u8() == 1 {
ctr.apply_keystream(buffer);
Ok(())
} else {
Expand Down
2 changes: 1 addition & 1 deletion ccm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ where
let (l, r) = adata.split_at(b.len() - n);
b[n..].copy_from_slice(l);
mac.block_update(&b);
mac.update(&r);
mac.update(r);
}
}

Expand Down
12 changes: 6 additions & 6 deletions deoxys/src/modes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ where
let mut block = [0u8; 16];
block.copy_from_slice(data);

B::encrypt_in_place(&mut block, &tweak, subkeys);
B::encrypt_in_place(&mut block, tweak, subkeys);

for (t, b) in tag.iter_mut().zip(block.iter()) {
*t ^= b;
Expand All @@ -320,7 +320,7 @@ where

block[data.len()] = 0x80;

B::encrypt_in_place(&mut block, &tweak, subkeys);
B::encrypt_in_place(&mut block, tweak, subkeys);

for (t, b) in tag.iter_mut().zip(block.iter()) {
*t ^= b;
Expand Down Expand Up @@ -352,7 +352,7 @@ where
let mut block = [0u8; 16];
block[1..].copy_from_slice(nonce);

B::encrypt_in_place(&mut block, &tweak, subkeys);
B::encrypt_in_place(&mut block, tweak, subkeys);

for (t, b) in data.iter_mut().zip(block.iter()) {
*t ^= b;
Expand Down Expand Up @@ -394,7 +394,7 @@ where
Self::authenticate_message(buffer, &mut tweak, subkeys, &mut tag);

tweak[0] = TWEAK_TAG;
tweak[1..].copy_from_slice(&nonce);
tweak[1..].copy_from_slice(nonce);
B::encrypt_in_place(&mut tag, &tweak, subkeys);

// Message encryption
Expand Down Expand Up @@ -430,8 +430,8 @@ where
Self::authenticate_message(buffer, &mut tweak, subkeys, &mut computed_tag);

tweak[0] = TWEAK_TAG;
tweak[1..].copy_from_slice(&nonce);
B::encrypt_in_place(&mut computed_tag, &tweak, &subkeys);
tweak[1..].copy_from_slice(nonce);
B::encrypt_in_place(&mut computed_tag, &tweak, subkeys);

if tag.ct_eq(&computed_tag).into() {
Ok(())
Expand Down
8 changes: 4 additions & 4 deletions eax/src/online.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,16 +303,16 @@ where
// l = block cipher size = 128 (for AES-128) = 16 byte
// 1. n ← OMAC(0 || Nonce)
// (the 0 means the number zero in l bits)
let n = prepend_cmac(&key, 0, nonce);
let n = prepend_cmac(key, 0, nonce);
let n = n.finalize().into_bytes();

// NOTE: These can be updated online later
// 2. h ← OMAC(1 || associated data)
let h = prepend_cmac(&key, 1, &[]);
let h = prepend_cmac(key, 1, &[]);
// 3. c ← OMAC(2 || enc)
let c = prepend_cmac(&key, 2, &[]);
let c = prepend_cmac(key, 2, &[]);

let cipher = ctr::Ctr128BE::<Cipher>::from_block_cipher(Cipher::new(&key), &n);
let cipher = ctr::Ctr128BE::<Cipher>::from_block_cipher(Cipher::new(key), &n);

Self {
nonce: n,
Expand Down
2 changes: 1 addition & 1 deletion xsalsa20poly1305/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ where
let expected_tag = self.mac.compute_unpadded(buffer).into_bytes();

// This performs a constant-time comparison using the `subtle` crate
if expected_tag.ct_eq(&tag).unwrap_u8() == 1 {
if expected_tag.ct_eq(tag).unwrap_u8() == 1 {
self.cipher.apply_keystream(buffer);
Ok(())
} else {
Expand Down