Skip to content
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

Mobile: Fixes #10409: Fix accepting encrypted shared notebooks #10429

Conversation

personalizedrefrigerator
Copy link
Collaborator

@personalizedrefrigerator personalizedrefrigerator commented May 14, 2024

Summary

This pull request adds support for decrypting data longer than 256 bytes in RSA.react-native.ts.

Previously, ppkEncryptionHandler was called with data longer than 256 bytes while accepting a share, causing an error.

This pull request does not add support for long-data encryption mobile. Long-data encryption should only be necessary for sharing encrypted notebooks.

Notes

  • node-rsa seems to use ECB-mode (breaking the data into chunks, then encrypting/decrypting each individually) for encrypting/decrypting multiple blocks.
  • The key size is now included in the RSAKeyPair data structure. This is used to calculate the block size. While it's possible to get the key size from the public key, it seems to be more complicated than providing a copy of the key size to encrypt/decrypt`.
  • Using a short key with longer data with length that's multiple of 128 bytes seems to fail. We currently use a key size of 256 bytes and is tested for a key size of 256 above.

Testing plan

This pull request extends the existing automated tests that run on app startup. It can also be tested manually by:

  1. Setup (if not already done):
    1. Set up two-user sync with Joplin server, where both users have encryption enabled (if not already set-up).
    2. Sync a mobile client with one account, a desktop client with the other.
  2. Create a new notebook from the desktop app.
  3. Share that notebook with the mobile client user.
  4. Sync the mobile client and accept the share.
  5. Sync the desktop client and restart the mobile client.
  6. Create a new note in the shared notebook from the mobile client and attach a drawing.
  7. Sync the desktop client and verify that the just-created note is visible.
  8. Edit the note on desktop and sync both clients.
  9. Verify that the desktop changes can be seen on mobile.

This has been tested successfully on an iOS 17.4 simulator and an Android 14 emulator.

@laurent22 laurent22 merged commit 27c5dd1 into laurent22:dev May 16, 2024
10 checks passed
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.

None yet

2 participants