core_crypto/mls/credential/
typ.rs

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
use std::unreachable;

use openmls::prelude::CredentialType;

/// Lists all the supported Credential types. Could list in the future some types not supported by
/// openmls such as Verifiable Presentation
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd)]
#[repr(u8)]
pub enum MlsCredentialType {
    /// Basic credential i.e. a KeyPair
    #[default]
    Basic = 0x01,
    /// A x509 certificate generally obtained through e2e identity enrollment process
    X509 = 0x02,
}

impl From<CredentialType> for MlsCredentialType {
    fn from(value: CredentialType) -> Self {
        match value {
            CredentialType::Basic => MlsCredentialType::Basic,
            CredentialType::X509 => MlsCredentialType::X509,
            _ => unreachable!("Unknown credential type"),
        }
    }
}

impl From<MlsCredentialType> for CredentialType {
    fn from(value: MlsCredentialType) -> Self {
        match value {
            MlsCredentialType::Basic => CredentialType::Basic,
            MlsCredentialType::X509 => CredentialType::X509,
        }
    }
}