Weave documentation
Filament referencefilament-crypto

filament-crypto · encryption

Source declarations, signatures and documentation for encryption.

Read the current implementation boundaries before integration. This reference reproduces declarations; it omits source comments whose examples or readiness claims have not been verified.

Source: sigil/weave/filament/filament-crypto/src/encryption.rs. SHA-256: 056bfa74877c2baade5d54147fd45628d8844f430b87e47bfde6cba1cbfde14f.

This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.

encryption::EncryptionError

#[derive(Error, Debug)]
pub enum EncryptionError {
    /// Invalid key size
    #[error("invalid key size: expected 32 bytes, got {0}")]
    InvalidKeySize(usize),

    /// Invalid IV size
    #[error("invalid IV size: expected 16 bytes, got {0}")]
    InvalidIvSize(usize),

    /// HMAC verification failed (message tampered or corrupted)
    #[error("authentication failed: message tampered or corrupted")]
    AuthenticationFailed,

    /// Ciphertext too short
    #[error("ciphertext too short: minimum 48 bytes (IV + MAC), got {0}")]
    CiphertextTooShort(usize),

    /// Padding error during decryption
    #[error("invalid padding")]
    InvalidPadding,

    /// Encryption operation failed
    #[error("encryption failed: {0}")]
    EncryptionFailed(String),

    /// Decryption operation failed
    #[error("decryption failed: {0}")]
    DecryptionFailed(String),
}

Source line: 39.

encryption::encrypt

pub fn encrypt(key: &[u8], plaintext: &[u8]) -> Result<Vec<u8>, EncryptionError>;

Source line: 106.

encryption::decrypt

pub fn decrypt(key: &[u8], ciphertext: &[u8]) -> Result<Vec<u8>, EncryptionError>;

Source line: 161.

On this page