Skip to content

Commit

Permalink
Use new prerelease dependencies; fix hybrid-array deprecations (#617)
Browse files Browse the repository at this point in the history
This includes the following dependency bumps along with fixing all of
the deprecation warnings that come when upgrading `hybrid-array` to
v0.2.0-pre.9:

- `aead` v0.6.0-rc.0
- `aes` v0.9.0-pre.1
- `chacha20` v0.10.0-pre.1
- `cipher` v0.5.0-pre.6
- `cmac` v0.8.0-pre.1
- `crypto-common` v0.2.0-rc.0
- `ctr` v0.10.0-pre.1
- `dbl` v0.4.0-rc.0
- `digest` v0.11.0-pre.9
- `ghash` v0.6.0-rc.0
- `hybrid-array` v0.2.0-rc.9
- `pmac` v0.8.0-pre.1
- `poly1305` v0.9.0-rc.0
- `polyval` v0.7.0-rc.0
- `universal-hash` v0.6.0-rc.0
  • Loading branch information
tarcieri authored Jul 27, 2024
1 parent f0a75cb commit 096d4e6
Show file tree
Hide file tree
Showing 32 changed files with 342 additions and 348 deletions.
77 changes: 40 additions & 37 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,3 @@ members = [
"ocb3",
]
resolver = "2"

[patch.crates-io]
# https://github.com/RustCrypto/MACs/pull/158
cmac = { git = "https://github.com/RustCrypto/MACs.git" }
pmac = { git = "https://github.com/RustCrypto/MACs.git" }

# https://github.com/RustCrypto/stream-ciphers/pull/345
chacha20 = { git = "https://github.com/RustCrypto/stream-ciphers.git" }
12 changes: 6 additions & 6 deletions aes-gcm-siv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ categories = ["cryptography", "no-std"]
rust-version = "1.65"

[dependencies]
aead = { version = "=0.6.0-pre.0", default-features = false }
aes = { version = "=0.9.0-pre", optional = true }
cipher = "=0.5.0-pre.4"
ctr = "=0.10.0-pre.0"
polyval = { version = "=0.7.0-pre.0", default-features = false }
aead = { version = "0.6.0-rc.0", default-features = false }
aes = { version = "=0.9.0-pre.1", optional = true }
cipher = "=0.5.0-pre.6"
ctr = "=0.10.0-pre.1"
polyval = { version = "0.7.0-rc.0", default-features = false }
subtle = { version = "2", default-features = false }
zeroize = { version = "1", default-features = false }

[dev-dependencies]
aead = { version = "=0.6.0-pre.0", features = ["dev"], default-features = false }
aead = { version = "0.6.0-rc.0", features = ["dev"], default-features = false }

[features]
default = ["aes", "alloc", "getrandom"]
Expand Down
24 changes: 12 additions & 12 deletions aes-gcm-siv/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ macro_rules! tests {
#[test]
fn encrypt() {
for vector in $vectors {
let key = Array::from_slice(vector.key);
let nonce = Array::from_slice(vector.nonce);
let key = Array(*vector.key);
let nonce = Array(*vector.nonce);
let payload = Payload {
msg: vector.plaintext,
aad: vector.aad,
};

let cipher = <$aead>::new(key);
let ciphertext = cipher.encrypt(nonce, payload).unwrap();
let cipher = <$aead>::new(&key);
let ciphertext = cipher.encrypt(&nonce, payload).unwrap();

assert_eq!(vector.ciphertext, ciphertext.as_slice());
}
Expand All @@ -33,16 +33,16 @@ macro_rules! tests {
#[test]
fn decrypt() {
for vector in $vectors {
let key = Array::from_slice(vector.key);
let nonce = Array::from_slice(vector.nonce);
let key = Array(*vector.key);
let nonce = Array(*vector.nonce);

let payload = Payload {
msg: vector.ciphertext,
aad: vector.aad,
};

let cipher = <$aead>::new(key);
let plaintext = cipher.decrypt(nonce, payload).unwrap();
let cipher = <$aead>::new(&key);
let plaintext = cipher.decrypt(&nonce, payload).unwrap();

assert_eq!(vector.plaintext, plaintext.as_slice());
}
Expand All @@ -51,8 +51,8 @@ macro_rules! tests {
#[test]
fn decrypt_modified() {
let vector = &$vectors[1];
let key = Array::from_slice(vector.key);
let nonce = Array::from_slice(vector.nonce);
let key = Array(*vector.key);
let nonce = Array(*vector.nonce);

let mut ciphertext = Vec::from(vector.ciphertext);

Expand All @@ -64,8 +64,8 @@ macro_rules! tests {
aad: vector.aad,
};

let cipher = <$aead>::new(key);
assert!(cipher.decrypt(nonce, payload).is_err());
let cipher = <$aead>::new(&key);
assert!(cipher.decrypt(&nonce, payload).is_err());

// TODO(tarcieri): test ciphertext is unmodified in in-place API
}
Expand Down
12 changes: 6 additions & 6 deletions aes-gcm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ categories = ["cryptography", "no-std"]
rust-version = "1.65"

[dependencies]
aead = { version = "=0.6.0-pre.0", default-features = false }
aes = { version = "=0.9.0-pre", optional = true }
cipher = "=0.5.0-pre.4"
ctr = "=0.10.0-pre.0"
ghash = { version = "=0.6.0-pre.0", default-features = false }
aead = { version = "0.6.0-rc.0", default-features = false }
aes = { version = "=0.9.0-pre.1", optional = true }
cipher = "=0.5.0-pre.6"
ctr = "=0.10.0-pre.1"
ghash = { version = "0.6.0-rc.0", default-features = false }
subtle = { version = "2", default-features = false }
zeroize = { version = "1", optional = true, default-features = false }

[dev-dependencies]
aead = { version = "=0.6.0-pre.0", features = ["dev"], default-features = false }
aead = { version = "0.6.0-rc.0", features = ["dev"], default-features = false }
hex-literal = "0.4"

[features]
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 @@ -287,7 +287,7 @@ where
ctr.apply_keystream_partial(buffer.into());

let full_tag = self.compute_tag(mask, associated_data, buffer);
Ok(Tag::clone_from_slice(&full_tag[..TagSize::to_usize()]))
Ok(Tag::try_from(&full_tag[..TagSize::to_usize()]).expect("tag size mismatch"))
}

fn decrypt_in_place_detached(
Expand Down
Loading

0 comments on commit 096d4e6

Please sign in to comment.