Skip to content

Add Google Tink dependency, replacing androidx.security.crypto #4405

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 3 commits into from
Mar 17, 2025

Conversation

jmartinesp
Copy link
Member

Content

  • Remove the deprecated androidx.security.crypto library.
  • Replace it with a simplified but backwards compatible implementation using Tink. There are some constants that are now hardcoded, but those were previously in the replaced library and accessible to anyone, so it shouldn't be a security concern.

Motivation and context

The library is being deprecated and was causing some conflicts related to it using an outdated Tink version. Maybe @BillCarsonFr should also take a quick look?

Tests

Start the app with a logged in account, if it works fine the replacement works.

Tested devices

  • Physical
  • Emulator
  • OS version(s): 14

Checklist

  • Changes have been tested on an Android device or Android emulator with API 24
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • You've made a self review of your PR

@jmartinesp jmartinesp added the PR-Dependencies Pull requests that update a dependency file label Mar 13, 2025
@jmartinesp jmartinesp requested a review from a team as a code owner March 13, 2025 10:16
@jmartinesp jmartinesp requested review from ganfra and removed request for a team March 13, 2025 10:16
Copy link
Contributor

github-actions bot commented Mar 13, 2025

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/CxKnVW

Copy link

codecov bot commented Mar 13, 2025

Codecov Report

Attention: Patch coverage is 0% with 44 lines in your changes missing coverage. Please review.

Project coverage is 80.05%. Comparing base (3ca6246) to head (bf8b747).
Report is 21 commits behind head on develop.

Files with missing lines Patch % Lines
...lin/io/element/encrypteddb/crypto/EncryptedFile.kt 0.00% 21 Missing ⚠️
...ent/encrypteddb/crypto/EncryptedFileInputStream.kt 0.00% 15 Missing ⚠️
...nt/encrypteddb/crypto/EncryptedFileOutputStream.kt 0.00% 7 Missing ⚠️
...teddb/passphrase/RandomSecretPassphraseProvider.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4405      +/-   ##
===========================================
- Coverage    80.10%   80.05%   -0.05%     
===========================================
  Files         2063     2065       +2     
  Lines        55180    55212      +32     
  Branches      6765     6765              
===========================================
  Hits         44201    44201              
- Misses        8664     8696      +32     
  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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

) {
private val androidKeysetManager by lazy {
val keysetManagerBuilder = AndroidKeysetManager.Builder()
.withKeyTemplate(KeyTemplates.get("AES256_GCM_HKDF_4KB"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you extract those constants?
I don't really like to have to use all those androidx constants by default :/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not great, but using our own constants means adding a migration system for somethings that's not supposed to change ever (unless we wanted to change something like the encryption scheme 😓 ).

Copy link

@jmartinesp jmartinesp requested a review from ganfra March 17, 2025 08:54
@jmartinesp jmartinesp merged commit 715d75c into develop Mar 17, 2025
29 of 31 checks passed
@jmartinesp jmartinesp deleted the misc/remove-androidx-security-crypto-dependency branch March 17, 2025 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants