diff --git a/crypto-ffi/src/generic.rs b/crypto-ffi/src/generic.rs index d982986531..c386f22f68 100644 --- a/crypto-ffi/src/generic.rs +++ b/crypto-ffi/src/generic.rs @@ -1079,7 +1079,7 @@ impl CoreCrypto { conversation_id: Vec, keypackage: Vec, ) -> CoreCryptoResult { - let kp = KeyPackageIn::tls_deserialize_bytes(keypackage) + let kp = KeyPackageIn::tls_deserialize_exact(keypackage) .map_err(MlsError::from) .map_err(CryptoError::from)?; self.central @@ -1145,7 +1145,7 @@ impl CoreCrypto { custom_configuration: CustomConfiguration, credential_type: MlsCredentialType, ) -> CoreCryptoResult { - let group_info = VerifiableGroupInfo::tls_deserialize_bytes(group_info) + let group_info = VerifiableGroupInfo::tls_deserialize_exact(group_info) .map_err(MlsError::from) .map_err(CryptoError::from)?; self.central diff --git a/crypto-ffi/src/wasm.rs b/crypto-ffi/src/wasm.rs index f13f7dd8a4..32feb7a8a2 100644 --- a/crypto-ffi/src/wasm.rs +++ b/crypto-ffi/src/wasm.rs @@ -1792,7 +1792,7 @@ impl CoreCrypto { let this = self.inner.clone(); future_to_promise( async move { - let kp = KeyPackageIn::tls_deserialize_bytes(keypackage) + let kp = KeyPackageIn::tls_deserialize_exact(keypackage) .map_err(MlsError::from) .map_err(CryptoError::from) .map_err(CoreCryptoError::from)?; @@ -1902,7 +1902,7 @@ impl CoreCrypto { let this = self.inner.clone(); future_to_promise( async move { - let group_info = VerifiableGroupInfo::tls_deserialize_bytes(&group_info) + let group_info = VerifiableGroupInfo::tls_deserialize_exact(&group_info) .map_err(MlsError::from) .map_err(CryptoError::from) .map_err(CoreCryptoError::from)?; diff --git a/crypto/benches/utils/mls.rs b/crypto/benches/utils/mls.rs index d318a6acc8..6a792950f1 100644 --- a/crypto/benches/utils/mls.rs +++ b/crypto/benches/utils/mls.rs @@ -216,7 +216,7 @@ pub async fn add_clients( .unwrap(); let group_info = commit_bundle.group_info.payload.bytes(); - let group_info = openmls::prelude::MlsMessageIn::tls_deserialize_bytes(&group_info[..]).unwrap(); + let group_info = openmls::prelude::MlsMessageIn::tls_deserialize_exact(&group_info[..]).unwrap(); let MlsMessageInBody::GroupInfo(group_info) = group_info.extract() else { panic!("error") }; diff --git a/crypto/src/e2e_identity/rotate.rs b/crypto/src/e2e_identity/rotate.rs index 72e338788c..9d15ef06bc 100644 --- a/crypto/src/e2e_identity/rotate.rs +++ b/crypto/src/e2e_identity/rotate.rs @@ -539,7 +539,7 @@ pub mod tests { .into_iter() .map(|c| { let credential = - openmls::prelude::Credential::tls_deserialize_bytes(c.credential.as_slice()).unwrap(); + openmls::prelude::Credential::tls_deserialize_exact(c.credential.as_slice()).unwrap(); (credential, c.created_at) }) .collect::>(); diff --git a/crypto/src/mls/client/key_package.rs b/crypto/src/mls/client/key_package.rs index c8131d3bc9..a6ddd81e08 100644 --- a/crypto/src/mls/client/key_package.rs +++ b/crypto/src/mls/client/key_package.rs @@ -233,7 +233,7 @@ impl Client { if all_to_delete { // then delete this Credential MlsCredential::delete_by_credential(&mut conn, credential.clone()).await?; - let credential = Credential::tls_deserialize_bytes(credential).map_err(MlsError::from)?; + let credential = Credential::tls_deserialize_exact(credential).map_err(MlsError::from)?; self.identities.remove(&credential)?; } } diff --git a/crypto/src/mls/client/mod.rs b/crypto/src/mls/client/mod.rs index 6d5520006a..96f4966f08 100644 --- a/crypto/src/mls/client/mod.rs +++ b/crypto/src/mls/client/mod.rs @@ -83,8 +83,7 @@ impl Client { .into_iter() .filter(|c| &c.id[..] == id.as_slice()) .try_fold(vec![], |mut acc, c| { - use tls_codec::Deserialize as _; - let credential = Credential::tls_deserialize_bytes(c.credential.as_slice()).map_err(MlsError::from)?; + let credential = Credential::tls_deserialize_exact(c.credential.as_slice()).map_err(MlsError::from)?; acc.push((credential, c.created_at)); CryptoResult::Ok(acc) })?; @@ -216,7 +215,7 @@ impl Client { .await?; let signature_key = - SignatureKeyPair::tls_deserialize_bytes(&new_keypair.keypair).map_err(MlsError::from)?; + SignatureKeyPair::tls_deserialize_exact(&new_keypair.keypair).map_err(MlsError::from)?; let cb = CredentialBundle { credential: Credential::new_basic(new_credential.credential.clone()), signature_key, @@ -292,14 +291,14 @@ impl Client { let kp = store_skps.iter().find(|skp| skp.signature_scheme == (sc as u16)); let signature_key = if let Some(kp) = kp { - SignatureKeyPair::tls_deserialize_bytes(&kp.keypair).map_err(MlsError::from)? + SignatureKeyPair::tls_deserialize_exact(&kp.keypair).map_err(MlsError::from)? } else { let (sk, pk) = backend.crypto().signature_key_gen(sc).map_err(MlsError::from)?; let keypair = SignatureKeyPair::from_raw(sc, sk, pk.clone()); let raw_keypair = keypair.tls_serialize_detached().map_err(MlsError::from)?; let store_keypair = MlsSignatureKeyPair::new(sc, pk, raw_keypair, id.as_slice().into()); backend.key_store().save(store_keypair.clone()).await?; - SignatureKeyPair::tls_deserialize_bytes(&store_keypair.keypair).map_err(MlsError::from)? + SignatureKeyPair::tls_deserialize_exact(&store_keypair.keypair).map_err(MlsError::from)? }; for (credential, created_at) in &credentials { @@ -339,7 +338,7 @@ impl Client { .await?; let mut credentials = Vec::with_capacity(store_credentials.len()); for store_credential in store_credentials.into_iter() { - let credential = Credential::tls_deserialize_bytes(&store_credential.credential).map_err(MlsError::from)?; + let credential = Credential::tls_deserialize_exact(&store_credential.credential).map_err(MlsError::from)?; if !matches!(credential.credential_type(), CredentialType::Basic) { continue; } diff --git a/crypto/src/mls/conversation/buffer_messages.rs b/crypto/src/mls/conversation/buffer_messages.rs index 658a9351f5..5ed0c3202f 100644 --- a/crypto/src/mls/conversation/buffer_messages.rs +++ b/crypto/src/mls/conversation/buffer_messages.rs @@ -84,7 +84,7 @@ impl MlsConversation { .into_iter() .filter(|pm| pm.id == group_id) .try_fold(vec![], |mut acc, m| { - let msg = MlsMessageIn::tls_deserialize_bytes(m.message.as_slice()).map_err(MlsError::from)?; + let msg = MlsMessageIn::tls_deserialize_exact(m.message.as_slice()).map_err(MlsError::from)?; let ct = match msg.body_as_ref() { MlsMessageInBody::PublicMessage(m) => Ok(m.content_type()), MlsMessageInBody::PrivateMessage(m) => Ok(m.content_type()), diff --git a/crypto/src/mls/conversation/decrypt.rs b/crypto/src/mls/conversation/decrypt.rs index 39aed28cfc..8f752852c8 100644 --- a/crypto/src/mls/conversation/decrypt.rs +++ b/crypto/src/mls/conversation/decrypt.rs @@ -294,7 +294,7 @@ impl MlsCentral { id: &ConversationId, message: impl AsRef<[u8]>, ) -> CryptoResult { - let msg = MlsMessageIn::tls_deserialize_bytes(message.as_ref()).map_err(MlsError::from)?; + let msg = MlsMessageIn::tls_deserialize_exact(message.as_ref()).map_err(MlsError::from)?; let Ok(conversation) = self.get_conversation(id).await else { return self.handle_when_group_is_pending(id, message).await; }; diff --git a/crypto/src/mls/conversation/group_info.rs b/crypto/src/mls/conversation/group_info.rs index 068fdfac61..55335f0557 100644 --- a/crypto/src/mls/conversation/group_info.rs +++ b/crypto/src/mls/conversation/group_info.rs @@ -42,7 +42,7 @@ impl MlsGroupInfoBundle { use tls_codec::Deserialize as _; match &mut self.payload { GroupInfoPayload::Plaintext(gi) => { - openmls::prelude::MlsMessageIn::tls_deserialize_bytes(gi.as_slice()).unwrap() + openmls::prelude::MlsMessageIn::tls_deserialize_exact(gi.as_slice()).unwrap() } } } diff --git a/crypto/src/mls/member.rs b/crypto/src/mls/member.rs index 0e0ed90de2..486885ee8e 100644 --- a/crypto/src/mls/member.rs +++ b/crypto/src/mls/member.rs @@ -44,7 +44,7 @@ impl ConversationMember { /// # Errors /// Deserialization errors pub fn new_raw(client_id: ClientId, kp_ser: Vec, backend: &MlsCryptoProvider) -> CryptoResult { - let kp = KeyPackageIn::tls_deserialize_bytes(kp_ser).map_err(MlsError::from)?; + let kp = KeyPackageIn::tls_deserialize_exact(kp_ser).map_err(MlsError::from)?; let kp = kp .standalone_validate(backend.crypto(), openmls::versions::ProtocolVersion::Mls10) .map_err(MlsError::from)?; @@ -103,7 +103,7 @@ impl ConversationMember { /// # Errors /// Deserialization errors pub fn add_keypackage(&mut self, kp: Vec, backend: &MlsCryptoProvider) -> CryptoResult<()> { - let kp = KeyPackageIn::tls_deserialize_bytes(kp).map_err(MlsError::from)?; + let kp = KeyPackageIn::tls_deserialize_exact(kp).map_err(MlsError::from)?; let kp = kp .standalone_validate(backend.crypto(), openmls::versions::ProtocolVersion::Mls10) .map_err(MlsError::from)?; diff --git a/crypto/src/test_utils/central.rs b/crypto/src/test_utils/central.rs index 4e04d5d596..f71e1956c7 100644 --- a/crypto/src/test_utils/central.rs +++ b/crypto/src/test_utils/central.rs @@ -511,7 +511,7 @@ impl MlsCentral { // the keystore let credential = self.find_credential_from_keystore(&cb).await.unwrap(); - let credential = Credential::tls_deserialize_bytes(credential.credential.as_slice()).unwrap(); + let credential = Credential::tls_deserialize_exact(credential.credential.as_slice()).unwrap(); assert_eq!(credential.identity(), &cid.0); let keystore_identity = credential.extract_identity().unwrap().unwrap(); assert_eq!(keystore_identity.display_name, new_display_name); diff --git a/interop/src/clients/corecrypto/web.rs b/interop/src/clients/corecrypto/web.rs index 27c8d598d3..32e60321ee 100644 --- a/interop/src/clients/corecrypto/web.rs +++ b/interop/src/clients/corecrypto/web.rs @@ -149,7 +149,7 @@ window.cc.clientKeypackages(ciphersuite, window.credentialType, 1).then(([kp]) = .await .and_then(|value| Ok(serde_json::from_value(value)?))?; - let kp: KeyPackage = KeyPackageIn::tls_deserialize_bytes(&kp_raw)?.into(); + let kp: KeyPackage = KeyPackageIn::tls_deserialize_exact(&kp_raw)?.into(); log::info!( "KP Init Key [took {}ms]: Client {} [{}] - {}", diff --git a/keystore-dump/src/main.rs b/keystore-dump/src/main.rs index f8dd76b8bc..3d167684a4 100644 --- a/keystore-dump/src/main.rs +++ b/keystore-dump/src/main.rs @@ -45,7 +45,7 @@ async fn main() -> Result<()> { .await? .into_iter() { - let mls_credential = openmls::prelude::Credential::tls_deserialize_bytes(&cred.credential)?; + let mls_credential = openmls::prelude::Credential::tls_deserialize_exact(&cred.credential)?; let date = chrono::Utc .timestamp_opt(cred.created_at as i64, 0) .single() @@ -65,7 +65,7 @@ async fn main() -> Result<()> { .await? .into_iter() { - let mls_keypair = openmls_basic_credential::SignatureKeyPair::tls_deserialize_bytes(&kp.keypair)?; + let mls_keypair = openmls_basic_credential::SignatureKeyPair::tls_deserialize_exact(&kp.keypair)?; signature_keypairs.push(serde_json::json!({ "signature_scheme": kp.signature_scheme, "mls_keypair": mls_keypair, diff --git a/keystore/tests/mls.rs b/keystore/tests/mls.rs index 228a81f0de..ad6f903632 100644 --- a/keystore/tests/mls.rs +++ b/keystore/tests/mls.rs @@ -121,7 +121,7 @@ pub mod tests { assert_eq!(keypair2.credential_id, credential2.id); - let keypair2 = SignatureKeyPair::tls_deserialize_bytes(&keypair2.keypair).unwrap(); + let keypair2 = SignatureKeyPair::tls_deserialize_exact(&keypair2.keypair).unwrap(); let (b1_kp, b1_sk) = (keypair.to_public_vec(), keypair.private().to_vec()); let (b2_kp, b2_sk) = (keypair2.to_public_vec(), keypair.private().to_vec());