diff options
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java index 6abef1ad2..aa85b1082 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java @@ -42,7 +42,7 @@ import org.spongycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator; import org.spongycastle.openpgp.operator.jcajce.JcaPGPContentVerifierBuilderProvider; import org.spongycastle.openpgp.operator.jcajce.JcaPGPDigestCalculatorProviderBuilder; import org.spongycastle.openpgp.operator.jcajce.JcePBEDataDecryptorFactoryBuilder; -import org.spongycastle.openpgp.operator.jcajce.NfcPublicKeyDataDecryptorFactoryBuilder; +import org.spongycastle.openpgp.operator.jcajce.NfcSyncPublicKeyDataDecryptorFactoryBuilder; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; @@ -78,6 +78,7 @@ public class PgpDecryptVerify { private String mPassphrase; private Set<Long> mAllowedKeyIds; private boolean mDecryptMetadataOnly; + private byte[] mDecryptedSessionKey; private PgpDecryptVerify(Builder builder) { // private Constructor can only be called from Builder @@ -91,6 +92,7 @@ public class PgpDecryptVerify { this.mPassphrase = builder.mPassphrase; this.mAllowedKeyIds = builder.mAllowedKeyIds; this.mDecryptMetadataOnly = builder.mDecryptMetadataOnly; + this.mDecryptedSessionKey = builder.mDecryptedSessionKey; } public static class Builder { @@ -106,6 +108,7 @@ public class PgpDecryptVerify { private String mPassphrase = null; private Set<Long> mAllowedKeyIds = null; private boolean mDecryptMetadataOnly = false; + private byte[] mDecryptedSessionKey = null; public Builder(ProviderHelper providerHelper, PassphraseCache passphraseCache, InputData data, OutputStream outStream) { @@ -148,6 +151,11 @@ public class PgpDecryptVerify { return this; } + public Builder setNfcState(byte[] decryptedSessionKey) { + mDecryptedSessionKey = decryptedSessionKey; + return this; + } + public PgpDecryptVerify build() { return new PgpDecryptVerify(this); } @@ -196,10 +204,12 @@ public class PgpDecryptVerify { } public static class NeedNfcDataException extends Exception { - public byte[] mDec; + public byte[] mEncryptedSessionKey; + public String mPassphrase; - public NeedNfcDataException(byte[] dec) { - mDec = dec; + public NeedNfcDataException(byte[] encryptedSessionKey, String passphrase) { + mEncryptedSessionKey = encryptedSessionKey; + mPassphrase = passphrase; } } @@ -379,11 +389,12 @@ public class PgpDecryptVerify { currentProgress += 2; updateProgress(R.string.progress_preparing_streams, currentProgress, 100); - PublicKeyDataDecryptorFactory decryptorFactory = secretEncryptionKey.getDecryptorFactory(); try { + PublicKeyDataDecryptorFactory decryptorFactory + = secretEncryptionKey.getDecryptorFactory(mDecryptedSessionKey); clear = encryptedDataAsymmetric.getDataStream(decryptorFactory); - } catch (NfcPublicKeyDataDecryptorFactoryBuilder.NfcInteractionNeeded e) { - throw new NeedNfcDataException(e.dec); + } catch (NfcSyncPublicKeyDataDecryptorFactoryBuilder.NfcInteractionNeeded e) { + throw new NeedNfcDataException(e.encryptedSessionKey, mPassphrase); } encryptedData = encryptedDataAsymmetric; } else { |