philbin 1.0.1

A pure Rust AEGIS library with SIMD and runtime CPU detection
Documentation
use thiserror::Error;

/// An [`Error`][std::error::Error] type for all Philbin errors.
///
/// The messages describing these errors intentionally lack detail to prevent
/// leaking information that attackers might find useful. While this is indeed
/// frustrating, [it is critically important][wiki].
///
/// [wiki]: https://en.wikipedia.org/wiki/Padding_oracle_attack
#[derive(Error, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum Error {
  #[error("all-zero input buffer not allowed")]
  /// An all-zero input buffer is not allowed.
  AllZeroNotAllowed,
  #[error("provided input buffer has wrong size")]
  /// The provided input buffer has the wrong size.
  InputBufferWrongSize,
  #[error("provided output buffer was too small")]
  /// The provided output buffer was too small.
  OutputBufferTooSmall,
  // SECURITY: We do NOT provide the computed or expected auth tag in the error
  // message to prevent leaks of the expected auth tag to attackers.
  /// The computed authentication tag did not equal the provided tag.
  #[error("the computed authentication tag did not equal the provided tag")]
  AuthTagInvalid,
  // SECURITY: We do NOT provide ANY information from the source `rand`
  // error to avoid leaking potentially useful info to the attacker.
  /// Failure while generating random numbers.
  #[error("failure while generating random numbers")]
  RandError,
}

/// A type alias of [`Result`] that uses [`easy::Error`][crate::easy::Error].
pub type Result<T> = std::result::Result<T, Error>;