Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions mls-rs-core/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ pub struct HpkeCiphertext {

impl Debug for HpkeCiphertext {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("HpkeCiphertext")
.field("kem_output", &crate::debug::pretty_bytes(&self.kem_output))
.field("ciphertext", &crate::debug::pretty_bytes(&self.ciphertext))
.finish()
f.debug_struct("HpkeCiphertext").finish()
}
}

Expand Down Expand Up @@ -109,9 +106,7 @@ pub struct HpkeSecretKey(

impl Debug for HpkeSecretKey {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
crate::debug::pretty_bytes(&self.0)
.named("HpkeSecretKey")
.fmt(f)
f.debug_struct("HpkeSecretKey").finish()
}
}

Expand Down Expand Up @@ -254,9 +249,7 @@ pub struct SignatureSecretKey {

impl Debug for SignatureSecretKey {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
crate::debug::pretty_bytes(&self.bytes)
.named("SignatureSecretKey")
.fmt(f)
f.debug_struct("SignatureSecretKey").finish()
}
}

Expand Down
6 changes: 1 addition & 5 deletions mls-rs-core/src/group/group_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ impl Debug for GroupState {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("GroupState")
.field("id", &crate::debug::pretty_bytes(&self.id))
.field("data", &crate::debug::pretty_bytes(&self.data))
.finish()
}
}
Expand All @@ -36,10 +35,7 @@ pub struct EpochRecord {

impl Debug for EpochRecord {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("EpochRecord")
.field("id", &self.id)
.field("data", &crate::debug::pretty_bytes(&self.data))
.finish()
f.debug_struct("EpochRecord").field("id", &self.id).finish()
}
}

Expand Down
4 changes: 1 addition & 3 deletions mls-rs-core/src/psk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ pub struct PreSharedKey(

impl Debug for PreSharedKey {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
crate::debug::pretty_bytes(&self.0)
.named("PreSharedKey")
.fmt(f)
f.debug_struct("PreSharedKey").finish()
}
}

Expand Down
2 changes: 1 addition & 1 deletion mls-rs-core/src/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct Secret(Zeroizing<Vec<u8>>);

impl Debug for Secret {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
crate::debug::pretty_bytes(&self.0).named("Secret").fmt(f)
f.debug_struct("Secret").finish()
}
}

Expand Down
8 changes: 0 additions & 8 deletions mls-rs-crypto-hpke/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ pub(super) struct Context<KDF: KdfType, AEAD: AeadType> {
impl<KDF: KdfType + Debug, AEAD: AeadType + Debug> Debug for Context<KDF, AEAD> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Context")
.field(
"exporter_secret",
&mls_rs_core::debug::pretty_bytes(&self.exporter_secret),
)
.field("encryption_context", &self.encryption_context)
.field("kdf", &self.kdf)
.finish()
Expand Down Expand Up @@ -153,10 +149,6 @@ impl<AEAD: AeadType + Debug> Debug for EncryptionContext<AEAD> {
)
.field("seq_number", &self.seq_number)
.field("aead", &self.aead)
.field(
"aead_key",
&mls_rs_core::debug::pretty_bytes(&self.aead_key),
)
.finish()
}
}
Expand Down
1 change: 0 additions & 1 deletion mls-rs-crypto-openssl/src/ec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ impl Debug for KeyPair {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("KeyPair")
.field("public", &mls_rs_core::debug::pretty_bytes(&self.public))
.field("secret", &mls_rs_core::debug::pretty_bytes(&self.secret))
.finish()
}
}
Expand Down
1 change: 0 additions & 1 deletion mls-rs-crypto-rustcrypto/src/ec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ impl Debug for KeyPair {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("KeyPair")
.field("public", &mls_rs_core::debug::pretty_bytes(&self.public))
.field("secret", &mls_rs_core::debug::pretty_bytes(&self.secret))
.finish()
}
}
Expand Down
10 changes: 9 additions & 1 deletion mls-rs-crypto-traits/src/kem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Copyright by contributors to this project.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

use core::fmt::Debug;

use mls_rs_core::{
crypto::{CipherSuite, HpkePublicKey, HpkeSecretKey},
error::IntoAnyError,
Expand Down Expand Up @@ -49,13 +51,19 @@ pub trait KemType: Send + Sync + Sized {
}

/// Struct to represent the output of the kem [encap](KemType::encap) function
#[derive(Clone, Debug, MlsDecode, MlsEncode, MlsSize, ZeroizeOnDrop)]
#[derive(Clone, MlsDecode, MlsEncode, MlsSize, ZeroizeOnDrop)]
pub struct KemResult {
pub shared_secret: Vec<u8>,
#[zeroize(skip)]
pub enc: Vec<u8>,
}

impl Debug for KemResult {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("KemResult").finish()
}
}

impl KemResult {
pub fn new(shared_secret: Vec<u8>, enc: Vec<u8>) -> Self {
Self { shared_secret, enc }
Expand Down
9 changes: 7 additions & 2 deletions mls-rs/src/client_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::{
};

use alloc::vec::Vec;
use core::time::Duration;
use core::{fmt::Debug, time::Duration};

#[cfg(feature = "sqlite")]
use mls_rs_provider_sqlite::{
Expand Down Expand Up @@ -173,9 +173,14 @@ pub type BaseSqlConfig = Config<
/// }
///
/// ```
#[derive(Debug)]
pub struct ClientBuilder<C>(C);

impl<C> Debug for ClientBuilder<C> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_tuple("ClientBuilder").finish()
}
}

impl Default for ClientBuilder<BaseConfig> {
fn default() -> Self {
Self::new()
Expand Down
7 changes: 6 additions & 1 deletion mls-rs/src/external_client/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,14 @@ pub type ExternalBaseConfig = Config<Missing, DefaultMlsRules, Missing>;
/// }
///
/// ```
#[derive(Debug)]
pub struct ExternalClientBuilder<C>(C);

impl<C> Debug for ExternalClientBuilder<C> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_tuple("ExternalClientBuilder").finish()
}
}

impl Default for ExternalClientBuilder<ExternalBaseConfig> {
fn default() -> Self {
Self::new()
Expand Down
6 changes: 1 addition & 5 deletions mls-rs/src/group/ciphertext_processor/sender_data_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@

impl<CP: CipherSuiteProvider + Debug> Debug for SenderDataKey<'_, CP> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SenderDataKey")
.field("key", &mls_rs_core::debug::pretty_bytes(&self.key))
.field("nonce", &mls_rs_core::debug::pretty_bytes(&self.nonce))
.field("cipher_suite_provider", self.cipher_suite_provider)
.finish()
f.debug_struct("SenderDataKey").finish()
}
}

Expand Down Expand Up @@ -191,7 +187,7 @@

use alloc::vec::Vec;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

Check warning on line 190 in mls-rs/src/group/ciphertext_processor/sender_data_key.rs

View workflow job for this annotation

GitHub Actions / BuildAndTest

unused import: `wasm_bindgen_test::wasm_bindgen_test as test`

Check warning on line 190 in mls-rs/src/group/ciphertext_processor/sender_data_key.rs

View workflow job for this annotation

GitHub Actions / BuildAndTest

unused import: `wasm_bindgen_test::wasm_bindgen_test as test`

use crate::{
crypto::test_utils::try_test_cipher_suite_provider,
Expand Down
4 changes: 1 addition & 3 deletions mls-rs/src/group/epoch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ pub(crate) struct SenderDataSecret(

impl Debug for SenderDataSecret {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
mls_rs_core::debug::pretty_bytes(&self.0)
.named("SenderDataSecret")
.fmt(f)
f.debug_struct("SenderDataSecret").finish()
}
}

Expand Down
28 changes: 3 additions & 25 deletions mls-rs/src/group/key_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,7 @@

impl Debug for KeySchedule {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("KeySchedule")
.field(
"exporter_secret",
&mls_rs_core::debug::pretty_bytes(&self.exporter_secret),
)
.field(
"authentication_secret",
&mls_rs_core::debug::pretty_bytes(&self.authentication_secret),
)
.field(
"external_secret",
&mls_rs_core::debug::pretty_bytes(&self.external_secret),
)
.field(
"membership_key",
&mls_rs_core::debug::pretty_bytes(&self.membership_key),
)
.field("init_secret", &self.init_secret)
.finish()
f.debug_struct("KeySchedule").finish()
}
}

Expand Down Expand Up @@ -341,9 +323,7 @@

impl Debug for JoinerSecret {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
mls_rs_core::debug::pretty_bytes(&self.0)
.named("JoinerSecret")
.fmt(f)
f.debug_struct("JoinerSecret").finish()
}
}

Expand Down Expand Up @@ -399,9 +379,7 @@

impl Debug for InitSecret {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
mls_rs_core::debug::pretty_bytes(&self.0)
.named("InitSecret")
.fmt(f)
f.debug_struct("InitSecret").finish()
}
}

Expand Down Expand Up @@ -597,7 +575,7 @@
use alloc::{string::ToString, vec};

#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

Check warning on line 578 in mls-rs/src/group/key_schedule.rs

View workflow job for this annotation

GitHub Actions / BuildAndTest

unused import: `wasm_bindgen_test::wasm_bindgen_test as test`

Check warning on line 578 in mls-rs/src/group/key_schedule.rs

View workflow job for this annotation

GitHub Actions / BuildAndTest

unused import: `wasm_bindgen_test::wasm_bindgen_test as test`
use zeroize::Zeroizing;

use super::test_utils::get_test_key_schedule;
Expand Down
7 changes: 1 addition & 6 deletions mls-rs/src/group/proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,7 @@ pub struct ExternalInit {

impl Debug for ExternalInit {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ExternalInit")
.field(
"kem_output",
&mls_rs_core::debug::pretty_bytes(&self.kem_output),
)
.finish()
f.debug_struct("ExternalInit").finish()
}
}

Expand Down
6 changes: 1 addition & 5 deletions mls-rs/src/group/secret_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ struct TreeSecret(

impl Debug for TreeSecret {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
mls_rs_core::debug::pretty_bytes(&self.0)
.named("TreeSecret")
.fmt(f)
f.debug_struct("TreeSecret").finish()
}
}

Expand Down Expand Up @@ -334,8 +332,6 @@ pub struct MessageKeyData {
impl Debug for MessageKeyData {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("MessageKeyData")
.field("nonce", &mls_rs_core::debug::pretty_bytes(&self.nonce))
.field("key", &mls_rs_core::debug::pretty_bytes(&self.key))
.field("generation", &self.generation)
.finish()
}
Expand Down
7 changes: 3 additions & 4 deletions mls-rs/src/psk/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ pub(crate) struct PskSecret(Zeroizing<Vec<u8>>);

impl Debug for PskSecret {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
mls_rs_core::debug::pretty_bytes(&self.0)
.named("PskSecret")
.fmt(f)
f.debug_struct("PskSecret").finish()
}
}

Expand Down Expand Up @@ -112,6 +110,7 @@ impl PskSecret {
#[cfg(test)]
mod tests {
use alloc::vec::Vec;
use core::fmt::Debug;
#[cfg(not(mls_build_async))]
use core::iter;
use serde::{Deserialize, Serialize};
Expand All @@ -131,7 +130,7 @@ mod tests {

use super::{PskSecret, PskSecretInput};

#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[derive(Debug, Clone, Deserialize, PartialEq, Serialize)]
struct PskInfo {
#[serde(with = "hex::serde")]
id: Vec<u8>,
Expand Down
4 changes: 1 addition & 3 deletions mls-rs/src/tree_kem/path_secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@

impl Debug for PathSecret {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
mls_rs_core::debug::pretty_bytes(&self.0)
.named("PathSecret")
.fmt(f)
f.debug_struct("PathSecret").finish()
}
}

Expand Down Expand Up @@ -139,7 +137,7 @@
#[cfg(test)]
mod tests {
use crate::{
cipher_suite::CipherSuite,

Check warning on line 140 in mls-rs/src/tree_kem/path_secret.rs

View workflow job for this annotation

GitHub Actions / AsyncBuildAndTest (macos-latest)

unused import: `cipher_suite::CipherSuite`

Check warning on line 140 in mls-rs/src/tree_kem/path_secret.rs

View workflow job for this annotation

GitHub Actions / AsyncBuildAndTest (macos-latest)

unused import: `cipher_suite::CipherSuite`

Check warning on line 140 in mls-rs/src/tree_kem/path_secret.rs

View workflow job for this annotation

GitHub Actions / AsyncBuildAndTest (macos-latest)

unused import: `cipher_suite::CipherSuite`

Check warning on line 140 in mls-rs/src/tree_kem/path_secret.rs

View workflow job for this annotation

GitHub Actions / AsyncBuildAndTest (macos-latest)

unused import: `cipher_suite::CipherSuite`

Check warning on line 140 in mls-rs/src/tree_kem/path_secret.rs

View workflow job for this annotation

GitHub Actions / AsyncBuildAndTest (ubuntu-latest)

unused import: `cipher_suite::CipherSuite`

Check warning on line 140 in mls-rs/src/tree_kem/path_secret.rs

View workflow job for this annotation

GitHub Actions / AsyncBuildAndTest (ubuntu-latest)

unused import: `cipher_suite::CipherSuite`

Check warning on line 140 in mls-rs/src/tree_kem/path_secret.rs

View workflow job for this annotation

GitHub Actions / AsyncBuildAndTest (ubuntu-latest)

unused import: `cipher_suite::CipherSuite`

Check warning on line 140 in mls-rs/src/tree_kem/path_secret.rs

View workflow job for this annotation

GitHub Actions / AsyncBuildAndTest (ubuntu-latest)

unused import: `cipher_suite::CipherSuite`

Check warning on line 140 in mls-rs/src/tree_kem/path_secret.rs

View workflow job for this annotation

GitHub Actions / AsyncBuildAndTest (windows-latest)

unused import: `cipher_suite::CipherSuite`

Check warning on line 140 in mls-rs/src/tree_kem/path_secret.rs

View workflow job for this annotation

GitHub Actions / AsyncBuildAndTest (windows-latest)

unused import: `cipher_suite::CipherSuite`

Check warning on line 140 in mls-rs/src/tree_kem/path_secret.rs

View workflow job for this annotation

GitHub Actions / AsyncBuildAndTest (windows-latest)

unused import: `cipher_suite::CipherSuite`

Check warning on line 140 in mls-rs/src/tree_kem/path_secret.rs

View workflow job for this annotation

GitHub Actions / AsyncBuildAndTest (windows-latest)

unused import: `cipher_suite::CipherSuite`
client::test_utils::TEST_CIPHER_SUITE,
crypto::test_utils::{
test_cipher_suite_provider, try_test_cipher_suite_provider, TestCryptoProvider,
Expand Down
Loading