Skip to content

Commit

Permalink
feat: change ClientId & Handle format to URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
beltram committed Jan 10, 2024
1 parent 73a4bdd commit 78947f1
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 36 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ branch = "wire/unstable-pq-xyber"
[patch.crates-io.wire-e2e-identity]
git = "https://github.com/wireapp/rusty-jwt-tools"
package = "wire-e2e-identity"
tag = "v0.6.1"
tag = "v0.8.0"

# aarch64-apple-ios-sim target support has not yet been released
[patch.crates-io.openssl-src]
Expand All @@ -86,7 +86,7 @@ package = "openssl-src"

[patch.crates-io.jwt-simple]
git = "https://github.com/wireapp/rust-jwt-simple"
tag = "v0.11.4-pre.core-crypto-0.7.0"
tag = "v0.12.1-pre.core-crypto-1.0.0"

[profile.release]
lto = true
Expand Down
8 changes: 4 additions & 4 deletions crypto-ffi/bindings/js/test/CoreCrypto.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ test("end-to-end-identity", async () => {
"identifiers": [
{
"type": "wireapp-id",
"value": "{\"name\":\"Alice Smith\",\"domain\":\"wire.com\",\"client-id\":\"im:wireapp=t6wRpI8BRSeviBwwiFp5MQ/[email protected]\",\"handle\":\"im:wireapp=alice_wire\"}",
"value": "{\"name\":\"Alice Smith\",\"domain\":\"wire.com\",\"client-id\":\"wireapp://t6wRpI8BRSeviBwwiFp5MQ![email protected]\",\"handle\":\"wireapp://%[email protected]\"}",
},
],
"authorizations": [
Expand All @@ -989,7 +989,7 @@ test("end-to-end-identity", async () => {
"expires": "2016-01-02T14:09:30Z",
"identifier": {
"type": "wireapp-id",
"value": "{\"name\":\"Alice Smith\",\"domain\":\"wire.com\",\"client-id\":\"im:wireapp=t6wRpI8BRSeviBwwiFp5MQ/[email protected]\",\"handle\":\"im:wireapp=alice_wire\"}",
"value": "{\"name\":\"Alice Smith\",\"domain\":\"wire.com\",\"client-id\":\"wireapp://t6wRpI8BRSeviBwwiFp5MQ![email protected]\",\"handle\":\"wireapp://%[email protected]\"}",
},
"challenges": [
{
Expand Down Expand Up @@ -1050,7 +1050,7 @@ test("end-to-end-identity", async () => {
"identifiers": [
{
"type": "wireapp-id",
"value": "{\"name\":\"Alice Smith\",\"domain\":\"wire.com\",\"client-id\":\"im:wireapp=t6wRpI8BRSeviBwwiFp5MQ/[email protected]\",\"handle\":\"im:wireapp=alice_wire\"}",
"value": "{\"name\":\"Alice Smith\",\"domain\":\"wire.com\",\"client-id\":\"wireapp://t6wRpI8BRSeviBwwiFp5MQ![email protected]\",\"handle\":\"wireapp://%[email protected]\"}",
},
],
"authorizations": [
Expand All @@ -1070,7 +1070,7 @@ test("end-to-end-identity", async () => {
"identifiers": [
{
"type": "wireapp-id",
"value": "{\"name\":\"Alice Smith\",\"domain\":\"wire.com\",\"client-id\":\"im:wireapp=t6wRpI8BRSeviBwwiFp5MQ/[email protected]\",\"handle\":\"im:wireapp=alice_wire\"}",
"value": "{\"name\":\"Alice Smith\",\"domain\":\"wire.com\",\"client-id\":\"wireapp://t6wRpI8BRSeviBwwiFp5MQ![email protected]\",\"handle\":\"wireapp://%[email protected]\"}",
},
],
"authorizations": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal class E2EITest {
"identifiers": [
{
"type": "wireapp-id",
"value": "{\"name\":\"Alice Smith\",\"domain\":\"wire.com\",\"client-id\":\"im:wireapp=t6wRpI8BRSeviBwwiFp5MQ/[email protected]\",\"handle\":\"im:wireapp=alice_wire\"}"
"value": "{\"name\":\"Alice Smith\",\"domain\":\"wire.com\",\"client-id\":\"wireapp://t6wRpI8BRSeviBwwiFp5MQ![email protected]\",\"handle\":\"wireapp://%[email protected]\"}"
}
],
"authorizations": [
Expand All @@ -85,7 +85,7 @@ internal class E2EITest {
"expires": "2016-01-02T14:09:30Z",
"identifier": {
"type": "wireapp-id",
"value": "{\"name\":\"Alice Smith\",\"domain\":\"wire.com\",\"client-id\":\"im:wireapp=t6wRpI8BRSeviBwwiFp5MQ/[email protected]\",\"handle\":\"im:wireapp=alice_wire\"}"
"value": "{\"name\":\"Alice Smith\",\"domain\":\"wire.com\",\"client-id\":\"wireapp://t6wRpI8BRSeviBwwiFp5MQ![email protected]\",\"handle\":\"wireapp://%[email protected]\"}"
},
"challenges": [
{
Expand Down Expand Up @@ -126,7 +126,7 @@ internal class E2EITest {
"identifiers": [
{
"type": "wireapp-id",
"value": "{\"name\":\"Alice Smith\",\"domain\":\"wire.com\",\"client-id\":\"im:wireapp=t6wRpI8BRSeviBwwiFp5MQ/[email protected]\",\"handle\":\"im:wireapp=alice_wire\"}"
"value": "{\"name\":\"Alice Smith\",\"domain\":\"wire.com\",\"client-id\":\"wireapp://t6wRpI8BRSeviBwwiFp5MQ![email protected]\",\"handle\":\"wireapp://%[email protected]\"}"
}
],
"authorizations": [
Expand All @@ -146,7 +146,7 @@ internal class E2EITest {
"identifiers": [
{
"type": "wireapp-id",
"value": "{\"name\":\"Alice Smith\",\"domain\":\"wire.com\",\"client-id\":\"im:wireapp=t6wRpI8BRSeviBwwiFp5MQ/[email protected]\",\"handle\":\"im:wireapp=alice_wire\"}"
"value": "{\"name\":\"Alice Smith\",\"domain\":\"wire.com\",\"client-id\":\"wireapp://t6wRpI8BRSeviBwwiFp5MQ![email protected]\",\"handle\":\"wireapp://%[email protected]\"}"
}
],
"authorizations": [
Expand Down
4 changes: 2 additions & 2 deletions crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async-trait = "0.1"
async-lock = "3.0"
schnellru = "0.2"
zeroize = "1.5"
wire-e2e-identity = { version = "=0.6.1", default-features = false }
wire-e2e-identity = { version = "=0.8.0", default-features = false }
indexmap = "2"
x509-cert = "0.2"
pem = "3.0"
Expand Down Expand Up @@ -101,7 +101,7 @@ async-std = { version = "1.12", features = ["attributes"] }
futures-util = { version = "0.3", features = ["std", "alloc"] }
proteus-traits = "2.0"
async-trait = "0.1"
wire-e2e-identity = { version = "=0.6.1", features = ["identity-builder"] }
wire-e2e-identity = { version = "=0.8.0", features = ["identity-builder"] }
fluvio-wasm-timer = "0.2"
time = { version = "0.3", features = ["wasm-bindgen"] }

Expand Down
6 changes: 3 additions & 3 deletions crypto/src/e2e_identity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ pub mod tests {
pub const E2EI_DISPLAY_NAME: &str = "Alice Smith";
pub const E2EI_HANDLE: &str = "alice_wire";
pub const E2EI_CLIENT_ID: &str = "bd4c7053-1c5a-4020-9559-cd7bf7961954:[email protected]";
pub const E2EI_CLIENT_ID_URI: &str = "vUxwUxxaQCCVWc1795YZVA/[email protected]";
pub const E2EI_CLIENT_ID_URI: &str = "vUxwUxxaQCCVWc1795YZVA![email protected]";
pub const E2EI_EXPIRY: u32 = 90;

#[apply(all_cred_cipher)]
Expand Down Expand Up @@ -653,9 +653,9 @@ pub mod tests {
let _order_req = enrollment.new_order_request(previous_nonce.to_string()).unwrap();

let client_id = client_id
.map(|c| format!("{}{c}", wire_e2e_identity::prelude::E2eiClientId::URI_PREFIX))
.map(|c| format!("{}{c}", wire_e2e_identity::prelude::E2eiClientId::URI_SCHEME))
.unwrap_or_else(|| cc.get_e2ei_client_id().to_uri());
let identifier_value = format!("{{\"name\":\"{display_name}\",\"domain\":\"wire.com\",\"client-id\":\"{client_id}\",\"handle\":\"im:wireapp=%40{handle}@wire.com\"}}");
let identifier_value = format!("{{\"name\":\"{display_name}\",\"domain\":\"wire.com\",\"client-id\":\"{client_id}\",\"handle\":\"wireapp://%40{handle}@wire.com\"}}");
let order_resp = json!({
"status": "pending",
"expires": "2037-01-05T14:09:07.99Z",
Expand Down
6 changes: 3 additions & 3 deletions crypto/src/e2e_identity/rotate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ pub mod tests {
assert_eq!(c.credential_type(), openmls::prelude::CredentialType::X509);
let identity = c.extract_identity().unwrap().unwrap();
assert_eq!(identity.display_name, NEW_DISPLAY_NAME);
assert_eq!(identity.handle, format!("im:wireapp=%40{NEW_HANDLE}@wire.com"));
assert_eq!(identity.handle, format!("wireapp://%40{NEW_HANDLE}@wire.com"));
}

// Alice has to delete her old KeyPackages
Expand Down Expand Up @@ -552,7 +552,7 @@ pub mod tests {
.unwrap();
let identity = cb.credential().extract_identity().unwrap().unwrap();
assert_eq!(identity.display_name, NEW_DISPLAY_NAME);
assert_eq!(identity.handle, format!("im:wireapp=%40{NEW_HANDLE}@wire.com"));
assert_eq!(identity.handle, format!("wireapp://%40{NEW_HANDLE}@wire.com"));

// but keeps her old one since it's referenced from some KeyPackages
let old_spk = SignaturePublicKey::from(old_cb.signature_key.public());
Expand Down Expand Up @@ -593,7 +593,7 @@ pub mod tests {
.unwrap();
let identity = cb.credential().extract_identity().unwrap().unwrap();
assert_eq!(identity.display_name, NEW_DISPLAY_NAME);
assert_eq!(identity.handle, format!("im:wireapp=%40{NEW_HANDLE}@wire.com"));
assert_eq!(identity.handle, format!("wireapp://%40{NEW_HANDLE}@wire.com"));

assert_eq!(
alice_central.mls_client().unwrap().identities.iter().count(),
Expand Down
2 changes: 1 addition & 1 deletion crypto/src/mls/client/user_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{CryptoError, CryptoResult};
/// End-to-end Identity re-shuffled that... But we still want to keep this isolated from the rest
/// of the crate that's why this should remain here and be used cautiously, having the context quoted
/// above in mind.
/// For example in `im:wireapp=LcksJb74Tm6N12cDjFy7lQ/[email protected]` the [UserId] is `LcksJb74Tm6N12cDjFy7lQ`
/// For example in `wireapp://LcksJb74Tm6N12cDjFy7lQ![email protected]` the [UserId] is `LcksJb74Tm6N12cDjFy7lQ`
#[derive(Debug, Clone, Copy, Eq, PartialEq, derive_more::Deref)]
pub struct UserId<'a>(&'a [u8]);

Expand Down
35 changes: 18 additions & 17 deletions crypto/src/test_utils/central.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,32 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.

use crate::{
mls::credential::{ext::CredentialExt, CredentialBundle},
prelude::{
CertificateBundle, Client, ClientId, ConversationId, CryptoError, CryptoResult, MlsCentral, MlsCiphersuite,
MlsConversation, MlsConversationConfiguration, MlsConversationDecryptMessage, MlsConversationInitBundle,
MlsCredentialType, MlsCustomConfiguration, MlsError,
},
test_utils::{MessageExt, TestCase},
};
use openmls::prelude::{
group_info::VerifiableGroupInfo, Capabilities, Credential, CredentialWithKey, CryptoConfig, HpkePublicKey,
KeyPackage, KeyPackageIn, LeafNodeIndex, Lifetime, MlsMessageIn, QueuedProposal, SignaturePublicKey, StagedCommit,
group_info::VerifiableGroupInfo, Credential, CredentialWithKey, CryptoConfig, HpkePublicKey, KeyPackage,
KeyPackageIn, LeafNodeIndex, Lifetime, MlsMessageIn, QueuedProposal, SignaturePublicKey, StagedCommit,
};
use openmls_traits::{types::SignatureScheme, OpenMlsCryptoProvider};
use tls_codec::{Deserialize, Serialize};
use wire_e2e_identity::prelude::WireIdentityReader;
use x509_cert::der::Encode;

use crate::e2e_identity::device_status::DeviceStatus;
use crate::e2e_identity::id::{QualifiedE2eiClientId, WireQualifiedClientId};
use crate::prelude::WireIdentity;
use core_crypto_keystore::entities::{
EntityFindParams, MlsCredential, MlsEncryptionKeyPair, MlsHpkePrivateKey, MlsKeyPackage, MlsSignatureKeyPair,
};
use mls_crypto_provider::MlsCryptoProvider;
use wire_e2e_identity::prelude::WireIdentityReader;
use x509_cert::der::Encode;

use crate::e2e_identity::device_status::DeviceStatus;
use crate::e2e_identity::id::{QualifiedE2eiClientId, WireQualifiedClientId};
use crate::prelude::WireIdentity;
use crate::{
mls::credential::{ext::CredentialExt, CredentialBundle},
prelude::{
CertificateBundle, Client, ClientId, ConversationId, CryptoError, CryptoResult, MlsCentral, MlsCiphersuite,
MlsConversation, MlsConversationConfiguration, MlsConversationDecryptMessage, MlsConversationInitBundle,
MlsCredentialType, MlsCustomConfiguration, MlsError,
},
test_utils::{MessageExt, TestCase},
};

#[allow(clippy::redundant_static_lifetimes)]
pub const TEAM: &'static str = "wire";
Expand Down Expand Up @@ -459,7 +460,7 @@ impl MlsCentral {
new_handle: &str,
new_display_name: &str,
) {
let new_handle = format!("im:wireapp=%40{new_handle}@wire.com");
let new_handle = format!("wireapp://%40{new_handle}@wire.com");
// verify the identity in..
// the MLS group
let cid = self.get_client_id();
Expand Down

0 comments on commit 78947f1

Please sign in to comment.