[PR #5297] [MERGED] [PM-21782] Pass encryptedFor to cipher functions #5652

Closed
opened 2025-11-27 00:11:41 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/5297
Author: @SaintPatrck
Created: 6/2/2025
Status: Merged
Merged: 6/3/2025
Merged by: @SaintPatrck

Base: mainHead: PM-21782/encrypted-for-property


📝 Commits (1)

  • bf0307b [PM-21782] Pass encryptedFor to cipher functions

📊 Changes

20 files changed (+372 additions, -137 deletions)

View changed files

📝 app/src/main/kotlin/com/x8bit/bitwarden/data/vault/datasource/sdk/VaultSdkSource.kt (+4 -3)
📝 app/src/main/kotlin/com/x8bit/bitwarden/data/vault/datasource/sdk/VaultSdkSourceImpl.kt (+4 -3)
📝 app/src/main/kotlin/com/x8bit/bitwarden/data/vault/datasource/sdk/model/Fido2CredentialStoreImpl.kt (+6 -5)
📝 app/src/main/kotlin/com/x8bit/bitwarden/data/vault/manager/CipherManagerImpl.kt (+39 -27)
📝 app/src/main/kotlin/com/x8bit/bitwarden/data/vault/manager/VaultLockManagerImpl.kt (+1 -0)
📝 app/src/main/kotlin/com/x8bit/bitwarden/data/vault/repository/util/VaultSdkCipherExtensions.kt (+27 -2)
📝 app/src/test/kotlin/com/x8bit/bitwarden/data/vault/datasource/disk/VaultDiskSourceTest.kt (+2 -1)
📝 app/src/test/kotlin/com/x8bit/bitwarden/data/vault/datasource/sdk/VaultSdkSourceTest.kt (+29 -26)
📝 app/src/test/kotlin/com/x8bit/bitwarden/data/vault/datasource/sdk/model/CipherViewUtil.kt (+2 -1)
app/src/test/kotlin/com/x8bit/bitwarden/data/vault/datasource/sdk/model/VaultSdkEncryptionContextUtil.kt (+29 -0)
📝 app/src/test/kotlin/com/x8bit/bitwarden/data/vault/manager/CipherManagerTest.kt (+157 -63)
📝 app/src/test/kotlin/com/x8bit/bitwarden/data/vault/manager/VaultLockManagerTest.kt (+19 -0)
📝 app/src/test/kotlin/com/x8bit/bitwarden/data/vault/repository/util/VaultSdkCipherExtensionsTest.kt (+33 -2)
📝 gradle/libs.versions.toml (+1 -1)
📝 network/src/main/kotlin/com/bitwarden/network/model/CipherJsonRequest.kt (+4 -0)
📝 network/src/main/kotlin/com/bitwarden/network/model/SyncResponseJson.kt (+5 -0)
📝 network/src/test/kotlin/com/bitwarden/network/service/CiphersServiceTest.kt (+4 -2)
📝 network/src/test/kotlin/com/bitwarden/network/service/SyncServiceTest.kt (+2 -1)
📝 network/src/testFixtures/kotlin/com/bitwarden/network/model/CipherJsonRequestUtil.kt (+2 -0)
📝 network/src/testFixtures/kotlin/com/bitwarden/network/model/SyncResponseCipherUtil.kt (+2 -0)

📄 Description

🎟️ Tracking

PM-21782

Relates to https://github.com/bitwarden/ios/pull/1604
Relates to https://github.com/bitwarden/server/pull/5838

📔 Objective

This commit updates several functions to accept an encryptedFor parameter, which specifies the user ID for whom the cipher is encrypted. This property is used by the server to verify the cipher is encrypted by the correct user. If verification fails the server responds with an appropriate error message.

This change affects the following:

  • toEncryptedNetworkCipher and toEncryptedNetworkCipherResponse extension functions for Cipher now require an encryptedFor parameter.
  • CipherJsonRequest and SyncResponseJson.Cipher now include an encryptedFor field.
  • SDK functions like encryptCipher and decryptFile have been updated to align with these changes.

Additionally, this update includes the following SDK related changes:

📸 Screenshots

Error message when server verification fails
image

Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/5297 **Author:** [@SaintPatrck](https://github.com/SaintPatrck) **Created:** 6/2/2025 **Status:** ✅ Merged **Merged:** 6/3/2025 **Merged by:** [@SaintPatrck](https://github.com/SaintPatrck) **Base:** `main` ← **Head:** `PM-21782/encrypted-for-property` --- ### 📝 Commits (1) - [`bf0307b`](https://github.com/bitwarden/android/commit/bf0307b137218f43efc766d40869ae57838dcc79) [PM-21782] Pass `encryptedFor` to cipher functions ### 📊 Changes **20 files changed** (+372 additions, -137 deletions) <details> <summary>View changed files</summary> 📝 `app/src/main/kotlin/com/x8bit/bitwarden/data/vault/datasource/sdk/VaultSdkSource.kt` (+4 -3) 📝 `app/src/main/kotlin/com/x8bit/bitwarden/data/vault/datasource/sdk/VaultSdkSourceImpl.kt` (+4 -3) 📝 `app/src/main/kotlin/com/x8bit/bitwarden/data/vault/datasource/sdk/model/Fido2CredentialStoreImpl.kt` (+6 -5) 📝 `app/src/main/kotlin/com/x8bit/bitwarden/data/vault/manager/CipherManagerImpl.kt` (+39 -27) 📝 `app/src/main/kotlin/com/x8bit/bitwarden/data/vault/manager/VaultLockManagerImpl.kt` (+1 -0) 📝 `app/src/main/kotlin/com/x8bit/bitwarden/data/vault/repository/util/VaultSdkCipherExtensions.kt` (+27 -2) 📝 `app/src/test/kotlin/com/x8bit/bitwarden/data/vault/datasource/disk/VaultDiskSourceTest.kt` (+2 -1) 📝 `app/src/test/kotlin/com/x8bit/bitwarden/data/vault/datasource/sdk/VaultSdkSourceTest.kt` (+29 -26) 📝 `app/src/test/kotlin/com/x8bit/bitwarden/data/vault/datasource/sdk/model/CipherViewUtil.kt` (+2 -1) ➕ `app/src/test/kotlin/com/x8bit/bitwarden/data/vault/datasource/sdk/model/VaultSdkEncryptionContextUtil.kt` (+29 -0) 📝 `app/src/test/kotlin/com/x8bit/bitwarden/data/vault/manager/CipherManagerTest.kt` (+157 -63) 📝 `app/src/test/kotlin/com/x8bit/bitwarden/data/vault/manager/VaultLockManagerTest.kt` (+19 -0) 📝 `app/src/test/kotlin/com/x8bit/bitwarden/data/vault/repository/util/VaultSdkCipherExtensionsTest.kt` (+33 -2) 📝 `gradle/libs.versions.toml` (+1 -1) 📝 `network/src/main/kotlin/com/bitwarden/network/model/CipherJsonRequest.kt` (+4 -0) 📝 `network/src/main/kotlin/com/bitwarden/network/model/SyncResponseJson.kt` (+5 -0) 📝 `network/src/test/kotlin/com/bitwarden/network/service/CiphersServiceTest.kt` (+4 -2) 📝 `network/src/test/kotlin/com/bitwarden/network/service/SyncServiceTest.kt` (+2 -1) 📝 `network/src/testFixtures/kotlin/com/bitwarden/network/model/CipherJsonRequestUtil.kt` (+2 -0) 📝 `network/src/testFixtures/kotlin/com/bitwarden/network/model/SyncResponseCipherUtil.kt` (+2 -0) </details> ### 📄 Description ## 🎟️ Tracking PM-21782 Relates to https://github.com/bitwarden/ios/pull/1604 Relates to https://github.com/bitwarden/server/pull/5838 ## 📔 Objective This commit updates several functions to accept an `encryptedFor` parameter, which specifies the user ID for whom the cipher is encrypted. This property is used by the server to verify the cipher is encrypted by the correct user. If verification fails the server responds with an appropriate error message. This change affects the following: - `toEncryptedNetworkCipher` and `toEncryptedNetworkCipherResponse` extension functions for `Cipher` now require an `encryptedFor` parameter. - `CipherJsonRequest` and `SyncResponseJson.Cipher` now include an `encryptedFor` field. - SDK functions like `encryptCipher` and `decryptFile` have been updated to align with these changes. Additionally, this update includes the following SDK related changes: - Adding the `encryptedFor` related logic (https://github.com/bitwarden/sdk-internal/pull/278) - Update in protocol and objects naming to have ``{foo}Client[Protocol]`` instead of `Client{foo}[Protocol]` (https://github.com/bitwarden/sdk-internal/pull/224) - Update attachments decryption to use `AttachmentView` instead of `Attachment` (https://github.com/bitwarden/sdk-internal/pull/255) ## 📸 Screenshots Error message when server verification fails <img width="461" alt="image" src="https://github.com/user-attachments/assets/b610a12c-d745-477a-a8b5-d24106ec3077" /> ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## 🦮 Reviewer guidelines <!-- Suggested interactions but feel free to use (or not) as you desire! --> - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹ️ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠️ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or ♻️ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-27 00:11:41 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#5652