-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
All: Resolves #8619: Add libsodium-based encryption method #8674
All: Resolves #8619: Add libsodium-based encryption method #8674
Conversation
Since this is also as js lib won't it have the same performance issues as sjcl? |
I think the new algorithm will bring the better performance than the AES in SJCL. |
Yes but if it hits memory limits or similar, we'll be back to poor performances, even if it's faster than SJCL. I'm not convinced it's worth the effort if we end up with another non-native lib. If someone contacts us and prove that SJCL is not secure anymore, then yes let's look for an alternative quickly, but in the meantime we can investigate without spending too much time on a final implementation. SJCL was developed by academics over many years so I'm not convinced it has any security issues, and indeed nobody so far has proven there is one (and we need a working PoC, not assumptions). |
See the above comment:
Switching to |
Yes I saw this, but I feel it's an all or nothing - either we can use the native implementation, or it's simply not worth switching. And actually this rn-libsodium package with its big .cpp file is a bit scary especially since it's developed by just one person. Ideally we would find a package that is widely used so that we know it's well maintained |
A faster alternative could be to directly use the Java/Swift built-in cryptographic libraries ( I'm closing this pull request for now. |
Electron has access to the Node.js crypto package so normally this part shouldn't be an issue. Whatever encryption works on mobile is what we'd use on the other platforms (including the CLI app). |
Summary
Adds a decryption method based on
libsodium
.This pull request targets version 2.13.
Resolves #8619.
To-do
crypto_generichash
is safe to use for key derivation — Joplin master keys have a length of 384 bytes and manylibsodium
functions (crypto_kdf_derive_from_key
,crypto_secretbox_easy
,crypto_aead_xchacha20poly1305_ietf_encrypt
, and probably others) require a key length of around 32 bytes. Alternatively, we could usepwhash
, but that's intended for short human-generated strings.randombytes_buf_deterministic
seems to have a fixed seed length).libsodium
discussions.crypto_secretstream
libsodium.js
encryption seems to work despite this issue.sjcl
.sodium-native
andreact-native-libsodium
for probably-better performance. However,libsodium.js
is maintained by the author oflibsodium
and seems to be more popular than the two alternatives.