Skip to content

Commit

Permalink
September cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelrobert authored and franziskuskiefer committed Sep 20, 2022
1 parent 4704a61 commit a950c98
Show file tree
Hide file tree
Showing 43 changed files with 105 additions and 84 deletions.
2 changes: 1 addition & 1 deletion cli/src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl User {

let msg = GroupMessage::new(message_out.into(), &self.recipients(group));
log::debug!(" >>> send: {:?}", msg);
let _response = self.backend.send_msg(&msg)?;
self.backend.send_msg(&msg)?;

// XXX: Need to update the client's local view of the conversation to include
// the message they sent.
Expand Down
2 changes: 1 addition & 1 deletion evercrypt_backend/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ impl OpenMlsRand for EvercryptProvider {
}
}

#[derive(thiserror::Error, Debug, Copy, Clone, PartialEq)]
#[derive(thiserror::Error, Debug, Copy, Clone, PartialEq, Eq)]
pub enum RandError {
#[error("Rng lock is poisoned.")]
LockPoisoned,
Expand Down
2 changes: 1 addition & 1 deletion memory_keystore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl OpenMlsKeyStore for MemoryKeyStore {
}

/// Errors thrown by the key store.
#[derive(thiserror::Error, Debug, Copy, Clone, PartialEq)]
#[derive(thiserror::Error, Debug, Copy, Clone, PartialEq, Eq)]
pub enum Error {
#[error("The key store does not allow storing serialized values.")]
UnsupportedValueTypeBytes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ fn read_test_vectors_tm() {

#[cfg(any(feature = "test-utils", test))]
/// TreeMath test vector error
#[derive(Error, Debug, PartialEq, Clone)]
#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum TmTestVectorError {
/// The computed tree size doesn't match the one in the test vector.
#[error("The computed tree size doesn't match the one in the test vector.")]
Expand Down
2 changes: 1 addition & 1 deletion openmls/src/ciphersuite/aead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub(crate) const NONCE_BYTES: usize = 12;

/// AEAD keys holding the plain key value and the AEAD algorithm type.
#[derive(Debug, Serialize, Deserialize)]
#[cfg_attr(any(feature = "test-utils", test), derive(Clone, PartialEq))]
#[cfg_attr(any(feature = "test-utils", test), derive(Clone, PartialEq, Eq))]
pub struct AeadKey {
aead_mode: AeadType,
value: Vec<u8>,
Expand Down
2 changes: 1 addition & 1 deletion openmls/src/ciphersuite/reuse_guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::*;
pub(crate) const REUSE_GUARD_BYTES: usize = 4;

#[derive(Debug, Clone, Copy, TlsSerialize, TlsDeserialize, TlsSize)]
#[cfg_attr(test, derive(PartialEq))]
#[cfg_attr(test, derive(PartialEq, Eq))]
pub struct ReuseGuard {
pub(in crate::ciphersuite) value: [u8; REUSE_GUARD_BYTES],
}
Expand Down
4 changes: 2 additions & 2 deletions openmls/src/ciphersuite/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ use super::*;

/// Signature.
#[derive(
Debug, PartialEq, Clone, Serialize, Deserialize, TlsDeserialize, TlsSerialize, TlsSize,
Debug, PartialEq, Eq, Clone, Serialize, Deserialize, TlsDeserialize, TlsSerialize, TlsSize,
)]
pub struct Signature {
value: TlsByteVecU16,
}

/// A private signature key.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(any(feature = "test-utils", test), derive(PartialEq))]
#[cfg_attr(any(feature = "test-utils", test), derive(PartialEq, Eq))]
pub struct SignaturePrivateKey {
signature_scheme: SignatureScheme,
value: Vec<u8>,
Expand Down
4 changes: 2 additions & 2 deletions openmls/src/credentials/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub mod errors;
///
/// This enum contains variants for the different Credential Types.
#[derive(
Copy, Clone, Debug, PartialEq, Serialize, Deserialize, TlsDeserialize, TlsSerialize, TlsSize,
Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, TlsDeserialize, TlsSerialize, TlsSize,
)]
#[repr(u16)]
pub enum CredentialType {
Expand All @@ -81,7 +81,7 @@ impl TryFrom<u16> for CredentialType {
///
/// This struct contains an X.509 certificate chain. Note that X.509
/// certificates are not yet supported by OpenMLS.
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub struct Certificate {
cert_data: Vec<u8>,
}
Expand Down
2 changes: 1 addition & 1 deletion openmls/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ enum InternalLibraryError {

/// A wrapper struct for an error string. This can be used when no complex error
/// variant is needed.
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ErrorString(String);

impl From<String> for ErrorString {
Expand Down
2 changes: 1 addition & 1 deletion openmls/src/extensions/capabilities_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{messages::proposals::ProposalType, versions::ProtocolVersion};
/// be listed.
///
/// This extension is always present in a KeyPackage.
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize, TlsSize, TlsSerialize)]
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize, TlsSize, TlsSerialize)]
pub struct CapabilitiesExtension {
versions: TlsVecU8<ProtocolVersion>,
ciphersuites: TlsVecU8<Ciphersuite>,
Expand Down
12 changes: 6 additions & 6 deletions openmls/src/extensions/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub enum ExtensionError {
}

/// Lifetime extension error
#[derive(Error, Debug, PartialEq, Clone)]
#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum LifetimeExtensionError {
/// Invalid lifetime extensions.
#[error("Invalid lifetime extensions.")]
Expand All @@ -64,7 +64,7 @@ pub enum LifetimeExtensionError {
}

/// Capabilities extension error
#[derive(Error, Debug, PartialEq, Clone)]
#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum CapabilitiesExtensionError {
/// Invalid capabilities extensions.
#[error("Invalid capabilities extensions.")]
Expand All @@ -78,31 +78,31 @@ pub enum CapabilitiesExtensionError {
}

/// KeyPackage Id error
#[derive(Error, Debug, PartialEq, Clone)]
#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum KeyPackageIdError {
/// Invalid key package ID extensions.
#[error("Invalid key package ID extensions.")]
Invalid,
}

/// Parent hash error
#[derive(Error, Debug, PartialEq, Clone)]
#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum ParentHashError {
/// Invalid parent hash extensions.
#[error("Invalid parent hash extensions.")]
Invalid,
}

/// Ratchet tree error
#[derive(Error, Debug, PartialEq, Clone)]
#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum RatchetTreeError {
/// Invalid ratchet tree extensions.
#[error("Invalid ratchet tree extensions.")]
Invalid,
}

/// Invalid extension error
#[derive(Error, Debug, PartialEq, Clone)]
#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum InvalidExtensionError {
/// The provided extension list contains duplicate extensions.
#[error("The provided extension list contains duplicate extensions.")]
Expand Down
11 changes: 10 additions & 1 deletion openmls/src/extensions/external_key_id_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ use super::{Deserialize, Serialize};
///
/// A byte vector of length at most 2^16-1.
#[derive(
PartialEq, Clone, Debug, Default, Serialize, Deserialize, TlsSerialize, TlsDeserialize, TlsSize,
PartialEq,
Eq,
Clone,
Debug,
Default,
Serialize,
Deserialize,
TlsSerialize,
TlsDeserialize,
TlsSize,
)]
pub struct ExternalKeyIdExtension {
key_id: TlsByteVecU16,
Expand Down
2 changes: 1 addition & 1 deletion openmls/src/extensions/life_time_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const DEFAULT_KEY_PACKAGE_LIFETIME_MARGIN: u64 = 60 * 60; // in Seconds
/// Applications MUST define a maximum total lifetime that is acceptable for a
/// KeyPackage, and reject any KeyPackage where the total lifetime is longer
/// than this duration.This extension MUST always be present in a KeyPackage.
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize, TlsSerialize, TlsSize)]
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize, TlsSerialize, TlsSize)]
pub struct LifetimeExtension {
not_before: u64,
not_after: u64,
Expand Down
11 changes: 10 additions & 1 deletion openmls/src/extensions/parent_hash_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ use super::{Deserialize, Serialize};
/// commit message. If the extension is present, OpenMLS verifies that the
/// parent hash matches the hash of the leaf's parent node.
#[derive(
PartialEq, Clone, Debug, Default, Serialize, Deserialize, TlsSerialize, TlsDeserialize, TlsSize,
PartialEq,
Eq,
Clone,
Debug,
Default,
Serialize,
Deserialize,
TlsSerialize,
TlsDeserialize,
TlsSize,
)]
pub struct ParentHashExtension {
parent_hash: TlsByteVecU8,
Expand Down
11 changes: 10 additions & 1 deletion openmls/src/extensions/required_capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@ use super::{Deserialize, ExtensionError, ExtensionType, Serialize};
/// contains a required capabilities extension that requires capabilities not
/// supported by all current members.
#[derive(
PartialEq, Clone, Debug, Default, Serialize, Deserialize, TlsSerialize, TlsDeserialize, TlsSize,
PartialEq,
Eq,
Clone,
Debug,
Default,
Serialize,
Deserialize,
TlsSerialize,
TlsDeserialize,
TlsSize,
)]
pub struct RequiredCapabilitiesExtension {
extensions: TlsVecU8<ExtensionType>,
Expand Down
3 changes: 1 addition & 2 deletions openmls/src/extensions/test_extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ fn lifetime() {
.tls_serialize_detached()
.expect("error encoding life time extension");
let ext_deserialized = LifetimeExtension::tls_deserialize(&mut serialized.as_slice())
.err()
.expect("Didn't get an error deserializing invalid life time extension");
.expect_err("Didn't get an error deserializing invalid life time extension");
assert_eq!(
ext_deserialized,
tls_codec::Error::DecodingError("Invalid".to_string()),
Expand Down
2 changes: 1 addition & 1 deletion openmls/src/framing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ mod test_framing;

/// Wire format of MLS messages.
#[derive(
PartialEq, Clone, Copy, Debug, Serialize, Deserialize, TlsDeserialize, TlsSerialize, TlsSize,
PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize, TlsDeserialize, TlsSerialize, TlsSize,
)]
#[repr(u8)]
pub enum WireFormat {
Expand Down
2 changes: 1 addition & 1 deletion openmls/src/framing/plaintext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ impl MlsPlaintext {
// === Helper structs ===

#[derive(
PartialEq, Clone, Copy, Debug, Serialize, Deserialize, TlsDeserialize, TlsSerialize, TlsSize,
PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize, TlsDeserialize, TlsSerialize, TlsSize,
)]
#[repr(u8)]
pub enum ContentType {
Expand Down
2 changes: 1 addition & 1 deletion openmls/src/framing/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use tls_codec::{TlsDeserialize, TlsSerialize, TlsSize};

/// All possible sender types according to the MLS protocol spec.
#[derive(
Debug, PartialEq, Clone, Serialize, Deserialize, TlsSerialize, TlsDeserialize, TlsSize,
Debug, PartialEq, Eq, Clone, Serialize, Deserialize, TlsSerialize, TlsDeserialize, TlsSize,
)]
#[repr(u8)]
pub enum Sender {
Expand Down
2 changes: 1 addition & 1 deletion openmls/src/framing/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ pub enum ProcessedMessage {
}

/// Application message received through a [ProcessedMessage].
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct ApplicationMessage {
bytes: Vec<u8>,
}
Expand Down
4 changes: 2 additions & 2 deletions openmls/src/group/core_group/proposals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ impl<'a> QueuedAddProposal<'a> {
}

/// A queued Remove proposal
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
pub struct QueuedRemoveProposal<'a> {
remove_proposal: &'a RemoveProposal,
sender: &'a Sender,
Expand Down Expand Up @@ -544,7 +544,7 @@ impl<'a> QueuedUpdateProposal<'a> {
}

/// A queued PresharedKey proposal
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
pub struct QueuedPskProposal<'a> {
psk_proposal: &'a PreSharedKeyProposal,
sender: &'a Sender,
Expand Down
2 changes: 1 addition & 1 deletion openmls/src/group/group_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use openmls_traits::types::Ciphersuite;
use super::*;

#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, TlsSerialize, TlsDeserialize, TlsSize,
Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TlsSerialize, TlsDeserialize, TlsSize,
)]
pub struct GroupContext {
group_id: GroupId,
Expand Down
8 changes: 4 additions & 4 deletions openmls/src/group/mls_group/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use serde::{Deserialize, Serialize};

/// Specifies the configuration parameters for a [`MlsGroup`]. Refer to
/// the [User Manual](https://openmls.tech/book/user_manual/group_config.html) for more information about the different configuration values.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct MlsGroupConfig {
/// Defines the wire format policy for outgoing and incoming handshake messages.
/// Application are always encrypted regardless.
Expand Down Expand Up @@ -170,7 +170,7 @@ impl MlsGroupConfigBuilder {

/// Defines what wire format is acceptable for incoming handshake messages.
/// Note that application messages must always be encrypted.
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum IncomingWireFormatPolicy {
/// Handshake messages must always be MlsCiphertext
AlwaysCiphertext,
Expand All @@ -194,7 +194,7 @@ impl IncomingWireFormatPolicy {

/// Defines what wire format should be used for outgoing handshake messages.
/// Note that application messages must always be encrypted.
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum OutgoingWireFormatPolicy {
/// Handshake messages must always be MlsCiphertext
AlwaysCiphertext,
Expand All @@ -204,7 +204,7 @@ pub enum OutgoingWireFormatPolicy {

/// Defines what wire format is desired for outgoing handshake messages.
/// Note that application messages must always be encrypted.
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct WireFormatPolicy {
outgoing: OutgoingWireFormatPolicy,
incoming: IncomingWireFormatPolicy,
Expand Down
2 changes: 1 addition & 1 deletion openmls/src/group/mls_group/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub enum NewGroupError {
}

/// EmptyInput error
#[derive(Error, Debug, PartialEq, Clone)]
#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum EmptyInputError {
/// An empty list of KeyPackages was provided.
#[error("An empty list of KeyPackages was provided.")]
Expand Down
4 changes: 3 additions & 1 deletion openmls/src/group/mls_group/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ impl MlsGroup {

/// Loads the state from persisted state.
pub fn load<R: Read>(reader: R) -> Result<MlsGroup, Error> {
// TODO #245: Remove this once we have a proper serialization format
#[allow(deprecated)]
let serialized_mls_group: SerializedMlsGroup = serde_json::from_reader(reader)?;
Ok(serialized_mls_group.into_mls_group())
}
Expand Down Expand Up @@ -402,7 +404,7 @@ impl MlsGroup {
/// `Enum` that indicates whether the inner group state has been modified since the last time it was persisted.
/// `InnerState::Changed` indicates that the state has changed and that [`.save()`] should be called.
/// `InnerState::Persisted` indicates that the state has not been modified and therefore doesn't need to be persisted.
#[derive(Debug, PartialEq, Clone, Copy)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum InnerState {
/// The inner group state has changed and needs to be persisted.
Changed,
Expand Down
3 changes: 3 additions & 0 deletions openmls/src/group/mls_group/ser.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// TODO #245: Remove this once we have a proper serialization format
#![allow(deprecated)]

use super::*;

use serde::{
Expand Down
1 change: 1 addition & 0 deletions openmls/src/group/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl GroupId {
#[derive(
Debug,
PartialEq,
Eq,
Copy,
Clone,
Hash,
Expand Down
2 changes: 1 addition & 1 deletion openmls/src/group/tests/kat_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ fn read_test_vectors_messages() {
}

/// Messages test vector error
#[derive(Error, Debug, PartialEq, Clone)]
#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum MessagesTestVectorError {
/// Lifetime encodings don't match.
#[error("Lifetime encodings don't match.")]
Expand Down
2 changes: 1 addition & 1 deletion openmls/src/group/tests/kat_transcripts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ fn read_test_vectors_transcript(backend: &impl OpenMlsCryptoProvider) {
}

/// Transcript test vector error
#[derive(Error, Debug, PartialEq, Clone)]
#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum TranscriptTestVectorError {
/// Membership tag could not be verified.
#[error("Membership tag could not be verified.")]
Expand Down
Loading

0 comments on commit a950c98

Please sign in to comment.