Skip to content

Commit

Permalink
Bump hybrid-array to v0.2.0-pre.6
Browse files Browse the repository at this point in the history
This removes the `ByteArray` type alias.

Updates the following crates:

- `aead`
- `crypto-common`
- `digest`
  • Loading branch information
tarcieri committed Dec 30, 2023
1 parent a17da80 commit 55259b1
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 30 deletions.
11 changes: 6 additions & 5 deletions Cargo.lock

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

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ members = [
]

[patch.crates-io]
block-buffer = { git = "https://github.com/RustCrypto/utils.git" }
block-buffer = { git = "https://github.com/RustCrypto/utils.git", branch = "bump-hybrid-array-to-v0.2.0-pre.6" }
crypto-common = { path = "crypto-common" }
hybrid-array = { git = "https://github.com/RustCrypto/utils.git" }
inout = { git = "https://github.com/RustCrypto/utils.git" }
inout = { git = "https://github.com/RustCrypto/utils.git", branch = "bump-hybrid-array-to-v0.2.0-pre.6" }
6 changes: 3 additions & 3 deletions aead/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub use heapless;
pub use crypto_common::rand_core;

use core::fmt;
use crypto_common::array::{typenum::Unsigned, ArraySize, ByteArray};
use crypto_common::array::{typenum::Unsigned, Array, ArraySize};

#[cfg(feature = "alloc")]
use alloc::vec::Vec;
Expand Down Expand Up @@ -74,10 +74,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> = ByteArray<<A as AeadCore>::NonceSize>;
pub type Nonce<A> = Array<u8, <A as AeadCore>::NonceSize>;

/// Tag: authentication code which ensures ciphertexts are authentic
pub type Tag<A> = ByteArray<<A as AeadCore>::TagSize>;
pub type Tag<A> = Array<u8, <A as AeadCore>::TagSize>;

/// Authenticated Encryption with Associated Data (AEAD) algorithm core trait.
///
Expand Down
8 changes: 4 additions & 4 deletions aead/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ use crate::{AeadCore, AeadInPlace, Buffer, Error, Key, KeyInit, Result};
use core::ops::{AddAssign, Sub};
use crypto_common::array::{
typenum::{Unsigned, U4, U5},
ArraySize, ByteArray,
Array, ArraySize,
};

#[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> = ByteArray<NonceSize<A, S>>;
pub type Nonce<A, S> = Array<u8, NonceSize<A, S>>;

/// Size of a nonce as used by a STREAM construction, sans the overhead of
/// the STREAM protocol itself.
Expand Down Expand Up @@ -433,7 +433,7 @@ where
/// 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 = ByteArray::default();
let mut result = Array::default();

// TODO(tarcieri): use `generic_array::sequence::Concat` (or const generics)
let (prefix, tail) = result.split_at_mut(NonceSize::<A, Self>::to_usize());
Expand Down Expand Up @@ -527,7 +527,7 @@ where
return Err(Error);
}

let mut result = ByteArray::default();
let mut result = Array::default();

// TODO(tarcieri): use `generic_array::sequence::Concat` (or const generics)
let (prefix, tail) = result.split_at_mut(NonceSize::<A, Self>::to_usize());
Expand Down
2 changes: 1 addition & 1 deletion crypto-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ keywords = ["crypto", "traits"]
categories = ["cryptography", "no-std"]

[dependencies]
hybrid-array = "=0.2.0-pre.5"
hybrid-array = "=0.2.0-pre.6"

# optional dependencies
rand_core = { version = "0.6.4", optional = true }
Expand Down
10 changes: 5 additions & 5 deletions crypto-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub use hybrid_array::typenum;
use core::fmt;
use hybrid_array::{
typenum::{Diff, Sum, Unsigned},
Array, ArraySize, ByteArray,
Array, ArraySize,
};

#[cfg(feature = "rand_core")]
Expand All @@ -36,19 +36,19 @@ pub use serializable_state::{
};

/// Block on which [`BlockSizeUser`] implementors operate.
pub type Block<B> = ByteArray<<B as BlockSizeUser>::BlockSize>;
pub type Block<B> = Array<u8, <B as BlockSizeUser>::BlockSize>;

/// Parallel blocks on which [`ParBlocksSizeUser`] implementors operate.
pub type ParBlocks<T> = Array<Block<T>, <T as ParBlocksSizeUser>::ParBlocksSize>;

/// Output array of [`OutputSizeUser`] implementors.
pub type Output<T> = ByteArray<<T as OutputSizeUser>::OutputSize>;
pub type Output<T> = Array<u8, <T as OutputSizeUser>::OutputSize>;

/// Key used by [`KeySizeUser`] implementors.
pub type Key<B> = ByteArray<<B as KeySizeUser>::KeySize>;
pub type Key<B> = Array<u8, <B as KeySizeUser>::KeySize>;

/// Initialization vector (nonce) used by [`IvSizeUser`] implementors.
pub type Iv<B> = ByteArray<<B as IvSizeUser>::IvSize>;
pub type Iv<B> = Array<u8, <B as IvSizeUser>::IvSize>;

/// Alias for `AddBlockSize<A, B> = Sum<T, B::BlockSize>`
pub type AddBlockSize<T, B> = Sum<T, <B as BlockSizeUser>::BlockSize>;
Expand Down
4 changes: 2 additions & 2 deletions crypto-common/src/serializable_state.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::array::{
self,
typenum::{Diff, Prod, Sum, Unsigned, U1, U16, U2, U4, U8},
ArraySize, ByteArray,
Array, ArraySize,
};
use core::{convert::TryInto, default::Default, fmt};

/// Serialized internal state.
pub type SerializedState<T> = ByteArray<<T as SerializableState>::SerializedStateSize>;
pub type SerializedState<T> = Array<u8, <T as SerializableState>::SerializedStateSize>;

/// Alias for `AddSerializedStateSize<T, S> = Sum<T, S::SerializedStateSize>`
pub type AddSerializedStateSize<T, S> = Sum<T, <S as SerializableState>::SerializedStateSize>;
Expand Down
4 changes: 2 additions & 2 deletions digest/src/core_api/ct_variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use core::{
ops::{Add, Sub},
};
use crypto_common::{
array::{Array, ArraySize, ByteArray},
array::{Array, ArraySize},
typenum::{IsLess, IsLessOrEqual, Le, LeEq, NonZero, Sum, U1, U256},
Block, BlockSizeUser, DeserializeStateError, OutputSizeUser, SerializableState,
SerializedState, SubSerializedStateSize,
Expand Down Expand Up @@ -212,7 +212,7 @@ where

fn serialize(&self) -> SerializedState<Self> {
let serialized_inner = self.inner.serialize();
let serialized_outsize = ByteArray::<U1>::clone_from_slice(&[OutSize::U8]);
let serialized_outsize = Array::<u8, U1>::clone_from_slice(&[OutSize::U8]);

serialized_inner.concat(serialized_outsize)
}
Expand Down
6 changes: 3 additions & 3 deletions digest/src/core_api/rt_variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use core::{
};
use crypto_common::SubSerializedStateSize;
use crypto_common::{
array::{ArraySize, ByteArray},
array::{Array, ArraySize},
typenum::{Diff, IsLess, Le, NonZero, Sum, Unsigned, U1, U256},
AddBlockSize, DeserializeStateError, SerializableState, SerializedState, SubBlockSize,
};
Expand Down Expand Up @@ -161,10 +161,10 @@ where
fn serialize(&self) -> SerializedState<Self> {
let serialized_core = self.core.serialize();
let serialized_pos =
ByteArray::<U1>::clone_from_slice(&[self.buffer.get_pos().try_into().unwrap()]);
Array::<u8, U1>::clone_from_slice(&[self.buffer.get_pos().try_into().unwrap()]);
let serialized_data = self.buffer.clone().pad_with_zeros();
let serialized_output_size =
ByteArray::<U1>::clone_from_slice(&[self.output_size.try_into().unwrap()]);
Array::<u8, U1>::clone_from_slice(&[self.output_size.try_into().unwrap()]);

serialized_core
.concat(serialized_pos)
Expand Down
4 changes: 2 additions & 2 deletions digest/src/core_api/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use core::{
ops::{Add, Sub},
};
use crypto_common::{
array::{ArraySize, ByteArray},
array::{Array, ArraySize},
typenum::{Diff, IsLess, Le, NonZero, Sum, U1, U256},
BlockSizeUser, DeserializeStateError, InvalidLength, Key, KeyInit, KeySizeUser, Output,
SerializableState, SerializedState, SubSerializedStateSize,
Expand Down Expand Up @@ -219,7 +219,7 @@ where
fn serialize(&self) -> SerializedState<Self> {
let serialized_core = self.core.serialize();
let serialized_pos =
ByteArray::<U1>::clone_from_slice(&[self.buffer.get_pos().try_into().unwrap()]);
Array::<u8, U1>::clone_from_slice(&[self.buffer.get_pos().try_into().unwrap()]);
let serialized_data = self.buffer.clone().pad_with_zeros();

serialized_core
Expand Down

0 comments on commit 55259b1

Please sign in to comment.