Skip to content

Commit 4d443db

Browse files
committed
chore: update crypto-ffi for 2024 edition
1 parent f923f6e commit 4d443db

File tree

9 files changed

+46
-37
lines changed

9 files changed

+46
-37
lines changed

crypto-ffi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "core-crypto-ffi"
33
description = "Platform-specific bindings (Android, iOS, WASM) for CoreCrypto"
44
repository = "https://github.com/wireapp/core-crypto"
55
version = "4.1.0"
6-
edition = "2021"
6+
edition = "2024"
77
license = "GPL-3.0-only"
88
publish = false
99

crypto-ffi/src/generic/context/e2ei.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use std::{collections::HashMap, ops::DerefMut};
22

33
use crate::{
4+
CoreCryptoError, NewCrlDistributionPoints,
45
generic::{
5-
context::CoreCryptoContext, Ciphersuite, ClientId, CoreCryptoResult, CrlRegistration, E2eiConversationState,
6-
E2eiDumpedPkiEnv, E2eiEnrollment, MlsCredentialType, WireIdentity,
6+
Ciphersuite, ClientId, CoreCryptoResult, CrlRegistration, E2eiConversationState, E2eiDumpedPkiEnv,
7+
E2eiEnrollment, MlsCredentialType, WireIdentity, context::CoreCryptoContext,
78
},
8-
CoreCryptoError, NewCrlDistributionPoints,
99
};
10-
use core_crypto::{prelude::VerifiableGroupInfo, RecursiveError};
10+
use core_crypto::{RecursiveError, prelude::VerifiableGroupInfo};
1111
use tls_codec::Deserialize;
1212

1313
#[uniffi::export]

crypto-ffi/src/generic/context/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ use super::{
55
use crate::NewCrlDistributionPoints;
66
use async_lock::{Mutex, OnceCell};
77
use core_crypto::{
8+
RecursiveError,
89
context::CentralContext,
910
prelude::{
1011
ClientIdentifier, ConversationId, KeyPackageIn, KeyPackageRef, MlsConversationConfiguration,
1112
VerifiableGroupInfo,
1213
},
13-
RecursiveError,
1414
};
1515
use std::{future::Future, ops::Deref, sync::Arc};
1616
use tls_codec::{Deserialize, Serialize};

crypto-ffi/src/generic/context/proteus.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
use crate::ProteusAutoPrekeyBundle;
12
use crate::context::CoreCryptoContext;
23
use crate::generic::CoreCryptoResult;
34
use crate::proteus_impl;
4-
use crate::ProteusAutoPrekeyBundle;
55

66
#[uniffi::export]
77
impl CoreCryptoContext {

crypto-ffi/src/generic/mod.rs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ use std::{
2121
};
2222

2323
use log::{
24-
kv::{self, Key, Value, VisitSource},
2524
Level, LevelFilter, Metadata, Record,
25+
kv::{self, Key, Value, VisitSource},
2626
};
2727
use log_reload::ReloadLog;
2828
use tls_codec::Deserialize;
2929

3030
use self::context::CoreCryptoContext;
31-
use crate::{proteus_impl, UniffiCustomTypeConverter};
31+
use crate::{UniffiCustomTypeConverter, proteus_impl};
3232
pub use core_crypto::prelude::ConversationId;
3333
use core_crypto::{
34+
InnermostErrorMessage, RecursiveError,
3435
prelude::{
3536
EntropySeed, MlsBufferedConversationDecryptMessage, MlsCentral, MlsCentralConfiguration, MlsCiphersuite,
3637
MlsCommitBundle, MlsConversationDecryptMessage, MlsCustomConfiguration, MlsGroupInfoBundle, MlsProposalBundle,
3738
VerifiableGroupInfo,
3839
},
39-
InnermostErrorMessage, RecursiveError,
4040
};
4141

4242
pub mod context;
@@ -97,7 +97,9 @@ pub enum MlsError {
9797
BufferedFutureMessage,
9898
#[error("Incoming message is from an epoch too far in the future to buffer.")]
9999
WrongEpoch,
100-
#[error("Incoming message is a commit for which we have not yet received all the proposals. Buffering until all proposals have arrived.")]
100+
#[error(
101+
"Incoming message is a commit for which we have not yet received all the proposals. Buffering until all proposals have arrived."
102+
)]
101103
BufferedCommit,
102104
#[error("The epoch in which message was encrypted is older than allowed")]
103105
MessageEpochTooOld,
@@ -115,7 +117,9 @@ pub enum MlsError {
115117
/// requests their old KeyPackages to be deleted but one has already been claimed by another client to create a Welcome.
116118
/// In that case the only solution is that the client receiving such a Welcome tries to join the group
117119
/// with an External Commit instead
118-
#[error("Although this Welcome seems valid, the local KeyPackage it references has already been deleted locally. Join this group with an external commit")]
120+
#[error(
121+
"Although this Welcome seems valid, the local KeyPackage it references has already been deleted locally. Join this group with an external commit"
122+
)]
119123
OrphanWelcome,
120124
/// Message rejected by the delivery service
121125
#[error("Message rejected by the delivery service. Reason: {reason}")]
@@ -258,7 +262,7 @@ impl From<RecursiveError> for CoreCryptoError {
258262
/// Hopefully only ever use this in conjunction with `interior_matches!`, because for most sane
259263
/// circumstances, `if let` is the better design pattern.
260264
macro_rules! matches_option {
261-
($val:expr, $pattern:pat $(if $guard:expr)? => $out:expr) => {
265+
($val:expr_2021, $pattern:pat $(if $guard:expr_2021)? => $out:expr_2021) => {
262266
match ($val) {
263267
$pattern $(if $guard)? => Some($out),
264268
_ => None,
@@ -270,9 +274,9 @@ impl From<RecursiveError> for CoreCryptoError {
270274
/// it solves a real problem here: how do we match against the innermost error variants,
271275
/// when we have a heterogenous set of types to match against?
272276
macro_rules! match_heterogenous {
273-
($err:expr => {
274-
$( $pattern:pat $(if $guard:expr)? => $var:expr, )*
275-
||=> $default:expr,
277+
($err:expr_2021 => {
278+
$( $pattern:pat $(if $guard:expr_2021)? => $var:expr_2021, )*
279+
||=> $default:expr_2021,
276280
}) => {{
277281
if false {unreachable!()}
278282
$(
@@ -695,14 +699,15 @@ impl TryFrom<MlsConversationDecryptMessage> for DecryptedMessage {
695699
.map(ProposalBundle::try_from)
696700
.collect::<CoreCryptoResult<Vec<_>>>()?;
697701

698-
let buffered_messages = if let Some(bm) = from.buffered_messages {
699-
let bm = bm
700-
.into_iter()
701-
.map(TryInto::try_into)
702-
.collect::<CoreCryptoResult<Vec<_>>>()?;
703-
Some(bm)
704-
} else {
705-
None
702+
let buffered_messages = match from.buffered_messages {
703+
Some(bm) => {
704+
let bm = bm
705+
.into_iter()
706+
.map(TryInto::try_into)
707+
.collect::<CoreCryptoResult<Vec<_>>>()?;
708+
Some(bm)
709+
}
710+
_ => None,
706711
};
707712

708713
Ok(Self {

crypto-ffi/src/wasm/context/e2ei.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ use std::{
44
};
55

66
use core_crypto::{
7-
prelude::{CiphersuiteName, ClientId, ConversationId, MlsCiphersuite, VerifiableGroupInfo},
87
RecursiveError,
8+
prelude::{CiphersuiteName, ClientId, ConversationId, MlsCiphersuite, VerifiableGroupInfo},
99
};
1010
use futures_util::TryFutureExt;
1111
use js_sys::{Promise, Uint8Array};
1212
use tls_codec::Deserialize;
13-
use wasm_bindgen::{prelude::wasm_bindgen, JsValue};
13+
use wasm_bindgen::{JsValue, prelude::wasm_bindgen};
1414
use wasm_bindgen_futures::future_to_promise;
1515

1616
use crate::{
17-
wasm::{context::CoreCryptoContext, E2eiConversationState},
1817
Ciphersuite, CoreCryptoError, CredentialType, CrlRegistration, E2eiDumpedPkiEnv, E2eiEnrollment, InternalError,
1918
WasmCryptoResult, WireIdentity,
19+
wasm::{E2eiConversationState, context::CoreCryptoContext},
2020
};
2121

2222
#[wasm_bindgen]

crypto-ffi/src/wasm/context/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
use crate::wasm::{lower_ciphersuites, InternalError};
1+
use crate::wasm::{InternalError, lower_ciphersuites};
22
use crate::{
33
Ciphersuite, ConversationConfiguration, CoreCrypto, CoreCryptoError, CoreCryptoResult, CredentialType,
44
CustomConfiguration, DecryptedMessage, FfiClientId, WasmCryptoResult, WelcomeBundle,
55
};
66
use core_crypto::{
7+
RecursiveError,
78
context::CentralContext,
89
prelude::{
910
CiphersuiteName, ClientId, ClientIdentifier, ConversationId, KeyPackageIn, KeyPackageRef,
1011
MlsConversationConfiguration, VerifiableGroupInfo,
1112
},
12-
RecursiveError,
1313
};
1414
use futures_util::TryFutureExt;
1515
use js_sys::{Promise, Uint8Array};
1616
use std::sync::Arc;
1717
use tls_codec::{Deserialize, Serialize};
18-
use wasm_bindgen::{prelude::wasm_bindgen, JsValue};
18+
use wasm_bindgen::{JsValue, prelude::wasm_bindgen};
1919
use wasm_bindgen_futures::future_to_promise;
2020

2121
pub mod e2ei;

crypto-ffi/src/wasm/context/proteus.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use crate::proteus_impl;
2-
use crate::wasm::context::CoreCryptoContext;
32
use crate::wasm::CoreCryptoError;
3+
use crate::wasm::context::CoreCryptoContext;
44
use crate::{ProteusAutoPrekeyBundle, WasmCryptoResult};
55
use futures_util::TryFutureExt;
66
use js_sys::{Promise, Uint8Array};
7-
use wasm_bindgen::prelude::wasm_bindgen;
87
use wasm_bindgen::JsValue;
8+
use wasm_bindgen::prelude::wasm_bindgen;
99
use wasm_bindgen_futures::future_to_promise;
1010

1111
#[wasm_bindgen]

crypto-ffi/src/wasm/mod.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ use std::{
2424
};
2525

2626
use crate::proteus_impl;
27-
use core_crypto::{prelude::*, InnermostErrorMessage, MlsTransportResponse};
27+
use core_crypto::{InnermostErrorMessage, MlsTransportResponse, prelude::*};
2828
use futures_util::future::TryFutureExt;
2929
use js_sys::{Promise, Uint8Array};
3030
use log::{
31-
kv::{self, Key, Value, VisitSource},
3231
Level, LevelFilter, Metadata, Record,
32+
kv::{self, Key, Value, VisitSource},
3333
};
3434
use log_reload::ReloadLog;
3535
use tls_codec::Deserialize;
3636
use utils::*;
37-
use wasm_bindgen::{prelude::*, JsCast};
37+
use wasm_bindgen::{JsCast, prelude::*};
3838
use wasm_bindgen_futures::future_to_promise;
3939

4040
#[allow(dead_code)]
@@ -90,7 +90,9 @@ pub enum MlsError {
9090
BufferedFutureMessage,
9191
#[error("Incoming message is from an epoch too far in the future to buffer.")]
9292
WrongEpoch,
93-
#[error("Incoming message is a commit for which we have not yet received all the proposals. Buffering until all proposals have arrived.")]
93+
#[error(
94+
"Incoming message is a commit for which we have not yet received all the proposals. Buffering until all proposals have arrived."
95+
)]
9496
BufferedCommit,
9597
#[error("The epoch in which message was encrypted is older than allowed")]
9698
MessageEpochTooOld,
@@ -108,7 +110,9 @@ pub enum MlsError {
108110
/// requests their old KeyPackages to be deleted but one has already been claimed by another client to create a Welcome.
109111
/// In that case the only solution is that the client receiving such a Welcome tries to join the group
110112
/// with an External Commit instead
111-
#[error("Although this Welcome seems valid, the local KeyPackage it references has already been deleted locally. Join this group with an external commit")]
113+
#[error(
114+
"Although this Welcome seems valid, the local KeyPackage it references has already been deleted locally. Join this group with an external commit"
115+
)]
112116
OrphanWelcome,
113117
/// Message rejected by the delivery service
114118
#[error("Message rejected by the delivery service. Reason: {reason}")]

0 commit comments

Comments
 (0)