1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
// Copyright (c) 2023 GoTo Group, Inc
// SPDX-License-Identifier: Apache-2.0 AND MIT
use crate::header::KeyId;
/// Represents either success(T) or an failure ([`SframeError`])
pub type Result<T> = std::result::Result<T, SframeError>;
/// Represents an error which has occured in the sframe-rs library
#[derive(PartialEq, Eq, Debug, thiserror::Error)]
pub enum SframeError {
/// [`Sender`] has no valid encryption key set
#[error("No EncryptionKey has been set")]
MissingEncryptionKey,
/// `Receiver` has no valid encryption key set
#[error("No DecryptionKey has been found")]
MissingDecryptionKey(KeyId),
/// Failed to decrypt a frame with AEAD
#[error("Failed to Decrypt")]
DecryptionFailure,
/// Failed to encrypt a frame with AEAD
#[error("Failed to Encrypt")]
EncryptionFailure,
/// Could not expand encryption key for [`Sender`] or decryption key for [`Receiver`] with HKDF
#[error("Unable to create unbound encryption key")]
KeyExpansion,
/// frame validation failed in the [`Receiver`] before decryption
#[error("{0}")]
FrameValidationFailed(String),
/// any arbitrary error
#[error("{0}")]
Other(String),
}