srp 0.7.0-rc.2

Pure Rust implementation of the Secure Remote Password (SRP) password-authenticated key exchange (PAKE) algorithm as described in RFC5054. Built on `crypto-bigint`, a mathematical library designed with constant-time algorithms.
Documentation
//! Error types.

use core::{error, fmt};

/// SRP authentication error.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum AuthError {
    /// Parameter with the given `name` is illegal.
    IllegalParameter {
        /// Parameter name
        name: &'static str,
    },
    /// Invalid MAC when computing proof for the given peer.
    BadRecordMac {
        /// Which peer's proof is invalid
        peer: &'static str,
    },
}

impl fmt::Display for AuthError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Self::IllegalParameter { name } => {
                write!(f, "illegal_parameter: bad '{name}' value")
            }
            Self::BadRecordMac { peer } => {
                write!(f, "bad_record_mac: incorrect '{peer}' proof")
            }
        }
    }
}

impl error::Error for AuthError {}