diff --git a/rmls/src/crypto/cipher_suite.rs b/rmls/src/crypto/cipher_suite.rs index 3929b53..7670af1 100644 --- a/rmls/src/crypto/cipher_suite.rs +++ b/rmls/src/crypto/cipher_suite.rs @@ -47,3 +47,20 @@ impl Display for CipherSuite { /// used in a leaf node in the tree to indicate an individual client's CipherSuite Capability. #[derive(Default, Debug, Copy, Clone, Eq, PartialEq, Hash)] pub struct CipherSuiteCapability(pub(crate) u16); + +impl TryFrom for CipherSuite { + type Error = Error; + + fn try_from(c: CipherSuiteCapability) -> std::result::Result { + match c.0 { + 0x0001 => Ok(CipherSuite::MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519), + 0x0002 => Ok(CipherSuite::MLS_128_DHKEMP256_AES128GCM_SHA256_P256), + 0x0003 => Ok(CipherSuite::MLS_128_DHKEMX25519_CHACHA20POLY1305_SHA256_Ed25519), + 0x0004 => Ok(CipherSuite::MLS_256_DHKEMX448_AES256GCM_SHA512_Ed448), + 0x0005 => Ok(CipherSuite::MLS_256_DHKEMP521_AES256GCM_SHA512_P521), + 0x0006 => Ok(CipherSuite::MLS_256_DHKEMX448_CHACHA20POLY1305_SHA512_Ed448), + 0x0007 => Ok(CipherSuite::MLS_256_DHKEMP384_AES256GCM_SHA384_P384), + _ => Err(Error::InvalidCipherSuiteValue(c.0)), + } + } +} diff --git a/rmls/src/framing/mod.rs b/rmls/src/framing/mod.rs index 8b46682..eb24c2a 100644 --- a/rmls/src/framing/mod.rs +++ b/rmls/src/framing/mod.rs @@ -643,10 +643,10 @@ impl AuthenticatedContent { /// [RFC9420 Sec.6.1](https://www.rfc-editor.org/rfc/rfc9420.html#section-6.1) FramedContentTBS #[derive(Default, Debug, Clone, Eq, PartialEq)] pub struct FramedContentTBS { - version: ProtocolVersion, - wire_format: WireFormat, - content: FramedContent, - context: Option, // for SenderType::Member and SenderType::NewMemberCommit + pub version: ProtocolVersion, + pub wire_format: WireFormat, + pub content: FramedContent, + pub context: Option, // for SenderType::Member and SenderType::NewMemberCommit } impl Deserializer for FramedContentTBS { @@ -703,8 +703,8 @@ impl Serializer for FramedContentTBS { /// is used for authenticating FramedContent #[derive(Default, Debug, Clone, Eq, PartialEq)] pub struct FramedContentAuthData { - signature: Bytes, - pub(crate) confirmation_tag: Bytes, // for ContentType::Commit + pub signature: Bytes, + pub confirmation_tag: Bytes, // for ContentType::Commit } impl FramedContentAuthData { @@ -801,9 +801,9 @@ impl FramedContentAuthData { /// authenticated but not encrypted are encoded using the PublicMessage structure. #[derive(Default, Debug, Clone, Eq, PartialEq)] pub struct PublicMessage { - pub(crate) content: FramedContent, - auth: FramedContentAuthData, - membership_tag: Option, // for SenderType::Member + pub content: FramedContent, + pub auth: FramedContentAuthData, + pub membership_tag: Option, // for SenderType::Member } impl Deserializer for PublicMessage { @@ -950,8 +950,8 @@ impl PublicMessage { /// by members, it MUST be set to AuthenticatedContentTBM #[derive(Default, Debug, Clone, Eq, PartialEq)] pub struct AuthenticatedContentTBM { - content_tbs: FramedContentTBS, - auth: FramedContentAuthData, + pub content_tbs: FramedContentTBS, + pub auth: FramedContentAuthData, } impl Deserializer for AuthenticatedContentTBM { @@ -983,12 +983,12 @@ impl Serializer for AuthenticatedContentTBM { /// encrypted messages are encoded using the PrivateMessage structure. #[derive(Default, Debug, Clone, Eq, PartialEq)] pub struct PrivateMessage { - group_id: GroupID, - epoch: u64, - pub(crate) content_type: ContentType, - authenticated_data: Bytes, - encrypted_sender_data: Bytes, - ciphertext: Bytes, + pub group_id: GroupID, + pub epoch: u64, + pub content_type: ContentType, + pub authenticated_data: Bytes, + pub encrypted_sender_data: Bytes, + pub ciphertext: Bytes, } impl Deserializer for PrivateMessage { @@ -1165,8 +1165,8 @@ impl PrivateMessage { /// encrypted is encoded in a PrivateMessageContent structure. #[derive(Default, Debug, Clone, Eq, PartialEq)] pub struct PrivateMessageContent { - pub(crate) content: Content, - auth: FramedContentAuthData, + pub content: Content, + pub auth: FramedContentAuthData, } impl PrivateMessageContent { @@ -1214,10 +1214,10 @@ impl Serializer for PrivateMessageContent { /// with the values used to identify the key and nonce #[derive(Default, Debug, Clone, Eq, PartialEq)] pub struct PrivateContentAAD { - group_id: GroupID, - epoch: u64, - content_type: ContentType, - authenticated_data: Bytes, + pub group_id: GroupID, + pub epoch: u64, + pub content_type: ContentType, + pub authenticated_data: Bytes, } impl Deserializer for PrivateContentAAD { @@ -1262,9 +1262,9 @@ impl Serializer for PrivateContentAAD { /// Before being encrypted, the sender data is encoded as an object of the following form #[derive(Default, Debug, Copy, Clone, Eq, PartialEq)] pub struct SenderData { - leaf_index: LeafIndex, - pub(crate) generation: u32, - pub(crate) reuse_guard: [u8; 4], + pub leaf_index: LeafIndex, + pub generation: u32, + pub reuse_guard: [u8; 4], } impl SenderData { @@ -1319,9 +1319,9 @@ impl Serializer for SenderData { /// SenderData ciphertext is the first three fields of PrivateMessage. #[derive(Default, Debug, Clone, Eq, PartialEq)] pub struct SenderDataAAD { - group_id: GroupID, - epoch: u64, - content_type: ContentType, + pub group_id: GroupID, + pub epoch: u64, + pub content_type: ContentType, } impl Serializer for SenderDataAAD { diff --git a/rmls/src/group/proposal.rs b/rmls/src/group/proposal.rs index 48bd276..a5e6c6a 100644 --- a/rmls/src/group/proposal.rs +++ b/rmls/src/group/proposal.rs @@ -12,7 +12,7 @@ use bytes::{Buf, BufMut, Bytes}; // http://www.iana.org/assignments/mls/mls.xhtml#mls-proposal-types #[derive(Default, Debug, Copy, Clone, Eq, PartialEq)] #[repr(u16)] -pub(crate) enum ProposalTypeCapability { +pub enum ProposalTypeCapability { #[default] Add = 0x0001, Update = 0x0002, diff --git a/rmls/src/ratchet_tree/mod.rs b/rmls/src/ratchet_tree/mod.rs index a6004fe..5ff74c6 100644 --- a/rmls/src/ratchet_tree/mod.rs +++ b/rmls/src/ratchet_tree/mod.rs @@ -169,11 +169,11 @@ impl Serializer for LeafNodeSource { /// [RFC9420 Sec.7.2](https://www.rfc-editor.org/rfc/rfc9420.html#section-7.2) Capabilities #[derive(Default, Debug, Clone, Eq, PartialEq)] pub struct Capabilities { - versions: Vec, - cipher_suites: Vec, - extensions: Vec, - proposals: Vec, - pub(crate) credentials: Vec, + pub versions: Vec, + pub cipher_suites: Vec, + pub extensions: Vec, + pub proposals: Vec, + pub credentials: Vec, } impl Deserializer for Capabilities { @@ -303,8 +303,8 @@ const MAX_LEAF_NODE_LIFETIME: Duration = Duration::from_secs(3 * 30 * 24); /// [RFC9420 Sec.7.2](https://www.rfc-editor.org/rfc/rfc9420.html#section-7.2) Lifetime #[derive(Default, Debug, Copy, Clone, Eq, PartialEq)] pub struct Lifetime { - not_before: u64, - not_after: u64, + pub not_before: u64, + pub not_after: u64, } impl Deserializer for Lifetime { @@ -408,8 +408,8 @@ impl From for u16 { /// [RFC9420 Sec.7.2](https://www.rfc-editor.org/rfc/rfc9420.html#section-7.2) Extension #[derive(Default, Debug, Clone, Eq, PartialEq)] pub struct Extension { - extension_type: ExtensionType, - extension_data: Bytes, + pub extension_type: ExtensionType, + pub extension_data: Bytes, } /// [RFC9420 Sec.7.2](https://www.rfc-editor.org/rfc/rfc9420.html#section-7.2) Extensions @@ -462,14 +462,13 @@ impl Extensions { /// [RFC9420 Sec.7.2](https://www.rfc-editor.org/rfc/rfc9420.html#section-7.2) LeafNode #[derive(Default, Debug, Clone, Eq, PartialEq)] pub struct LeafNode { - pub(crate) encryption_key: HPKEPublicKey, - pub(crate) signature_key: SignaturePublicKey, - credential: Credential, - pub(crate) capabilities: Capabilities, - pub(crate) leaf_node_source: LeafNodeSource, - extensions: Extensions, - - signature: Bytes, + pub encryption_key: HPKEPublicKey, + pub signature_key: SignaturePublicKey, + pub credential: Credential, + pub capabilities: Capabilities, + pub leaf_node_source: LeafNodeSource, + pub extensions: Extensions, + pub signature: Bytes, } impl LeafNode { @@ -741,8 +740,8 @@ impl Serializer for UpdatePathNode { /// as the filtered direct path. #[derive(Default, Debug, Clone, Eq, PartialEq)] pub struct UpdatePath { - pub(crate) leaf_node: LeafNode, - pub(crate) nodes: Vec, + pub leaf_node: LeafNode, + pub nodes: Vec, } impl Deserializer for UpdatePath {