blindplane-access 0.1.0

Signed enterprise access grants, capability policies, revocation and encrypted audit events for Blindplane
Documentation
//! Access-layer errors.

/// A structural, trust, policy, or cryptographic access failure.
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum AccessError {
    /// The input ended before the object did.
    Truncated,
    /// The object has bytes after its canonical end.
    TrailingBytes,
    /// The object uses an unsupported version.
    UnsupportedVersion(u16),
    /// The encoded object tag does not match the requested type.
    WrongObjectType,
    /// An identifier is empty or exceeds the configured bound.
    InvalidIdentifier,
    /// An encoded identifier is not UTF-8.
    InvalidUtf8,
    /// A length exceeds the configured bound.
    LengthLimit(usize),
    /// An epoch or monotonic revision is zero or otherwise invalid.
    InvalidEpoch,
    /// A key does not match its domain-separated identifier or is unusable.
    InvalidKeyIdentity,
    /// Re-encoding did not reproduce the original bytes.
    NonCanonicalEncoding,
    /// A capability kind/name pair appears more than once.
    DuplicateRule,
    /// A signature is malformed or does not verify.
    InvalidSignature,
    /// The object was not issued by the caller's pinned issuer.
    UntrustedIssuer,
    /// The object belongs to a different tenant, subject, or scope.
    SubjectMismatch,
    /// The signed object is not active yet.
    NotYetValid,
    /// The signed object has expired.
    Expired,
    /// A monotonic policy or revocation revision is below the required floor.
    StaleRevision,
    /// An authorization or key epoch has been revoked.
    Revoked,
    /// A grant contains no permissions or unknown permission bits.
    InvalidPermissions,
    /// HPKE sealing or opening failed without exposing a decryption oracle.
    CryptographicFailure,
}

impl core::fmt::Display for AccessError {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        match self {
            Self::Truncated => f.write_str("access object is truncated"),
            Self::TrailingBytes => f.write_str("access object has trailing bytes"),
            Self::UnsupportedVersion(version) => {
                write!(f, "unsupported access object version {version}")
            }
            Self::WrongObjectType => f.write_str("wrong access object type"),
            Self::InvalidIdentifier => f.write_str("invalid access identifier"),
            Self::InvalidUtf8 => f.write_str("access identifier is not UTF-8"),
            Self::LengthLimit(length) => write!(f, "access length {length} exceeds its limit"),
            Self::InvalidEpoch => f.write_str("invalid access epoch or revision"),
            Self::InvalidKeyIdentity => f.write_str("invalid access key identity"),
            Self::NonCanonicalEncoding => f.write_str("non-canonical access object encoding"),
            Self::DuplicateRule => f.write_str("duplicate capability rule"),
            Self::InvalidSignature => f.write_str("invalid access object signature"),
            Self::UntrustedIssuer => f.write_str("access object issuer is not trusted"),
            Self::SubjectMismatch => {
                f.write_str("access object tenant, subject, or scope does not match")
            }
            Self::NotYetValid => f.write_str("access object is not active yet"),
            Self::Expired => f.write_str("access object has expired"),
            Self::StaleRevision => f.write_str("access object revision is stale"),
            Self::Revoked => f.write_str("access object epoch has been revoked"),
            Self::InvalidPermissions => f.write_str("invalid access permissions"),
            Self::CryptographicFailure => f.write_str("access cryptographic operation failed"),
        }
    }
}

impl std::error::Error for AccessError {}