-
Notifications
You must be signed in to change notification settings - Fork 478
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
WIP: Migration to symmetrically encoded key blocks for secret keys #1884
Conversation
* Parcelable representation of an encrypted keyring block as raw data, | ||
* with related fields not obtainable without decrypting the block | ||
*/ | ||
public class ParcelableEncryptedKeyRing implements Parcelable{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code style ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woops I should fix that. Sounds pretty confusing now that I read that comment ><
Regarding failing tests: Regarding encoding of keyring blocks: Code for routines can be found at OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ByteArrayEncryptor.java The salt and IV are stored together with the encrypted keyring data through serialization, and the entire serialized object is saved into the db as a blob. We could also store the salt and IV in the database directly in their own columns but I thought that serialization might make the code easier to read. I do feel that the encryption routines I wrote are kinda flaky, but I'm gonna leave this for later. |
5f7ad75
to
e938cc0
Compare
47ef4d3
to
959afcd
Compare
In the migration system's current state, if the user has forgotten the password for one of his keys, the app becomes unusable until he clears data. Would it be possible to make the migration optional, or allow it to be skipped for some keys (with the skipped keys being rendered unusable until migrated)? |
I was planning on using an interface similar to what we have for key On Thu, Aug 18, 2016 at 3:34 AM, Adithya Abraham Philip <
|
PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider( | ||
Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(cryptoInput.getPassphrase().getCharArray()); | ||
masterPrivateKey = masterSecretKey.extractPrivateKey(keyDecryptor); | ||
masterPrivateKey = masterSecretKey.extractPrivateKey(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you put in a comment explaining where the unlocking is happening now?
Just a note, I have not amended the 'no password' indicator which shows up when a user tries to examine his subkeys. Was using it as an indication that stripping s2k was working. Will be hiding that in a future commit. |
import java.security.SecureRandom; | ||
import java.security.spec.KeySpec; | ||
|
||
public final class ByteArrayEncryptor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why you implement your own encryption method for byte arrays? Why not use our PGP methods for this? If there is no specific reason, I would propose switching to PGP encryption.
And please merge/rebase master. Some changes shown in your PR by @runnerway are now on master and shouldn't be displayed here as changes. |
I think something went wrong when I was rebasing. Will fix that in a bit. On Thu, Aug 18, 2016 at 10:42 PM, Dominik Schürmann <
|
959afcd
to
9bf9c92
Compare
try { | ||
|
||
mProviderHelper.log(LogType.MSG_IP_PREPARE); | ||
result += 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this used to be mIndent+=1
before it was copied over. This also highlights an issue with logging in ProviderWriter
and ProviderReader
in general - I'm not very sure whether accessing the ProviderHelper
's operation log this way is ideal (getting it to work would involve changing ProviderHelper.mIndent
too).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any suggestions on how I should go about fixing the logging issue?
Just got a crash while trying to update a private key, which was imported from a file.
|
Sure, I'll look into that. On Fri, Aug 19, 2016 at 6:55 AM, Adithya Abraham Philip <
|
With reference to the aforemention crash - looks like line 792 in |
f3dec3e
to
1c9d784
Compare
@alexfjw Just posting the stacktrace to the issue you had mentioned. App crashes on start right after consolidate is completed, without asking for passphrases for any keys.
Does not happen on a fresh install or after clearing data. |
Also, opting out of master passphrase in preferences has a few issues:
Considering these issues, it might be better to not have the preference for now and make the master passphrase compulsory. Any thoughts, @dschuermann @Valodim? |
Thanks Adithya, I"ll look into the bugs in a bit. |
@@ -131,6 +125,76 @@ public void setFirstTime(boolean value) { | |||
editor.commit(); | |||
} | |||
|
|||
public boolean isUsingEncryptedKeyRings() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be nice to add a comment explaining what this means.
About "[Bug] Opting in again still requires the old master password to be remembered and entered." We would still require the master passphrase if want to provide the user the option of using the applock no matter what workflow he's on. That was the reason I coded it as such. I suppose the alternative would be to prevent applock usage if he is on the multi-passphrase workflow. |
When importing a secret key from file after opting into master passphrase, the associated public key is imported and appears in the public key list, but the secret key is not.
Debugging Line 103, |
@alexfjw Great work fixing the import bug. Works flawlessly now. Just to nitpick, the passphrase dialog asks for the master passphrase while importing keys but does not cache it. Could you fix that? |
Upgrading from master also works great. The only potential issue that remains is if a user has a secret key which he has forgotten the password to, he will have to clear data to proceed. Maybe the option to select which keys will be migrated (with the rest deleted), you had mentioned earlier would be a good solution. |
I'll look into the caching issue this weekend. As for the secret key selection for migration, was thinking of waiting till Could try and do it now with the current import key ui but having to fix it On Sep 5, 2016 5:40 PM, "Adithya Abraham Philip" notifications@github.com
|
closing stale PR |
Migration away from s2k to symmetric secret key blocks
TODO:
*Current consolidation requires reimporting secret keys. This would not work with symmetric key blocks as they would have to be decrypted, which means we have to ask for passphrases on each consolidate.
Targets for refactoring:
Both the single & multi-passphrase workflows have been added,
along with an applock which works with the master passphrase.
There is probably a need to refine the UI for both migration and a fresh install of the application.
However, it is definitely usable in its current state, with support for all pre-existing features before this PR.