philbin 1.0.1

A pure Rust AEGIS library with SIMD and runtime CPU detection
Documentation
use std::fmt::Debug;

/// A type alias for a byte array storing a 128 bit (16 byte) authentication tag.
///
/// See also: [`AuthTag`].
pub type AuthTag128 = [u8; 16];

/// A type alias for a byte array storing a 256 bit (32 byte) authentication tag.
///
/// See also: [`AuthTag`].
pub type AuthTag256 = [u8; 32];

/// An authentication tag.
///
/// See also: [`AuthTag128`] and [`AuthTag256`] which implement this trait.
pub trait AuthTag
where
  Self: private::Sealed,           // Prevent client impls
  Self: AsMut<[u8]> + AsRef<[u8]>, // Looks, swims and quacks like a byte array
  Self: PartialEq + Debug + Default,
{
  /// The length of the `AuthTag` in bytes.
  const BYTES: usize;
}

impl AuthTag for AuthTag128 {
  const BYTES: usize = 16;
}

impl AuthTag for AuthTag256 {
  const BYTES: usize = 32;
}

mod private {
  // Prevent client implementations of AuthTag
  pub trait Sealed {}
  impl Sealed for super::AuthTag128 {}
  impl Sealed for super::AuthTag256 {}
}