diff --git a/openmls/src/extensions/test_extensions.rs b/openmls/src/extensions/test_extensions.rs index 81782204f..3d1c38a6f 100644 --- a/openmls/src/extensions/test_extensions.rs +++ b/openmls/src/extensions/test_extensions.rs @@ -6,7 +6,6 @@ use tls_codec::{Deserialize, Serialize}; use super::*; use crate::{ - ciphersuite::HpkePrivateKey, credentials::*, framing::*, group::{errors::*, *}, @@ -17,7 +16,6 @@ use crate::{ schedule::psk::store::ResumptionPskStore, storage::OpenMlsProvider, test_utils::*, - treesync::node::encryption_keys::EncryptionKeyPair, versions::ProtocolVersion, }; @@ -501,7 +499,7 @@ fn last_resort_extension(ciphersuite: Ciphersuite, provider: &impl OpenMlsProvid .expect("An unexpected error occurred."); use openmls_traits::storage::StorageProvider; - let kp: KeyPackageBundle = provider + let _: KeyPackageBundle = provider .storage() .key_package( &kp.key_package() @@ -510,14 +508,4 @@ fn last_resort_extension(ciphersuite: Ciphersuite, provider: &impl OpenMlsProvid ) .expect("error retrieving key package") .expect("key package does not exist"); - let kp = kp.unwrap(); - - let leaf_keypair = - EncryptionKeyPair::read_from_key_store(provider, kp.leaf_node().encryption_key()); - assert!(leaf_keypair.is_some()); - - let private_key = provider - .key_store() - .read::(kp.hpke_init_key().as_slice()); - assert!(private_key.is_some()); } diff --git a/openmls/src/group/core_group/test_proposals.rs b/openmls/src/group/core_group/test_proposals.rs index 7b4a344f6..c30a4d250 100644 --- a/openmls/src/group/core_group/test_proposals.rs +++ b/openmls/src/group/core_group/test_proposals.rs @@ -1,4 +1,3 @@ -use openmls_rust_crypto::OpenMlsRustCrypto; use openmls_traits::types::Ciphersuite; use super::CoreGroup; @@ -517,7 +516,7 @@ fn test_group_context_extension_proposal_fails( #[apply(ciphersuites_and_providers)] fn test_group_context_extension_proposal( ciphersuite: Ciphersuite, - provider: &impl crate::storage::OpenMlsProvider, + provider: &Provider, ) { // Basic group setup. let group_aad = b"Alice's test group"; diff --git a/openmls/src/group/mls_group/test_mls_group.rs b/openmls/src/group/mls_group/test_mls_group.rs index 66e9286f0..c96011971 100644 --- a/openmls/src/group/mls_group/test_mls_group.rs +++ b/openmls/src/group/mls_group/test_mls_group.rs @@ -1210,7 +1210,7 @@ fn immutable_metadata(ciphersuite: Ciphersuite, provider: &impl OpenMlsProvider) .commit_to_pending_proposals(provider, &alice_signer) .expect_err("should not have been able to commit to proposal that changes metadata"); - group_with_metadata.clear_pending_proposals(); + group_with_metadata.clear_pending_proposals(provider.storage()).unwrap(); assert_eq!(group_with_metadata.pending_proposals().count(), 0); @@ -1790,169 +1790,6 @@ fn unknown_extensions(ciphersuite: Ciphersuite, provider: &impl crate::storage:: .expect("Error creating group from staged join"); } -// Test the successful update of Group Context Extension with type Extension::Unknown(0xff11) -#[apply(ciphersuites_and_providers)] -fn update_group_context_with_unknown_extension( - ciphersuite: Ciphersuite, - provider: &impl OpenMlsProvider, -) { - let (alice_credential_with_key, _alice_kpb, alice_signer, _alice_pk) = - setup_client("Alice", ciphersuite, provider); - - // === Define the unknown group context extension and initial data === - let unknown_extension_data = vec![1, 2]; - let unknown_gc_extension = Extension::Unknown(0xff11, UnknownExtension(unknown_extension_data)); - let required_extension_types = &[ExtensionType::Unknown(0xff11)]; - let required_capabilities = Extension::RequiredCapabilities( - RequiredCapabilitiesExtension::new(required_extension_types, &[], &[]), - ); - let capabilities = Capabilities::new(None, None, Some(required_extension_types), None, None); - let test_gc_extensions = Extensions::from_vec(vec![ - unknown_gc_extension.clone(), - required_capabilities.clone(), - ]) - .expect("error creating test group context extensions"); - let mls_group_create_config = MlsGroupCreateConfig::builder() - .with_group_context_extensions(test_gc_extensions.clone()) - .expect("error adding unknown extension to config") - .capabilities(capabilities.clone()) - .crypto_config(CryptoConfig::with_default_version(ciphersuite)) - .build(); - - // === Alice creates a group === - let mut alice_group = MlsGroup::new( - provider, - &alice_signer, - &mls_group_create_config, - alice_credential_with_key, - ) - .expect("error creating group"); - - // === Verify the initial group context extension data is correct === - let group_context_extensions = alice_group.group().context().extensions(); - let mut extracted_data = None; - for extension in group_context_extensions.iter() { - if let Extension::Unknown(0xff11, UnknownExtension(data)) = extension { - extracted_data = Some(data.clone()); - } - } - assert_eq!( - extracted_data.unwrap(), - vec![1, 2], - "The data of Extension::Unknown(0xff11) does not match the expected data" - ); - - // === Alice adds Bob === - let (bob_credential_with_key, _bob_kpb, bob_signer, _bob_pk) = - setup_client("Bob", ciphersuite, provider); - - let bob_key_package = KeyPackage::builder() - .leaf_node_capabilities(capabilities) - .build( - CryptoConfig::with_default_version(ciphersuite), - provider, - &bob_signer, - bob_credential_with_key, - ) - .expect("error building key package"); - - let (_, welcome, _) = alice_group - .add_members(provider, &alice_signer, &[bob_key_package.clone()]) - .unwrap(); - alice_group.merge_pending_commit(provider).unwrap(); - - let welcome: MlsMessageIn = welcome.into(); - let welcome = welcome - .into_welcome() - .expect("expected message to be a welcome"); - - let bob_group = StagedWelcome::new_from_welcome( - provider, - &MlsGroupJoinConfig::default(), - welcome, - Some(alice_group.export_ratchet_tree().into()), - ) - .expect("Error creating staged join from Welcome") - .into_group(provider) - .expect("Error creating group from staged join"); - - // === Verify Bob's initial group context extension data is correct === - let group_context_extensions = bob_group.group().context().extensions(); - let mut extracted_data_2 = None; - for extension in group_context_extensions.iter() { - if let Extension::Unknown(0xff11, UnknownExtension(data)) = extension { - extracted_data_2 = Some(data.clone()); - } - } - assert_eq!( - extracted_data_2.unwrap(), - vec![1, 2], - "The data of Extension::Unknown(0xff11) does not match the expected data" - ); - - // === Propose the new group context extension === - let updated_unknown_extension_data = vec![3, 4]; // Sample data for the extension - let updated_unknown_gc_extension = Extension::Unknown( - 0xff11, - UnknownExtension(updated_unknown_extension_data.clone()), - ); - - let mut updated_extensions = test_gc_extensions.clone(); - updated_extensions.add_or_replace(updated_unknown_gc_extension); - alice_group - .propose_group_context_extensions(provider, updated_extensions, &alice_signer) - .expect("failed to propose group context extensions with unknown extension"); - - assert_eq!( - alice_group.pending_proposals().count(), - 1, - "Expected one pending proposal" - ); - - // === Commit to the proposed group context extension === - alice_group - .commit_to_pending_proposals(provider, &alice_signer) - .expect("failed to commit to pending group context extensions"); - - alice_group - .merge_pending_commit(provider) - .expect("error merging pending commit"); - - alice_group - .save(provider.key_store()) - .expect("error saving group"); - - // === Verify the group context extension was updated === - let group_context_extensions = alice_group.group().context().extensions(); - let mut extracted_data_updated = None; - for extension in group_context_extensions.iter() { - if let Extension::Unknown(0xff11, UnknownExtension(data)) = extension { - extracted_data_updated = Some(data.clone()); - } - } - assert_eq!( - extracted_data_updated.unwrap(), - vec![3, 4], - "The data of Extension::Unknown(0xff11) does not match the expected data" - ); - - // === Verify Bob sees the group context extension updated === - let bob_group_loaded = MlsGroup::load(bob_group.group().group_id(), provider.key_store()) - .expect("error loading group"); - let group_context_extensions_2 = bob_group_loaded.export_group_context().extensions(); - let mut extracted_data_2 = None; - for extension in group_context_extensions_2.iter() { - if let Extension::Unknown(0xff11, UnknownExtension(data)) = extension { - extracted_data_2 = Some(data.clone()); - } - } - assert_eq!( - extracted_data_2.unwrap(), - vec![3, 4], - "The data of Extension::Unknown(0xff11) does not match the expected data" - ); -} - #[apply(ciphersuites_and_providers)] fn join_multiple_groups_last_resort_extension( ciphersuite: Ciphersuite,