diff --git a/openmls/src/credentials/codec.rs b/openmls/src/credentials/codec.rs index a54ae144be..f366180f74 100644 --- a/openmls/src/credentials/codec.rs +++ b/openmls/src/credentials/codec.rs @@ -7,9 +7,9 @@ impl tls_codec::Size for Credential { fn tls_serialized_len(&self) -> usize { self.credential_type.tls_serialized_len() + match &self.credential { - MlsCredentialType::Basic(c) => c.tls_serialized_len(), - MlsCredentialType::X509(c) => c.tls_serialized_len(), - } + MlsCredentialType::Basic(c) => c.tls_serialized_len(), + MlsCredentialType::X509(c) => c.tls_serialized_len(), + } } } @@ -32,8 +32,7 @@ impl tls_codec::Serialize for Credential { impl tls_codec::Deserialize for Credential { fn tls_deserialize(bytes: &mut R) -> Result { let val = u16::tls_deserialize(bytes)?; - let credential_type = CredentialType::try_from(val) - .map_err(|e| tls_codec::Error::DecodingError(e.to_string()))?; + let credential_type = CredentialType::from(val); match credential_type { CredentialType::Basic => Ok(Credential::from(MlsCredentialType::Basic( BasicCredential::tls_deserialize(bytes)?, diff --git a/openmls/src/credentials/mod.rs b/openmls/src/credentials/mod.rs index 5277aed58c..a9888d5553 100644 --- a/openmls/src/credentials/mod.rs +++ b/openmls/src/credentials/mod.rs @@ -22,10 +22,7 @@ //! There are multiple [`CredentialType`]s, although OpenMLS currently only //! supports the [`BasicCredential`]. -use std::{ - convert::TryFrom, - io::{Read, Write}, -}; +use std::io::{Read, Write}; use serde::{Deserialize, Serialize}; use tls_codec::{TlsDeserialize, TlsSerialize, TlsSize, VLBytes}; @@ -34,6 +31,7 @@ use tls_codec::{TlsDeserialize, TlsSerialize, TlsSize, VLBytes}; mod codec; #[cfg(test)] mod tests; + use errors::*; use openmls_x509_credential::X509Ext; use x509_cert::{der::Decode, PkiPath}; @@ -93,8 +91,8 @@ impl tls_codec::Size for CredentialType { impl tls_codec::Deserialize for CredentialType { fn tls_deserialize(bytes: &mut R) -> Result - where - Self: Sized, + where + Self: Sized, { let mut extension_type = [0u8; 2]; bytes.read_exact(&mut extension_type)?; @@ -162,8 +160,8 @@ impl tls_codec::Serialize for Certificate { impl tls_codec::Deserialize for Certificate { fn tls_deserialize(bytes: &mut R) -> Result - where - Self: Sized, + where + Self: Sized, { let certificates = Vec::>::tls_deserialize(bytes)?; // we should not do this in a deserializer but otherwise we have to deal with a `identity: Option>` everywhere @@ -184,7 +182,7 @@ impl Certificate { fn try_new(certificates: Vec>) -> Result { let leaf = certificates - .get(0) + .first() .ok_or(CredentialError::InvalidCertificateChain)?; let leaf = x509_cert::Certificate::from_der(leaf)?; let identity = leaf @@ -201,7 +199,7 @@ impl Certificate { /// /// This enum contains variants containing the different available credentials. #[derive( - Debug, PartialEq, Eq, Clone, Serialize, Deserialize, TlsSerialize, TlsDeserialize, TlsSize, +Debug, PartialEq, Eq, Clone, Serialize, Deserialize, TlsSerialize, TlsDeserialize, TlsSize, )] #[repr(u8)] pub enum MlsCredentialType { @@ -298,7 +296,7 @@ impl From for Credential { /// OpenMLS provides an implementation of signature keys for convenience in the /// `openmls_basic_credential` crate. #[derive( - Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TlsSerialize, TlsDeserialize, TlsSize, +Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TlsSerialize, TlsDeserialize, TlsSize, )] pub struct BasicCredential { identity: VLBytes, @@ -348,7 +346,7 @@ pub mod test_utils { signature_scheme, Some(cert_data), ) - .await + .await } /// Convenience function that generates a new credential and a key pair for @@ -368,7 +366,7 @@ pub mod test_utils { signature_scheme, None, ) - .await + .await } async fn build_credential( @@ -387,7 +385,7 @@ pub mod test_utils { signature_scheme, &mut *backend.rand().borrow_rand().unwrap(), ) - .unwrap(); + .unwrap(); signature_keys.store(backend.key_store()).await.unwrap(); ( diff --git a/openmls/src/group/mod.rs b/openmls/src/group/mod.rs index 8bce84c933..24fa8cc1c3 100644 --- a/openmls/src/group/mod.rs +++ b/openmls/src/group/mod.rs @@ -28,7 +28,6 @@ pub use core_group::proposals::*; pub use core_group::staged_commit::StagedCommit; pub use mls_group::config::*; pub use mls_group::membership::*; -pub use mls_group::processing::*; pub use mls_group::*; pub use public_group::*; diff --git a/openmls/src/prelude.rs b/openmls/src/prelude.rs index 00999d5f54..7ec47a8c4a 100644 --- a/openmls/src/prelude.rs +++ b/openmls/src/prelude.rs @@ -6,7 +6,7 @@ // MlsGroup pub use crate::group::{config::CryptoConfig, core_group::Member, errors::*, ser::*, *}; -pub use crate::group::public_group::{errors::*, process::*, *}; +pub use crate::group::public_group::errors::*; // Ciphersuite pub use crate::ciphersuite::{hash_ref::KeyPackageRef, signable::*, signature::*, *}; @@ -25,11 +25,8 @@ pub use crate::extensions::{errors::*, *}; // Framing pub use crate::framing::{ - message_in::*, - message_out::{MlsMessageOutBody, *}, + message_out::MlsMessageOutBody, mls_content_in::FramedContentBodyIn, - sender::*, - validation::*, *, }; diff --git a/x509_credential/src/lib.rs b/x509_credential/src/lib.rs index b37f806bb3..93906dedbb 100644 --- a/x509_credential/src/lib.rs +++ b/x509_credential/src/lib.rs @@ -35,7 +35,7 @@ impl CertificateKeyPair { }, )?; - let leaf = pki_path.get(0).ok_or(CryptoError::CryptoLibraryError)?; + let leaf = pki_path.first().ok_or(CryptoError::CryptoLibraryError)?; let signature_scheme = leaf.signature_scheme()?; let pk = leaf.public_key()?;