EncryptionConfig

Struct EncryptionConfig 

Source
pub struct EncryptionConfig {
    pub algorithm: EncryptionAlgorithm,
    pub key_derivation: KeyDerivationFunction,
    pub key_size: u32,
    pub nonce_size: u32,
    pub salt_size: u32,
    pub iterations: u32,
    pub memory_cost: Option<u32>,
    pub parallel_cost: Option<u32>,
    pub associated_data: Option<Vec<u8>>,
}
Expand description

Encryption configuration that encapsulates all parameters for encryption operations

This configuration struct provides comprehensive control over encryption behavior, including algorithm selection, key derivation parameters, and security settings. The configuration is immutable and thread-safe.

§Configuration Parameters

  • Algorithm: The encryption algorithm to use
  • Key Derivation: Function for deriving keys from passwords
  • Key Size: Size of encryption keys in bytes
  • Nonce Size: Size of nonces/initialization vectors in bytes
  • Salt Size: Size of salt for key derivation in bytes
  • Iterations: Number of iterations for key derivation
  • Memory Cost: Memory usage for memory-hard functions (optional)
  • Parallel Cost: Parallelism level for key derivation (optional)
  • Associated Data: Additional authenticated data (optional)

§Examples

§Security Considerations

  • Key Size: Larger keys provide better security but may impact performance
  • Iterations: Higher iteration counts increase security but slow key derivation
  • Memory Cost: Higher memory usage improves resistance to attacks
  • Salt Size: Larger salts prevent rainbow table attacks
  • Associated Data: Additional data authenticated but not encrypted

Fields§

§algorithm: EncryptionAlgorithm

The encryption algorithm to use for processing

§key_derivation: KeyDerivationFunction

Key derivation function for generating keys from passwords

§key_size: u32

Size of encryption keys in bytes

§nonce_size: u32

Size of nonces/initialization vectors in bytes

§salt_size: u32

Size of salt for key derivation in bytes

§iterations: u32

Number of iterations for key derivation functions

§memory_cost: Option<u32>

Memory cost for memory-hard functions (bytes)

§parallel_cost: Option<u32>

Parallelism level for key derivation functions

§associated_data: Option<Vec<u8>>

Additional authenticated data (not encrypted)

Implementations§

Source§

impl EncryptionConfig

Source

pub fn new(algorithm: EncryptionAlgorithm) -> Self

Creates a new encryption configuration

Source

pub fn with_key_derivation(self, kdf: KeyDerivationFunction) -> Self

Sets key derivation function

Source

pub fn with_key_size(self, size: u32) -> Self

Sets key size

Source

pub fn with_iterations(self, iterations: u32) -> Self

Sets iterations

Source

pub fn with_memory_cost(self, cost: u32) -> Self

Sets memory cost (for Argon2)

Source

pub fn with_parallel_cost(self, cost: u32) -> Self

Sets parallel cost (for Argon2)

Source

pub fn with_associated_data(self, data: Vec<u8>) -> Self

Sets associated data

Source

pub fn high_security() -> Self

Creates a high-security configuration

Source

pub fn performance_optimized() -> Self

Creates a performance-optimized configuration

Trait Implementations§

Source§

impl Clone for EncryptionConfig

Source§

fn clone(&self) -> EncryptionConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EncryptionConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EncryptionConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl FromParameters for EncryptionConfig

Implementation of FromParameters for type-safe config extraction.

This implementation converts StageConfiguration.parameters HashMap into a typed EncryptionConfig object.

§Expected Parameters
  • algorithm (required): Encryption algorithm name

    • Valid values: “aes256gcm”, “aes128gcm”, “chacha20poly1305”, “xchacha20poly1305”
    • Example: "algorithm" => "aes256gcm"
  • key_size (optional): Key size in bytes

    • Default: 32
    • Example: "key_size" => "32"
  • iterations (optional): KDF iterations

    • Default: 3
    • Example: "iterations" => "10000"
§Usage Example
use adaptive_pipeline_domain::services::{EncryptionConfig, FromParameters};
use std::collections::HashMap;

let mut params = HashMap::new();
params.insert("algorithm".to_string(), "aes256gcm".to_string());

let config = EncryptionConfig::from_parameters(&params).unwrap();
Source§

fn from_parameters( params: &HashMap<String, String>, ) -> Result<Self, PipelineError>

Converts HashMap parameters to typed configuration. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V