mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
Fix file decryption interface
Actually use mAssumeSymmetricEncryption and set it to false as default. Don't close the file input stream, so we can actually look for PGP encrypted data in the next step.
This commit is contained in:
parent
60998f114c
commit
a2048773ee
@ -443,8 +443,7 @@ public class DecryptActivity extends DrawerActivity {
|
|||||||
getDecryptionKeyFromInputStream();
|
getDecryptionKeyFromInputStream();
|
||||||
|
|
||||||
// if we need a symmetric passphrase or a passphrase to use a secret key ask for it
|
// if we need a symmetric passphrase or a passphrase to use a secret key ask for it
|
||||||
if (mSecretKeyId == Id.key.symmetric
|
if (mAssumeSymmetricEncryption || PassphraseCacheService.getCachedPassphrase(this, mSecretKeyId) == null) {
|
||||||
|| PassphraseCacheService.getCachedPassphrase(this, mSecretKeyId) == null) {
|
|
||||||
showPassphraseDialog();
|
showPassphraseDialog();
|
||||||
} else {
|
} else {
|
||||||
if (mDecryptTarget == Id.target.file) {
|
if (mDecryptTarget == Id.target.file) {
|
||||||
@ -494,6 +493,7 @@ public class DecryptActivity extends DrawerActivity {
|
|||||||
* TODO: Rework function, remove global variables
|
* TODO: Rework function, remove global variables
|
||||||
*/
|
*/
|
||||||
private void getDecryptionKeyFromInputStream() {
|
private void getDecryptionKeyFromInputStream() {
|
||||||
|
mAssumeSymmetricEncryption = false;
|
||||||
InputStream inStream = null;
|
InputStream inStream = null;
|
||||||
if (mContentUri != null) {
|
if (mContentUri != null) {
|
||||||
try {
|
try {
|
||||||
@ -517,13 +517,6 @@ public class DecryptActivity extends DrawerActivity {
|
|||||||
Log.e(Constants.TAG, "File not found!", e);
|
Log.e(Constants.TAG, "File not found!", e);
|
||||||
AppMsg.makeText(this, getString(R.string.error_file_not_found, e.getMessage()),
|
AppMsg.makeText(this, getString(R.string.error_file_not_found, e.getMessage()),
|
||||||
AppMsg.STYLE_ALERT).show();
|
AppMsg.STYLE_ALERT).show();
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (inStream != null) {
|
|
||||||
inStream.close();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
inStream = new ByteArrayInputStream(mMessage.getText().toString().getBytes());
|
inStream = new ByteArrayInputStream(mMessage.getText().toString().getBytes());
|
||||||
@ -540,7 +533,6 @@ public class DecryptActivity extends DrawerActivity {
|
|||||||
if (mSecretKeyId == Id.key.none) {
|
if (mSecretKeyId == Id.key.none) {
|
||||||
throw new PgpGeneralException(getString(R.string.error_no_secret_key_found));
|
throw new PgpGeneralException(getString(R.string.error_no_secret_key_found));
|
||||||
}
|
}
|
||||||
mAssumeSymmetricEncryption = false;
|
|
||||||
} catch (NoAsymmetricEncryptionException e) {
|
} catch (NoAsymmetricEncryptionException e) {
|
||||||
if (inStream.markSupported()) {
|
if (inStream.markSupported()) {
|
||||||
inStream.reset();
|
inStream.reset();
|
||||||
@ -553,6 +545,7 @@ public class DecryptActivity extends DrawerActivity {
|
|||||||
mAssumeSymmetricEncryption = true;
|
mAssumeSymmetricEncryption = true;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Log.e(Constants.TAG, "error while reading decryption key from input stream", e);
|
||||||
AppMsg.makeText(this, getString(R.string.error_message, e.getMessage()),
|
AppMsg.makeText(this, getString(R.string.error_message, e.getMessage()),
|
||||||
AppMsg.STYLE_ALERT).show();
|
AppMsg.STYLE_ALERT).show();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user