[PR #2116] [CLOSED] [PS-1608] Use .NET's cross-platform cryptographic APIs. #3364

Closed
opened 2025-11-26 23:31:44 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/2116
Author: @teo-tsirpanis
Created: 10/4/2022
Status: Closed

Base: mainHead: xplat-crypto


📝 Commits (10+)

📊 Changes

3 files changed (+51 additions, -1 deletions)

View changed files

src/iOS.Core/Services/AppleCryptoPrimitiveService.cs (+49 -0)
📝 src/iOS.Core/Utilities/iOSCoreHelpers.cs (+1 -1)
📝 src/iOS.Core/iOS.Core.csproj (+1 -0)

📄 Description

Type of change

  • Bug fix
  • New feature development
  • Tech debt (refactoring, code cleanup, dependency upgrades, etc)
  • Build/deploy pipeline (DevOps)
  • Other

Objective

.NET provides a plethora of cross-platform cryptographic APIs but nevertheless the BitWarden mobile apps don't use them at all, resorting to either directly using platform-specific dependencies like Apple's CommonCrypto, managed implementations like Bouncy Castle, or wrapper libraries like PCLCrypto.

With this PR all cryptography (except for HKDF whose APIs are on .NET 6+) is performed using .NET's System.Security.Cryptography types. Bouncy Castle and PCLCrypto dependencies were removed.

Code changes

  • The main changes are in the PclCryptoFunctionService class which was renamed to CryptoFunctionService. Each of its functions was rewritten to use the System.Security.Cryptography types. Reviewing the code should be easy; the method and type names match.
  • I also removed ICryptoPrimitiveService and its implementations; there's not much value in having a separate implementation just for PBKDF2, now that they have the same implementation across platforms.
  • The project changes and the rest of the C# code changes involve renaming and removing types and dependencies.

Before you submit


🔄 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/2116 **Author:** [@teo-tsirpanis](https://github.com/teo-tsirpanis) **Created:** 10/4/2022 **Status:** ❌ Closed **Base:** `main` ← **Head:** `xplat-crypto` --- ### 📝 Commits (10+) - [`3f1674c`](https://github.com/bitwarden/android/commit/3f1674c1f15dfbc91716d9d03feebb174b648661) Icon Updates (#1541) - [`137c762`](https://github.com/bitwarden/android/commit/137c762e40de978d4da98185cbe1b32daaef3dc5) Autosync the updated translations (#1724) - [`5a6aec5`](https://github.com/bitwarden/android/commit/5a6aec51f39d924af743685e160e5e1f72e2360d) Fix Progress dialog crash on tombstoning (#1682) - [`4e7ceaf`](https://github.com/bitwarden/android/commit/4e7ceaf5b5f91a636fb59592f166b5b71fe6e2df) Account Deletion on SSO with CME (#1721) - [`939db8e`](https://github.com/bitwarden/android/commit/939db8ebe02673537a559add09394d443a7948ed) Fix icon update on verify code view (#1728) - [`74e90da`](https://github.com/bitwarden/android/commit/74e90da662e1f7c17f1ce621a5ad1a1beb04e144) Improve Theming (#1707) - [`f1ccbbc`](https://github.com/bitwarden/android/commit/f1ccbbc105827f2bdd4bf105282f195873adc27f) Expand Settings TimePicker tap recognition to entire row (#1714) - [`37f4439`](https://github.com/bitwarden/android/commit/37f443989206762d994140fa6c46d8ee9a3aaa00) Added Logs for PN registration checks (#1731) - [`ef6184a`](https://github.com/bitwarden/android/commit/ef6184a05ba2b5eda91e5bc5de2693f96a85da56) Added hide loading after requesting OTP on verification code (#1732) - [`f8a7eb4`](https://github.com/bitwarden/android/commit/f8a7eb4c941354aff935d29931943584b4587a2b) Add Share app Extension on iOS for Send (re-PR) (#1660) ### 📊 Changes **3 files changed** (+51 additions, -1 deletions) <details> <summary>View changed files</summary> ➕ `src/iOS.Core/Services/AppleCryptoPrimitiveService.cs` (+49 -0) 📝 `src/iOS.Core/Utilities/iOSCoreHelpers.cs` (+1 -1) 📝 `src/iOS.Core/iOS.Core.csproj` (+1 -0) </details> ### 📄 Description ## Type of change - [ ] Bug fix - [ ] New feature development - [X] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ## Objective .NET provides a plethora of cross-platform cryptographic APIs but nevertheless the BitWarden mobile apps don't use them at all, resorting to either directly using platform-specific dependencies like Apple's CommonCrypto, managed implementations like Bouncy Castle, or wrapper libraries like PCLCrypto. With this PR all cryptography (except for HKDF whose APIs are on .NET 6+) is performed using .NET's `System.Security.Cryptography` types. Bouncy Castle and PCLCrypto dependencies were removed. ## Code changes * The main changes are in the `PclCryptoFunctionService` class which was renamed to `CryptoFunctionService`. Each of its functions was rewritten to use the `System.Security.Cryptography` types. Reviewing the code should be easy; the method and type names match. * I also removed `ICryptoPrimitiveService` and its implementations; there's not much value in having a separate implementation just for PBKDF2, now that they have the same implementation across platforms. * The project changes and the rest of the C# code changes involve renaming and removing types and dependencies. ## Before you submit - If this change requires a **documentation update** - notify the documentation team - https://bitwarden.com/help/what-encryption-is-used/#invoked-crypto-libraries will need to be changed. --- <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-26 23:31:44 -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#3364