Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2025

Conversation

SaintPatrck
Copy link
Contributor

@SaintPatrck SaintPatrck commented Jun 2, 2025

🎟️ Tracking

PM-21782

Relates to bitwarden/ios#1604
Relates to bitwarden/server#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

Copy link
Contributor

github-actions bot commented Jun 2, 2025

Logo
Checkmarx One – Scan Summary & Details537601b6-8370-48c9-a4b0-3209405de3ee

Great job, no security vulnerabilities found in this Pull Request

@SaintPatrck SaintPatrck force-pushed the PM-21782/encrypted-for-property branch 2 times, most recently from c3ba66a to 1e4e784 Compare June 2, 2025 20:54
@SaintPatrck SaintPatrck marked this pull request as ready for review June 2, 2025 21:20
@SaintPatrck SaintPatrck force-pushed the PM-21782/encrypted-for-property branch from 1e4e784 to ce5501d Compare June 2, 2025 22:32
david-livefront
david-livefront previously approved these changes Jun 2, 2025
Copy link

codecov bot commented Jun 2, 2025

Codecov Report

Attention: Patch coverage is 95.12195% with 2 lines in your changes missing coverage. Please review.

Project coverage is 82.81%. Comparing base (a3d2e51) to head (bf0307b).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
.../bitwarden/data/vault/manager/CipherManagerImpl.kt 94.28% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5297   +/-   ##
=======================================
  Coverage   82.80%   82.81%           
=======================================
  Files         678      678           
  Lines       50889    50905   +16     
  Branches     6924     6924           
=======================================
+ Hits        42141    42157   +16     
  Misses       6433     6433           
  Partials     2315     2315           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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 (bitwarden/sdk-internal#278)
- Update in protocol and objects naming to have ``{foo}Client[Protocol]`` instead of `Client{foo}[Protocol]` (bitwarden/sdk-internal#224)
- Update attachments decryption to use `AttachmentView` instead of `Attachment` (bitwarden/sdk-internal#255)
@SaintPatrck SaintPatrck force-pushed the PM-21782/encrypted-for-property branch from eefd795 to bf0307b Compare June 3, 2025 13:37
@SaintPatrck SaintPatrck added this pull request to the merge queue Jun 3, 2025
Merged via the queue into main with commit 0892e0f Jun 3, 2025
9 checks passed
@SaintPatrck SaintPatrck deleted the PM-21782/encrypted-for-property branch June 3, 2025 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants