-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support receiving own proposals without an error (#154)
* Support receiving own proposals without an error * Fixup * Apply suggestions from code review Co-authored-by: Stephane Raux <[email protected]> * Rebase on main and unify received proposal * Fixup * Remove unused field * Remove unused enum variant --------- Co-authored-by: mulmarta <[email protected]> Co-authored-by: Stephane Raux <[email protected]>
- Loading branch information
1 parent
73be4cb
commit 9b55525
Showing
11 changed files
with
250 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use alloc::vec::Vec; | ||
use core::fmt; | ||
use core::fmt::Debug; | ||
|
||
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize}; | ||
use mls_rs_core::crypto::CipherSuiteProvider; | ||
|
||
use crate::{client::MlsError, error::IntoAnyError, MlsMessage}; | ||
|
||
#[derive(Clone, PartialEq, Eq, MlsEncode, MlsDecode, MlsSize, Hash)] | ||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] | ||
pub(crate) struct MessageHash( | ||
#[mls_codec(with = "mls_rs_codec::byte_vec")] | ||
#[cfg_attr(feature = "serde", serde(with = "mls_rs_core::vec_serde"))] | ||
Vec<u8>, | ||
); | ||
|
||
impl Debug for MessageHash { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
mls_rs_core::debug::pretty_bytes(&self.0) | ||
.named("MessageHash") | ||
.fmt(f) | ||
} | ||
} | ||
|
||
impl MessageHash { | ||
#[cfg_attr(not(mls_build_async), maybe_async::must_be_sync)] | ||
pub(crate) async fn compute<CS: CipherSuiteProvider>( | ||
cs: &CS, | ||
message: &MlsMessage, | ||
) -> Result<Self, MlsError> { | ||
cs.hash(&message.mls_encode_to_vec()?) | ||
.await | ||
.map_err(|e| MlsError::CryptoProviderError(e.into_any_error())) | ||
.map(Self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.