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
40
//! # Group Configurations
//!
//! This modules holds helper structs to group together configurations and
//! parameters.

use openmls_traits::types::Ciphersuite;
use serde::{Deserialize, Serialize};

use crate::versions::ProtocolVersion;

/// A config struct for commonly used values when performing cryptographic
/// operations.
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
pub struct CryptoConfig {
    /// The [`Ciphersuite`] used.
    pub ciphersuite: Ciphersuite,

    /// The MLS [`ProtocolVersion`] used.
    pub version: ProtocolVersion,
}

impl CryptoConfig {
    /// Create a new crypto config with the given ciphersuite and the default
    /// protocol version.
    pub fn with_default_version(ciphersuite: Ciphersuite) -> Self {
        Self {
            ciphersuite,
            version: ProtocolVersion::default(),
        }
    }
}

impl Default for CryptoConfig {
    fn default() -> Self {
        Self {
            ciphersuite: Ciphersuite::MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519,
            version: ProtocolVersion::default(),
        }
    }
}