From e981724c6fc8f7294ac7d387b8bc5113b87307bc Mon Sep 17 00:00:00 2001
From: Tony Arcieri <bascule@gmail.com>
Date: Sat, 11 Nov 2023 20:40:27 -0700
Subject: [PATCH 1/4] aead: bump `crypto-common` to v0.2.0-pre; MSRV 1.65

Replaces `generic-array` with `hybrid-array`, which is built on a
combination of `typenum` and const generics, providing a degree of
interoperability between the two systems.
---
 .github/workflows/aead.yml |   4 +-
 Cargo.lock                 | 120 +++++++++++++++++++++++++++--
 Cargo.toml                 |   2 +-
 aead/Cargo.lock            | 151 -------------------------------------
 aead/Cargo.toml            |   9 +--
 aead/src/lib.rs            |  30 ++++----
 aead/src/stream.rs         |  36 ++++-----
 crypto/Cargo.toml          |   2 +-
 8 files changed, 155 insertions(+), 199 deletions(-)
 delete mode 100644 aead/Cargo.lock

diff --git a/.github/workflows/aead.yml b/.github/workflows/aead.yml
index 409b6bd58..d2f273657 100644
--- a/.github/workflows/aead.yml
+++ b/.github/workflows/aead.yml
@@ -22,7 +22,7 @@ jobs:
     strategy:
       matrix:
         rust:
-          - 1.56.0 # MSRV
+          - 1.65.0 # MSRV
           - stable
         target:
           - thumbv7em-none-eabi
@@ -52,7 +52,7 @@ jobs:
     strategy:
       matrix:
         rust:
-          - 1.56.0 # MSRV
+          - 1.65.0 # MSRV
           - stable
     steps:
       - uses: actions/checkout@v4
diff --git a/Cargo.lock b/Cargo.lock
index c8aae2089..a9cbef675 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5,6 +5,8 @@ version = 3
 [[package]]
 name = "aead"
 version = "0.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0"
 dependencies = [
  "crypto-common 0.1.6",
  "generic-array",
@@ -12,12 +14,13 @@ dependencies = [
 
 [[package]]
 name = "aead"
-version = "0.5.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0"
+version = "0.6.0-pre"
 dependencies = [
- "crypto-common 0.1.6",
- "generic-array",
+ "arrayvec",
+ "blobby",
+ "bytes",
+ "crypto-common 0.2.0-pre",
+ "heapless",
 ]
 
 [[package]]
@@ -37,7 +40,7 @@ version = "0.10.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1"
 dependencies = [
- "aead 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "aead 0.5.2",
  "aes",
  "cipher 0.4.4",
  "ctr",
@@ -45,6 +48,27 @@ dependencies = [
  "subtle",
 ]
 
+[[package]]
+name = "arrayvec"
+version = "0.7.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
+
+[[package]]
+name = "atomic-polyfill"
+version = "0.1.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3ff7eb3f316534d83a8a2c3d1674ace8a5a71198eba31e2e2b597833f699b28"
+dependencies = [
+ "critical-section",
+]
+
+[[package]]
+name = "autocfg"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
+
 [[package]]
 name = "base16ct"
 version = "0.1.1"
@@ -139,6 +163,12 @@ version = "1.4.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
 
+[[package]]
+name = "bytes"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223"
+
 [[package]]
 name = "cc"
 version = "1.0.83"
@@ -172,7 +202,7 @@ version = "0.10.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35"
 dependencies = [
- "aead 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "aead 0.5.2",
  "chacha20",
  "cipher 0.4.4",
  "poly1305",
@@ -221,6 +251,12 @@ dependencies = [
  "libc",
 ]
 
+[[package]]
+name = "critical-section"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216"
+
 [[package]]
 name = "crypto"
 version = "0.5.1"
@@ -571,6 +607,28 @@ dependencies = [
  "subtle",
 ]
 
+[[package]]
+name = "hash32"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67"
+dependencies = [
+ "byteorder",
+]
+
+[[package]]
+name = "heapless"
+version = "0.7.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "db04bc24a18b9ea980628ecf00e6c0264f3c1426dac36c00cb49b6fbad8b0743"
+dependencies = [
+ "atomic-polyfill",
+ "hash32",
+ "rustc_version",
+ "spin",
+ "stable_deref_trait",
+]
+
 [[package]]
 name = "hex-literal"
 version = "0.4.1"
@@ -621,7 +679,7 @@ version = "0.10.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "cf39e5461bfdc6ad0fbc97067519fcaf96a7a2e67f24cc0eb8a1e7c0c45af792"
 dependencies = [
- "aead 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "aead 0.5.2",
  "aes-gcm",
  "byteorder",
  "chacha20poly1305",
@@ -709,6 +767,16 @@ version = "0.2.149"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b"
 
+[[package]]
+name = "lock_api"
+version = "0.4.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45"
+dependencies = [
+ "autocfg",
+ "scopeguard",
+]
+
 [[package]]
 name = "opaque-debug"
 version = "0.3.0"
@@ -914,12 +982,27 @@ dependencies = [
  "getrandom",
 ]
 
+[[package]]
+name = "rustc_version"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
+dependencies = [
+ "semver",
+]
+
 [[package]]
 name = "ryu"
 version = "1.0.15"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
 
+[[package]]
+name = "scopeguard"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
+
 [[package]]
 name = "sec1"
 version = "0.3.0"
@@ -948,6 +1031,12 @@ dependencies = [
  "zeroize",
 ]
 
+[[package]]
+name = "semver"
+version = "1.0.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090"
+
 [[package]]
 name = "serde"
 version = "1.0.189"
@@ -1046,6 +1135,15 @@ dependencies = [
 name = "signature"
 version = "2.1.0"
 
+[[package]]
+name = "spin"
+version = "0.9.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
+dependencies = [
+ "lock_api",
+]
+
 [[package]]
 name = "spki"
 version = "0.4.1"
@@ -1065,6 +1163,12 @@ dependencies = [
  "der 0.7.8",
 ]
 
+[[package]]
+name = "stable_deref_trait"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
+
 [[package]]
 name = "subtle"
 version = "2.5.0"
diff --git a/Cargo.toml b/Cargo.toml
index 436bc20fc..e4cda3420 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,7 @@
 [workspace]
 resolver = "2"
 members = [
+    "aead",
     "cipher",
     "crypto",
     "crypto-common",
@@ -11,7 +12,6 @@ members = [
 ]
 # TODO: re-add to `members` when MSRV has been bumped to 1.60+
 exclude = [
-    "aead",
     "signature",
     "signature/async",
     "universal-hash",
diff --git a/aead/Cargo.lock b/aead/Cargo.lock
deleted file mode 100644
index 6fb255ac7..000000000
--- a/aead/Cargo.lock
+++ /dev/null
@@ -1,151 +0,0 @@
-# This file is automatically @generated by Cargo.
-# It is not intended for manual editing.
-version = 3
-
-[[package]]
-name = "aead"
-version = "0.5.2"
-dependencies = [
- "arrayvec",
- "blobby",
- "bytes",
- "crypto-common",
- "generic-array",
- "heapless",
-]
-
-[[package]]
-name = "arrayvec"
-version = "0.7.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5a2f58b0bb10c380af2b26e57212856b8c9a59e0925b4c20f4a174a49734eaf7"
-
-[[package]]
-name = "atomic-polyfill"
-version = "0.1.11"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e3ff7eb3f316534d83a8a2c3d1674ace8a5a71198eba31e2e2b597833f699b28"
-dependencies = [
- "critical-section",
-]
-
-[[package]]
-name = "blobby"
-version = "0.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fc52553543ecb104069b0ff9e0fcc5c739ad16202935528a112d974e8f1a4ee8"
-
-[[package]]
-name = "byteorder"
-version = "1.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "73b5bdfe7ee3ad0b99c9801d58807a9dbc9e09196365b0203853b99889ab3c87"
-
-[[package]]
-name = "bytes"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ad1f8e949d755f9d79112b5bb46938e0ef9d3804a0b16dfab13aafcaa5f0fa72"
-
-[[package]]
-name = "cfg-if"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de"
-
-[[package]]
-name = "critical-section"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d02ba51481d019be9c74a831d1133c364d78831b75c833478f3a21e1fd91e01a"
-
-[[package]]
-name = "crypto-common"
-version = "0.1.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5999502d32b9c48d492abe66392408144895020ec4709e549e840799f3bb74c0"
-dependencies = [
- "generic-array",
- "rand_core",
- "typenum",
-]
-
-[[package]]
-name = "generic-array"
-version = "0.14.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817"
-dependencies = [
- "typenum",
- "version_check",
-]
-
-[[package]]
-name = "getrandom"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ee8025cf36f917e6a52cce185b7c7177689b838b7ec138364e50cc2277a56cf4"
-dependencies = [
- "cfg-if",
- "libc",
- "wasi",
-]
-
-[[package]]
-name = "hash32"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67"
-dependencies = [
- "byteorder",
-]
-
-[[package]]
-name = "heapless"
-version = "0.7.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e94c13b78b595d2adbd708bce276664f1047f98fc32ddbf463b4c191158334a6"
-dependencies = [
- "atomic-polyfill",
- "hash32",
- "stable_deref_trait",
-]
-
-[[package]]
-name = "libc"
-version = "0.2.64"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "74dfca3d9957906e8d1e6a0b641dc9a59848e793f1da2165889fd4f62d10d79c"
-
-[[package]]
-name = "rand_core"
-version = "0.6.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7"
-dependencies = [
- "getrandom",
-]
-
-[[package]]
-name = "stable_deref_trait"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "15132e0e364248108c5e2c02e3ab539be8d6f5d52a01ca9bbf27ed657316f02b"
-
-[[package]]
-name = "typenum"
-version = "1.14.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec"
-
-[[package]]
-name = "version_check"
-version = "0.9.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "45d3d553fd9413fffe7147a20171d640eda0ad4c070acd7d0c885a21bcd2e8b7"
-
-[[package]]
-name = "wasi"
-version = "0.9.0+wasi-snapshot-preview1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
diff --git a/aead/Cargo.toml b/aead/Cargo.toml
index 29eb0bf26..dd424eb0c 100644
--- a/aead/Cargo.toml
+++ b/aead/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "aead"
-version = "0.5.2"
+version = "0.6.0-pre"
 description = """
 Traits for Authenticated Encryption with Associated Data (AEAD) algorithms,
 such as AES-GCM as ChaCha20Poly1305, which provide a high-level API
@@ -13,11 +13,10 @@ documentation = "https://docs.rs/aead"
 repository = "https://github.com/RustCrypto/traits"
 keywords = ["crypto", "encryption"]
 categories = ["cryptography", "no-std"]
-rust-version = "1.56"
+rust-version = "1.65"
 
 [dependencies]
-crypto-common = "0.1.4"
-generic-array = { version = "0.14", default-features = false }
+crypto-common = "=0.2.0-pre"
 
 # optional dependencies
 arrayvec = { version = "0.7", optional = true, default-features = false }
@@ -30,7 +29,7 @@ default = ["rand_core"]
 alloc = []
 std = ["alloc", "crypto-common/std"]
 dev = ["blobby"]
-getrandom = ["crypto-common/getrandom", "rand_core"]
+getrandom = ["crypto-common/getrandom"]
 rand_core = ["crypto-common/rand_core"]
 stream = []
 
diff --git a/aead/src/lib.rs b/aead/src/lib.rs
index df9bf1262..84af56531 100644
--- a/aead/src/lib.rs
+++ b/aead/src/lib.rs
@@ -34,8 +34,10 @@ pub mod dev;
 #[cfg(feature = "stream")]
 pub mod stream;
 
-pub use crypto_common::{Key, KeyInit, KeySizeUser};
-pub use generic_array::{self, typenum::consts};
+pub use crypto_common::{
+    array::{self, typenum::consts},
+    Key, KeyInit, KeySizeUser,
+};
 
 #[cfg(feature = "arrayvec")]
 pub use arrayvec;
@@ -53,7 +55,7 @@ pub use heapless;
 pub use crypto_common::rand_core;
 
 use core::fmt;
-use generic_array::{typenum::Unsigned, ArrayLength, GenericArray};
+use crypto_common::array::{typenum::Unsigned, ArraySize, ByteArray};
 
 #[cfg(feature = "alloc")]
 use alloc::vec::Vec;
@@ -62,7 +64,7 @@ use alloc::vec::Vec;
 use bytes::BytesMut;
 
 #[cfg(feature = "rand_core")]
-use rand_core::{CryptoRng, RngCore};
+use rand_core::CryptoRngCore;
 
 /// Error type.
 ///
@@ -84,10 +86,10 @@ impl fmt::Display for Error {
 impl std::error::Error for Error {}
 
 /// Nonce: single-use value for ensuring ciphertexts are unique
-pub type Nonce<A> = GenericArray<u8, <A as AeadCore>::NonceSize>;
+pub type Nonce<A> = ByteArray<<A as AeadCore>::NonceSize>;
 
 /// Tag: authentication code which ensures ciphertexts are authentic
-pub type Tag<A> = GenericArray<u8, <A as AeadCore>::TagSize>;
+pub type Tag<A> = ByteArray<<A as AeadCore>::TagSize>;
 
 /// Authenticated Encryption with Associated Data (AEAD) algorithm core trait.
 ///
@@ -95,14 +97,14 @@ pub type Tag<A> = GenericArray<u8, <A as AeadCore>::TagSize>;
 /// `Aead*` traits.
 pub trait AeadCore {
     /// The length of a nonce.
-    type NonceSize: ArrayLength<u8>;
+    type NonceSize: ArraySize;
 
     /// The maximum length of the tag.
-    type TagSize: ArrayLength<u8>;
+    type TagSize: ArraySize;
 
     /// The upper bound amount of additional space required to support a
     /// ciphertext vs. a plaintext.
-    type CiphertextOverhead: ArrayLength<u8> + Unsigned;
+    type CiphertextOverhead: ArraySize + Unsigned;
 
     /// Generate a random nonce for this AEAD algorithm.
     ///
@@ -140,13 +142,15 @@ pub trait AeadCore {
     ///
     /// [NIST SP 800-38D]: https://csrc.nist.gov/publications/detail/sp/800-38d/final
     #[cfg(feature = "rand_core")]
-    fn generate_nonce(mut rng: impl CryptoRng + RngCore) -> Nonce<Self>
+    fn generate_nonce_with_rng(
+        rng: &mut impl CryptoRngCore,
+    ) -> core::result::Result<Nonce<Self>, rand_core::Error>
     where
         Nonce<Self>: Default,
     {
         let mut nonce = Nonce::<Self>::default();
-        rng.fill_bytes(&mut nonce);
-        nonce
+        rng.try_fill_bytes(&mut nonce)?;
+        Ok(nonce)
     }
 }
 
@@ -248,7 +252,7 @@ macro_rules! impl_decrypt_in_place {
 
         let tag_pos = $buffer.len() - Self::TagSize::to_usize();
         let (msg, tag) = $buffer.as_mut().split_at_mut(tag_pos);
-        $aead.decrypt_in_place_detached($nonce, $aad, msg, Tag::<Self>::from_slice(tag))?;
+        $aead.decrypt_in_place_detached($nonce, $aad, msg, Tag::<Self>::ref_from_slice(tag))?;
         $buffer.truncate(tag_pos);
         Ok(())
     }};
diff --git a/aead/src/stream.rs b/aead/src/stream.rs
index a5c3c6586..13aa593ef 100644
--- a/aead/src/stream.rs
+++ b/aead/src/stream.rs
@@ -34,16 +34,16 @@
 
 use crate::{AeadCore, AeadInPlace, Buffer, Error, Key, KeyInit, Result};
 use core::ops::{AddAssign, Sub};
-use generic_array::{
+use crypto_common::array::{
     typenum::{Unsigned, U4, U5},
-    ArrayLength, GenericArray,
+    ArraySize, ByteArray,
 };
 
 #[cfg(feature = "alloc")]
 use {crate::Payload, alloc::vec::Vec};
 
 /// Nonce as used by a given AEAD construction and STREAM primitive.
-pub type Nonce<A, S> = GenericArray<u8, NonceSize<A, S>>;
+pub type Nonce<A, S> = ByteArray<NonceSize<A, S>>;
 
 /// Size of a nonce as used by a STREAM construction, sans the overhead of
 /// the STREAM protocol itself.
@@ -71,7 +71,7 @@ pub trait NewStream<A>: StreamPrimitive<A>
 where
     A: AeadInPlace,
     A::NonceSize: Sub<Self::NonceOverhead>,
-    NonceSize<A, Self>: ArrayLength<u8>,
+    NonceSize<A, Self>: ArraySize,
 {
     /// Create a new STREAM with the given key and nonce.
     fn new(key: &Key<A>, nonce: &Nonce<A, Self>) -> Self
@@ -96,10 +96,10 @@ pub trait StreamPrimitive<A>
 where
     A: AeadInPlace,
     A::NonceSize: Sub<Self::NonceOverhead>,
-    NonceSize<A, Self>: ArrayLength<u8>,
+    NonceSize<A, Self>: ArraySize,
 {
     /// Number of bytes this STREAM primitive requires from the nonce.
-    type NonceOverhead: ArrayLength<u8>;
+    type NonceOverhead: ArraySize;
 
     /// Type used as the STREAM counter.
     type Counter: AddAssign + Copy + Default + Eq;
@@ -204,7 +204,7 @@ macro_rules! impl_stream_object {
             A: AeadInPlace,
             S: StreamPrimitive<A>,
             A::NonceSize: Sub<<S as StreamPrimitive<A>>::NonceOverhead>,
-            NonceSize<A, S>: ArrayLength<u8>,
+            NonceSize<A, S>: ArraySize,
         {
             /// Underlying STREAM primitive.
             stream: S,
@@ -218,7 +218,7 @@ macro_rules! impl_stream_object {
             A: AeadInPlace,
             S: StreamPrimitive<A>,
             A::NonceSize: Sub<<S as StreamPrimitive<A>>::NonceOverhead>,
-            NonceSize<A, S>: ArrayLength<u8>,
+            NonceSize<A, S>: ArraySize,
         {
             #[doc = "Create a"]
             #[doc = $obj_desc]
@@ -365,7 +365,7 @@ pub struct StreamBE32<A>
 where
     A: AeadInPlace,
     A::NonceSize: Sub<U5>,
-    <<A as AeadCore>::NonceSize as Sub<U5>>::Output: ArrayLength<u8>,
+    <<A as AeadCore>::NonceSize as Sub<U5>>::Output: ArraySize,
 {
     /// Underlying AEAD cipher
     aead: A,
@@ -378,7 +378,7 @@ impl<A> NewStream<A> for StreamBE32<A>
 where
     A: AeadInPlace,
     A::NonceSize: Sub<U5>,
-    <<A as AeadCore>::NonceSize as Sub<U5>>::Output: ArrayLength<u8>,
+    <<A as AeadCore>::NonceSize as Sub<U5>>::Output: ArraySize,
 {
     fn from_aead(aead: A, nonce: &Nonce<A, Self>) -> Self {
         Self {
@@ -392,7 +392,7 @@ impl<A> StreamPrimitive<A> for StreamBE32<A>
 where
     A: AeadInPlace,
     A::NonceSize: Sub<U5>,
-    <<A as AeadCore>::NonceSize as Sub<U5>>::Output: ArrayLength<u8>,
+    <<A as AeadCore>::NonceSize as Sub<U5>>::Output: ArraySize,
 {
     type NonceOverhead = U5;
     type Counter = u32;
@@ -426,12 +426,12 @@ impl<A> StreamBE32<A>
 where
     A: AeadInPlace,
     A::NonceSize: Sub<U5>,
-    <<A as AeadCore>::NonceSize as Sub<U5>>::Output: ArrayLength<u8>,
+    <<A as AeadCore>::NonceSize as Sub<U5>>::Output: ArraySize,
 {
     /// Compute the full AEAD nonce including the STREAM counter and last
     /// block flag.
     fn aead_nonce(&self, position: u32, last_block: bool) -> crate::Nonce<A> {
-        let mut result = GenericArray::default();
+        let mut result = ByteArray::default();
 
         // TODO(tarcieri): use `generic_array::sequence::Concat` (or const generics)
         let (prefix, tail) = result.split_at_mut(NonceSize::<A, Self>::to_usize());
@@ -454,7 +454,7 @@ pub struct StreamLE31<A>
 where
     A: AeadInPlace,
     A::NonceSize: Sub<U4>,
-    <<A as AeadCore>::NonceSize as Sub<U4>>::Output: ArrayLength<u8>,
+    <<A as AeadCore>::NonceSize as Sub<U4>>::Output: ArraySize,
 {
     /// Underlying AEAD cipher
     aead: A,
@@ -467,7 +467,7 @@ impl<A> NewStream<A> for StreamLE31<A>
 where
     A: AeadInPlace,
     A::NonceSize: Sub<U4>,
-    <<A as AeadCore>::NonceSize as Sub<U4>>::Output: ArrayLength<u8>,
+    <<A as AeadCore>::NonceSize as Sub<U4>>::Output: ArraySize,
 {
     fn from_aead(aead: A, nonce: &Nonce<A, Self>) -> Self {
         Self {
@@ -481,7 +481,7 @@ impl<A> StreamPrimitive<A> for StreamLE31<A>
 where
     A: AeadInPlace,
     A::NonceSize: Sub<U4>,
-    <<A as AeadCore>::NonceSize as Sub<U4>>::Output: ArrayLength<u8>,
+    <<A as AeadCore>::NonceSize as Sub<U4>>::Output: ArraySize,
 {
     type NonceOverhead = U4;
     type Counter = u32;
@@ -515,7 +515,7 @@ impl<A> StreamLE31<A>
 where
     A: AeadInPlace,
     A::NonceSize: Sub<U4>,
-    <<A as AeadCore>::NonceSize as Sub<U4>>::Output: ArrayLength<u8>,
+    <<A as AeadCore>::NonceSize as Sub<U4>>::Output: ArraySize,
 {
     /// Compute the full AEAD nonce including the STREAM counter and last
     /// block flag.
@@ -524,7 +524,7 @@ where
             return Err(Error);
         }
 
-        let mut result = GenericArray::default();
+        let mut result = ByteArray::default();
 
         // TODO(tarcieri): use `generic_array::sequence::Concat` (or const generics)
         let (prefix, tail) = result.split_at_mut(NonceSize::<A, Self>::to_usize());
diff --git a/crypto/Cargo.toml b/crypto/Cargo.toml
index ede350b70..c3968eda1 100644
--- a/crypto/Cargo.toml
+++ b/crypto/Cargo.toml
@@ -16,7 +16,7 @@ rust-version = "1.65"
 crypto-common = { version = "0.1", default-features = false }
 
 # optional dependencies
-aead = { version = "0.5", optional = true, path = "../aead" }
+aead = { version = "0.5", optional = true }
 cipher = { version = "0.4", optional = true }
 digest = { version = "0.10", optional = true, features = ["mac"] }
 elliptic-curve = { version = "0.13", optional = true, path = "../elliptic-curve" }

From 4fc04a5838132973457e756378eb8320156d822e Mon Sep 17 00:00:00 2001
From: Tony Arcieri <bascule@gmail.com>
Date: Sat, 11 Nov 2023 20:52:30 -0700
Subject: [PATCH 2/4] Temporarily disable minimal-versions CI job

---
 .github/workflows/aead.yml | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/aead.yml b/.github/workflows/aead.yml
index d2f273657..462108e7a 100644
--- a/.github/workflows/aead.yml
+++ b/.github/workflows/aead.yml
@@ -42,10 +42,11 @@ jobs:
       - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features rand_core
       - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features stream
 
-  minimal-versions:
-    uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master
-    with:
-        working-directory: ${{ github.workflow }}
+  # TODO(tarcieri): re-enable after next `crypto-common` release
+  #  minimal-versions:
+  #    uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master
+  #    with:
+  #        working-directory: ${{ github.workflow }}
 
   test:
     runs-on: ubuntu-latest

From 8f4c75158fc3e3309d293da5b76b9903d5e1a7eb Mon Sep 17 00:00:00 2001
From: Tony Arcieri <bascule@gmail.com>
Date: Sat, 11 Nov 2023 21:00:38 -0700
Subject: [PATCH 3/4] Update MSRV in documentation

---
 aead/README.md  |  4 ++--
 aead/src/lib.rs | 16 +---------------
 2 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/aead/README.md b/aead/README.md
index ff1a580a2..b481f9c37 100644
--- a/aead/README.md
+++ b/aead/README.md
@@ -19,7 +19,7 @@ See [RustCrypto/AEADs] for cipher implementations which use this trait.
 
 ## Minimum Supported Rust Version
 
-Rust **1.56** or higher.
+Rust **1.65** or higher.
 
 Minimum supported Rust version can be changed in the future, but it will be
 done with a minor version bump.
@@ -51,7 +51,7 @@ dual licensed as above, without any additional terms or conditions.
 [docs-image]: https://docs.rs/aead/badge.svg
 [docs-link]: https://docs.rs/aead/
 [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
-[rustc-image]: https://img.shields.io/badge/rustc-1.56+-blue.svg
+[rustc-image]: https://img.shields.io/badge/rustc-1.65+-blue.svg
 [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg
 [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260038-AEADs
 [build-image]: https://github.com/RustCrypto/traits/workflows/aead/badge.svg?branch=master&event=push
diff --git a/aead/src/lib.rs b/aead/src/lib.rs
index 84af56531..497e2e1ed 100644
--- a/aead/src/lib.rs
+++ b/aead/src/lib.rs
@@ -1,20 +1,6 @@
-//! [Authenticated Encryption with Associated Data] (AEAD) traits
-//!
-//! This crate provides an abstract interface for AEAD ciphers, which guarantee
-//! both confidentiality and integrity, even from a powerful attacker who is
-//! able to execute [chosen-ciphertext attacks]. The resulting security property,
-//! [ciphertext indistinguishability], is considered a basic requirement for
-//! modern cryptographic implementations.
-//!
-//! See [RustCrypto/AEADs] for cipher implementations which use this trait.
-//!
-//! [Authenticated Encryption with Associated Data]: https://en.wikipedia.org/wiki/Authenticated_encryption
-//! [chosen-ciphertext attacks]: https://en.wikipedia.org/wiki/Chosen-ciphertext_attack
-//! [ciphertext indistinguishability]: https://en.wikipedia.org/wiki/Ciphertext_indistinguishability
-//! [RustCrypto/AEADs]: https://github.com/RustCrypto/AEADs
-
 #![no_std]
 #![cfg_attr(docsrs, feature(doc_auto_cfg))]
+#![doc = include_str!("../README.md")]
 #![doc(
     html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg",
     html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg"

From 963a8cf5aee061effb5541c2d95c5b3c25e98f96 Mon Sep 17 00:00:00 2001
From: Tony Arcieri <bascule@gmail.com>
Date: Sat, 11 Nov 2023 21:03:19 -0700
Subject: [PATCH 4/4] Add getrandom-based AeadCore::generate_nonce

---
 aead/src/lib.rs | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/aead/src/lib.rs b/aead/src/lib.rs
index 497e2e1ed..62cf29dbb 100644
--- a/aead/src/lib.rs
+++ b/aead/src/lib.rs
@@ -27,13 +27,10 @@ pub use crypto_common::{
 
 #[cfg(feature = "arrayvec")]
 pub use arrayvec;
-
 #[cfg(feature = "bytes")]
 pub use bytes;
-
 #[cfg(feature = "getrandom")]
 pub use crypto_common::rand_core::OsRng;
-
 #[cfg(feature = "heapless")]
 pub use heapless;
 
@@ -45,10 +42,10 @@ use crypto_common::array::{typenum::Unsigned, ArraySize, ByteArray};
 
 #[cfg(feature = "alloc")]
 use alloc::vec::Vec;
-
 #[cfg(feature = "bytes")]
 use bytes::BytesMut;
-
+#[cfg(feature = "getrandom")]
+use crypto_common::getrandom;
 #[cfg(feature = "rand_core")]
 use rand_core::CryptoRngCore;
 
@@ -127,6 +124,21 @@ pub trait AeadCore {
     /// See the [`stream`] module for a ready-made implementation of the latter.
     ///
     /// [NIST SP 800-38D]: https://csrc.nist.gov/publications/detail/sp/800-38d/final
+    #[cfg(feature = "getrandom")]
+    fn generate_nonce() -> core::result::Result<Nonce<Self>, getrandom::Error>
+    where
+        Nonce<Self>: Default,
+    {
+        let mut nonce = Nonce::<Self>::default();
+        getrandom::getrandom(&mut nonce)?;
+        Ok(nonce)
+    }
+
+    /// Generate a random nonce for this AEAD algorithm using the specified
+    /// [`CryptoRngCore`].
+    ///
+    /// See [`AeadCore::generate_nonce`] documentation for requirements for
+    /// random nonces.
     #[cfg(feature = "rand_core")]
     fn generate_nonce_with_rng(
         rng: &mut impl CryptoRngCore,
