Skip to content

Commit e0c43af

Browse files
committed
chore: adjust CC to handle new type names
Note that this includes renaming a bunch of keystore entities from `MlsFoo` to `StoredFoo`, because 1. Those were not properly types owned by MLS 2. They were causing conflicts with actual types owned by MLS 3. The whole situation there was just confusing.
1 parent 0c64ea8 commit e0c43af

File tree

41 files changed

+483
-488
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+483
-488
lines changed

crypto/src/e2e_identity/enrollment/crypto.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use mls_crypto_provider::{MlsCryptoProvider, RustCrypto};
22
use openmls::prelude::SignatureScheme;
3-
use openmls_traits::{OpenMlsCryptoProvider as _, crypto::OpenMlsCrypto as _};
3+
use openmls_traits::crypto::OpenMlsCrypto as _;
44

55
use super::{Error, Result};
66
use crate::{MlsCiphersuite, MlsError, e2e_identity::crypto::E2eiSignatureKeypair};
@@ -11,7 +11,6 @@ impl super::E2eiEnrollment {
1111
backend: &MlsCryptoProvider,
1212
) -> Result<E2eiSignatureKeypair> {
1313
let (sk, _) = backend
14-
.crypto()
1514
.signature_key_gen(ciphersuite.signature_algorithm())
1615
.map_err(MlsError::wrap("performing signature keygen"))?;
1716
E2eiSignatureKeypair::try_new(ciphersuite.signature_algorithm(), sk)

crypto/src/mls/ciphersuite.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ use wire_e2e_identity::prelude::HashAlgorithm;
44
use super::{Error, Result};
55
use crate::CiphersuiteName;
66

7-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, derive_more::Deref, serde::Serialize, serde::Deserialize)]
7+
#[derive(
8+
Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Hash, derive_more::Deref, serde::Serialize, serde::Deserialize,
9+
)]
810
#[serde(transparent)]
911
#[repr(transparent)]
1012
/// A wrapper for the OpenMLS Ciphersuite, so that we are able to provide a default value.

crypto/src/mls/conversation/config.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use openmls::prelude::{
1010
RequiredCapabilitiesExtension, SenderRatchetConfiguration, WireFormatPolicy,
1111
};
1212
use openmls_traits::{
13-
OpenMlsCryptoProvider,
1413
crypto::OpenMlsCrypto,
1514
types::{Ciphersuite, SignatureScheme},
1615
};
@@ -125,7 +124,6 @@ impl MlsConversationConfiguration {
125124
backend: &MlsCryptoProvider,
126125
) -> Result<ExternalSender> {
127126
backend
128-
.crypto()
129127
.validate_signature_key(signature_scheme, &key[..])
130128
.map_err(MlsError::wrap("validating signature key"))?;
131129
let key = OpenMlsSignaturePublicKey::new(key.into(), signature_scheme)

crypto/src/mls/conversation/conversation_guard/commit.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::{
1111
Conversation as _, ConversationGuard, ConversationWithMls as _, Error, Result, commit::MlsCommitBundle,
1212
},
1313
credential::{
14-
CredentialBundle,
14+
Credential,
1515
crl::{extract_crl_uris_from_credentials, get_new_crl_distribution_points},
1616
},
1717
},
@@ -109,7 +109,7 @@ impl ConversationGuard {
109109
) -> Result<(NewCrlDistributionPoints, MlsCommitBundle)> {
110110
self.ensure_no_pending_commit().await?;
111111
let backend = self.crypto_provider().await?;
112-
let credential = self.credential_bundle().await?;
112+
let credential = self.credential().await?;
113113
let signer = credential.signature_key();
114114
let mut conversation = self.conversation_mut().await;
115115

@@ -155,7 +155,7 @@ impl ConversationGuard {
155155
pub async fn remove_members(&mut self, clients: &[ClientId]) -> Result<()> {
156156
self.ensure_no_pending_commit().await?;
157157
let backend = self.crypto_provider().await?;
158-
let credential = self.credential_bundle().await?;
158+
let credential = self.credential().await?;
159159
let signer = credential.signature_key();
160160
let mut conversation = self.inner.write().await;
161161

@@ -205,19 +205,19 @@ impl ConversationGuard {
205205
/// [crate::transaction_context::TransactionContext::e2ei_new_activation_enrollment] or
206206
/// [crate::transaction_context::TransactionContext::e2ei_new_rotate_enrollment] and having saved it with
207207
/// [crate::transaction_context::TransactionContext::save_x509_credential].
208-
pub async fn e2ei_rotate(&mut self, cb: Option<&CredentialBundle>) -> Result<()> {
208+
pub async fn e2ei_rotate(&mut self, cb: Option<&Credential>) -> Result<()> {
209209
let client = &self.session().await?;
210210
let conversation = self.conversation().await;
211211

212212
let cb = match cb {
213213
Some(cb) => cb,
214-
None => &client
215-
.find_most_recent_credential_bundle(
214+
None => &*client
215+
.find_most_recent_credential(
216216
conversation.ciphersuite().signature_algorithm(),
217217
MlsCredentialType::X509,
218218
)
219219
.await
220-
.map_err(RecursiveError::mls_client("finding most recent x509 credential bundle"))?,
220+
.map_err(RecursiveError::mls_client("finding most recent x509 credential"))?,
221221
};
222222

223223
let mut leaf_node = conversation
@@ -237,20 +237,20 @@ impl ConversationGuard {
237237

238238
pub(crate) async fn update_key_material_inner(
239239
&mut self,
240-
cb: Option<&CredentialBundle>,
240+
cb: Option<&Credential>,
241241
leaf_node: Option<LeafNode>,
242242
) -> Result<MlsCommitBundle> {
243243
self.ensure_no_pending_commit().await?;
244244
let session = &self.session().await?;
245245
let backend = &self.crypto_provider().await?;
246246
let mut conversation = self.conversation_mut().await;
247247
let cb = match cb {
248-
None => &conversation.find_most_recent_credential_bundle(session).await?,
248+
None => &conversation.find_most_recent_credential(session).await?,
249249
Some(cb) => cb,
250250
};
251251
let (commit, welcome, group_info) = conversation
252252
.group
253-
.explicit_self_update(backend, &cb.signature_key, leaf_node)
253+
.explicit_self_update(backend, &cb.signature_key_pair, leaf_node)
254254
.await
255255
.map_err(MlsError::wrap("group self update"))?;
256256

@@ -288,7 +288,7 @@ impl ConversationGuard {
288288
return Ok(None);
289289
}
290290

291-
let signer = &inner.find_most_recent_credential_bundle(session).await?.signature_key;
291+
let signer = &inner.find_most_recent_credential(session).await?.signature_key_pair;
292292

293293
let (commit, welcome, gi) = inner
294294
.group
@@ -317,7 +317,7 @@ impl ConversationGuard {
317317
if proposals.is_empty() {
318318
return Ok(None);
319319
}
320-
let signer = &inner.find_most_recent_credential_bundle(session).await?.signature_key;
320+
let signer = &inner.find_most_recent_credential(session).await?.signature_key_pair;
321321

322322
let (commit, welcome, gi) = inner
323323
.group

crypto/src/mls/conversation/conversation_guard/decrypt/buffer_commit.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use core_crypto_keystore::{connection::FetchFromDatabase as _, entities::MlsBufferedCommit};
1+
use core_crypto_keystore::{connection::FetchFromDatabase as _, entities::StoredBufferedCommit};
22
use log::info;
33
use openmls::framing::MlsMessageIn;
44
use openmls_traits::OpenMlsCryptoProvider as _;
@@ -16,7 +16,7 @@ impl ConversationGuard {
1616
let conversation = self.conversation().await;
1717
info!(group_id = conversation.id(); "buffering commit");
1818

19-
let buffered_commit = MlsBufferedCommit::new(conversation.id().to_bytes(), commit.as_ref().to_owned());
19+
let buffered_commit = StoredBufferedCommit::new(conversation.id().to_bytes(), commit.as_ref().to_owned());
2020

2121
self.crypto_provider()
2222
.await?
@@ -34,9 +34,9 @@ impl ConversationGuard {
3434
self.crypto_provider()
3535
.await?
3636
.keystore()
37-
.find::<MlsBufferedCommit>(conversation.id())
37+
.find::<StoredBufferedCommit>(conversation.id())
3838
.await
39-
.map(|option| option.map(MlsBufferedCommit::into_commit_data))
39+
.map(|option| option.map(StoredBufferedCommit::into_commit_data))
4040
.map_err(KeystoreError::wrap("attempting to retrieve buffered commit"))
4141
.map_err(Into::into)
4242
}
@@ -69,7 +69,7 @@ impl ConversationGuard {
6969
self.crypto_provider()
7070
.await?
7171
.keystore()
72-
.remove::<MlsBufferedCommit, _>(conversation.id())
72+
.remove::<StoredBufferedCommit, _>(conversation.id())
7373
.await
7474
.map_err(KeystoreError::wrap("attempting to clear buffered commit"))
7575
.map_err(Into::into)

crypto/src/mls/conversation/conversation_guard/encrypt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl ConversationGuard {
2020
/// from OpenMls and the KeyStore
2121
pub async fn encrypt_message(&mut self, message: impl AsRef<[u8]>) -> Result<Vec<u8>> {
2222
let backend = self.crypto_provider().await?;
23-
let credential = self.credential_bundle().await?;
23+
let credential = self.credential().await?;
2424
let signer = credential.signature_key();
2525
let mut inner = self.conversation_mut().await;
2626
let encrypted = inner

crypto/src/mls/conversation/conversation_guard/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use super::{ConversationWithMls, Error, MlsConversation, Result};
99
use crate::{
1010
KeystoreError, LeafError, MlsGroupInfoBundle, MlsTransport, RecursiveError,
1111
group_store::GroupStoreValue,
12-
mls::{conversation::ConversationIdRef, credential::CredentialBundle},
12+
mls::{conversation::ConversationIdRef, credential::Credential},
1313
transaction_context::TransactionContext,
1414
};
1515
mod commit;
@@ -121,11 +121,11 @@ impl ConversationGuard {
121121
}
122122
}
123123

124-
async fn credential_bundle(&self) -> Result<Arc<CredentialBundle>> {
124+
async fn credential(&self) -> Result<Arc<Credential>> {
125125
let client = self.session().await?;
126126
let inner = self.conversation().await;
127127
inner
128-
.find_current_credential_bundle(&client)
128+
.find_current_credential(&client)
129129
.await
130130
.map_err(|_| Error::IdentityInitializationError)
131131
}

crypto/src/mls/conversation/merge.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! | 1+ pend. Proposal | ❌ | ✅ |
1212
//!
1313
14-
use core_crypto_keystore::entities::MlsEncryptionKeyPair;
14+
use core_crypto_keystore::entities::StoredEncryptionKeyPair;
1515
use mls_crypto_provider::MlsCryptoProvider;
1616
use openmls_traits::OpenMlsCryptoProvider;
1717

@@ -35,7 +35,7 @@ impl MlsConversation {
3535
// ..so if there's any, we clear them after the commit is merged
3636
for oln in &previous_own_leaf_nodes {
3737
let ek = oln.encryption_key().as_slice();
38-
let _ = backend.key_store().remove::<MlsEncryptionKeyPair, _>(ek).await;
38+
let _ = backend.key_store().remove::<StoredEncryptionKeyPair, _>(ek).await;
3939
}
4040

4141
client

crypto/src/mls/conversation/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use log::trace;
2525
use mls_crypto_provider::{Database, MlsCryptoProvider};
2626
use openmls::{
2727
group::MlsGroup,
28-
prelude::{Credential, CredentialWithKey, LeafNodeIndex, Proposal, SignaturePublicKey},
28+
prelude::{Credential as MlsCredential, CredentialWithKey, LeafNodeIndex, Proposal, SignaturePublicKey},
2929
};
3030
use openmls_traits::{OpenMlsCryptoProvider, types::SignatureScheme};
3131

@@ -57,7 +57,7 @@ pub use conversation_guard::ConversationGuard;
5757
pub use error::{Error, Result};
5858
pub use immutable_conversation::ImmutableConversation;
5959

60-
use super::credential::CredentialBundle;
60+
use super::credential::Credential;
6161
use crate::{
6262
UserId,
6363
mls::{HasSessionAndCrypto, credential::ext::CredentialExt as _},
@@ -391,13 +391,13 @@ impl MlsConversation {
391391
) -> Result<Self> {
392392
let (cs, ct) = (configuration.ciphersuite, creator_credential_type);
393393
let cb = author_client
394-
.get_most_recent_or_create_credential_bundle(backend, cs.signature_algorithm(), ct)
394+
.get_most_recent_or_create_credential(backend, cs.signature_algorithm(), ct)
395395
.await
396-
.map_err(RecursiveError::mls_client("getting or creating credential bundle"))?;
396+
.map_err(RecursiveError::mls_client("getting or creating credential"))?;
397397

398398
let group = MlsGroup::new_with_group_id(
399399
backend,
400-
&cb.signature_key,
400+
&cb.signature_key_pair,
401401
&configuration.as_openmls_default_configuration()?,
402402
openmls::prelude::GroupId::from_slice(id.as_ref()),
403403
cb.to_mls_credential_with_key(),
@@ -469,7 +469,7 @@ impl MlsConversation {
469469
}
470470

471471
/// Returns all members credentials from the group/conversation
472-
pub fn members(&self) -> HashMap<Vec<u8>, Credential> {
472+
pub fn members(&self) -> HashMap<Vec<u8>, MlsCredential> {
473473
self.group.members().fold(HashMap::new(), |mut acc, kp| {
474474
let credential = kp.credential;
475475
let id = credential.identity().to_vec();
@@ -557,30 +557,30 @@ impl MlsConversation {
557557
self.ciphersuite().signature_algorithm()
558558
}
559559

560-
pub(crate) async fn find_current_credential_bundle(&self, client: &Session) -> Result<Arc<CredentialBundle>> {
560+
pub(crate) async fn find_current_credential(&self, client: &Session) -> Result<Arc<Credential>> {
561561
let own_leaf = self.group.own_leaf().ok_or(LeafError::InternalMlsError)?;
562562
let sc = self.ciphersuite().signature_algorithm();
563563
let ct = self
564564
.own_credential_type()
565565
.map_err(RecursiveError::mls_conversation("getting own credential type"))?;
566566

567567
client
568-
.find_credential_bundle_by_public_key(sc, ct, own_leaf.signature_key())
568+
.find_credential_by_public_key(sc, ct, own_leaf.signature_key())
569569
.await
570-
.map_err(RecursiveError::mls_client("finding current credential bundle"))
570+
.map_err(RecursiveError::mls_client("finding current credential"))
571571
.map_err(Into::into)
572572
}
573573

574-
pub(crate) async fn find_most_recent_credential_bundle(&self, client: &Session) -> Result<Arc<CredentialBundle>> {
574+
pub(crate) async fn find_most_recent_credential(&self, client: &Session) -> Result<Arc<Credential>> {
575575
let sc = self.ciphersuite().signature_algorithm();
576576
let ct = self
577577
.own_credential_type()
578578
.map_err(RecursiveError::mls_conversation("getting own credential type"))?;
579579

580580
client
581-
.find_most_recent_credential_bundle(sc, ct)
581+
.find_most_recent_credential(sc, ct)
582582
.await
583-
.map_err(RecursiveError::mls_client("finding most recent credential bundle"))
583+
.map_err(RecursiveError::mls_client("finding most recent credential"))
584584
.map_err(Into::into)
585585
}
586586
}

crypto/src/mls/conversation/proposal.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ impl MlsConversation {
2626
key_package: KeyPackageIn,
2727
) -> Result<MlsProposalBundle> {
2828
let signer = &self
29-
.find_current_credential_bundle(client)
29+
.find_current_credential(client)
3030
.await
3131
.map_err(|_| Error::IdentityInitializationError)?
32-
.signature_key;
32+
.signature_key_pair;
3333

3434
let crl_new_distribution_points = get_new_crl_distribution_points(
3535
backend,
@@ -62,10 +62,10 @@ impl MlsConversation {
6262
member: LeafNodeIndex,
6363
) -> Result<MlsProposalBundle> {
6464
let signer = &self
65-
.find_current_credential_bundle(client)
65+
.find_current_credential(client)
6666
.await
6767
.map_err(|_| Error::IdentityInitializationError)?
68-
.signature_key;
68+
.signature_key_pair;
6969
let proposal = self
7070
.group
7171
.propose_remove_member(backend, signer, member)
@@ -94,13 +94,13 @@ impl MlsConversation {
9494
leaf_node: Option<LeafNode>,
9595
) -> Result<MlsProposalBundle> {
9696
let msg_signer = &self
97-
.find_current_credential_bundle(client)
97+
.find_current_credential(client)
9898
.await
9999
.map_err(|_| Error::IdentityInitializationError)?
100-
.signature_key;
100+
.signature_key_pair;
101101

102102
let proposal = if let Some(leaf_node) = leaf_node {
103-
let leaf_node_signer = &self.find_most_recent_credential_bundle(client).await?.signature_key;
103+
let leaf_node_signer = &self.find_most_recent_credential(client).await?.signature_key_pair;
104104

105105
self.group
106106
.propose_explicit_self_update(backend, msg_signer, leaf_node, leaf_node_signer)

0 commit comments

Comments
 (0)