wrapped-key-ring: no more pgp imports in PassphraseDialogFragment
This commit is contained in:
@@ -41,17 +41,18 @@ public class CachedSecretKey extends CachedPublicKey {
|
||||
return (CachedSecretKeyRing) mRing;
|
||||
}
|
||||
|
||||
public void unlock(String passphrase) throws PgpGeneralException {
|
||||
public boolean unlock(String passphrase) throws PgpGeneralException {
|
||||
try {
|
||||
PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider(
|
||||
Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(passphrase.toCharArray());
|
||||
mPrivateKey = mSecretKey.extractPrivateKey(keyDecryptor);
|
||||
} catch (PGPException e) {
|
||||
throw new PgpGeneralException("error extracting key!", e);
|
||||
return false;
|
||||
}
|
||||
if(mPrivateKey == null) {
|
||||
throw new PgpGeneralException("error extracting key (bad passphrase?)");
|
||||
throw new PgpGeneralException("error extracting key");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public PGPSignatureGenerator getSignatureGenerator(int hashAlgo, boolean cleartext)
|
||||
|
||||
@@ -344,9 +344,11 @@ public class PgpDecryptVerify {
|
||||
currentProgress += 5;
|
||||
updateProgress(R.string.progress_extracting_key, currentProgress, 100);
|
||||
try {
|
||||
secretEncryptionKey.unlock(mPassphrase);
|
||||
} catch (PgpGeneralException e) {
|
||||
throw new WrongPassphraseException();
|
||||
if (!secretEncryptionKey.unlock(mPassphrase)) {
|
||||
throw new WrongPassphraseException();
|
||||
}
|
||||
} catch(PgpGeneralException e) {
|
||||
throw new KeyExtractionException();
|
||||
}
|
||||
currentProgress += 5;
|
||||
updateProgress(R.string.progress_preparing_streams, currentProgress, 100);
|
||||
|
||||
@@ -338,8 +338,8 @@ public class PgpKeyOperation {
|
||||
}
|
||||
|
||||
public UncachedKeyRing buildSecretKey(CachedSecretKeyRing wmKR,
|
||||
CachedPublicKeyRing wpKR,
|
||||
SaveKeyringParcel saveParcel)
|
||||
CachedPublicKeyRing wpKR,
|
||||
SaveKeyringParcel saveParcel)
|
||||
throws PgpGeneralMsgIdException, PGPException, SignatureException, IOException {
|
||||
|
||||
PGPSecretKeyRing mKR = wmKR.getRing();
|
||||
|
||||
Reference in New Issue
Block a user