Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
Marta Mularczyk committed Dec 5, 2024
1 parent ead6c64 commit 1e456d0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions mls-rs-crypto-webcrypto/src/aead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ impl Aead {
.then_some(())
.ok_or(CryptoError::WrongKeyLength)?;

let params = AesGcmParams::new(key_type.algorithm(), &Uint8Array::from(nonce));
let mut params = AesGcmParams::new(key_type.algorithm(), &Uint8Array::from(nonce));
let aad = Uint8Array::from(aad.unwrap_or_default());
params.set_additional_data(&aad);
params.additional_data(&aad);
let key = key_type.import(&crypto, key).await?;

let out = match key_type {
Expand Down
4 changes: 2 additions & 2 deletions mls-rs-crypto-webcrypto/src/key_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ impl KeyType {
| KeyType::EcdhSecret(curve)
| KeyType::EcdsaPublic(curve)
| KeyType::EcdsaSecret(curve) => {
let params = EcKeyImportParams::new(self.algorithm());
params.set_named_curve(curve);
let mut params = EcKeyImportParams::new(self.algorithm());
params.named_curve(curve);

crypto.import_key_with_object(self.format(), &key, &params, true, &key_usages)?
}
Expand Down
21 changes: 12 additions & 9 deletions mls-rs/src/group/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2318,7 +2318,7 @@ mod tests {
}

#[maybe_async::test(not(mls_build_async), async(mls_build_async, crate::futures_test))]
async fn test_reused_key_package() -> Result<(), MlsError> {
async fn test_reused_key_package() {
let mut alice_group = test_group(TEST_PROTOCOL_VERSION, TEST_CIPHER_SUITE).await;
let (bob_client, bob_key_package) =
test_client_with_key_pkg(TEST_PROTOCOL_VERSION, TEST_CIPHER_SUITE, "bob").await;
Expand All @@ -2328,33 +2328,36 @@ mod tests {
let commit_output = alice_group
.group
.commit_builder()
.add_member(bob_key_package.clone())?
.add_member(bob_key_package.clone())
.unwrap()
.build()
.await?;
.await
.unwrap();

// Bob joins group.
let (mut bob_group, _) = bob_client
.join_group(None, &commit_output.welcome_messages[0])
.await?;
.await
.unwrap();
// This deletes the key package used to join the group.
bob_group.write_to_storage().await?;
bob_group.write_to_storage().await.unwrap();

// Carla adds Bob, reusing the same key package.
let commit_output = carla_group
.group
.commit_builder()
.add_member(bob_key_package.clone())?
.add_member(bob_key_package.clone())
.unwrap()
.build()
.await?;
.await
.unwrap();

// Bob cannot join Carla's group.
let bob_group = bob_client
.join_group(None, &commit_output.welcome_messages[0])
.await
.map(|_| ());
assert_matches!(bob_group, Err(MlsError::WelcomeKeyPackageNotFound));

Ok(())
}

#[cfg(feature = "last_resort_key_package_ext")]
Expand Down

0 comments on commit 1e456d0

Please sign in to comment.