Skip to content

Commit

Permalink
chore: fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
beltram committed Jan 10, 2024
1 parent 8e30301 commit 19c3d7a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 21 deletions.
3 changes: 1 addition & 2 deletions openmls/src/credentials/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ impl tls_codec::Serialize for Credential {
impl tls_codec::Deserialize for Credential {
fn tls_deserialize<R: Read>(bytes: &mut R) -> Result<Self, tls_codec::Error> {
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)?,
Expand Down
8 changes: 3 additions & 5 deletions openmls/src/credentials/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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};
Expand Down Expand Up @@ -184,7 +182,7 @@ impl Certificate {

fn try_new(certificates: Vec<Vec<u8>>) -> Result<Self, CredentialError> {
let leaf = certificates
.get(0)
.first()
.ok_or(CredentialError::InvalidCertificateChain)?;
let leaf = x509_cert::Certificate::from_der(leaf)?;
let identity = leaf
Expand Down
3 changes: 0 additions & 3 deletions openmls/src/group/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;

Expand All @@ -38,8 +37,6 @@ pub(crate) use core_group::create_commit_params::*;
#[cfg(any(feature = "test-utils", test))]
pub(crate) mod tests;
use openmls_traits::random::OpenMlsRand;
#[cfg(any(feature = "test-utils", test))]
pub use proposals::*;

/// A group ID. The group ID is chosen by the creator of the group and should be globally unique.
#[derive(
Expand Down
11 changes: 2 additions & 9 deletions openmls/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*, *};
Expand All @@ -24,14 +24,7 @@ pub use crate::versions::*;
pub use crate::extensions::{errors::*, *};

// Framing
pub use crate::framing::{
message_in::*,
message_out::{MlsMessageOutBody, *},
mls_content_in::FramedContentBodyIn,
sender::*,
validation::*,
*,
};
pub use crate::framing::{message_out::MlsMessageOutBody, mls_content_in::FramedContentBodyIn, *};

// Key packages
pub use crate::key_packages::{errors::*, *};
Expand Down
4 changes: 2 additions & 2 deletions x509_credential/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
//! An implementation of the x509 credential from the MLS spec.
use base64::Engine;
use percent_encoding::percent_decode_str;
use openmls_basic_credential::SignatureKeyPair;
use percent_encoding::percent_decode_str;
use x509_cert::der::Decode;
use x509_cert::Certificate;

Expand Down Expand Up @@ -36,7 +36,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()?;
Expand Down

0 comments on commit 19c3d7a

Please sign in to comment.