From de88e8b2deaaad15c3dc60256d3e115b6ce422a4 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Wed, 27 Mar 2024 11:12:04 -0700 Subject: [PATCH] ocb3: bump `cipher` to `0.5.0-pre.4 --- Cargo.lock | 246 ++++++++------------------------------------- ocb3/Cargo.toml | 10 +- ocb3/README.md | 6 +- ocb3/src/lib.rs | 51 +++++----- ocb3/src/util.rs | 14 ++- ocb3/tests/kats.rs | 12 +-- 6 files changed, 92 insertions(+), 247 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 86115d74..ac19f917 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,19 +3,6 @@ # version = 3 -[[package]] -name = "aead" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" -dependencies = [ - "arrayvec", - "blobby", - "crypto-common 0.1.6", - "generic-array", - "heapless 0.7.17", -] - [[package]] name = "aead" version = "0.6.0-pre.0" @@ -24,19 +11,8 @@ checksum = "3de53f67567d2692f69357ee20fef7ddf7969d1dff34acefc05db91873aee0ce" dependencies = [ "arrayvec", "blobby", - "crypto-common 0.2.0-pre.5", - "heapless 0.8.0", -] - -[[package]] -name = "aes" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" -dependencies = [ - "cfg-if", - "cipher 0.4.4", - "cpufeatures", + "crypto-common", + "heapless", ] [[package]] @@ -46,7 +22,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25512cae539ab9089dcbd69c4f704e787fdc8c1cea8d9daa68a9d89b02b0501f" dependencies = [ "cfg-if", - "cipher 0.5.0-pre.4", + "cipher", "cpufeatures", ] @@ -54,10 +30,10 @@ dependencies = [ name = "aes-gcm" version = "0.11.0-pre" dependencies = [ - "aead 0.6.0-pre.0", - "aes 0.9.0-pre", - "cipher 0.5.0-pre.4", - "ctr 0.10.0-pre", + "aead", + "aes", + "cipher", + "ctr", "ghash", "hex-literal 0.3.4", "subtle", @@ -68,10 +44,10 @@ dependencies = [ name = "aes-gcm-siv" version = "0.12.0-pre" dependencies = [ - "aead 0.6.0-pre.0", - "aes 0.9.0-pre", - "cipher 0.5.0-pre.4", - "ctr 0.10.0-pre", + "aead", + "aes", + "cipher", + "ctr", "polyval", "subtle", "zeroize", @@ -81,12 +57,12 @@ dependencies = [ name = "aes-siv" version = "0.7.0" dependencies = [ - "aead 0.6.0-pre.0", - "aes 0.9.0-pre", + "aead", + "aes", "blobby", - "cipher 0.5.0-pre.4", + "cipher", "cmac", - "ctr 0.10.0-pre", + "ctr", "dbl", "digest", "hex-literal 0.3.4", @@ -113,28 +89,13 @@ dependencies = [ name = "ascon-aead" version = "0.4.2" dependencies = [ - "aead 0.6.0-pre.0", + "aead", "ascon", "hex-literal 0.3.4", "subtle", "zeroize", ] -[[package]] -name = "atomic-polyfill" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4" -dependencies = [ - "critical-section", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - [[package]] name = "blobby" version = "0.3.1" @@ -147,7 +108,7 @@ version = "0.11.0-pre.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ded684142010808eb980d9974ef794da2bcf97d13396143b1515e9f0fb4a10e" dependencies = [ - "crypto-common 0.2.0-pre.5", + "crypto-common", ] [[package]] @@ -169,10 +130,10 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" name = "ccm" version = "0.5.0" dependencies = [ - "aead 0.6.0-pre.0", - "aes 0.9.0-pre", - "cipher 0.5.0-pre.4", - "ctr 0.10.0-pre", + "aead", + "aes", + "cipher", + "ctr", "hex-literal 0.3.4", "subtle", ] @@ -189,7 +150,7 @@ version = "0.10.0-pre" source = "git+https://github.com/RustCrypto/stream-ciphers.git#fea3dd013ee9c35fba56903ad44b411957de8cb2" dependencies = [ "cfg-if", - "cipher 0.5.0-pre.4", + "cipher", "cpufeatures", ] @@ -197,31 +158,21 @@ dependencies = [ name = "chacha20poly1305" version = "0.10.1" dependencies = [ - "aead 0.6.0-pre.0", + "aead", "chacha20", - "cipher 0.5.0-pre.4", + "cipher", "poly1305", "zeroize", ] -[[package]] -name = "cipher" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" -dependencies = [ - "crypto-common 0.1.6", - "inout 0.1.3", -] - [[package]] name = "cipher" version = "0.5.0-pre.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84fba98785cecd0e308818a87c817576a40f99d8bab6405bf422bacd3efb6c1f" dependencies = [ - "crypto-common 0.2.0-pre.5", - "inout 0.2.0-pre.4", + "crypto-common", + "inout", "zeroize", ] @@ -230,7 +181,7 @@ name = "cmac" version = "0.8.0-pre" source = "git+https://github.com/RustCrypto/MACs.git#43cc597a8881d6924ae56bb22edf19600e981e3e" dependencies = [ - "cipher 0.5.0-pre.4", + "cipher", "dbl", "digest", ] @@ -244,23 +195,6 @@ 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-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "rand_core", - "typenum", -] - [[package]] name = "crypto-common" version = "0.2.0-pre.5" @@ -272,21 +206,12 @@ dependencies = [ "rand_core", ] -[[package]] -name = "ctr" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" -dependencies = [ - "cipher 0.4.4", -] - [[package]] name = "ctr" version = "0.10.0-pre" source = "git+https://github.com/RustCrypto/block-modes.git#532a46166bcc74bf718ca351cc3b5a86a2fcb2a3" dependencies = [ - "cipher 0.5.0-pre.4", + "cipher", ] [[package]] @@ -302,8 +227,8 @@ dependencies = [ name = "deoxys" version = "0.1.0" dependencies = [ - "aead 0.6.0-pre.0", - "aes 0.9.0-pre", + "aead", + "aes", "hex-literal 0.3.4", "subtle", "zeroize", @@ -316,7 +241,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "065d93ead7c220b85d5b4be4795d8398eac4ff68b5ee63895de0a3c1fb6edf25" dependencies = [ "block-buffer", - "crypto-common 0.2.0-pre.5", + "crypto-common", "subtle", ] @@ -324,24 +249,14 @@ dependencies = [ name = "eax" version = "0.5.0" dependencies = [ - "aead 0.6.0-pre.0", - "aes 0.9.0-pre", - "cipher 0.5.0-pre.4", + "aead", + "aes", + "cipher", "cmac", - "ctr 0.10.0-pre", + "ctr", "subtle", ] -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - [[package]] name = "getrandom" version = "0.2.12" @@ -363,15 +278,6 @@ dependencies = [ "polyval", ] -[[package]] -name = "hash32" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67" -dependencies = [ - "byteorder", -] - [[package]] name = "hash32" version = "0.3.1" @@ -381,26 +287,13 @@ dependencies = [ "byteorder", ] -[[package]] -name = "heapless" -version = "0.7.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f" -dependencies = [ - "atomic-polyfill", - "hash32 0.2.1", - "rustc_version", - "spin", - "stable_deref_trait", -] - [[package]] name = "heapless" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" dependencies = [ - "hash32 0.3.1", + "hash32", "stable_deref_trait", ] @@ -425,15 +318,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "inout" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" -dependencies = [ - "generic-array", -] - [[package]] name = "inout" version = "0.2.0-pre.4" @@ -450,24 +334,14 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" -[[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 = "ocb3" version = "0.1.0" dependencies = [ - "aead 0.5.2", - "aes 0.8.4", - "cipher 0.4.4", - "ctr 0.9.2", + "aead", + "aes", + "cipher", + "ctr", "hex-literal 0.4.1", "subtle", "zeroize", @@ -484,7 +358,7 @@ name = "pmac" version = "0.8.0-pre" source = "git+https://github.com/RustCrypto/MACs.git#43cc597a8881d6924ae56bb22edf19600e981e3e" dependencies = [ - "cipher 0.5.0-pre.4", + "cipher", "dbl", "digest", ] @@ -539,36 +413,6 @@ 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 = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "semver" -version = "1.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -610,16 +454,10 @@ version = "0.6.0-pre.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a05336f34009f6bb1c24794e2c04df87f4a0ced7a091692e395119f34fd3f4c5" dependencies = [ - "crypto-common 0.2.0-pre.5", + "crypto-common", "subtle", ] -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/ocb3/Cargo.toml b/ocb3/Cargo.toml index f8cd8f3c..4be3484e 100644 --- a/ocb3/Cargo.toml +++ b/ocb3/Cargo.toml @@ -16,15 +16,15 @@ categories = ["cryptography", "no-std"] rust-version = "1.60" [dependencies] -aead = { version = "0.5", default-features = false } -cipher = "0.4" -ctr = "0.9" +aead = { version = "=0.6.0-pre.0", default-features = false } +cipher = "=0.5.0-pre.4" +ctr = "=0.10.0-pre" subtle = { version = "2", default-features = false } zeroize = { version = "1", optional = true, default-features = false } [dev-dependencies] -aead = { version = "0.5", features = ["dev"], default-features = false } -aes = { version = "0.8", default-features = false } +aead = { version = "=0.6.0-pre.0", features = ["dev"], default-features = false } +aes = { version = "=0.9.0-pre", default-features = false } hex-literal = "0.4" [features] diff --git a/ocb3/README.md b/ocb3/README.md index fdb8636a..a46bed30 100644 --- a/ocb3/README.md +++ b/ocb3/README.md @@ -17,16 +17,16 @@ Pure Rust implementation of the Offset Codebook Mode v3 (OCB3) ```rust use aes::Aes128; use ocb3::{ - aead::{Aead, AeadCore, KeyInit, OsRng, generic_array::GenericArray}, + aead::{array::Array, Aead, AeadCore, KeyInit, OsRng}, consts::U12, Ocb3, }; type Aes128Ocb3 = Ocb3; -let key = Aes128::generate_key(&mut OsRng); +let key = Aes128::generate_key().unwrap(); let cipher = Aes128Ocb3::new(&key); -let nonce = Aes128Ocb3::generate_nonce(&mut OsRng); +let nonce = Aes128Ocb3::generate_nonce().unwrap(); let ciphertext = cipher.encrypt(&nonce, b"plaintext message".as_ref()).unwrap(); let plaintext = cipher.decrypt(&nonce, ciphertext.as_ref()).unwrap(); diff --git a/ocb3/src/lib.rs b/ocb3/src/lib.rs index b096e33d..cfa17a01 100644 --- a/ocb3/src/lib.rs +++ b/ocb3/src/lib.rs @@ -16,13 +16,15 @@ pub mod consts { mod util; pub use aead::{ - self, generic_array::GenericArray, AeadCore, AeadInPlace, Error, KeyInit, KeySizeUser, + self, + array::{Array, AssocArraySize}, + AeadCore, AeadInPlace, Error, KeyInit, KeySizeUser, }; use crate::util::{double, inplace_xor, ntz, Block}; use cipher::{ consts::{U0, U12, U16}, - BlockDecrypt, BlockEncrypt, BlockSizeUser, + BlockCipherDecrypt, BlockCipherEncrypt, BlockSizeUser, Unsigned, }; use core::marker::PhantomData; use subtle::ConstantTimeEq; @@ -49,34 +51,34 @@ pub const P_MAX: usize = 1 << (L_TABLE_SIZE + 4); pub const C_MAX: usize = 1 << (L_TABLE_SIZE + 4); /// OCB3 nonce -pub type Nonce = GenericArray; +pub type Nonce = Array; /// OCB3 tag -pub type Tag = GenericArray; +pub type Tag = Array; mod sealed { - use aead::generic_array::{ + use aead::array::{ typenum::{GrEq, IsGreaterOrEqual, IsLessOrEqual, LeEq, NonZero, U15, U16, U6}, - ArrayLength, + ArraySize, }; /// Sealed trait for nonce sizes in the range of `6..=15` bytes. - pub trait NonceSizes: ArrayLength {} + pub trait NonceSizes: ArraySize {} impl NonceSizes for T where - T: ArrayLength + IsGreaterOrEqual + IsLessOrEqual, + T: ArraySize + IsGreaterOrEqual + IsLessOrEqual, GrEq: NonZero, LeEq: NonZero, { } /// Sealed trait for tag sizes in the range of `1..=16` bytes. - pub trait TagSizes: ArrayLength {} + pub trait TagSizes: ArraySize {} impl TagSizes for T where - T: ArrayLength + NonZero + IsLessOrEqual, + T: ArraySize + NonZero + IsLessOrEqual, LeEq: NonZero, { } @@ -140,7 +142,7 @@ where /// Output of the HASH function defined in https://www.rfc-editor.org/rfc/rfc7253.html#section-4.1 type SumSize = U16; -type Sum = GenericArray; +type Sum = Array; impl KeySizeUser for Ocb3 where @@ -153,7 +155,7 @@ where impl KeyInit for Ocb3 where - Cipher: BlockSizeUser + BlockEncrypt + KeyInit + BlockDecrypt, + Cipher: BlockSizeUser + BlockCipherEncrypt + KeyInit + BlockCipherDecrypt, NonceSize: sealed::NonceSizes, TagSize: sealed::TagSizes, { @@ -174,7 +176,7 @@ where impl From for Ocb3 where - Cipher: BlockSizeUser + BlockEncrypt + BlockDecrypt, + Cipher: BlockSizeUser + BlockCipherEncrypt + BlockCipherDecrypt, NonceSize: sealed::NonceSizes, TagSize: sealed::TagSizes, { @@ -194,7 +196,7 @@ where /// Computes key-dependent variables defined in /// https://www.rfc-editor.org/rfc/rfc7253.html#section-4.1 -fn key_dependent_variables + BlockEncrypt>( +fn key_dependent_variables + BlockCipherEncrypt>( cipher: &Cipher, ) -> (Block, Block, [Block; L_TABLE_SIZE]) { let mut zeros = [0u8; 16]; @@ -214,7 +216,7 @@ fn key_dependent_variables + BlockEncrypt impl AeadInPlace for Ocb3 where - Cipher: BlockSizeUser + BlockEncrypt + BlockDecrypt, + Cipher: BlockSizeUser + BlockCipherEncrypt + BlockCipherDecrypt, NonceSize: sealed::NonceSizes, TagSize: sealed::TagSizes, { @@ -296,7 +298,7 @@ where impl Ocb3 where - Cipher: BlockSizeUser + BlockEncrypt + BlockDecrypt, + Cipher: BlockSizeUser + BlockCipherEncrypt + BlockCipherDecrypt, NonceSize: sealed::NonceSizes, TagSize: sealed::TagSizes, { @@ -371,7 +373,7 @@ where let mut offset_i = [Block::default(); WIDTH]; offset_i[offset_i.len() - 1] = initial_offset(&self.cipher, nonce, TagSize::to_u32()); let mut checksum_i = Block::default(); - for wide_blocks in buffer.chunks_exact_mut(16 * WIDTH) { + for wide_blocks in buffer.chunks_exact_mut(::Size::USIZE * WIDTH) { let p_i = split_into_blocks(wide_blocks); // checksum_i = checksum_{i-1} xor p_i @@ -446,7 +448,7 @@ where /// Computes nonce-dependent variables as defined /// in https://www.rfc-editor.org/rfc/rfc7253.html#section-4.2 fn nonce_dependent_variables< - Cipher: BlockSizeUser + BlockEncrypt, + Cipher: BlockSizeUser + BlockCipherEncrypt, NonceSize: sealed::NonceSizes, >( cipher: &Cipher, @@ -485,7 +487,7 @@ fn nonce_dependent_variables< /// Computes the initial offset as defined /// in https://www.rfc-editor.org/rfc/rfc7253.html#section-4.2 fn initial_offset< - Cipher: BlockSizeUser + BlockEncrypt, + Cipher: BlockSizeUser + BlockCipherEncrypt, NonceSize: sealed::NonceSizes, >( cipher: &Cipher, @@ -504,7 +506,7 @@ fn initial_offset< impl Ocb3 where - Cipher: BlockSizeUser + BlockEncrypt, + Cipher: BlockSizeUser + BlockCipherEncrypt, NonceSize: sealed::NonceSizes, TagSize: sealed::TagSizes, { @@ -588,7 +590,7 @@ mod tests { let expected_ll0 = Block::from(hex!("1A84ECDE1E3D6E09BD3E058A8723606D")); let expected_ll1 = Block::from(hex!("3509D9BC3C7ADC137A7C0B150E46C0DA")); - let cipher = aes::Aes128::new(GenericArray::from_slice(&key)); + let cipher = aes::Aes128::new(Array::from_slice(&key)); let (ll_star, ll_dollar, ll) = key_dependent_variables(&cipher); assert_eq!(ll_star, expected_ll_star); @@ -608,9 +610,10 @@ mod tests { const TAGLEN: u32 = 16; - let cipher = aes::Aes128::new(GenericArray::from_slice(&key)); - let (bottom, stretch) = nonce_dependent_variables(&cipher, &Nonce::from(nonce), TAGLEN); - let offset_0 = initial_offset(&cipher, &Nonce::from(nonce), TAGLEN); + let cipher = aes::Aes128::new(Array::from_slice(&key)); + let (bottom, stretch) = + nonce_dependent_variables::(&cipher, &Nonce::from(nonce), TAGLEN); + let offset_0 = initial_offset::(&cipher, &Nonce::from(nonce), TAGLEN); assert_eq!(bottom, expected_bottom, "bottom"); assert_eq!(stretch, expected_stretch, "stretch"); diff --git a/ocb3/src/util.rs b/ocb3/src/util.rs index 67574f1e..e90a6d05 100644 --- a/ocb3/src/util.rs +++ b/ocb3/src/util.rs @@ -1,12 +1,15 @@ -use aead::generic_array::{typenum::U16, ArrayLength, GenericArray}; +use aead::{ + array::{Array, ArraySize}, + consts::U16, +}; const BLOCK_SIZE: usize = 16; -pub(crate) type Block = GenericArray; +pub(crate) type Block = Array; #[inline] -pub(crate) fn inplace_xor(a: &mut GenericArray, b: &GenericArray) +pub(crate) fn inplace_xor(a: &mut Array, b: &Array) where - U: ArrayLength, + U: ArraySize, T: core::ops::BitXor + Copy, { for (aa, bb) in a.as_mut_slice().iter_mut().zip(b.as_slice()) { @@ -39,6 +42,7 @@ pub(crate) fn ntz(n: usize) -> usize { #[inline] pub(crate) fn split_into_two_blocks(two_blocks: &mut [u8]) -> [&mut Block; 2] { + debug_assert_eq!(two_blocks.len(), BLOCK_SIZE * 2); let (b0, b1) = two_blocks.split_at_mut(BLOCK_SIZE); - [b0.into(), b1.into()] + [b0.try_into().unwrap(), b1.try_into().unwrap()] } diff --git a/ocb3/tests/kats.rs b/ocb3/tests/kats.rs index 3abedf97..ae79cb12 100644 --- a/ocb3/tests/kats.rs +++ b/ocb3/tests/kats.rs @@ -6,7 +6,7 @@ use aead::{ }; use aes::{Aes128, Aes192, Aes256}; use hex_literal::hex; -use ocb3::{GenericArray, Ocb3}; +use ocb3::{Array, Ocb3}; // Test vectors from https://www.rfc-editor.org/rfc/rfc7253.html#appendix-A aead::new_test!(rfc7253_ocb_aes, "rfc7253_ocb_aes", Aes128Ocb3); @@ -24,7 +24,7 @@ macro_rules! rfc7253_wider_variety { let mut key_bytes = vec![0u8; $keylen]; key_bytes[$keylen - 1] = 8 * $taglen; // taglen in bytes - let key = GenericArray::from_slice(key_bytes.as_slice()); + let key = Array::from_slice(key_bytes.as_slice()); let ocb = $ocb::new(key); let mut ciphertext = Vec::new(); @@ -38,7 +38,7 @@ macro_rules! rfc7253_wider_variety { let N = num2str96(3 * i + 1); let mut buffer = S.clone(); let tag = ocb - .encrypt_in_place_detached(N.as_slice().into(), &S, &mut buffer) + .encrypt_in_place_detached(N.as_slice().try_into().unwrap(), &S, &mut buffer) .unwrap(); ciphertext.append(&mut buffer); ciphertext.append(&mut tag.as_slice().to_vec()); @@ -48,7 +48,7 @@ macro_rules! rfc7253_wider_variety { let N = num2str96(3 * i + 2); let mut buffer = S.clone(); let tag = ocb - .encrypt_in_place_detached(N.as_slice().into(), &[], &mut buffer) + .encrypt_in_place_detached(N.as_slice().try_into().unwrap(), &[], &mut buffer) .unwrap(); ciphertext.append(&mut buffer); ciphertext.append(&mut tag.as_slice().to_vec()); @@ -57,7 +57,7 @@ macro_rules! rfc7253_wider_variety { // C = C || OCB-ENCRYPT(K,N,S,) let N = num2str96(3 * i + 3); let tag = ocb - .encrypt_in_place_detached(N.as_slice().into(), &S, &mut []) + .encrypt_in_place_detached(N.as_slice().try_into().unwrap(), &S, &mut []) .unwrap(); ciphertext.append(&mut tag.as_slice().to_vec()); } @@ -75,7 +75,7 @@ macro_rules! rfc7253_wider_variety { // Output : OCB-ENCRYPT(K,N,C,) let N = num2str96(385); let tag = ocb - .encrypt_in_place_detached(N.as_slice().into(), &ciphertext, &mut []) + .encrypt_in_place_detached(N.as_slice().try_into().unwrap(), &ciphertext, &mut []) .unwrap(); assert_eq!(tag.as_slice(), hex!($expected))