Fix caching of empty passphrase before moving keys to card

This commit is contained in:
Dominik Schürmann
2015-07-03 02:48:54 +02:00
parent f10785ec5a
commit d6b4d4b4f2
3 changed files with 24 additions and 14 deletions

View File

@@ -131,13 +131,22 @@ public class EditKeyOperation extends BaseOperation<SaveKeyringParcel> {
// There is a new passphrase - cache it
if (saveParcel.mNewUnlock != null) {
log.add(LogType.MSG_ED_CACHING_NEW, 1);
PassphraseCacheService.addCachedPassphrase(mContext,
ring.getMasterKeyId(),
ring.getMasterKeyId(),
saveParcel.mNewUnlock.mNewPassphrase != null
? saveParcel.mNewUnlock.mNewPassphrase
: saveParcel.mNewUnlock.mNewPin,
ring.getPublicKey().getPrimaryUserIdWithFallback());
// NOTE: Don't cache empty passphrases! Important for MOVE_KEY_TO_CARD
if (saveParcel.mNewUnlock.mNewPassphrase != null
&& ( ! saveParcel.mNewUnlock.mNewPassphrase.isEmpty())) {
PassphraseCacheService.addCachedPassphrase(mContext,
ring.getMasterKeyId(),
ring.getMasterKeyId(),
saveParcel.mNewUnlock.mNewPassphrase,
ring.getPublicKey().getPrimaryUserIdWithFallback());
} else if (saveParcel.mNewUnlock.mNewPin != null) {
PassphraseCacheService.addCachedPassphrase(mContext,
ring.getMasterKeyId(),
ring.getMasterKeyId(),
saveParcel.mNewUnlock.mNewPin,
ring.getPublicKey().getPrimaryUserIdWithFallback());
}
}
updateProgress(R.string.progress_done, 100, 100);