Skip to content

Commit

Permalink
chore!: Update aes-gcm to 0.10.3 and aes to 0.8.4 (#261)
Browse files Browse the repository at this point in the history
* update aes-gcm to 0.10.3

* update code to use new version

* update `aes` crate and pull in block-cypher dependency for Aes128CtrBE mode

* update code

* use big endian

* Update Cargo.toml

Co-authored-by: Michael Sproul <[email protected]>

---------

Co-authored-by: Michael Sproul <[email protected]>
  • Loading branch information
kevaundray and michaelsproul authored Aug 28, 2024
1 parent 8d20f81 commit 8609864
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ socket2 = "0.4"
smallvec = "1"
parking_lot = "0.11"
lazy_static = "1"
aes = { version = "0.7", features = ["ctr"] }
aes-gcm = "0.9"
aes = "0.8.4"
ctr = "0.9.2"
aes-gcm = "0.10.3"
tracing = { version = "0.1", features = ["log"] }
lru = "0.12"
hashlink = "0.8"
Expand Down
2 changes: 1 addition & 1 deletion src/handler/crypto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
packet::{ChallengeData, MessageNonce},
};
use aes_gcm::{
aead::{generic_array::GenericArray, Aead, NewAead, Payload},
aead::{generic_array::GenericArray, Aead, KeyInit, Payload},
Aes128Gcm,
};
use ecdh::ecdh;
Expand Down
12 changes: 6 additions & 6 deletions src/packet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
//! [`Packet`]: enum.Packet.html
use crate::{error::PacketError, Enr};
use aes::{
cipher::{generic_array::GenericArray, NewCipher, StreamCipher},
Aes128Ctr,
};
use aes::cipher::{generic_array::GenericArray, KeyIvInit, StreamCipher};

type Aes128Ctr64BE = ctr::Ctr64BE<aes::Aes128>;

use alloy_rlp::Decodable;
use enr::NodeId;
use rand::Rng;
Expand Down Expand Up @@ -411,7 +411,7 @@ impl Packet {
let mut key = GenericArray::clone_from_slice(&dst_id.raw()[..16]);
let mut nonce = GenericArray::clone_from_slice(&self.iv.to_be_bytes());

let mut cipher = Aes128Ctr::new(&key, &nonce);
let mut cipher = Aes128Ctr64BE::new(&key, &nonce);
cipher.apply_keystream(&mut header_bytes);
key.zeroize();
nonce.zeroize();
Expand Down Expand Up @@ -442,7 +442,7 @@ impl Packet {
*/
let key = GenericArray::clone_from_slice(&src_id.raw()[..16]);
let nonce = GenericArray::clone_from_slice(&iv);
let mut cipher = Aes128Ctr::new(&key, &nonce);
let mut cipher = Aes128Ctr64BE::new(&key, &nonce);

// Take the static header content
let mut static_header = data[IV_LENGTH..IV_LENGTH + STATIC_HEADER_LENGTH].to_vec();
Expand Down

0 comments on commit 8609864

Please sign in to comment.