Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add Rust key rotate logic (#2524)
Leendert de Borst1c103582dc2a
diff --git a/core/rust/src/crypto/key_chain.rs b/core/rust/src/crypto/key_chain.rsindex 86955903c..28bd973d6 100644--- a/core/rust/src/crypto/key_chain.rs+++ b/core/rust/src/crypto/key_chain.rs@@ -220,10 +220,86 @@ pub fn reencrypt_account_key(encrypted_account_key: &str, old_unlock_key_base64:Ok(ReencryptedAccountKey { account_key: account_key.to_string(), new_encrypted_account_key })}+/// A rotated account key hierarchy: the new wrapped blobs the server stores, what ties them to the old generation,+/// and the plaintext halves the client keeps.+#[derive(Clone, Serialize, Deserialize, Zeroize, ZeroizeOnDrop)]+#[serde(rename_all = "camelCase")]+pub struct RotatedAccountKeys {+ pub account_key: String,+ pub vault_encryption_key: String,+ pub account_private_key: String,+ pub signing_private_key: String,++ #[zeroize(skip)]+ pub account_keys: AccountKeyBlobs,++ /// The previous VEK encrypted with the new Account Key, which keeps older manifest revisions readable.+ #[zeroize(skip)]+ pub retired_encrypted_vek: String,++ /// The previous signing key's signature over the new signing public key (see [`signing::SIGNING_KEY_ROTATION_LABEL`]).+ #[zeroize(skip)]+ pub previous_signing_key_signature: String,+}++impl fmt::Debug for RotatedAccountKeys {+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {+ f.debug_struct("RotatedAccountKeys").field("account_keys", &self.account_keys).field("retired_encrypted_vek", &self.retired_encrypted_vek).finish_non_exhaustive()+ }+}++/// Rotate an account's keys: a new Account Key, VEK and signing keypair around an account keypair the host generated,+/// wrapped under the KEK of `new_unlock_key_base64`. The previous VEK rides along under the new Account Key, and the+/// previous signing key is used to confirm the new one.+pub fn rotate_account_keys(current_vek_base64: &str, current_signing_private_key_base64: &str, user_id: &str, new_unlock_key_base64: &str, key_pair: &RsaKeyPair) -> VaultResult<RotatedAccountKeys> {+ let hierarchy = create_account_key_hierarchy_with_key_pair(new_unlock_key_base64, key_pair)?;+ let account_key = unwrap_account_key(&hierarchy.account_keys.encrypted_account_key, new_unlock_key_base64)?;+ let retired_encrypted_vek = wrap_key(current_vek_base64, &account_key, aad::PERSONAL_VEK)?;+ let rotation_message = signing::signing_key_rotation_message(user_id, &hierarchy.account_keys.signing_public_key);+ let previous_signing_key_signature = signing::sign(current_signing_private_key_base64, &rotation_message)?;+ Ok(RotatedAccountKeys {+ account_key: account_key.to_string(),+ vault_encryption_key: hierarchy.vault_encryption_key.clone(),+ account_private_key: hierarchy.account_private_key.clone(),+ signing_private_key: hierarchy.signing_private_key.clone(),+ account_keys: hierarchy.account_keys.clone(),+ retired_encrypted_vek,+ previous_signing_key_signature,+ })+}+#[cfg(test)]mod tests {use super::*;+ #[test]+ fn rotated_keys_open_with_the_new_unlock_key_and_vouch_for_each_other() {+ let old_hierarchy = create_account_key_hierarchy(&generate_key_base64()).unwrap();+ let new_unlock_key = generate_key_base64();+ let key_pair = generate_rsa_key_pair().unwrap();++ let rotated = rotate_account_keys(&old_hierarchy.vault_encryption_key, &old_hierarchy.signing_private_key, "user-1", &new_unlock_key, &key_pair).unwrap();+ let blobs = &rotated.account_keys;++ // The new chain opens with the new unlock key and yields the new VEK and private keys.+ let opened = open_account_key_chain(&new_unlock_key, &blobs.encrypted_account_key, &blobs.encrypted_vek, Some(&blobs.encrypted_account_private_key)).unwrap();+ assert_eq!(*opened.vault_encryption_key, rotated.vault_encryption_key);+ assert_eq!(*opened.account_key, rotated.account_key);+ assert_eq!(opened.account_private_key.as_deref().map(String::as_str), Some(key_pair.private_key.as_str()));+ assert_ne!(rotated.vault_encryption_key, old_hierarchy.vault_encryption_key);+ assert_ne!(blobs.signing_public_key, old_hierarchy.account_keys.signing_public_key);++ // The retired VEK opens under the new Account Key, in the VEK slot only.+ assert_eq!(*unwrap_key(&rotated.retired_encrypted_vek, &rotated.account_key, aad::PERSONAL_VEK).unwrap(), old_hierarchy.vault_encryption_key);+ assert!(unwrap_key(&rotated.retired_encrypted_vek, &rotated.account_key, aad::ACCOUNT_KEY).is_err());++ // The old signing key vouches for the new one, bound to the account.+ let message = signing::signing_key_rotation_message("user-1", &blobs.signing_public_key);+ assert!(signing::verify(&old_hierarchy.account_keys.signing_public_key, &message, &rotated.previous_signing_key_signature));+ assert!(!signing::verify(&old_hierarchy.account_keys.signing_public_key, &signing::signing_key_rotation_message("user-2", &blobs.signing_public_key), &rotated.previous_signing_key_signature));+ assert!(signing::verify(&blobs.signing_public_key, &signing::account_public_key_message(&blobs.account_public_key), &blobs.account_public_key_signature));+ }+/// Known-answer vector: every host derives the KEK through this one function, and a changed output means no/// stored Account Key opens any more. Never regenerate it.#[test]diff --git a/core/rust/src/crypto/mod.rs b/core/rust/src/crypto/mod.rsindex dd716e9b2..f4d024773 100644--- a/core/rust/src/crypto/mod.rs+++ b/core/rust/src/crypto/mod.rs@@ -30,7 +30,7 @@ pub use aes_gcm::{};pub use key_chain::{create_account_key_hierarchy, create_account_key_hierarchy_with_key_pair, derive_srp_password_hash, open_account_key_chain, open_account_private_key, open_account_signing_private_key,- reencrypt_account_key, unwrap_account_key, unwrap_key, wrap_key, AccountKeyBlobs, AccountKeyHierarchy, KeyChainError, SrpInputError,+ reencrypt_account_key, rotate_account_keys, unwrap_account_key, unwrap_key, wrap_key, AccountKeyBlobs, AccountKeyHierarchy, KeyChainError, RotatedAccountKeys, SrpInputError,};pub use pin::{pin_decrypt, pin_encrypt, pin_generate_salt, pin_is_locked, pin_register_failure, PinFailure};pub use rsa_oaep::{decrypt_with_private_key, decrypt_with_private_key_and_label, encrypt_with_public_key, encrypt_with_public_key_and_label, generate_rsa_key_pair, RsaKeyPair};diff --git a/core/rust/src/vault_sync/db.rs b/core/rust/src/vault_sync/db.rsindex a615a6bd9..5c4dc25c9 100644--- a/core/rust/src/vault_sync/db.rs+++ b/core/rust/src/vault_sync/db.rs@@ -238,6 +238,40 @@ pub(crate) async fn active_public_key_for_manifest(host: &Host, manifest_id: &stOk(rows.first().and_then(|row| row.get("PublicKey")).and_then(Value::as_str).map(str::to_string))}+/// A delivery keypair change that can be undone when the write it was made for does not land.+pub(crate) struct DeliveryKeyChange {+ pub new_key_id: String,+ pub previous_primary_ids: Vec<String>,+}++const PRIMARY_KEY_IDS_FOR_MANIFEST: &str = "SELECT Id FROM EncryptionKeys WHERE ManifestId = ? AND IsPrimary = 1";+const DELETE_KEY: &str = "DELETE FROM EncryptionKeys WHERE Id = ?";+const PROMOTE_KEY: &str = "UPDATE EncryptionKeys SET IsPrimary = 1 WHERE Id = ?";++/// [`set_active_key_for_manifest`], remembering what it changed so [`undo_active_key_change`] can put it back.+pub(crate) async fn rotate_active_key_for_manifest(host: &Host, manifest_id: &str, public_key: &str, private_key: &str) -> SyncResult<DeliveryKeyChange> {+ let previous_primary_ids = query(host, Db::Local, PRIMARY_KEY_IDS_FOR_MANIFEST, vec![json!(manifest_id)]).await?.iter().filter_map(|row| row.get("Id").and_then(Value::as_str)).map(str::to_string).collect();+ let new_key_id = new_id();+ let now = now_vault_datetime();+ exec(+ host,+ Db::Local,+ vec![+ SqlStatement { sql: DEMOTE_KEYS_FOR_MANIFEST.to_string(), params: vec![json!(now), json!(manifest_id)] },+ SqlStatement { sql: INSERT_KEY_FOR_MANIFEST.to_string(), params: vec![json!(new_key_id), json!(manifest_id), json!(public_key), json!(private_key), json!(now), json!(now)] },+ ],+ )+ .await?;+ Ok(DeliveryKeyChange { new_key_id, previous_primary_ids })+}++/// Put the delivery keypair back the way it was before [`rotate_active_key_for_manifest`].+pub(crate) async fn undo_active_key_change(host: &Host, change: &DeliveryKeyChange) -> SyncResult<()> {+ let mut statements = vec![SqlStatement { sql: DELETE_KEY.to_string(), params: vec![json!(change.new_key_id)] }];+ statements.extend(change.previous_primary_ids.iter().map(|id| SqlStatement { sql: PROMOTE_KEY.to_string(), params: vec![json!(id)] }));+ exec(host, Db::Local, statements).await+}+/// Make a keypair the manifest's active one, demoting (never deleting) whatever it supersedes.pub(crate) async fn set_active_key_for_manifest(host: &Host, manifest_id: &str, public_key: &str, private_key: &str) -> SyncResult<()> {let now = now_vault_datetime();diff --git a/core/rust/src/vault_sync/email_routing.rs b/core/rust/src/vault_sync/email_routing.rsindex 745334d2a..ab0f08bec 100644--- a/core/rust/src/vault_sync/email_routing.rs+++ b/core/rust/src/vault_sync/email_routing.rs@@ -61,7 +61,7 @@ pub(crate) fn build_email_routing(manifests: &[Manifest], private_email_domains:covered_manifest_ids: manifests.iter().map(|manifest| manifest.manifest_id.clone()).collect(),base_revisions: manifests.iter()- .map(|manifest| ManifestRevision { manifest_id: manifest.manifest_id.clone(), revision: manifest_revisions.get(&manifest.manifest_id).copied().unwrap_or(0), encrypted_name: None })+ .map(|manifest| ManifestRevision { manifest_id: manifest.manifest_id.clone(), revision: manifest_revisions.get(&manifest.manifest_id).copied().unwrap_or(0), encrypted_name: None, key_version: 0 }).collect(),}}diff --git a/core/rust/src/vault_sync/engine.rs b/core/rust/src/vault_sync/engine.rsindex be8a4573d..a063396fd 100644--- a/core/rust/src/vault_sync/engine.rs+++ b/core/rust/src/vault_sync/engine.rs@@ -12,7 +12,7 @@ use super::push::{self, CanonicalizedSet, PushStatus, WriteKind};use super::session::Host;use super::state::{self, Ctx};use super::types::{FailureFields, FullSyncResult, LogLevel, ResolveVaultKeyResult, StatusCheckResult, StatusResponse, SyncOperation, SyncRequest};-use super::{db, http, keys, migration, sharing};+use super::{db, http, keys, migration, rotation, sharing};use crate::crypto;use crate::vault_model::{id_key, ids_equal};@@ -35,6 +35,7 @@ pub(crate) async fn run(host: Host, request: SyncRequest) -> Value {SyncOperation::CreateSharedManifest => serde_json::to_value(sharing::create_shared_manifest_operation(&mut ctx).await),SyncOperation::InviteToSharedManifest => serde_json::to_value(sharing::invite_to_shared_manifest_operation(&mut ctx).await),SyncOperation::UpdateSharedManifest => serde_json::to_value(sharing::update_shared_manifest_operation(&mut ctx).await),+ SyncOperation::RotateAccountKeys => serde_json::to_value(rotation::rotate_account_keys_operation(&mut ctx).await),};finish(&ctx, result.unwrap_or(Value::Null))}@@ -279,7 +280,7 @@ fn split_version(version: &str) -> (&str, Option<&str>) {}/// Whether the client has to pull and re-materialize: any manifest or data bucket changed on the server.-async fn server_state_needs_pull(ctx: &Ctx, status: &StatusResponse) -> SyncResult<bool> {+pub(crate) async fn server_state_needs_pull(ctx: &Ctx, status: &StatusResponse) -> SyncResult<bool> {let server_manifests: HashMap<String, i64> = status.manifest_revisions.iter().map(|m| (m.manifest_id.clone(), m.revision)).collect();let server_buckets: HashMap<String, i64> = status.bucket_revisions.iter().map(|b| (state::bucket_revision_key(&b.manifest_id, &b.category), b.revision)).collect();let local_manifests: HashMap<String, i64> = state::get(&ctx.host, state::SERVER_MANIFEST_REVISIONS).await?.unwrap_or_default();@@ -300,7 +301,7 @@ fn requiring_pull(server: &HashMap<String, i64>, local: &HashMap<String, i64>) -server.iter().filter(|(id, revision)| local.get(*id) != Some(revision)).count() + local.keys().filter(|id| !server.contains_key(*id)).count()}-async fn assert_salt_unchanged(ctx: &Ctx, server_salt: Option<&str>) -> SyncResult<()> {+pub(crate) async fn assert_salt_unchanged(ctx: &Ctx, server_salt: Option<&str>) -> SyncResult<()> {let stored: Option<Value> = state::get(&ctx.host, state::UNLOCK_KEY_DERIVATION_PARAMS).await?;let stored_salt = stored.as_ref().and_then(|params| params.get("salt")).and_then(Value::as_str).map(str::to_string);if let (Some(stored), Some(server)) = (stored_salt, server_salt) {diff --git a/core/rust/src/vault_sync/mod.rs b/core/rust/src/vault_sync/mod.rsindex af645676e..a9711d31b 100644--- a/core/rust/src/vault_sync/mod.rs+++ b/core/rust/src/vault_sync/mod.rs@@ -13,6 +13,7 @@ mod merge;mod migration;mod pull;mod push;+mod rotation;mod session;mod sharing;pub(crate) mod state;diff --git a/core/rust/src/vault_sync/pull.rs b/core/rust/src/vault_sync/pull.rsindex a53214cb6..49834de97 100644--- a/core/rust/src/vault_sync/pull.rs+++ b/core/rust/src/vault_sync/pull.rs@@ -175,7 +175,7 @@ pub(crate) async fn open_manifests_and_record_sync_state(ctx: &mut Ctx, snapshot// A shared manifest served without content yet (created but never written); its grant and revision are still tracked.let (encrypted_vek, account_public_key, algorithm) = grant_of(dto).ok_or_else(|| SyncError::Snapshot(format!("shared manifest {} was served without content and without a grant, refusing to assemble", dto.manifest_id)))?;let encrypted_name = served_encrypted_name(ctx, &previous_records, &dto.manifest_id);- shared_records.insert(dto.manifest_id.clone(), SharedManifestDto { manifest_id: dto.manifest_id.clone(), encrypted_vek, account_public_key, algorithm, salt: vault_codec::generate_manifest_salt(), encrypted_name, can_administer: dto.can_administer });+ shared_records.insert(dto.manifest_id.clone(), SharedManifestDto { manifest_id: dto.manifest_id.clone(), encrypted_vek, account_public_key, algorithm, salt: vault_codec::generate_manifest_salt(), encrypted_name, can_administer: dto.can_administer, key_version: dto.key_version });contentless_revisions.insert(dto.manifest_id.clone(), dto.revision);continue;}@@ -189,7 +189,7 @@ pub(crate) async fn open_manifests_and_record_sync_state(ctx: &mut Ctx, snapshotNone => ctx.warn(format!("[Pull] The name of shared manifest {} did not open with its key; leaving it unnamed.", entry.manifest_id)).await,}}- shared_records.insert(entry.manifest_id.clone(), SharedManifestDto { manifest_id: entry.manifest_id.clone(), encrypted_vek, account_public_key, algorithm, salt: entry.manifest.manifest_salt.clone(), encrypted_name, can_administer: dto.can_administer });+ shared_records.insert(entry.manifest_id.clone(), SharedManifestDto { manifest_id: entry.manifest_id.clone(), encrypted_vek, account_public_key, algorithm, salt: entry.manifest.manifest_salt.clone(), encrypted_name, can_administer: dto.can_administer, key_version: dto.key_version });resolved.push(entry);}keys::set_shared_manifest_records(ctx, &shared_records, vek).await?;diff --git a/core/rust/src/vault_sync/push.rs b/core/rust/src/vault_sync/push.rsindex 4da34630b..b7199e8cd 100644--- a/core/rust/src/vault_sync/push.rs+++ b/core/rust/src/vault_sync/push.rs@@ -392,20 +392,20 @@ fn format_kb(chars: usize) -> String {}/// A payload as JSON text plus its content fingerprint.-fn fingerprinted<T: serde::Serialize>(payload: &T) -> SyncResult<(String, String)> {+pub(crate) fn fingerprinted<T: serde::Serialize>(payload: &T) -> SyncResult<(String, String)> {let plaintext = serde_json::to_string(payload)?;let fingerprint = vault_codec::compute_content_fingerprint(&plaintext);Ok((plaintext, fingerprint))}/// A payload packed and encrypted for the write, with the hash the server verifies it by.-struct EncryptedPayload {- ciphertext: Vec<u8>,- hash: String,+pub(crate) struct EncryptedPayload {+ pub ciphertext: Vec<u8>,+ pub hash: String,}/// Pack and encrypt a JSON payload under `key` bound to `aad`, logging its size at every stage.-async fn encrypt_payload(ctx: &Ctx, label: &str, plaintext: &str, key: &str, aad: &[u8]) -> SyncResult<EncryptedPayload> {+pub(crate) async fn encrypt_payload(ctx: &Ctx, label: &str, plaintext: &str, key: &str, aad: &[u8]) -> SyncResult<EncryptedPayload> {let packed = vault_codec::pack_payload(plaintext)?;let ciphertext = crypto::symmetric_encrypt_raw_with_aad(&packed, key, aad)?;ctx.log(format!("[Push] {}: raw {} > compressed {} > encrypted {}.", label, format_kb(plaintext.len()), format_kb(packed.len()), format_kb(ciphertext.len()))).await;diff --git a/core/rust/src/vault_sync/rotation.rs b/core/rust/src/vault_sync/rotation.rsnew file mode 100644index 000000000..15060f804--- /dev/null+++ b/core/rust/src/vault_sync/rotation.rs@@ -0,0 +1,376 @@+//! Key rotation: a new Account Key, VEK, account keypair and signing keypair, with the personal vault re-encrypted and+//! every grant rewrapped, which the server applies in one transaction or not at all.++use std::collections::HashMap;++use secrecy::{ExposeSecret, SecretString};+use serde::{Deserialize, Serialize};++use super::blob_keys::EncryptedBlob;+use super::errors::{SyncError, SyncResult};+use super::frame::{FrameBody, FramePart};+use super::state::{self, Ctx};+use super::types::{BlobRef, BucketRevision, BucketWrite, FailureFields, KeyRotationParams, KeyRotationRefusal, KeyRotationResult, ManifestWrite, SharedManifestDto, ALGORITHM_AES256_GCM, ALGORITHM_RSA_OAEP_SHA256};+use super::{db, engine, http, keys, migration, push};+use crate::crypto;+use crate::vault_codec;+use crate::vault_model::ids_equal;+use crate::vault_model::names::ITEMS_TABLE;++const KEY_ROTATION_ENDPOINT: &str = "KeyRotation";++/// `GET v2/Vault/blob-keys/{manifestId}`.+#[derive(Debug, Default, Deserialize)]+#[serde(rename_all = "camelCase")]+struct BlobKeysResponse {+ #[serde(default)]+ blob_keys: Vec<BlobKeyEntry>,+}++#[derive(Debug, Clone, Deserialize)]+#[serde(rename_all = "camelCase")]+struct BlobKeyEntry {+ hash: String,+ encrypted_blob_key: String,+}++/// `POST v2/KeyRotation`.+#[derive(Serialize)]+#[serde(rename_all = "camelCase")]+struct KeyRotationRequest {+ current_client_public_ephemeral: String,+ current_client_session_proof: String,+ expected: ExpectedState,+ unlock_method: UnlockMethodWrite,+ account_keys: AccountKeysWrite,+ manifest: ManifestWrite,+ buckets: Vec<BucketWrite>,+ blob_keys: Vec<BlobKeyWrite>,+ grants: Vec<GrantWrite>,+}++impl FrameBody for KeyRotationRequest {+ fn parts(&mut self) -> Vec<&mut FramePart> {+ std::iter::once(&mut self.manifest.ciphertext).chain(self.buckets.iter_mut().map(|b| &mut b.ciphertext)).collect()+ }+}++#[derive(Serialize)]+#[serde(rename_all = "camelCase")]+struct ExpectedState {+ account_key_version: i64,+ personal_manifest_id: String,+ manifest_revision: i64,+ manifest_key_version: i64,+ bucket_revisions: Vec<BucketRevision>,+}++#[derive(Serialize)]+#[serde(rename_all = "camelCase")]+struct UnlockMethodWrite {+ salt: String,+ verifier: String,+ encryption_type: String,+ encryption_settings: String,+ encrypted_account_key: String,+ encrypted_account_key_algorithm: String,+}++#[derive(Serialize)]+#[serde(rename_all = "camelCase")]+struct AccountKeysWrite {+ encrypted_vek: String,+ retired_encrypted_vek: String,+ account_public_key: String,+ encrypted_account_private_key: String,+ account_public_key_signature: String,+ signing_public_key: String,+ encrypted_signing_private_key: String,+ previous_signing_key_signature: String,+}++#[derive(Serialize)]+#[serde(rename_all = "camelCase")]+struct BlobKeyWrite {+ hash: String,+ encrypted_blob_key: String,+}++#[derive(Serialize)]+#[serde(rename_all = "camelCase")]+struct GrantWrite {+ manifest_id: String,+ key_version: i64,+ encrypted_vek: String,+ algorithm: String,+ signature: String,+}++#[derive(Debug, Default, Deserialize)]+#[serde(rename_all = "camelCase")]+struct KeyRotationResponse {+ #[serde(default)]+ status: String,+ #[serde(default)]+ manifest_revision: i64,+ #[serde(default)]+ bucket_revisions: Vec<BucketRevision>,+}++/// What the server reported after applying the rotation, for the local state to take over.+struct Applied {+ manifest_revision: i64,+ bucket_revisions: Vec<BucketRevision>,+}++/// What a rotation came to: the new session keys, or why it did not run.+type Outcome = SyncResult<Result<(SecretString, SecretString), KeyRotationRefusal>>;++/// Rotate the account's keys.+pub(crate) async fn rotate_account_keys_operation(ctx: &mut Ctx) -> KeyRotationResult {+ match rotate(ctx).await {+ Ok(Ok((account_key, encryption_key))) => KeyRotationResult { success: true, account_key: Some(account_key), encryption_key: Some(encryption_key), ..Default::default() },+ Ok(Err(refusal)) => KeyRotationResult { refusal: Some(refusal), ..Default::default() },+ Err(error) => {+ ctx.warn(format!("[KeyRotation] Could not rotate the account's keys: {}", error)).await;+ KeyRotationResult { failure: FailureFields::from(&error), ..Default::default() }+ }+ }+}++async fn rotate(ctx: &mut Ctx) -> Outcome {+ let params = ctx.request.key_rotation.clone().ok_or_else(|| SyncError::Other("The key rotation carries no parameters".to_string()))?;+ let vek = ctx.encryption_key()?;++ // This device: an upgraded account with its chain cached and a vault the codec can write.+ if !ctx.has_local_vault().await? || migration::vault_requires_manifest_migration(ctx).await? || migration::vault_predates_current_schema(ctx).await? || !keys::has_cached_key_chain(&ctx.host).await? {+ return Ok(Err(KeyRotationRefusal::VaultUpgradeRequired));+ }+ let Some(personal_manifest_id) = state::get::<String>(&ctx.host, state::VAULT_PERSONAL_MANIFEST_ID).await? else { return Ok(Err(KeyRotationRefusal::VaultUpgradeRequired)) };+ let Some(signing_key) = keys::signing_private_key(ctx).await? else { return Ok(Err(KeyRotationRefusal::VaultUpgradeRequired)) };+ if ctx.is_dirty {+ return Ok(Err(KeyRotationRefusal::VaultOutOfDate));+ }++ // The server: reachable, on the same password this device knows, holding nothing newer.+ let status = http::get_status(&ctx.host).await?;+ if status.server_version == http::SERVER_UNREACHABLE_VERSION {+ return Err(SyncError::Network("the server cannot be reached".to_string()));+ }+ engine::assert_salt_unchanged(ctx, status.srp_salt.as_deref()).await?;+ if engine::server_state_needs_pull(ctx, &status).await? {+ return Ok(Err(KeyRotationRefusal::VaultOutOfDate));+ }+ let served_key_version = status.manifest_revisions.iter().find(|m| ids_equal(&m.manifest_id, &personal_manifest_id)).map(|m| m.key_version).unwrap_or(0);+ if served_key_version != params.manifest_key_version {+ return Ok(Err(KeyRotationRefusal::ServerStateChanged));+ }++ // Every grant this account holds has to open here, or the rewrap would leave that shared vault unreachable.+ let shared_records = keys::shared_manifest_records(ctx).await?;+ let mut shared_veks: HashMap<String, SecretString> = HashMap::new();+ for record in shared_records.values() {+ match keys::open_shared_manifest_vek(ctx, record).await? {+ Some(shared_vek) => drop(shared_veks.insert(record.manifest_id.clone(), shared_vek)),+ None => return Ok(Err(KeyRotationRefusal::SharedVaultKeyUnavailable)),+ }+ }++ let blob_keys: BlobKeysResponse = http::with_outdated_server_guard(http::get(&ctx.host, &format!("Vault/blob-keys/{}", personal_manifest_id), false).await)?;++ let key_pair = crypto::RsaKeyPair { public_key: params.new_account_public_key.clone(), private_key: params.new_account_private_key.expose_secret().to_string() };+ let rotated = crypto::rotate_account_keys(vek.expose_secret(), signing_key.expose_secret(), ¶ms.user_id, params.new_unlock_key.expose_secret(), &key_pair)?;+ let new_vek = SecretString::from(rotated.vault_encryption_key.as_str());+ ctx.log("[KeyRotation] Generated the new Account Key, VEK, account keypair and signing keypair.").await;++ // A new mail delivery keypair, written into the local vault so the manifest sent below carries its private half.+ let delivery_pair = crypto::generate_rsa_key_pair()?;+ let delivery_change = db::rotate_active_key_for_manifest(&ctx.host, &personal_manifest_id, &delivery_pair.public_key, &delivery_pair.private_key).await?;++ let posted = build_and_post(ctx, ¶ms, &personal_manifest_id, &rotated, &new_vek, &vek, &shared_records, &shared_veks, &blob_keys.blob_keys, &delivery_pair.public_key).await;+ match posted {+ Ok(Ok((applied, rewrapped_blob_keys, rewrapped_grants, fingerprints))) => {+ adopt(ctx, ¶ms, &personal_manifest_id, &rotated, &new_vek, &applied, &rewrapped_blob_keys, &rewrapped_grants, &fingerprints).await?;+ ctx.log("[KeyRotation] The server applied the rotation; this device now holds the new keys.").await;+ Ok(Ok((SecretString::from(rotated.account_key.as_str()), new_vek)))+ }+ Ok(Err(refusal)) => {+ db::undo_active_key_change(&ctx.host, &delivery_change).await?;+ Ok(Err(refusal))+ }+ Err(error) => {+ if let Err(undo) = db::undo_active_key_change(&ctx.host, &delivery_change).await {+ ctx.warn(format!("[KeyRotation] Could not put the delivery keypair back after the failed rotation: {}", undo)).await;+ }+ Err(error)+ }+ }+}++/// The rewrapped blob keys, the rewrapped grants and the content fingerprints a successful rotation commits locally.+type Built = (Applied, HashMap<String, String>, HashMap<String, SharedManifestDto>, HashMap<String, String>);++/// Encrypt everything under the new keys, send it, and read the server's answer.+#[allow(clippy::too_many_arguments)]+async fn build_and_post(ctx: &mut Ctx, params: &KeyRotationParams, personal_manifest_id: &str, rotated: &crypto::RotatedAccountKeys, new_vek: &SecretString, old_vek: &SecretString, shared_records: &HashMap<String, SharedManifestDto>, shared_veks: &HashMap<String, SecretString>, server_blob_keys: &[BlobKeyEntry], delivery_public_key: &str) -> SyncResult<Result<Built, KeyRotationRefusal>> {+ let manifest_revisions: HashMap<String, i64> = state::get(&ctx.host, state::SERVER_MANIFEST_REVISIONS).await?.unwrap_or_default();+ let bucket_revisions: HashMap<String, i64> = state::get(&ctx.host, state::VAULT_BUCKET_REVISIONS).await?.unwrap_or_default();+ let current_revision = manifest_revisions.get(personal_manifest_id).copied().unwrap_or(0);++ // The personal manifest and its buckets, as the codec produces them, under the new VEK.+ let set = push::canonicalize_vault(ctx, None).await?;+ let entry = set.canonicalized.manifests.iter().find(|m| ids_equal(&m.manifest.manifest_id, personal_manifest_id)).ok_or_else(|| SyncError::Other("canonicalize produced no personal manifest".to_string()))?;+ let validation = vault_codec::validate_manifest(&entry.manifest);+ if !validation.ok {+ return Err(SyncError::UploadRejected(vec![format!("Manifest validation failed: {}. {}", validation.failed_rules.join(", "), validation.message).trim().to_string()]));+ }+ let mut fingerprints: HashMap<String, String> = HashMap::new();+ let (manifest_plaintext, manifest_fingerprint) = push::fingerprinted(&entry.manifest)?;+ fingerprints.insert(state::fingerprint_manifest_key(personal_manifest_id), manifest_fingerprint);+ let encrypted_manifest = push::encrypt_payload(ctx, "Personal manifest", &manifest_plaintext, new_vek.expose_secret(), &crypto::aad::manifest(personal_manifest_id)).await?;++ let mut buckets = Vec::new();+ let mut expected_buckets = Vec::new();+ for bucket in set.canonicalized.data_buckets.iter().filter(|b| ids_equal(&b.manifest_id, personal_manifest_id)) {+ let validation = vault_codec::validate_data_bucket(bucket);+ if !validation.ok {+ return Err(SyncError::UploadRejected(vec![format!("Data bucket \"{}\" validation failed: {}. {}", bucket.category, validation.failed_rules.join(", "), validation.message).trim().to_string()]));+ }+ let (plaintext, fingerprint) = push::fingerprinted(bucket)?;+ fingerprints.insert(state::fingerprint_bucket_key(personal_manifest_id, &bucket.category), fingerprint);+ let encrypted = push::encrypt_payload(ctx, &format!("Data bucket \"{}\"", bucket.category), &plaintext, new_vek.expose_secret(), &crypto::aad::bucket(personal_manifest_id, &bucket.category)).await?;+ let revision = bucket_revisions.get(&state::bucket_revision_key(personal_manifest_id, &bucket.category)).copied().unwrap_or(0);+ buckets.push(BucketWrite { manifest_id: personal_manifest_id.to_string(), category: bucket.category.clone(), ciphertext: encrypted.ciphertext.into(), ciphertext_hash: encrypted.hash, current_revision: revision });+ expected_buckets.push(BucketRevision { manifest_id: personal_manifest_id.to_string(), category: bucket.category.clone(), revision });+ }++ // Every blob key the server holds, under the new VEK; a blob the manifest references without a key cannot be rotated.+ let mut blob_keys = Vec::new();+ let mut rewrapped_blob_keys: HashMap<String, String> = HashMap::new();+ for blob_key in server_blob_keys {+ let aad = crypto::aad::blob_key(personal_manifest_id, &blob_key.hash);+ let plain = crypto::unwrap_key(&blob_key.encrypted_blob_key, old_vek.expose_secret(), &aad).map_err(|e| SyncError::Other(format!("the key of blob {} does not open with the current vault key: {}", blob_key.hash, e)))?;+ let rewrapped = crypto::wrap_key(&plain, new_vek.expose_secret(), &aad)?;+ rewrapped_blob_keys.insert(blob_key.hash.clone(), rewrapped.clone());+ blob_keys.push(BlobKeyWrite { hash: blob_key.hash.clone(), encrypted_blob_key: rewrapped });+ }+ let references: Vec<BlobRef> = entry.manifest.referenced_blobs().into_iter().map(|(hash, category)| BlobRef { hash, category }).collect();+ if let Some(unkeyed) = references.iter().find(|r| !rewrapped_blob_keys.contains_key(&r.hash)) {+ return Err(SyncError::Other(format!("the server holds no key for referenced blob {}; sync and try again", unkeyed.hash)));+ }++ // Every grant, for the new account public key, signed by the new signing key.+ let mut grants = Vec::new();+ let mut rewrapped_grants = shared_records.clone();+ for record in rewrapped_grants.values_mut() {+ let shared_vek = &shared_veks[&record.manifest_id];+ let encrypted_vek = keys::encrypt_manifest_vek(shared_vek.expose_secret(), &record.manifest_id, &rotated.account_keys.account_public_key)?;+ let message = crypto::signing::grant_message(&record.manifest_id, record.key_version, ¶ms.user_id, &rotated.account_keys.account_public_key, ALGORITHM_RSA_OAEP_SHA256, &encrypted_vek);+ let signature = crypto::signing::sign(&rotated.signing_private_key, &message)?;+ grants.push(GrantWrite { manifest_id: record.manifest_id.clone(), key_version: record.key_version, encrypted_vek: encrypted_vek.clone(), algorithm: ALGORITHM_RSA_OAEP_SHA256.to_string(), signature });+ record.encrypted_vek = encrypted_vek;+ record.account_public_key = rotated.account_keys.account_public_key.clone();+ record.algorithm = ALGORITHM_RSA_OAEP_SHA256.to_string();+ }++ let delivery_key_signature = crypto::signing::sign(&rotated.signing_private_key, &crypto::signing::delivery_key_message(personal_manifest_id, delivery_public_key, current_revision))?;+ let mut request = KeyRotationRequest {+ current_client_public_ephemeral: params.current_client_public_ephemeral.clone(),+ current_client_session_proof: params.current_client_session_proof.clone(),+ expected: ExpectedState { account_key_version: params.account_key_version, personal_manifest_id: personal_manifest_id.to_string(), manifest_revision: current_revision, manifest_key_version: params.manifest_key_version, bucket_revisions: expected_buckets },+ unlock_method: UnlockMethodWrite {+ salt: params.new_salt.clone(),+ verifier: params.new_verifier.clone(),+ encryption_type: params.new_encryption_type.clone(),+ encryption_settings: params.new_encryption_settings.clone(),+ encrypted_account_key: rotated.account_keys.encrypted_account_key.clone(),+ encrypted_account_key_algorithm: ALGORITHM_AES256_GCM.to_string(),+ },+ account_keys: AccountKeysWrite {+ encrypted_vek: rotated.account_keys.encrypted_vek.clone(),+ retired_encrypted_vek: rotated.retired_encrypted_vek.clone(),+ account_public_key: rotated.account_keys.account_public_key.clone(),+ encrypted_account_private_key: rotated.account_keys.encrypted_account_private_key.clone(),+ account_public_key_signature: rotated.account_keys.account_public_key_signature.clone(),+ signing_public_key: rotated.account_keys.signing_public_key.clone(),+ encrypted_signing_private_key: rotated.account_keys.encrypted_signing_private_key.clone(),+ previous_signing_key_signature: rotated.previous_signing_key_signature.clone(),+ },+ manifest: ManifestWrite {+ manifest_id: personal_manifest_id.to_string(),+ ciphertext: encrypted_manifest.ciphertext.into(),+ manifest_ciphertext_hash: encrypted_manifest.hash,+ current_revision,+ credentials_count: entry.manifest.tables.get(ITEMS_TABLE).map(Vec::len).unwrap_or(0),+ blob_references: references,+ delivery_public_key: Some(delivery_public_key.to_string()),+ delivery_public_key_algorithm: Some(ALGORITHM_RSA_OAEP_SHA256.to_string()),+ delivery_public_key_signature: Some(delivery_key_signature),+ },+ buckets,+ blob_keys,+ grants,+ };+ ctx.log(format!("[KeyRotation] Sending the rotation: {} bucket(s), {} blob key(s), {} grant(s).", request.buckets.len(), request.blob_keys.len(), request.grants.len())).await;++ let response: KeyRotationResponse = match http::with_outdated_server_guard(http::post_frame(&ctx.host, KEY_ROTATION_ENDPOINT, &mut request).await) {+ Ok(response) => response,+ // The request may have been applied before the answer was lost; the salt is new per attempt, so the server's salt tells.+ Err(error @ (SyncError::Network(_) | SyncError::Timeout(_))) => {+ ctx.warn(format!("[KeyRotation] No answer to the rotation ({}); asking the server whether it was applied.", error)).await;+ let status = http::get_status(&ctx.host).await?;+ if status.srp_salt.as_deref() != Some(params.new_salt.as_str()) {+ return Err(error);+ }+ KeyRotationResponse { status: "ok".to_string(), manifest_revision: current_revision + 1, bucket_revisions: request.buckets.iter().map(|b| BucketRevision { manifest_id: b.manifest_id.clone(), category: b.category.clone(), revision: b.current_revision + 1 }).collect() }+ }+ Err(error) => return Err(error),+ };+ match response.status.as_str() {+ "ok" => Ok(Ok((Applied { manifest_revision: response.manifest_revision, bucket_revisions: response.bucket_revisions }, rewrapped_blob_keys, rewrapped_grants, fingerprints))),+ "outdated" => Ok(Err(KeyRotationRefusal::ServerStateChanged)),+ other => Err(SyncError::Other(format!("the server answered the rotation with an unknown status \"{}\"", other))),+ }+}++/// Take the new keys over: the cached chain, the derivation parameters, the revisions and fingerprints the server+/// now holds, the blob keys and grants under the new keys, and the stored vault under the new VEK.+#[allow(clippy::too_many_arguments)]+async fn adopt(ctx: &mut Ctx, params: &KeyRotationParams, personal_manifest_id: &str, rotated: &crypto::RotatedAccountKeys, new_vek: &SecretString, applied: &Applied, rewrapped_blob_keys: &HashMap<String, String>, rewrapped_grants: &HashMap<String, SharedManifestDto>, fingerprints: &HashMap<String, String>) -> SyncResult<()> {+ let blobs = &rotated.account_keys;+ state::set(&ctx.host, state::ENCRYPTED_ACCOUNT_KEY, &blobs.encrypted_account_key).await?;+ state::set(&ctx.host, state::ENCRYPTED_VEK, &blobs.encrypted_vek).await?;+ state::set(&ctx.host, state::ACCOUNT_PUBLIC_KEY, &blobs.account_public_key).await?;+ state::set(&ctx.host, state::ENCRYPTED_ACCOUNT_PRIVATE_KEY, &blobs.encrypted_account_private_key).await?;+ state::set(&ctx.host, state::SIGNING_PUBLIC_KEY, &blobs.signing_public_key).await?;+ state::set(&ctx.host, state::ENCRYPTED_SIGNING_PRIVATE_KEY, &blobs.encrypted_signing_private_key).await?;+ state::set(&ctx.host, state::UNLOCK_KEY_DERIVATION_PARAMS, &serde_json::json!({ "salt": params.new_salt, "encryptionType": params.new_encryption_type, "encryptionSettings": params.new_encryption_settings })).await?;++ let mut manifest_revisions: HashMap<String, i64> = state::get(&ctx.host, state::SERVER_MANIFEST_REVISIONS).await?.unwrap_or_default();+ manifest_revisions.insert(personal_manifest_id.to_string(), applied.manifest_revision);+ state::set(&ctx.host, state::SERVER_MANIFEST_REVISIONS, &manifest_revisions).await?;+ let mut bucket_revisions: HashMap<String, i64> = state::get(&ctx.host, state::VAULT_BUCKET_REVISIONS).await?.unwrap_or_default();+ for bucket in &applied.bucket_revisions {+ bucket_revisions.insert(state::bucket_revision_key(&bucket.manifest_id, &bucket.category), bucket.revision);+ }+ state::set(&ctx.host, state::VAULT_BUCKET_REVISIONS, &bucket_revisions).await?;+ let mut stored_fingerprints: HashMap<String, String> = state::get(&ctx.host, state::VAULT_CONTENT_FINGERPRINTS).await?.unwrap_or_default();+ stored_fingerprints.extend(fingerprints.iter().map(|(k, v)| (k.clone(), v.clone())));+ state::set(&ctx.host, state::VAULT_CONTENT_FINGERPRINTS, &stored_fingerprints).await?;++ let mut cache: HashMap<String, EncryptedBlob> = state::get(&ctx.host, state::VAULT_BLOB_CIPHER_CACHE).await?.unwrap_or_default();+ for (hash, encrypted) in cache.iter_mut() {+ if let Some(rewrapped) = rewrapped_blob_keys.get(hash) {+ encrypted.encrypted_blob_key = rewrapped.clone();+ }+ }+ state::set(&ctx.host, state::VAULT_BLOB_CIPHER_CACHE, &cache).await?;++ ctx.account_key = Some(SecretString::from(rotated.account_key.as_str()));+ ctx.account_public_key = Some(blobs.account_public_key.clone());+ ctx.account_private_key = Some(SecretString::from(rotated.account_private_key.as_str()));+ ctx.signing_private_key = Some(SecretString::from(rotated.signing_private_key.as_str()));+ keys::set_shared_manifest_records(ctx, rewrapped_grants, new_vek.expose_secret()).await?;+ ctx.set_encryption_key(new_vek.clone());+ ctx.persist_local_vault(false).await+}diff --git a/core/rust/src/vault_sync/sharing.rs b/core/rust/src/vault_sync/sharing.rsindex d23dc93ee..7ce5dadf7 100644--- a/core/rust/src/vault_sync/sharing.rs+++ b/core/rust/src/vault_sync/sharing.rs@@ -195,6 +195,9 @@ async fn own_public_key(ctx: &Ctx) -> SyncResult<Option<String>> {}}+/// The VEK generation a new shared manifest starts at; its self-grant is signed over it.+const NEW_MANIFEST_KEY_VERSION: i64 = 0;+async fn create_shared_manifest(ctx: &mut Ctx) -> Outcome {let key = ctx.encryption_key()?;let target = params(ctx)?;@@ -216,8 +219,7 @@ async fn create_shared_manifest(ctx: &mut Ctx) -> Outcome {let manifest_vek = crypto::generate_key_base64();let requested_id = db::new_id();let self_encrypted_vek = keys::encrypt_manifest_vek(&manifest_vek, &requested_id, &self_public_key)?;- // A new manifest starts at key version 0.- let self_grant_signature = crypto::signing::sign(signing_key.expose_secret(), &crypto::signing::grant_message(&requested_id, 0, &own_user_id(ctx, &group)?, &self_public_key, ALGORITHM_RSA_OAEP_SHA256, &self_encrypted_vek))?;+ let self_grant_signature = crypto::signing::sign(signing_key.expose_secret(), &crypto::signing::grant_message(&requested_id, NEW_MANIFEST_KEY_VERSION, &own_user_id(ctx, &group)?, &self_public_key, ALGORITHM_RSA_OAEP_SHA256, &self_encrypted_vek))?;let encrypted_name = pull::encrypt_manifest_name(&name, &requested_id, &manifest_vek)?;let response: CreateSharedManifestResponse = http::post(&ctx.host,@@ -242,6 +244,7 @@ async fn create_shared_manifest(ctx: &mut Ctx) -> Outcome {salt: vault_codec::generate_manifest_salt(),encrypted_name: Some(encrypted_name),can_administer: true,+ key_version: NEW_MANIFEST_KEY_VERSION,},);keys::set_shared_manifest_records(ctx, &records, key.expose_secret()).await?;diff --git a/core/rust/src/vault_sync/types.rs b/core/rust/src/vault_sync/types.rsindex 0970df36f..648b05d61 100644--- a/core/rust/src/vault_sync/types.rs+++ b/core/rust/src/vault_sync/types.rs@@ -31,6 +31,28 @@ pub enum SyncOperation {InviteToSharedManifest,/// Change the details of a shared manifest (its name); the server refuses anyone but an administrator of its group.UpdateSharedManifest,+ /// Rotate the account's keys and re-encrypt the personal vault under them; see `KeyRotationParams`.+ RotateAccountKeys,+}++/// What a key rotation needs from the host: the proof of the current password and the new unlock method, both+/// derived from the master password on the host, and the new account keypair (WebCrypto generates RSA keys far+/// faster than wasm).+#[derive(Debug, Clone, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct KeyRotationParams {+ pub user_id: String,+ pub current_client_public_ephemeral: String,+ pub current_client_session_proof: String,+ pub account_key_version: i64,+ pub manifest_key_version: i64,+ pub new_unlock_key: SecretString,+ pub new_salt: String,+ pub new_verifier: String,+ pub new_encryption_type: String,+ pub new_encryption_settings: String,+ pub new_account_public_key: String,+ pub new_account_private_key: SecretString,}/// What a sharing operation acts on.@@ -47,18 +69,18 @@ pub struct SharingParams {}/// Sync request.-#[derive(Debug, Clone, Serialize, Deserialize)]+#[derive(Debug, Clone, Deserialize)]#[serde(rename_all = "camelCase")]pub struct SyncRequest {pub operation: SyncOperation,pub username: String,- #[serde(default, serialize_with = "serialize_option")]+ #[serde(default)]pub encryption_key: Option<SecretString>,#[serde(default)]pub account_public_key: Option<String>,- #[serde(default, serialize_with = "serialize_option")]+ #[serde(default)]pub account_private_key: Option<SecretString>,- #[serde(default, serialize_with = "serialize_option")]+ #[serde(default)]pub account_key: Option<SecretString>,#[serde(default)]pub is_dirty: bool,@@ -75,6 +97,9 @@ pub struct SyncRequest {/// The target of a sharing operation; absent for every other operation.#[serde(default)]pub sharing: Option<SharingParams>,+ /// What a key rotation works with; absent for every other operation.+ #[serde(default)]+ pub key_rotation: Option<KeyRotationParams>,}/// How a failed operation reports itself: a coded error the host translates, or a forced logout.@@ -196,6 +221,35 @@ pub struct SharingOperationResult {pub failure: FailureFields,}+/// Why a key rotation did not run, as the host has words for each.+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub enum KeyRotationRefusal {+ /// The local vault has changes the server has not seen, or the server holds changes this device has not pulled; sync first.+ VaultOutOfDate,+ /// The server state moved on between initiate and the rotation; sync and try again.+ ServerStateChanged,+ /// A shared vault's key could not be opened on this device, so its grant could not be rewrapped.+ SharedVaultKeyUnavailable,+ /// The vault or the account's key hierarchy has to finish upgrading first.+ VaultUpgradeRequired,+}++/// Outcome of a key rotation.+#[derive(Debug, Clone, Default, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct KeyRotationResult {+ pub success: bool,+ #[serde(skip_serializing_if = "Option::is_none", serialize_with = "serialize_option")]+ pub account_key: Option<SecretString>,+ #[serde(skip_serializing_if = "Option::is_none", serialize_with = "serialize_option")]+ pub encryption_key: Option<SecretString>,+ #[serde(skip_serializing_if = "Option::is_none")]+ pub refusal: Option<KeyRotationRefusal>,+ #[serde(flatten)]+ pub failure: FailureFields,+}+/// Outcome of the lightweight status check.#[derive(Debug, Clone, Default, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]@@ -420,6 +474,9 @@ pub struct ManifestRevision {pub revision: i64,#[serde(default, skip_serializing_if = "Option::is_none")]pub encrypted_name: Option<String>,+ /// Served by the status, never sent with a routing push.+ #[serde(default, skip_serializing)]+ pub key_version: i64,}#[derive(Debug, Clone, Serialize, Deserialize)]@@ -723,6 +780,8 @@ pub struct VaultKeyResponse {pub encrypted_signing_private_key: Option<String>,#[serde(default)]pub encrypted_vek: Option<String>,+ #[serde(default)]+ pub key_version: i64,}/// A shared manifest as this account holds it: the grant on its key plus what the last pull learned about it.@@ -741,6 +800,8 @@ pub struct SharedManifestDto {pub encrypted_name: Option<String>,#[serde(default)]pub can_administer: bool,+ #[serde(default)]+ pub key_version: i64,}#[cfg(test)]diff --git a/core/rust/src/vault_sync/write_set.rs b/core/rust/src/vault_sync/write_set.rsindex e6369dd36..a5401d3e7 100644--- a/core/rust/src/vault_sync/write_set.rs+++ b/core/rust/src/vault_sync/write_set.rs@@ -58,7 +58,7 @@ mod tests {use secrecy::ExposeSecret;fn held(ids: &[&str]) -> HashMap<String, SharedManifestDto> {- ids.iter().map(|id| (id.to_string(), SharedManifestDto { manifest_id: id.to_string(), encrypted_vek: String::new(), account_public_key: String::new(), algorithm: String::new(), salt: format!("salt-{}", id), encrypted_name: None, can_administer: true })).collect()+ ids.iter().map(|id| (id.to_string(), SharedManifestDto { manifest_id: id.to_string(), encrypted_vek: String::new(), account_public_key: String::new(), algorithm: String::new(), salt: format!("salt-{}", id), encrypted_name: None, can_administer: true, key_version: 0 })).collect()}fn opened(ids: &[&str]) -> HashMap<String, SecretString> {