Merge pull request #1465 from open-keychain/requirements
Min crypto requirements
This commit is contained in:
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -4,11 +4,11 @@
|
||||
ignore = dirty
|
||||
[submodule "extern/openpgp-api-lib"]
|
||||
path = extern/openpgp-api-lib
|
||||
url = https://github.com/open-keychain/openpgp-api-lib.git
|
||||
url = https://github.com/open-keychain/openpgp-api.git
|
||||
ignore = dirty
|
||||
[submodule "extern/openkeychain-api-lib"]
|
||||
path = extern/openkeychain-api-lib
|
||||
url = https://github.com/open-keychain/openkeychain-api-lib.git
|
||||
url = https://github.com/open-keychain/openkeychain-intents.git
|
||||
ignore = dirty
|
||||
[submodule "extern/KeybaseLib"]
|
||||
path = extern/KeybaseLib
|
||||
|
||||
@@ -94,15 +94,15 @@ dependencyVerification {
|
||||
'com.mikepenz.iconics:meteocons-typeface:39a8a9e70cd8287cdb119af57a672a41dd09240dba6697f5a0dbda1ccc33298b',
|
||||
'com.mikepenz.iconics:community-material-typeface:f1c5afee5f0f10d66beb3ed0df977246a02a9c46de4e05d7c0264bcde53b6b7f',
|
||||
'com.squareup.okhttp:okhttp:bc0da7ac1f5441619faa2082811938acf7df97e4a8e08f0e043ff4937414d5ad',
|
||||
// 'OpenKeychain.extern.openpgp-api-lib:openpgp-api:b918e50a7876fad34e4020ee41418039772c5fe8dd36825720ca8ffecb7d0f06',
|
||||
// 'OpenKeychain.extern.openkeychain-api-lib:openkeychain-intents:111d7d53b9e920ad3405f8f3eb0ab7bd3aee66d577442452754b83c7c1c1d49a',
|
||||
// 'com.madgag.spongycastle:core:97276487be598747ba78c063c90cea7fc3c7ad9bc7aeba03c0b9c98692052b8a',
|
||||
// 'com.madgag.spongycastle:pg:da319de706d946f178140959c74aec126f7803f1104dbad89bb1f55a53f6e1a9',
|
||||
// 'com.madgag.spongycastle:pkix:979aa4b2aaef94866e0f97b05b1922244eaf8b650f3691a3c44760ff0a41562b',
|
||||
// 'com.madgag.spongycastle:prov:902a484219bbf4e395a1c32da65b2453133e195bcc92336dc8c33b7c58edcd60',
|
||||
// 'OpenKeychain.extern:minidns:8274d50124d9584e95df0c5da7798269ac9caf0eab560df929c2c658ca624037',
|
||||
// 'OpenKeychain.extern.KeybaseLib:Lib:d52e7888cea6de9e077501bb533270b2a86b52cb8af49e5f44ee8c4bb19ea017',
|
||||
// 'OpenKeychain.extern.safeslinger-exchange:safeslinger-exchange:76e5da6b4f5f8835b12649e17569f0d0d8d89552815a61383c128545632689d1',
|
||||
// 'OpenKeychain.extern.openpgp-api-lib:openpgp-api:bbbc0b964757450ec78823ec448b0754999e16c9c620e3587c14289cba8e87f8',
|
||||
// 'OpenKeychain.extern.openkeychain-api-lib:openkeychain-intents:4b2f5637580b9bad786d57c32e8b86d6554e2d4ed55ccbfb028bbece655100cc',
|
||||
// 'OpenKeychain.extern.spongycastle:core:4a2a3c86616944bfdaf8f3148a9e047d5007433f1af0a4b38a552b4ec94f6804',
|
||||
// 'OpenKeychain.extern.spongycastle:pg:44690d345d806626d0a83eb5434ba9b52ccfcb37f5a775842333470658ffe28f',
|
||||
// 'OpenKeychain.extern.spongycastle:pkix:bb08d67b726bcf09018cac43c57dfaa00bb7540d16e6e986f0378feb0fed5327',
|
||||
// 'OpenKeychain.extern.spongycastle:prov:b9f0df403c1c9ac6ec7b0bb138fd8dda3d1ac72983c7a5e4a6dc9deab1d7a11e',
|
||||
// 'OpenKeychain.extern:minidns:feb3bbbb3ce15e6e2a4711b35695a54f420188e4264b87116a03b8374b74eb86',
|
||||
// 'OpenKeychain.extern.KeybaseLib:Lib:c80857e2347fb0a80f48a0da8aa510cdfe7c2486784af1d17fb385382f45fe6c',
|
||||
// 'OpenKeychain.extern.safeslinger-exchange:safeslinger-exchange:781c4a5723b6a3c68d1178ac67908cd250d7bac6f11c39836618cc8fc8d0177f',
|
||||
// 'OpenKeychain.extern.snackbar:lib:6847a73d2680558d35f0b384ac3ed006532c0a2306598b000db94ef18aab62aa',
|
||||
'com.android.support:support-annotations:beac5cae60bdb597df9af9c916f785c2f71f8c8ae4be9a32d4298dea85496a42',
|
||||
'com.squareup.okio:okio:b53c1760864e1c39b5275d9023e2a6fbe8f3189e6e67b4c87877b8ec8f92e05a',
|
||||
@@ -110,6 +110,7 @@ dependencyVerification {
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.buildToolsVersion
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
* Copyright (C) 2014-2015 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
* Copyright (C) 2014 Vincent Breitmoser <v.breitmoser@mugenguild.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -20,6 +20,7 @@ package org.sufficientlysecure.keychain.operations.results;
|
||||
|
||||
import android.os.Parcel;
|
||||
|
||||
import org.openintents.openpgp.OpenPgpDecryptionResult;
|
||||
import org.openintents.openpgp.OpenPgpMetadata;
|
||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
@@ -31,7 +32,8 @@ public class DecryptVerifyResult extends InputPendingResult {
|
||||
public static final int RESULT_KEY_DISALLOWED = RESULT_ERROR + 32;
|
||||
|
||||
OpenPgpSignatureResult mSignatureResult;
|
||||
OpenPgpMetadata mDecryptMetadata;
|
||||
OpenPgpDecryptionResult mDecryptionResult;
|
||||
OpenPgpMetadata mDecryptionMetadata;
|
||||
// This holds the charset which was specified in the ascii armor, if specified
|
||||
// https://tools.ietf.org/html/rfc4880#page56
|
||||
String mCharset;
|
||||
@@ -52,7 +54,8 @@ public class DecryptVerifyResult extends InputPendingResult {
|
||||
public DecryptVerifyResult(Parcel source) {
|
||||
super(source);
|
||||
mSignatureResult = source.readParcelable(OpenPgpSignatureResult.class.getClassLoader());
|
||||
mDecryptMetadata = source.readParcelable(OpenPgpMetadata.class.getClassLoader());
|
||||
mDecryptionResult = source.readParcelable(OpenPgpDecryptionResult.class.getClassLoader());
|
||||
mDecryptionMetadata = source.readParcelable(OpenPgpMetadata.class.getClassLoader());
|
||||
mCachedCryptoInputParcel = source.readParcelable(CryptoInputParcel.class.getClassLoader());
|
||||
}
|
||||
|
||||
@@ -69,6 +72,14 @@ public class DecryptVerifyResult extends InputPendingResult {
|
||||
mSignatureResult = signatureResult;
|
||||
}
|
||||
|
||||
public OpenPgpDecryptionResult getDecryptionResult() {
|
||||
return mDecryptionResult;
|
||||
}
|
||||
|
||||
public void setDecryptionResult(OpenPgpDecryptionResult decryptionResult) {
|
||||
mDecryptionResult = decryptionResult;
|
||||
}
|
||||
|
||||
public CryptoInputParcel getCachedCryptoInputParcel() {
|
||||
return mCachedCryptoInputParcel;
|
||||
}
|
||||
@@ -77,12 +88,12 @@ public class DecryptVerifyResult extends InputPendingResult {
|
||||
mCachedCryptoInputParcel = cachedCryptoInputParcel;
|
||||
}
|
||||
|
||||
public OpenPgpMetadata getDecryptMetadata() {
|
||||
return mDecryptMetadata;
|
||||
public OpenPgpMetadata getDecryptionMetadata() {
|
||||
return mDecryptionMetadata;
|
||||
}
|
||||
|
||||
public void setDecryptMetadata(OpenPgpMetadata decryptMetadata) {
|
||||
mDecryptMetadata = decryptMetadata;
|
||||
public void setDecryptionMetadata(OpenPgpMetadata decryptMetadata) {
|
||||
mDecryptionMetadata = decryptMetadata;
|
||||
}
|
||||
|
||||
public String getCharset () {
|
||||
@@ -107,9 +118,10 @@ public class DecryptVerifyResult extends InputPendingResult {
|
||||
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeParcelable(mSignatureResult, 0);
|
||||
dest.writeParcelable(mDecryptMetadata, 0);
|
||||
dest.writeParcelable(mCachedCryptoInputParcel, 0);
|
||||
dest.writeParcelable(mSignatureResult, flags);
|
||||
dest.writeParcelable(mDecryptionResult, flags);
|
||||
dest.writeParcelable(mDecryptionMetadata, flags);
|
||||
dest.writeParcelable(mCachedCryptoInputParcel, flags);
|
||||
}
|
||||
|
||||
public static final Creator<DecryptVerifyResult> CREATOR = new Creator<DecryptVerifyResult>() {
|
||||
|
||||
@@ -611,14 +611,12 @@ public abstract class OperationResult implements Parcelable {
|
||||
MSG_DC_ERROR_CORRUPT_DATA (LogLevel.ERROR, R.string.msg_dc_error_corrupt_data),
|
||||
MSG_DC_ERROR_EXTRACT_KEY (LogLevel.ERROR, R.string.msg_dc_error_extract_key),
|
||||
MSG_DC_ERROR_INTEGRITY_CHECK (LogLevel.ERROR, R.string.msg_dc_error_integrity_check),
|
||||
MSG_DC_ERROR_INTEGRITY_MISSING (LogLevel.ERROR, R.string.msg_dc_error_integrity_missing),
|
||||
MSG_DC_ERROR_INVALID_DATA (LogLevel.ERROR, R.string.msg_dc_error_invalid_data),
|
||||
MSG_DC_ERROR_IO (LogLevel.ERROR, R.string.msg_dc_error_io),
|
||||
MSG_DC_ERROR_INPUT (LogLevel.ERROR, R.string.msg_dc_error_input),
|
||||
MSG_DC_ERROR_NO_DATA (LogLevel.ERROR, R.string.msg_dc_error_no_data),
|
||||
MSG_DC_ERROR_NO_KEY (LogLevel.ERROR, R.string.msg_dc_error_no_key),
|
||||
MSG_DC_ERROR_PGP_EXCEPTION (LogLevel.ERROR, R.string.msg_dc_error_pgp_exception),
|
||||
MSG_DC_ERROR_UNSUPPORTED_HASH_ALGO (LogLevel.ERROR, R.string.msg_dc_error_unsupported_hash_algo),
|
||||
MSG_DC_INTEGRITY_CHECK_OK (LogLevel.INFO, R.string.msg_dc_integrity_check_ok),
|
||||
MSG_DC_OK_META_ONLY (LogLevel.OK, R.string.msg_dc_ok_meta_only),
|
||||
MSG_DC_OK (LogLevel.OK, R.string.msg_dc_ok),
|
||||
@@ -633,7 +631,10 @@ public abstract class OperationResult implements Parcelable {
|
||||
MSG_DC_TRAIL_SYM (LogLevel.DEBUG, R.string.msg_dc_trail_sym),
|
||||
MSG_DC_TRAIL_UNKNOWN (LogLevel.DEBUG, R.string.msg_dc_trail_unknown),
|
||||
MSG_DC_UNLOCKING (LogLevel.INFO, R.string.msg_dc_unlocking),
|
||||
MSG_DC_OLD_SYMMETRIC_ENCRYPTION_ALGO (LogLevel.WARN, R.string.msg_dc_old_symmetric_encryption_algo),
|
||||
MSG_DC_INSECURE_SYMMETRIC_ENCRYPTION_ALGO(LogLevel.WARN, R.string.msg_dc_insecure_symmetric_encryption_algo),
|
||||
MSG_DC_INSECURE_HASH_ALGO(LogLevel.ERROR, R.string.msg_dc_insecure_hash_algo),
|
||||
MSG_DC_INSECURE_MDC_MISSING(LogLevel.ERROR, R.string.msg_dc_insecure_mdc_missing),
|
||||
MSG_DC_INSECURE_KEY(LogLevel.ERROR, R.string.msg_dc_insecure_key),
|
||||
|
||||
// verify signed literal data
|
||||
MSG_VL (LogLevel.INFO, R.string.msg_vl),
|
||||
@@ -660,7 +661,6 @@ public abstract class OperationResult implements Parcelable {
|
||||
MSG_PSE_COMPRESSING (LogLevel.DEBUG, R.string.msg_pse_compressing),
|
||||
MSG_PSE_ENCRYPTING (LogLevel.DEBUG, R.string.msg_pse_encrypting),
|
||||
MSG_PSE_ERROR_BAD_PASSPHRASE (LogLevel.ERROR, R.string.msg_pse_error_bad_passphrase),
|
||||
MSG_PSE_ERROR_HASH_ALGO (LogLevel.ERROR, R.string.msg_pse_error_hash_algo),
|
||||
MSG_PSE_ERROR_IO (LogLevel.ERROR, R.string.msg_pse_error_io),
|
||||
MSG_PSE_ERROR_SIGN_KEY(LogLevel.ERROR, R.string.msg_pse_error_sign_key),
|
||||
MSG_PSE_ERROR_KEY_SIGN (LogLevel.ERROR, R.string.msg_pse_error_key_sign),
|
||||
|
||||
@@ -43,7 +43,6 @@ import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.interfaces.RSAPrivateCrtKey;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -177,16 +176,6 @@ public class CanonicalizedSecretKey extends CanonicalizedPublicKey {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all supported hash algorithms.
|
||||
*/
|
||||
public ArrayList<Integer> getSupportedHashAlgorithms() {
|
||||
// TODO: intersection between preferred hash algos of this key and PgpConstants.PREFERRED_HASH_ALGORITHMS
|
||||
// choose best algo
|
||||
|
||||
return PgpConstants.sPreferredHashAlgorithms;
|
||||
}
|
||||
|
||||
private PGPContentSignerBuilder getContentSignerBuilder(int hashAlgo,
|
||||
Map<ByteBuffer,byte[]> signedHashes) {
|
||||
if (mPrivateKeyState == PRIVATE_KEY_STATE_DIVERT_TO_CARD) {
|
||||
@@ -205,7 +194,7 @@ public class CanonicalizedSecretKey extends CanonicalizedPublicKey {
|
||||
|
||||
public PGPSignatureGenerator getCertSignatureGenerator(Map<ByteBuffer, byte[]> signedHashes) {
|
||||
PGPContentSignerBuilder contentSignerBuilder = getContentSignerBuilder(
|
||||
PgpConstants.CERTIFY_HASH_ALGO, signedHashes);
|
||||
PgpSecurityConstants.CERTIFY_HASH_ALGO, signedHashes);
|
||||
|
||||
if (mPrivateKeyState == PRIVATE_KEY_STATE_LOCKED) {
|
||||
throw new PrivateKeyNotUnlockedException();
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.sufficientlysecure.keychain.pgp;
|
||||
|
||||
import org.openintents.openpgp.OpenPgpDecryptionResult;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
public class OpenPgpDecryptionResultBuilder {
|
||||
|
||||
// builder
|
||||
private boolean mInsecure = false;
|
||||
private boolean mEncrypted = false;
|
||||
|
||||
public void setInsecure(boolean insecure) {
|
||||
this.mInsecure = insecure;
|
||||
}
|
||||
|
||||
public void setEncrypted(boolean encrypted) {
|
||||
this.mEncrypted = encrypted;
|
||||
}
|
||||
|
||||
public OpenPgpDecryptionResult build() {
|
||||
OpenPgpDecryptionResult result = new OpenPgpDecryptionResult();
|
||||
|
||||
if (mInsecure) {
|
||||
Log.d(Constants.TAG, "RESULT_INSECURE");
|
||||
result.setResult(OpenPgpDecryptionResult.RESULT_INSECURE);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (mEncrypted) {
|
||||
Log.d(Constants.TAG, "RESULT_ENCRYPTED");
|
||||
result.setResult(OpenPgpDecryptionResult.RESULT_ENCRYPTED);
|
||||
} else {
|
||||
Log.d(Constants.TAG, "RESULT_NOT_ENCRYPTED");
|
||||
result.setResult(OpenPgpDecryptionResult.RESULT_NOT_ENCRYPTED);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -30,7 +30,6 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public class OpenPgpSignatureResultBuilder {
|
||||
// OpenPgpSignatureResult
|
||||
private boolean mSignatureOnly = false;
|
||||
private String mPrimaryUserId;
|
||||
private ArrayList<String> mUserIds = new ArrayList<>();
|
||||
private long mKeyId;
|
||||
@@ -42,10 +41,7 @@ public class OpenPgpSignatureResultBuilder {
|
||||
private boolean mIsSignatureKeyCertified = false;
|
||||
private boolean mIsKeyRevoked = false;
|
||||
private boolean mIsKeyExpired = false;
|
||||
|
||||
public void setSignatureOnly(boolean signatureOnly) {
|
||||
this.mSignatureOnly = signatureOnly;
|
||||
}
|
||||
private boolean mInsecure = false;
|
||||
|
||||
public void setPrimaryUserId(String userId) {
|
||||
this.mPrimaryUserId = userId;
|
||||
@@ -63,6 +59,10 @@ public class OpenPgpSignatureResultBuilder {
|
||||
this.mValidSignature = validSignature;
|
||||
}
|
||||
|
||||
public void setInsecure(boolean insecure) {
|
||||
this.mInsecure = insecure;
|
||||
}
|
||||
|
||||
public void setSignatureKeyCertified(boolean isSignatureKeyCertified) {
|
||||
this.mIsSignatureKeyCertified = isSignatureKeyCertified;
|
||||
}
|
||||
@@ -87,6 +87,10 @@ public class OpenPgpSignatureResultBuilder {
|
||||
return mValidSignature;
|
||||
}
|
||||
|
||||
public boolean isInsecure() {
|
||||
return mInsecure;
|
||||
}
|
||||
|
||||
public void initValid(CanonicalizedPublicKeyRing signingRing,
|
||||
CanonicalizedPublicKey signingKey) {
|
||||
setSignatureAvailable(true);
|
||||
@@ -109,47 +113,50 @@ public class OpenPgpSignatureResultBuilder {
|
||||
}
|
||||
|
||||
public OpenPgpSignatureResult build() {
|
||||
if (mSignatureAvailable) {
|
||||
OpenPgpSignatureResult result = new OpenPgpSignatureResult();
|
||||
result.setSignatureOnly(mSignatureOnly);
|
||||
|
||||
// valid sig!
|
||||
if (mKnownKey) {
|
||||
if (mValidSignature) {
|
||||
result.setKeyId(mKeyId);
|
||||
result.setPrimaryUserId(mPrimaryUserId);
|
||||
result.setUserIds(mUserIds);
|
||||
|
||||
if (mIsKeyRevoked) {
|
||||
Log.d(Constants.TAG, "SIGNATURE_KEY_REVOKED");
|
||||
result.setStatus(OpenPgpSignatureResult.SIGNATURE_KEY_REVOKED);
|
||||
} else if (mIsKeyExpired) {
|
||||
Log.d(Constants.TAG, "SIGNATURE_KEY_EXPIRED");
|
||||
result.setStatus(OpenPgpSignatureResult.SIGNATURE_KEY_EXPIRED);
|
||||
} else if (mIsSignatureKeyCertified) {
|
||||
Log.d(Constants.TAG, "SIGNATURE_SUCCESS_CERTIFIED");
|
||||
result.setStatus(OpenPgpSignatureResult.SIGNATURE_SUCCESS_CERTIFIED);
|
||||
} else {
|
||||
Log.d(Constants.TAG, "SIGNATURE_SUCCESS_UNCERTIFIED");
|
||||
result.setStatus(OpenPgpSignatureResult.SIGNATURE_SUCCESS_UNCERTIFIED);
|
||||
}
|
||||
} else {
|
||||
Log.d(Constants.TAG, "Error! Invalid signature.");
|
||||
result.setStatus(OpenPgpSignatureResult.SIGNATURE_ERROR);
|
||||
}
|
||||
} else {
|
||||
result.setKeyId(mKeyId);
|
||||
|
||||
Log.d(Constants.TAG, "SIGNATURE_KEY_MISSING");
|
||||
result.setStatus(OpenPgpSignatureResult.SIGNATURE_KEY_MISSING);
|
||||
}
|
||||
OpenPgpSignatureResult result = new OpenPgpSignatureResult();
|
||||
|
||||
if (!mSignatureAvailable) {
|
||||
Log.d(Constants.TAG, "RESULT_NO_SIGNATURE");
|
||||
result.setResult(OpenPgpSignatureResult.RESULT_NO_SIGNATURE);
|
||||
return result;
|
||||
} else {
|
||||
Log.d(Constants.TAG, "no signature found!");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!mKnownKey) {
|
||||
result.setKeyId(mKeyId);
|
||||
|
||||
Log.d(Constants.TAG, "RESULT_KEY_MISSING");
|
||||
result.setResult(OpenPgpSignatureResult.RESULT_KEY_MISSING);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!mValidSignature) {
|
||||
Log.d(Constants.TAG, "RESULT_INVALID_SIGNATURE");
|
||||
result.setResult(OpenPgpSignatureResult.RESULT_INVALID_SIGNATURE);
|
||||
return result;
|
||||
}
|
||||
|
||||
result.setKeyId(mKeyId);
|
||||
result.setPrimaryUserId(mPrimaryUserId);
|
||||
result.setUserIds(mUserIds);
|
||||
|
||||
if (mIsKeyRevoked) {
|
||||
Log.d(Constants.TAG, "RESULT_INVALID_KEY_REVOKED");
|
||||
result.setResult(OpenPgpSignatureResult.RESULT_INVALID_KEY_REVOKED);
|
||||
} else if (mIsKeyExpired) {
|
||||
Log.d(Constants.TAG, "RESULT_INVALID_KEY_EXPIRED");
|
||||
result.setResult(OpenPgpSignatureResult.RESULT_INVALID_KEY_EXPIRED);
|
||||
} else if (mInsecure) {
|
||||
Log.d(Constants.TAG, "RESULT_INVALID_INSECURE");
|
||||
result.setResult(OpenPgpSignatureResult.RESULT_INVALID_INSECURE);
|
||||
} else if (mIsSignatureKeyCertified) {
|
||||
Log.d(Constants.TAG, "RESULT_VALID_CONFIRMED");
|
||||
result.setResult(OpenPgpSignatureResult.RESULT_VALID_CONFIRMED);
|
||||
} else {
|
||||
Log.d(Constants.TAG, "RESULT_VALID_UNCONFIRMED");
|
||||
result.setResult(OpenPgpSignatureResult.RESULT_VALID_UNCONFIRMED);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.sufficientlysecure.keychain.pgp;
|
||||
|
||||
import org.spongycastle.bcpg.CompressionAlgorithmTags;
|
||||
import org.spongycastle.bcpg.HashAlgorithmTags;
|
||||
import org.spongycastle.bcpg.SymmetricKeyAlgorithmTags;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PgpConstants {
|
||||
|
||||
public static ArrayList<Integer> sPreferredSymmetricAlgorithms = new ArrayList<>();
|
||||
public static ArrayList<Integer> sPreferredHashAlgorithms = new ArrayList<>();
|
||||
public static ArrayList<Integer> sPreferredCompressionAlgorithms = new ArrayList<>();
|
||||
|
||||
// TODO: use hashmaps for contains in O(1) and intersections!
|
||||
|
||||
/*
|
||||
* Most preferred is first
|
||||
* These arrays are written as preferred algorithms into the keys on creation.
|
||||
* Other implementations may choose to honor this selection.
|
||||
*
|
||||
* These lists also define the only algorithms which are used in OpenKeychain.
|
||||
* We do not support algorithms such as MD5
|
||||
*/
|
||||
static {
|
||||
sPreferredSymmetricAlgorithms.add(SymmetricKeyAlgorithmTags.AES_256);
|
||||
sPreferredSymmetricAlgorithms.add(SymmetricKeyAlgorithmTags.AES_192);
|
||||
sPreferredSymmetricAlgorithms.add(SymmetricKeyAlgorithmTags.AES_128);
|
||||
sPreferredSymmetricAlgorithms.add(SymmetricKeyAlgorithmTags.TWOFISH);
|
||||
|
||||
// NOTE: some implementations do not support SHA512, thus we choose SHA256 as default (Mailvelope?)
|
||||
sPreferredHashAlgorithms.add(HashAlgorithmTags.SHA256);
|
||||
sPreferredHashAlgorithms.add(HashAlgorithmTags.SHA512);
|
||||
sPreferredHashAlgorithms.add(HashAlgorithmTags.SHA384);
|
||||
sPreferredHashAlgorithms.add(HashAlgorithmTags.SHA224);
|
||||
sPreferredHashAlgorithms.add(HashAlgorithmTags.SHA1);
|
||||
sPreferredHashAlgorithms.add(HashAlgorithmTags.RIPEMD160);
|
||||
|
||||
/*
|
||||
* Prefer ZIP
|
||||
* "ZLIB provides no benefit over ZIP and is more malleable"
|
||||
* - (OpenPGP WG mailinglist: "[openpgp] Intent to deprecate: Insecure primitives")
|
||||
* BZIP2: very slow
|
||||
*/
|
||||
sPreferredCompressionAlgorithms.add(CompressionAlgorithmTags.ZIP);
|
||||
sPreferredCompressionAlgorithms.add(CompressionAlgorithmTags.ZLIB);
|
||||
sPreferredCompressionAlgorithms.add(CompressionAlgorithmTags.BZIP2);
|
||||
}
|
||||
|
||||
public static final int CERTIFY_HASH_ALGO = HashAlgorithmTags.SHA256;
|
||||
|
||||
/*
|
||||
* Note: s2kcount is a number between 0 and 0xff that controls the
|
||||
* number of times to iterate the password hash before use. More
|
||||
* iterations are useful against offline attacks, as it takes more
|
||||
* time to check each password. The actual number of iterations is
|
||||
* rather complex, and also depends on the hash function in use.
|
||||
* Refer to Section 3.7.1.3 in rfc4880.txt. Bigger numbers give
|
||||
* you more iterations. As a rough rule of thumb, when using
|
||||
* SHA256 as the hashing function, 0x10 gives you about 64
|
||||
* iterations, 0x20 about 128, 0x30 about 256 and so on till 0xf0,
|
||||
* or about 1 million iterations. The maximum you can go to is
|
||||
* 0xff, or about 2 million iterations.
|
||||
* from http://kbsriram.com/2013/01/generating-rsa-keys-with-bouncycastle.html
|
||||
*
|
||||
* Bouncy Castle default: 0x60
|
||||
* kbsriram proposes: 0xc0
|
||||
* OpenKeychain: 0x90
|
||||
*/
|
||||
public static final int SECRET_KEY_ENCRYPTOR_S2K_COUNT = 0x90;
|
||||
public static final int SECRET_KEY_ENCRYPTOR_HASH_ALGO = HashAlgorithmTags.SHA256;
|
||||
public static final int SECRET_KEY_ENCRYPTOR_SYMMETRIC_ALGO = SymmetricKeyAlgorithmTags.AES_256;
|
||||
public static final int SECRET_KEY_SIGNATURE_HASH_ALGO = HashAlgorithmTags.SHA256;
|
||||
// NOTE: only SHA1 is supported for key checksum calculations in OpenPGP,
|
||||
// see http://tools.ietf.org/html/rfc488 0#section-5.5.3
|
||||
public static final int SECRET_KEY_SIGNATURE_CHECKSUM_HASH_ALGO = HashAlgorithmTags.SHA1;
|
||||
|
||||
public static interface OpenKeychainSymmetricKeyAlgorithmTags extends SymmetricKeyAlgorithmTags {
|
||||
public static final int USE_PREFERRED = -1;
|
||||
}
|
||||
|
||||
public static interface OpenKeychainHashAlgorithmTags extends HashAlgorithmTags {
|
||||
public static final int USE_PREFERRED = -1;
|
||||
}
|
||||
|
||||
public static interface OpenKeychainCompressionAlgorithmTags extends CompressionAlgorithmTags {
|
||||
public static final int USE_PREFERRED = -1;
|
||||
}
|
||||
|
||||
public static int[] getAsArray(ArrayList<Integer> list) {
|
||||
int[] array = new int[list.size()];
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
array[i] = list.get(i);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.webkit.MimeTypeMap;
|
||||
|
||||
import org.openintents.openpgp.OpenPgpDecryptionResult;
|
||||
import org.openintents.openpgp.OpenPgpMetadata;
|
||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
import org.spongycastle.bcpg.ArmoredInputStream;
|
||||
@@ -283,10 +284,6 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
PGPSignatureList signatureList = (PGPSignatureList) pgpF.nextObject();
|
||||
PGPSignature messageSignature = signatureList.get(signatureIndex);
|
||||
|
||||
// these are not cleartext signatures!
|
||||
// TODO: what about binary signatures?
|
||||
signatureResultBuilder.setSignatureOnly(false);
|
||||
|
||||
// Verify signature and check binding signatures
|
||||
boolean validSignature = signature.verify(messageSignature);
|
||||
if (validSignature) {
|
||||
@@ -298,8 +295,8 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
|
||||
OpenPgpSignatureResult signatureResult = signatureResultBuilder.build();
|
||||
|
||||
if (signatureResult.getStatus() != OpenPgpSignatureResult.SIGNATURE_SUCCESS_CERTIFIED
|
||||
&& signatureResult.getStatus() != OpenPgpSignatureResult.SIGNATURE_SUCCESS_UNCERTIFIED) {
|
||||
if (signatureResult.getResult() != OpenPgpSignatureResult.RESULT_VALID_CONFIRMED
|
||||
&& signatureResult.getResult() != OpenPgpSignatureResult.RESULT_VALID_UNCONFIRMED) {
|
||||
log.add(LogType.MSG_VL_ERROR_INTEGRITY_CHECK, indent);
|
||||
return new DecryptVerifyResult(DecryptVerifyResult.RESULT_ERROR, log);
|
||||
}
|
||||
@@ -309,9 +306,10 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
log.add(LogType.MSG_VL_OK, indent);
|
||||
|
||||
// Return a positive result, with metadata and verification info
|
||||
DecryptVerifyResult result =
|
||||
new DecryptVerifyResult(DecryptVerifyResult.RESULT_OK, log);
|
||||
DecryptVerifyResult result = new DecryptVerifyResult(DecryptVerifyResult.RESULT_OK, log);
|
||||
result.setSignatureResult(signatureResult);
|
||||
result.setDecryptionResult(
|
||||
new OpenPgpDecryptionResult(OpenPgpDecryptionResult.RESULT_NOT_ENCRYPTED));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -322,6 +320,8 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
PgpDecryptVerifyInputParcel input, CryptoInputParcel cryptoInput,
|
||||
InputStream in, OutputStream out, int indent) throws IOException, PGPException {
|
||||
|
||||
OpenPgpSignatureResultBuilder signatureResultBuilder = new OpenPgpSignatureResultBuilder();
|
||||
OpenPgpDecryptionResultBuilder decryptionResultBuilder = new OpenPgpDecryptionResultBuilder();
|
||||
OperationLog log = new OperationLog();
|
||||
|
||||
log.add(LogType.MSG_DC, indent);
|
||||
@@ -464,6 +464,12 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
}
|
||||
}
|
||||
|
||||
// check for insecure encryption key
|
||||
if ( ! PgpSecurityConstants.isSecureKey(secretEncryptionKey)) {
|
||||
log.add(LogType.MSG_DC_INSECURE_KEY, indent + 1);
|
||||
decryptionResultBuilder.setInsecure(true);
|
||||
}
|
||||
|
||||
// break out of while, only decrypt the first packet where we have a key
|
||||
break;
|
||||
|
||||
@@ -614,15 +620,16 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
log.add(LogType.MSG_DC_ERROR_NO_KEY, indent + 1);
|
||||
return new DecryptVerifyResult(DecryptVerifyResult.RESULT_ERROR, log);
|
||||
}
|
||||
decryptionResultBuilder.setEncrypted(true);
|
||||
|
||||
// Warn about old encryption algorithms!
|
||||
if (!PgpConstants.sPreferredSymmetricAlgorithms.contains(symmetricEncryptionAlgo)) {
|
||||
log.add(LogType.MSG_DC_OLD_SYMMETRIC_ENCRYPTION_ALGO, indent + 1);
|
||||
// Check for insecure encryption algorithms!
|
||||
if (!PgpSecurityConstants.isSecureSymmetricAlgorithm(symmetricEncryptionAlgo)) {
|
||||
log.add(LogType.MSG_DC_INSECURE_SYMMETRIC_ENCRYPTION_ALGO, indent + 1);
|
||||
decryptionResultBuilder.setInsecure(true);
|
||||
}
|
||||
|
||||
JcaPGPObjectFactory plainFact = new JcaPGPObjectFactory(clear);
|
||||
Object dataChunk = plainFact.nextObject();
|
||||
OpenPgpSignatureResultBuilder signatureResultBuilder = new OpenPgpSignatureResultBuilder();
|
||||
int signatureIndex = -1;
|
||||
CanonicalizedPublicKeyRing signingRing = null;
|
||||
CanonicalizedPublicKey signingKey = null;
|
||||
@@ -686,6 +693,13 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
}
|
||||
}
|
||||
|
||||
// check for insecure signing key
|
||||
// TODO: checks on signingRing ?
|
||||
if (signingKey != null && ! PgpSecurityConstants.isSecureKey(signingKey)) {
|
||||
log.add(LogType.MSG_DC_INSECURE_KEY, indent + 1);
|
||||
signatureResultBuilder.setInsecure(true);
|
||||
}
|
||||
|
||||
dataChunk = plainFact.nextObject();
|
||||
}
|
||||
|
||||
@@ -752,7 +766,7 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
DecryptVerifyResult result =
|
||||
new DecryptVerifyResult(DecryptVerifyResult.RESULT_OK, log);
|
||||
result.setCharset(charset);
|
||||
result.setDecryptMetadata(metadata);
|
||||
result.setDecryptionMetadata(metadata);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -809,11 +823,9 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
PGPSignatureList signatureList = (PGPSignatureList) plainFact.nextObject();
|
||||
PGPSignature messageSignature = signatureList.get(signatureIndex);
|
||||
|
||||
// these are not cleartext signatures!
|
||||
// TODO: what about binary signatures?
|
||||
signatureResultBuilder.setSignatureOnly(false);
|
||||
|
||||
// Verify signature and check binding signatures
|
||||
// Verify signature
|
||||
boolean validSignature = signature.verify(messageSignature);
|
||||
if (validSignature) {
|
||||
log.add(LogType.MSG_DC_CLEAR_SIGNATURE_OK, indent + 1);
|
||||
@@ -821,10 +833,10 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
log.add(LogType.MSG_DC_CLEAR_SIGNATURE_BAD, indent + 1);
|
||||
}
|
||||
|
||||
// Don't allow verification of old hash algorithms!
|
||||
if (!PgpConstants.sPreferredHashAlgorithms.contains(signature.getHashAlgorithm())) {
|
||||
validSignature = false;
|
||||
log.add(LogType.MSG_DC_ERROR_UNSUPPORTED_HASH_ALGO, indent + 1);
|
||||
// check for insecure hash algorithms
|
||||
if (!PgpSecurityConstants.isSecureHashAlgorithm(signature.getHashAlgorithm())) {
|
||||
log.add(LogType.MSG_DC_INSECURE_HASH_ALGO, indent + 1);
|
||||
signatureResultBuilder.setInsecure(true);
|
||||
}
|
||||
|
||||
signatureResultBuilder.setValidSignature(validSignature);
|
||||
@@ -851,8 +863,8 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
// The MDC packet can be stripped by an attacker!
|
||||
Log.d(Constants.TAG, "MDC fail");
|
||||
if (!signatureResultBuilder.isValidSignature()) {
|
||||
log.add(LogType.MSG_DC_ERROR_INTEGRITY_MISSING, indent);
|
||||
return new DecryptVerifyResult(DecryptVerifyResult.RESULT_ERROR, log);
|
||||
log.add(LogType.MSG_DC_INSECURE_MDC_MISSING, indent);
|
||||
decryptionResultBuilder.setInsecure(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -861,12 +873,12 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
log.add(LogType.MSG_DC_OK, indent);
|
||||
|
||||
// Return a positive result, with metadata and verification info
|
||||
DecryptVerifyResult result =
|
||||
new DecryptVerifyResult(DecryptVerifyResult.RESULT_OK, log);
|
||||
DecryptVerifyResult result = new DecryptVerifyResult(DecryptVerifyResult.RESULT_OK, log);
|
||||
result.setCachedCryptoInputParcel(cryptoInput);
|
||||
result.setDecryptMetadata(metadata);
|
||||
result.setSignatureResult(signatureResultBuilder.build());
|
||||
result.setCharset(charset);
|
||||
result.setDecryptionResult(decryptionResultBuilder.build());
|
||||
result.setDecryptionMetadata(metadata);
|
||||
return result;
|
||||
|
||||
}
|
||||
@@ -885,8 +897,6 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
OperationLog log = new OperationLog();
|
||||
|
||||
OpenPgpSignatureResultBuilder signatureResultBuilder = new OpenPgpSignatureResultBuilder();
|
||||
// cleartext signatures are never encrypted ;)
|
||||
signatureResultBuilder.setSignatureOnly(true);
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
||||
@@ -924,7 +934,7 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
return new DecryptVerifyResult(DecryptVerifyResult.RESULT_ERROR, log);
|
||||
}
|
||||
|
||||
PGPSignature signature = processPGPSignatureList(sigList, signatureResultBuilder);
|
||||
PGPSignature signature = processPGPSignatureList(sigList, signatureResultBuilder, log, indent);
|
||||
|
||||
if (signature != null) {
|
||||
try {
|
||||
@@ -956,10 +966,10 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
log.add(LogType.MSG_DC_CLEAR_SIGNATURE_BAD, indent + 1);
|
||||
}
|
||||
|
||||
// Don't allow verification of old hash algorithms!
|
||||
if (!PgpConstants.sPreferredHashAlgorithms.contains(signature.getHashAlgorithm())) {
|
||||
validSignature = false;
|
||||
log.add(LogType.MSG_DC_ERROR_UNSUPPORTED_HASH_ALGO, indent + 1);
|
||||
// check for insecure hash algorithms
|
||||
if (!PgpSecurityConstants.isSecureHashAlgorithm(signature.getHashAlgorithm())) {
|
||||
log.add(LogType.MSG_DC_INSECURE_HASH_ALGO, indent + 1);
|
||||
signatureResultBuilder.setInsecure(true);
|
||||
}
|
||||
|
||||
signatureResultBuilder.setValidSignature(validSignature);
|
||||
@@ -981,8 +991,10 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
clearText.length);
|
||||
|
||||
DecryptVerifyResult result = new DecryptVerifyResult(DecryptVerifyResult.RESULT_OK, log);
|
||||
result.setDecryptMetadata(metadata);
|
||||
result.setSignatureResult(signatureResultBuilder.build());
|
||||
result.setDecryptionResult(
|
||||
new OpenPgpDecryptionResult(OpenPgpDecryptionResult.RESULT_NOT_ENCRYPTED));
|
||||
result.setDecryptionMetadata(metadata);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -994,8 +1006,6 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
OperationLog log = new OperationLog();
|
||||
|
||||
OpenPgpSignatureResultBuilder signatureResultBuilder = new OpenPgpSignatureResultBuilder();
|
||||
// detached signatures are never encrypted
|
||||
signatureResultBuilder.setSignatureOnly(true);
|
||||
|
||||
updateProgress(R.string.progress_processing_signature, 0, 100);
|
||||
InputStream detachedSigIn = new ByteArrayInputStream(input.getDetachedSignature());
|
||||
@@ -1016,7 +1026,7 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
return new DecryptVerifyResult(DecryptVerifyResult.RESULT_ERROR, log);
|
||||
}
|
||||
|
||||
PGPSignature signature = processPGPSignatureList(sigList, signatureResultBuilder);
|
||||
PGPSignature signature = processPGPSignatureList(sigList, signatureResultBuilder, log, indent);
|
||||
|
||||
if (signature != null) {
|
||||
updateProgress(R.string.progress_reading_data, 60, 100);
|
||||
@@ -1050,9 +1060,6 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
updateProgress(R.string.progress_verifying_signature, 90, 100);
|
||||
log.add(LogType.MSG_DC_CLEAR_SIGNATURE_CHECK, indent);
|
||||
|
||||
// these are not cleartext signatures!
|
||||
signatureResultBuilder.setSignatureOnly(false);
|
||||
|
||||
// Verify signature and check binding signatures
|
||||
boolean validSignature = signature.verify();
|
||||
if (validSignature) {
|
||||
@@ -1061,10 +1068,10 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
log.add(LogType.MSG_DC_CLEAR_SIGNATURE_BAD, indent + 1);
|
||||
}
|
||||
|
||||
// Don't allow verification of old hash algorithms!
|
||||
if (!PgpConstants.sPreferredHashAlgorithms.contains(signature.getHashAlgorithm())) {
|
||||
validSignature = false;
|
||||
log.add(LogType.MSG_DC_ERROR_UNSUPPORTED_HASH_ALGO, indent + 1);
|
||||
// check for insecure hash algorithms
|
||||
if (!PgpSecurityConstants.isSecureHashAlgorithm(signature.getHashAlgorithm())) {
|
||||
log.add(LogType.MSG_DC_INSECURE_HASH_ALGO, indent + 1);
|
||||
signatureResultBuilder.setInsecure(true);
|
||||
}
|
||||
|
||||
signatureResultBuilder.setValidSignature(validSignature);
|
||||
@@ -1076,11 +1083,14 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
|
||||
DecryptVerifyResult result = new DecryptVerifyResult(DecryptVerifyResult.RESULT_OK, log);
|
||||
result.setSignatureResult(signatureResultBuilder.build());
|
||||
result.setDecryptionResult(
|
||||
new OpenPgpDecryptionResult(OpenPgpDecryptionResult.RESULT_NOT_ENCRYPTED));
|
||||
return result;
|
||||
}
|
||||
|
||||
private PGPSignature processPGPSignatureList(
|
||||
PGPSignatureList sigList, OpenPgpSignatureResultBuilder signatureResultBuilder)
|
||||
PGPSignatureList sigList, OpenPgpSignatureResultBuilder signatureResultBuilder,
|
||||
OperationLog log, int indent)
|
||||
throws PGPException {
|
||||
CanonicalizedPublicKeyRing signingRing = null;
|
||||
CanonicalizedPublicKey signingKey = null;
|
||||
@@ -1122,6 +1132,13 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
||||
}
|
||||
}
|
||||
|
||||
// check for insecure signing key
|
||||
// TODO: checks on signingRing ?
|
||||
if (signingKey != null && ! PgpSecurityConstants.isSecureKey(signingKey)) {
|
||||
log.add(LogType.MSG_DC_INSECURE_KEY, indent + 1);
|
||||
signatureResultBuilder.setInsecure(true);
|
||||
}
|
||||
|
||||
return signature;
|
||||
}
|
||||
|
||||
|
||||
@@ -316,14 +316,14 @@ public class PgpKeyOperation {
|
||||
|
||||
// Build key encrypter and decrypter based on passphrase
|
||||
PGPDigestCalculator encryptorHashCalc = new JcaPGPDigestCalculatorProviderBuilder()
|
||||
.build().get(PgpConstants.SECRET_KEY_ENCRYPTOR_HASH_ALGO);
|
||||
.build().get(PgpSecurityConstants.SECRET_KEY_ENCRYPTOR_HASH_ALGO);
|
||||
PBESecretKeyEncryptor keyEncryptor = new JcePBESecretKeyEncryptorBuilder(
|
||||
PgpConstants.SECRET_KEY_ENCRYPTOR_SYMMETRIC_ALGO,
|
||||
encryptorHashCalc, PgpConstants.SECRET_KEY_ENCRYPTOR_S2K_COUNT)
|
||||
PgpSecurityConstants.SECRET_KEY_ENCRYPTOR_SYMMETRIC_ALGO,
|
||||
encryptorHashCalc, PgpSecurityConstants.SECRET_KEY_ENCRYPTOR_S2K_COUNT)
|
||||
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build("".toCharArray());
|
||||
|
||||
PGPDigestCalculator sha1Calc = new JcaPGPDigestCalculatorProviderBuilder()
|
||||
.build().get(PgpConstants.SECRET_KEY_SIGNATURE_CHECKSUM_HASH_ALGO);
|
||||
.build().get(PgpSecurityConstants.SECRET_KEY_SIGNATURE_CHECKSUM_HASH_ALGO);
|
||||
PGPSecretKey masterSecretKey = new PGPSecretKey(keyPair.getPrivateKey(), keyPair.getPublicKey(),
|
||||
sha1Calc, true, keyEncryptor);
|
||||
|
||||
@@ -1021,15 +1021,15 @@ public class PgpKeyOperation {
|
||||
PGPSecretKey sKey; {
|
||||
// Build key encrypter and decrypter based on passphrase
|
||||
PGPDigestCalculator encryptorHashCalc = new JcaPGPDigestCalculatorProviderBuilder()
|
||||
.build().get(PgpConstants.SECRET_KEY_ENCRYPTOR_HASH_ALGO);
|
||||
.build().get(PgpSecurityConstants.SECRET_KEY_ENCRYPTOR_HASH_ALGO);
|
||||
PBESecretKeyEncryptor keyEncryptor = new JcePBESecretKeyEncryptorBuilder(
|
||||
PgpConstants.SECRET_KEY_ENCRYPTOR_SYMMETRIC_ALGO, encryptorHashCalc,
|
||||
PgpConstants.SECRET_KEY_ENCRYPTOR_S2K_COUNT)
|
||||
PgpSecurityConstants.SECRET_KEY_ENCRYPTOR_SYMMETRIC_ALGO, encryptorHashCalc,
|
||||
PgpSecurityConstants.SECRET_KEY_ENCRYPTOR_S2K_COUNT)
|
||||
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(
|
||||
cryptoInput.getPassphrase().getCharArray());
|
||||
|
||||
PGPDigestCalculator sha1Calc = new JcaPGPDigestCalculatorProviderBuilder()
|
||||
.build().get(PgpConstants.SECRET_KEY_SIGNATURE_CHECKSUM_HASH_ALGO);
|
||||
.build().get(PgpSecurityConstants.SECRET_KEY_SIGNATURE_CHECKSUM_HASH_ALGO);
|
||||
sKey = new PGPSecretKey(keyPair.getPrivateKey(), pKey, sha1Calc, false, keyEncryptor);
|
||||
}
|
||||
|
||||
@@ -1206,7 +1206,7 @@ public class PgpKeyOperation {
|
||||
// add packet with EMPTY notation data (updates old one, but will be stripped later)
|
||||
PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder(
|
||||
masterPrivateKey.getPublicKeyPacket().getAlgorithm(),
|
||||
PgpConstants.SECRET_KEY_SIGNATURE_HASH_ALGO)
|
||||
PgpSecurityConstants.SECRET_KEY_BINDING_SIGNATURE_HASH_ALGO)
|
||||
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME);
|
||||
PGPSignatureGenerator sGen = new PGPSignatureGenerator(signerBuilder);
|
||||
{ // set subpackets
|
||||
@@ -1233,7 +1233,7 @@ public class PgpKeyOperation {
|
||||
// add packet with "pin" notation data
|
||||
PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder(
|
||||
masterPrivateKey.getPublicKeyPacket().getAlgorithm(),
|
||||
PgpConstants.SECRET_KEY_SIGNATURE_HASH_ALGO)
|
||||
PgpSecurityConstants.SECRET_KEY_BINDING_SIGNATURE_HASH_ALGO)
|
||||
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME);
|
||||
PGPSignatureGenerator sGen = new PGPSignatureGenerator(signerBuilder);
|
||||
{ // set subpackets
|
||||
@@ -1280,13 +1280,13 @@ public class PgpKeyOperation {
|
||||
OperationLog log, int indent) throws PGPException {
|
||||
|
||||
PGPDigestCalculator encryptorHashCalc = new JcaPGPDigestCalculatorProviderBuilder().build()
|
||||
.get(PgpConstants.SECRET_KEY_ENCRYPTOR_HASH_ALGO);
|
||||
.get(PgpSecurityConstants.SECRET_KEY_ENCRYPTOR_HASH_ALGO);
|
||||
PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider(
|
||||
Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(passphrase.getCharArray());
|
||||
// Build key encryptor based on new passphrase
|
||||
PBESecretKeyEncryptor keyEncryptorNew = new JcePBESecretKeyEncryptorBuilder(
|
||||
PgpConstants.SECRET_KEY_ENCRYPTOR_SYMMETRIC_ALGO, encryptorHashCalc,
|
||||
PgpConstants.SECRET_KEY_ENCRYPTOR_S2K_COUNT)
|
||||
PgpSecurityConstants.SECRET_KEY_ENCRYPTOR_SYMMETRIC_ALGO, encryptorHashCalc,
|
||||
PgpSecurityConstants.SECRET_KEY_ENCRYPTOR_S2K_COUNT)
|
||||
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(newPassphrase.getCharArray());
|
||||
|
||||
// noinspection unchecked
|
||||
@@ -1440,13 +1440,13 @@ public class PgpKeyOperation {
|
||||
if (divertToCard) {
|
||||
// use synchronous "NFC based" SignerBuilder
|
||||
builder = new NfcSyncPGPContentSignerBuilder(
|
||||
pKey.getAlgorithm(), PgpConstants.SECRET_KEY_SIGNATURE_HASH_ALGO,
|
||||
pKey.getAlgorithm(), PgpSecurityConstants.SECRET_KEY_BINDING_SIGNATURE_HASH_ALGO,
|
||||
pKey.getKeyID(), cryptoInput.getCryptoData())
|
||||
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME);
|
||||
} else {
|
||||
// content signer based on signing key algorithm and chosen hash algorithm
|
||||
builder = new JcaPGPContentSignerBuilder(
|
||||
pKey.getAlgorithm(), PgpConstants.SECRET_KEY_SIGNATURE_HASH_ALGO)
|
||||
pKey.getAlgorithm(), PgpSecurityConstants.SECRET_KEY_BINDING_SIGNATURE_HASH_ALGO)
|
||||
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME);
|
||||
}
|
||||
|
||||
@@ -1472,11 +1472,11 @@ public class PgpKeyOperation {
|
||||
*/
|
||||
/* non-critical subpackets: */
|
||||
hashedPacketsGen.setPreferredSymmetricAlgorithms(false,
|
||||
PgpConstants.getAsArray(PgpConstants.sPreferredSymmetricAlgorithms));
|
||||
PgpSecurityConstants.PREFERRED_SYMMETRIC_ALGORITHMS);
|
||||
hashedPacketsGen.setPreferredHashAlgorithms(false,
|
||||
PgpConstants.getAsArray(PgpConstants.sPreferredHashAlgorithms));
|
||||
PgpSecurityConstants.PREFERRED_HASH_ALGORITHMS);
|
||||
hashedPacketsGen.setPreferredCompressionAlgorithms(false,
|
||||
PgpConstants.getAsArray(PgpConstants.sPreferredCompressionAlgorithms));
|
||||
PgpSecurityConstants.PREFERRED_COMPRESSION_ALGORITHMS);
|
||||
hashedPacketsGen.setPrimaryUserID(false, primary);
|
||||
|
||||
/* critical subpackets: we consider those important for a modern pgp implementation */
|
||||
|
||||
@@ -0,0 +1,262 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.sufficientlysecure.keychain.pgp;
|
||||
|
||||
import org.spongycastle.asn1.nist.NISTNamedCurves;
|
||||
import org.spongycastle.bcpg.CompressionAlgorithmTags;
|
||||
import org.spongycastle.bcpg.HashAlgorithmTags;
|
||||
import org.spongycastle.bcpg.PublicKeyAlgorithmTags;
|
||||
import org.spongycastle.bcpg.SymmetricKeyAlgorithmTags;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* NIST requirements for 2011-2030 (http://www.keylength.com/en/4/):
|
||||
* - RSA: 2048 bit
|
||||
* - ECC: 224 bit
|
||||
* - Symmetric: 3TDEA
|
||||
* - Digital Signature (hash A): SHA-224 - SHA-512
|
||||
*
|
||||
* Extreme Decisions for Yahoo's End-to-End:
|
||||
* https://github.com/yahoo/end-to-end/issues/31
|
||||
* https://gist.github.com/coruus/68a8c65571e2b4225a69
|
||||
*/
|
||||
public class PgpSecurityConstants {
|
||||
|
||||
/**
|
||||
* Whitelist of accepted symmetric encryption algorithms
|
||||
* all other algorithms are rejected with OpenPgpDecryptionResult.RESULT_INSECURE
|
||||
*/
|
||||
private static HashSet<Integer> sSymmetricAlgorithmsWhitelist = new HashSet<>();
|
||||
static {
|
||||
// General remarks: We try to keep the whitelist short to reduce attack surface
|
||||
// TODO: block IDEA?: Bad key schedule (weak keys), implementation difficulties (easy to make errors)
|
||||
sSymmetricAlgorithmsWhitelist.add(SymmetricKeyAlgorithmTags.IDEA);
|
||||
sSymmetricAlgorithmsWhitelist.add(SymmetricKeyAlgorithmTags.TRIPLE_DES); // a MUST in RFC
|
||||
sSymmetricAlgorithmsWhitelist.add(SymmetricKeyAlgorithmTags.CAST5); // default in many gpg, pgp versions, 128 bit key
|
||||
// BLOWFISH: Twofish is the successor
|
||||
// SAFER: not used widely
|
||||
// DES: < 128 bit security
|
||||
sSymmetricAlgorithmsWhitelist.add(SymmetricKeyAlgorithmTags.AES_128);
|
||||
sSymmetricAlgorithmsWhitelist.add(SymmetricKeyAlgorithmTags.AES_192);
|
||||
sSymmetricAlgorithmsWhitelist.add(SymmetricKeyAlgorithmTags.AES_256);
|
||||
sSymmetricAlgorithmsWhitelist.add(SymmetricKeyAlgorithmTags.TWOFISH); // 128 bit
|
||||
// CAMELLIA_128: not used widely
|
||||
// CAMELLIA_192: not used widely
|
||||
// CAMELLIA_256: not used widely
|
||||
}
|
||||
|
||||
public static boolean isSecureSymmetricAlgorithm(int id) {
|
||||
return sSymmetricAlgorithmsWhitelist.contains(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whitelist of accepted hash algorithms
|
||||
* all other algorithms are rejected with OpenPgpSignatureResult.RESULT_INSECURE
|
||||
*
|
||||
* coorus:
|
||||
* Implementations SHOULD use SHA-512 for RSA or DSA signatures. They SHOULD NOT use SHA-384.
|
||||
* ((cite to affine padding attacks; unproven status of RSA-PKCSv15))
|
||||
*
|
||||
* Implementations MUST NOT sign SHA-224 hashes. They SHOULD NOT accept signatures over SHA-224 hashes.
|
||||
* ((collision resistance of 112-bits))
|
||||
* Implementations SHOULD NOT sign SHA-256 hashes. They MUST NOT default to signing SHA-256 hashes.
|
||||
*/
|
||||
private static HashSet<Integer> sHashAlgorithmsWhitelist = new HashSet<>();
|
||||
static {
|
||||
// MD5: broken
|
||||
// SHA1: broken
|
||||
// RIPEMD160: same security properties as SHA1
|
||||
// DOUBLE_SHA: not used widely
|
||||
// MD2: not used widely
|
||||
// TIGER_192: not used widely
|
||||
// HAVAL_5_160: not used widely
|
||||
sHashAlgorithmsWhitelist.add(HashAlgorithmTags.SHA256); // compatibility for old Mailvelope versions
|
||||
sHashAlgorithmsWhitelist.add(HashAlgorithmTags.SHA384);
|
||||
sHashAlgorithmsWhitelist.add(HashAlgorithmTags.SHA512);
|
||||
// SHA224: Not used widely, Yahoo argues against it
|
||||
}
|
||||
|
||||
public static boolean isSecureHashAlgorithm(int id) {
|
||||
return sHashAlgorithmsWhitelist.contains(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whitelist of accepted asymmetric algorithms in switch statement
|
||||
* all other algorithms are rejected with OpenPgpSignatureResult.RESULT_INSECURE or
|
||||
* OpenPgpDecryptionResult.RESULT_INSECURE
|
||||
*
|
||||
* coorus:
|
||||
* Implementations MUST NOT accept, or treat any signature as valid, by an RSA key with
|
||||
* bitlength less than 1023 bits.
|
||||
* Implementations MUST NOT accept any RSA keys with bitlength less than 2047 bits after January 1, 2016.
|
||||
*/
|
||||
private static HashSet<String> sCurveWhitelist = new HashSet<>();
|
||||
static {
|
||||
sCurveWhitelist.add(NISTNamedCurves.getOID("P-256").getId());
|
||||
sCurveWhitelist.add(NISTNamedCurves.getOID("P-384").getId());
|
||||
sCurveWhitelist.add(NISTNamedCurves.getOID("P-521").getId());
|
||||
}
|
||||
|
||||
public static boolean isSecureKey(CanonicalizedPublicKey key) {
|
||||
switch (key.getAlgorithm()) {
|
||||
case PublicKeyAlgorithmTags.RSA_GENERAL: {
|
||||
return (key.getBitStrength() >= 2048);
|
||||
}
|
||||
// RSA_ENCRYPT, RSA_SIGN: deprecated in RFC 4880, use RSA_GENERAL with key flags
|
||||
case PublicKeyAlgorithmTags.ELGAMAL_ENCRYPT: {
|
||||
return (key.getBitStrength() >= 2048);
|
||||
}
|
||||
case PublicKeyAlgorithmTags.DSA: {
|
||||
return (key.getBitStrength() >= 2048);
|
||||
}
|
||||
case PublicKeyAlgorithmTags.ECDH:
|
||||
case PublicKeyAlgorithmTags.ECDSA: {
|
||||
return PgpSecurityConstants.sCurveWhitelist.contains(key.getCurveOid());
|
||||
}
|
||||
// ELGAMAL_GENERAL: deprecated in RFC 4880, use ELGAMAL_ENCRYPT
|
||||
// DIFFIE_HELLMAN: unsure
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* These array is written as a list of preferred encryption algorithms into keys created by us.
|
||||
* Other implementations may choose to honor this selection.
|
||||
* (Most preferred is first)
|
||||
*
|
||||
* REASON: See corresponding whitelist. AES received most cryptanalysis over the years
|
||||
* and is still secure!
|
||||
*/
|
||||
public static final int[] PREFERRED_SYMMETRIC_ALGORITHMS = new int[]{
|
||||
SymmetricKeyAlgorithmTags.AES_256,
|
||||
SymmetricKeyAlgorithmTags.AES_192,
|
||||
SymmetricKeyAlgorithmTags.AES_128,
|
||||
};
|
||||
|
||||
/**
|
||||
* These array is written as a list of preferred hash algorithms into keys created by us.
|
||||
* Other implementations may choose to honor this selection.
|
||||
* (Most preferred is first)
|
||||
*
|
||||
* REASON: See corresponding whitelist. If possible use SHA-512, this is state of the art!
|
||||
*/
|
||||
public static final int[] PREFERRED_HASH_ALGORITHMS = new int[]{
|
||||
HashAlgorithmTags.SHA512,
|
||||
};
|
||||
|
||||
/**
|
||||
* These array is written as a list of preferred compression algorithms into keys created by us.
|
||||
* Other implementations may choose to honor this selection.
|
||||
* (Most preferred is first)
|
||||
*
|
||||
* REASON: See DEFAULT_COMPRESSION_ALGORITHM
|
||||
*/
|
||||
public static final int[] PREFERRED_COMPRESSION_ALGORITHMS = new int[]{
|
||||
CompressionAlgorithmTags.ZIP,
|
||||
};
|
||||
|
||||
/**
|
||||
* Hash algorithm used to certify public keys
|
||||
*/
|
||||
public static final int CERTIFY_HASH_ALGO = HashAlgorithmTags.SHA512;
|
||||
|
||||
|
||||
/**
|
||||
* Always use AES-256! We always ignore the preferred encryption algos of the recipient!
|
||||
*
|
||||
* coorus:
|
||||
* Implementations SHOULD ignore the symmetric algorithm preferences of a recipient's public key;
|
||||
* in particular, implementations MUST NOT choose an algorithm forbidden by this
|
||||
* document because a recipient prefers it.
|
||||
*
|
||||
* NEEDCITE downgrade attacks on TLS, other protocols
|
||||
*/
|
||||
public static final int DEFAULT_SYMMETRIC_ALGORITHM = SymmetricKeyAlgorithmTags.AES_256;
|
||||
|
||||
public interface OpenKeychainSymmetricKeyAlgorithmTags extends SymmetricKeyAlgorithmTags {
|
||||
int USE_DEFAULT = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Always use SHA-512! We always ignore the preferred hash algos of the recipient!
|
||||
*
|
||||
* coorus:
|
||||
* Implementations MUST ignore the hash algorithm preferences of a recipient when signing
|
||||
* a message to a recipient. The difficulty of forging a signature under a given key,
|
||||
* using generic attacks on hash functions, is the difficulty of the weakest hash signed by that key.
|
||||
*
|
||||
* Implementations MUST default to using SHA-512 for RSA signatures,
|
||||
*
|
||||
* and either SHA-512 or the matched instance of SHA-2 for ECDSA signatures.
|
||||
* TODO: Ed25519
|
||||
* CITE: zooko's hash function table CITE: distinguishers on SHA-256
|
||||
*/
|
||||
public static final int DEFAULT_HASH_ALGORITHM = HashAlgorithmTags.SHA512;
|
||||
|
||||
public interface OpenKeychainHashAlgorithmTags extends HashAlgorithmTags {
|
||||
int USE_DEFAULT = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compression is disabled by default.
|
||||
*
|
||||
* The default compression algorithm is only used if explicitly enabled in the activity's
|
||||
* overflow menu or via the OpenPGP API's extra OpenPgpApi.EXTRA_ENABLE_COMPRESSION
|
||||
*
|
||||
* REASON: Enabling compression can lead to a sidechannel. Consider a voting that is done via
|
||||
* OpenPGP. Compression can lead to different ciphertext lengths based on the user's voting.
|
||||
* This has happened in a voting done by Wikipedia (Google it).
|
||||
*
|
||||
* ZLIB: the format provides no benefits over DEFLATE, and is more malleable
|
||||
* BZIP2: very slow
|
||||
*/
|
||||
public static final int DEFAULT_COMPRESSION_ALGORITHM = CompressionAlgorithmTags.ZIP;
|
||||
|
||||
public interface OpenKeychainCompressionAlgorithmTags extends CompressionAlgorithmTags {
|
||||
int USE_DEFAULT = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: s2kcount is a number between 0 and 0xff that controls the
|
||||
* number of times to iterate the password hash before use. More
|
||||
* iterations are useful against offline attacks, as it takes more
|
||||
* time to check each password. The actual number of iterations is
|
||||
* rather complex, and also depends on the hash function in use.
|
||||
* Refer to Section 3.7.1.3 in rfc4880.txt. Bigger numbers give
|
||||
* you more iterations. As a rough rule of thumb, when using
|
||||
* SHA256 as the hashing function, 0x10 gives you about 64
|
||||
* iterations, 0x20 about 128, 0x30 about 256 and so on till 0xf0,
|
||||
* or about 1 million iterations. The maximum you can go to is
|
||||
* 0xff, or about 2 million iterations.
|
||||
* from http://kbsriram.com/2013/01/generating-rsa-keys-with-bouncycastle.html
|
||||
*
|
||||
* Bouncy Castle default: 0x60
|
||||
* kbsriram proposes: 0xc0
|
||||
* Yahoo's End-to-End: 96 (65536 iterations) (https://github.com/yahoo/end-to-end/blob/master/src/javascript/crypto/e2e/openpgp/keyring.js)
|
||||
*/
|
||||
public static final int SECRET_KEY_ENCRYPTOR_S2K_COUNT = 96;
|
||||
public static final int SECRET_KEY_ENCRYPTOR_HASH_ALGO = HashAlgorithmTags.SHA512;
|
||||
public static final int SECRET_KEY_ENCRYPTOR_SYMMETRIC_ALGO = SymmetricKeyAlgorithmTags.AES_256;
|
||||
public static final int SECRET_KEY_BINDING_SIGNATURE_HASH_ALGO = HashAlgorithmTags.SHA512;
|
||||
// NOTE: only SHA1 is supported for key checksum calculations in OpenPGP,
|
||||
// see http://tools.ietf.org/html/rfc488 0#section-5.5.3
|
||||
public static final int SECRET_KEY_SIGNATURE_CHECKSUM_HASH_ALGO = HashAlgorithmTags.SHA1;
|
||||
|
||||
}
|
||||
@@ -30,19 +30,20 @@ public class PgpSignEncryptInputParcel implements Parcelable {
|
||||
|
||||
protected String mVersionHeader = null;
|
||||
protected boolean mEnableAsciiArmorOutput = false;
|
||||
protected int mCompressionId = CompressionAlgorithmTags.UNCOMPRESSED;
|
||||
protected int mCompressionAlgorithm = CompressionAlgorithmTags.UNCOMPRESSED;
|
||||
protected long[] mEncryptionMasterKeyIds = null;
|
||||
protected Passphrase mSymmetricPassphrase = null;
|
||||
protected int mSymmetricEncryptionAlgorithm = PgpConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_PREFERRED;
|
||||
protected int mSymmetricEncryptionAlgorithm = PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_DEFAULT;
|
||||
protected long mSignatureMasterKeyId = Constants.key.none;
|
||||
protected Long mSignatureSubKeyId = null;
|
||||
protected int mSignatureHashAlgorithm = PgpConstants.OpenKeychainHashAlgorithmTags.USE_PREFERRED;
|
||||
protected int mSignatureHashAlgorithm = PgpSecurityConstants.OpenKeychainHashAlgorithmTags.USE_DEFAULT;
|
||||
protected long mAdditionalEncryptId = Constants.key.none;
|
||||
protected boolean mFailOnMissingEncryptionKeyIds = false;
|
||||
protected String mCharset;
|
||||
protected boolean mCleartextSignature;
|
||||
protected boolean mDetachedSignature = false;
|
||||
protected boolean mHiddenRecipients = false;
|
||||
protected boolean mIntegrityProtected = true;
|
||||
|
||||
public PgpSignEncryptInputParcel() {
|
||||
|
||||
@@ -55,7 +56,7 @@ public class PgpSignEncryptInputParcel implements Parcelable {
|
||||
// we do all of those here, so the PgpSignEncryptInput class doesn't have to be parcelable
|
||||
mVersionHeader = source.readString();
|
||||
mEnableAsciiArmorOutput = source.readInt() == 1;
|
||||
mCompressionId = source.readInt();
|
||||
mCompressionAlgorithm = source.readInt();
|
||||
mEncryptionMasterKeyIds = source.createLongArray();
|
||||
mSymmetricPassphrase = source.readParcelable(loader);
|
||||
mSymmetricEncryptionAlgorithm = source.readInt();
|
||||
@@ -68,6 +69,7 @@ public class PgpSignEncryptInputParcel implements Parcelable {
|
||||
mCleartextSignature = source.readInt() == 1;
|
||||
mDetachedSignature = source.readInt() == 1;
|
||||
mHiddenRecipients = source.readInt() == 1;
|
||||
mIntegrityProtected = source.readInt() == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,7 +81,7 @@ public class PgpSignEncryptInputParcel implements Parcelable {
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(mVersionHeader);
|
||||
dest.writeInt(mEnableAsciiArmorOutput ? 1 : 0);
|
||||
dest.writeInt(mCompressionId);
|
||||
dest.writeInt(mCompressionAlgorithm);
|
||||
dest.writeLongArray(mEncryptionMasterKeyIds);
|
||||
dest.writeParcelable(mSymmetricPassphrase, 0);
|
||||
dest.writeInt(mSymmetricEncryptionAlgorithm);
|
||||
@@ -97,6 +99,7 @@ public class PgpSignEncryptInputParcel implements Parcelable {
|
||||
dest.writeInt(mCleartextSignature ? 1 : 0);
|
||||
dest.writeInt(mDetachedSignature ? 1 : 0);
|
||||
dest.writeInt(mHiddenRecipients ? 1 : 0);
|
||||
dest.writeInt(mIntegrityProtected ? 1 : 0);
|
||||
}
|
||||
|
||||
public String getCharset() {
|
||||
@@ -174,12 +177,12 @@ public class PgpSignEncryptInputParcel implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getCompressionId() {
|
||||
return mCompressionId;
|
||||
public int getCompressionAlgorithm() {
|
||||
return mCompressionAlgorithm;
|
||||
}
|
||||
|
||||
public PgpSignEncryptInputParcel setCompressionId(int compressionId) {
|
||||
mCompressionId = compressionId;
|
||||
public PgpSignEncryptInputParcel setCompressionAlgorithm(int compressionAlgorithm) {
|
||||
mCompressionAlgorithm = compressionAlgorithm;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -229,6 +232,18 @@ public class PgpSignEncryptInputParcel implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isIntegrityProtected() {
|
||||
return mIntegrityProtected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only use for testing! Never disable integrity protection!
|
||||
*/
|
||||
public PgpSignEncryptInputParcel setIntegrityProtected(boolean integrityProtected) {
|
||||
this.mIntegrityProtected = integrityProtected;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isHiddenRecipients() {
|
||||
return mHiddenRecipients;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.SignatureException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
@@ -124,7 +123,7 @@ public class PgpSignEncryptOperation extends BaseOperation {
|
||||
boolean enableSignature = input.getSignatureMasterKeyId() != Constants.key.none;
|
||||
boolean enableEncryption = ((input.getEncryptionMasterKeyIds() != null && input.getEncryptionMasterKeyIds().length > 0)
|
||||
|| input.getSymmetricPassphrase() != null);
|
||||
boolean enableCompression = (input.getCompressionId() != CompressionAlgorithmTags.UNCOMPRESSED);
|
||||
boolean enableCompression = (input.getCompressionAlgorithm() != CompressionAlgorithmTags.UNCOMPRESSED);
|
||||
|
||||
Log.d(Constants.TAG, "enableSignature:" + enableSignature
|
||||
+ "\nenableEncryption:" + enableEncryption
|
||||
@@ -226,15 +225,10 @@ public class PgpSignEncryptOperation extends BaseOperation {
|
||||
return new PgpSignEncryptResult(PgpSignEncryptResult.RESULT_ERROR, log);
|
||||
}
|
||||
|
||||
// Use preferred hash algo
|
||||
// Use requested hash algo
|
||||
int requestedAlgorithm = input.getSignatureHashAlgorithm();
|
||||
ArrayList<Integer> supported = signingKey.getSupportedHashAlgorithms();
|
||||
if (requestedAlgorithm == PgpConstants.OpenKeychainHashAlgorithmTags.USE_PREFERRED) {
|
||||
// get most preferred
|
||||
input.setSignatureHashAlgorithm(supported.get(0));
|
||||
} else if (!supported.contains(requestedAlgorithm)) {
|
||||
log.add(LogType.MSG_PSE_ERROR_HASH_ALGO, indent);
|
||||
return new PgpSignEncryptResult(PgpSignEncryptResult.RESULT_ERROR, log);
|
||||
if (requestedAlgorithm == PgpSecurityConstants.OpenKeychainHashAlgorithmTags.USE_DEFAULT) {
|
||||
input.setSignatureHashAlgorithm(PgpSecurityConstants.DEFAULT_HASH_ALGORITHM);
|
||||
}
|
||||
}
|
||||
updateProgress(R.string.progress_preparing_streams, 2, 100);
|
||||
@@ -243,18 +237,15 @@ public class PgpSignEncryptOperation extends BaseOperation {
|
||||
PGPEncryptedDataGenerator cPk = null;
|
||||
if (enableEncryption) {
|
||||
|
||||
// Use preferred encryption algo
|
||||
// Use requested encryption algo
|
||||
int algo = input.getSymmetricEncryptionAlgorithm();
|
||||
if (algo == PgpConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_PREFERRED) {
|
||||
// get most preferred
|
||||
// TODO: get from recipients
|
||||
algo = PgpConstants.sPreferredSymmetricAlgorithms.get(0);
|
||||
if (algo == PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_DEFAULT) {
|
||||
algo = PgpSecurityConstants.DEFAULT_SYMMETRIC_ALGORITHM;
|
||||
}
|
||||
// has Integrity packet enabled!
|
||||
JcePGPDataEncryptorBuilder encryptorBuilder =
|
||||
new JcePGPDataEncryptorBuilder(algo)
|
||||
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME)
|
||||
.setWithIntegrityPacket(true);
|
||||
.setWithIntegrityPacket(input.isIntegrityProtected());
|
||||
|
||||
cPk = new PGPEncryptedDataGenerator(encryptorBuilder);
|
||||
|
||||
@@ -341,7 +332,13 @@ public class PgpSignEncryptOperation extends BaseOperation {
|
||||
|
||||
if (enableCompression) {
|
||||
log.add(LogType.MSG_PSE_COMPRESSING, indent);
|
||||
compressGen = new PGPCompressedDataGenerator(input.getCompressionId());
|
||||
|
||||
// Use preferred compression algo
|
||||
int algo = input.getCompressionAlgorithm();
|
||||
if (algo == PgpSecurityConstants.OpenKeychainCompressionAlgorithmTags.USE_DEFAULT) {
|
||||
algo = PgpSecurityConstants.DEFAULT_COMPRESSION_ALGORITHM;
|
||||
}
|
||||
compressGen = new PGPCompressedDataGenerator(algo);
|
||||
bcpgOut = new BCPGOutputStream(compressGen.open(encryptionOut));
|
||||
} else {
|
||||
bcpgOut = new BCPGOutputStream(encryptionOut);
|
||||
@@ -464,7 +461,7 @@ public class PgpSignEncryptOperation extends BaseOperation {
|
||||
InputStream in = inputData.getInputStream();
|
||||
|
||||
if (enableCompression) {
|
||||
compressGen = new PGPCompressedDataGenerator(input.getCompressionId());
|
||||
compressGen = new PGPCompressedDataGenerator(input.getCompressionAlgorithm());
|
||||
bcpgOut = new BCPGOutputStream(compressGen.open(out));
|
||||
} else {
|
||||
bcpgOut = new BCPGOutputStream(out);
|
||||
|
||||
@@ -211,12 +211,19 @@ public class UncachedPublicKey {
|
||||
return getAlgorithm() == PGPPublicKey.ELGAMAL_ENCRYPT;
|
||||
}
|
||||
|
||||
public boolean isRSA() {
|
||||
return getAlgorithm() == PGPPublicKey.RSA_GENERAL
|
||||
|| getAlgorithm() == PGPPublicKey.RSA_ENCRYPT
|
||||
|| getAlgorithm() == PGPPublicKey.RSA_SIGN;
|
||||
}
|
||||
|
||||
public boolean isDSA() {
|
||||
return getAlgorithm() == PGPPublicKey.DSA;
|
||||
}
|
||||
|
||||
public boolean isEC() {
|
||||
return getAlgorithm() == PGPPublicKey.ECDH || getAlgorithm() == PGPPublicKey.ECDSA;
|
||||
return getAlgorithm() == PGPPublicKey.ECDH
|
||||
|| getAlgorithm() == PGPPublicKey.ECDSA;
|
||||
}
|
||||
|
||||
public byte[] getFingerprint() {
|
||||
|
||||
@@ -45,7 +45,7 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpConstants;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpSecurityConstants;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedPublicKey;
|
||||
@@ -1434,9 +1434,9 @@ public class ProviderHelper {
|
||||
// DEPRECATED and thus hardcoded
|
||||
values.put(KeychainContract.ApiAccounts.COMPRESSION, CompressionAlgorithmTags.ZLIB);
|
||||
values.put(KeychainContract.ApiAccounts.ENCRYPTION_ALGORITHM,
|
||||
PgpConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_PREFERRED);
|
||||
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_DEFAULT);
|
||||
values.put(KeychainContract.ApiAccounts.HASH_ALORITHM,
|
||||
PgpConstants.OpenKeychainHashAlgorithmTags.USE_PREFERRED);
|
||||
PgpSecurityConstants.OpenKeychainHashAlgorithmTags.USE_DEFAULT);
|
||||
return values;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013-2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
* Copyright (C) 2013-2015 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -24,19 +24,20 @@ import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.IBinder;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.openintents.openpgp.IOpenPgpService;
|
||||
import org.openintents.openpgp.OpenPgpDecryptionResult;
|
||||
import org.openintents.openpgp.OpenPgpError;
|
||||
import org.openintents.openpgp.OpenPgpMetadata;
|
||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
import org.openintents.openpgp.util.OpenPgpApi;
|
||||
import org.spongycastle.bcpg.CompressionAlgorithmTags;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogEntryParcel;
|
||||
import org.sufficientlysecure.keychain.operations.results.PgpSignEncryptResult;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpConstants;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpSecurityConstants;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyInputParcel;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpSignEncryptInputParcel;
|
||||
@@ -247,7 +248,7 @@ public class OpenPgpService extends RemoteService {
|
||||
.setCleartextSignature(cleartextSign)
|
||||
.setDetachedSignature(!cleartextSign)
|
||||
.setVersionHeader(null)
|
||||
.setSignatureHashAlgorithm(PgpConstants.OpenKeychainHashAlgorithmTags.USE_PREFERRED);
|
||||
.setSignatureHashAlgorithm(PgpSecurityConstants.OpenKeychainHashAlgorithmTags.USE_DEFAULT);
|
||||
|
||||
Intent signKeyIdIntent = getSignKeyMasterId(data);
|
||||
// NOTE: Fallback to return account settings (Old API)
|
||||
@@ -358,9 +359,9 @@ public class OpenPgpService extends RemoteService {
|
||||
boolean enableCompression = data.getBooleanExtra(OpenPgpApi.EXTRA_ENABLE_COMPRESSION, true);
|
||||
int compressionId;
|
||||
if (enableCompression) {
|
||||
compressionId = CompressionAlgorithmTags.ZLIB;
|
||||
compressionId = PgpSecurityConstants.OpenKeychainCompressionAlgorithmTags.USE_DEFAULT;
|
||||
} else {
|
||||
compressionId = CompressionAlgorithmTags.UNCOMPRESSED;
|
||||
compressionId = PgpSecurityConstants.OpenKeychainCompressionAlgorithmTags.UNCOMPRESSED;
|
||||
}
|
||||
|
||||
// first try to get key ids from non-ambiguous key id extra
|
||||
@@ -390,8 +391,8 @@ public class OpenPgpService extends RemoteService {
|
||||
PgpSignEncryptInputParcel pseInput = new PgpSignEncryptInputParcel();
|
||||
pseInput.setEnableAsciiArmorOutput(asciiArmor)
|
||||
.setVersionHeader(null)
|
||||
.setCompressionId(compressionId)
|
||||
.setSymmetricEncryptionAlgorithm(PgpConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_PREFERRED)
|
||||
.setCompressionAlgorithm(compressionId)
|
||||
.setSymmetricEncryptionAlgorithm(PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_DEFAULT)
|
||||
.setEncryptionMasterKeyIds(keyIds)
|
||||
.setFailOnMissingEncryptionKeyIds(true);
|
||||
|
||||
@@ -420,7 +421,7 @@ public class OpenPgpService extends RemoteService {
|
||||
}
|
||||
|
||||
// sign and encrypt
|
||||
pseInput.setSignatureHashAlgorithm(PgpConstants.OpenKeychainHashAlgorithmTags.USE_PREFERRED)
|
||||
pseInput.setSignatureHashAlgorithm(PgpSecurityConstants.OpenKeychainHashAlgorithmTags.USE_DEFAULT)
|
||||
.setAdditionalEncryptId(signKeyId); // add sign key for encryption
|
||||
}
|
||||
|
||||
@@ -540,10 +541,10 @@ public class OpenPgpService extends RemoteService {
|
||||
// allow only private keys associated with accounts of this app
|
||||
// no support for symmetric encryption
|
||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel()
|
||||
.setAllowSymmetricDecryption(false)
|
||||
.setAllowedKeyIds(allowedKeyIds)
|
||||
.setDecryptMetadataOnly(decryptMetadataOnly)
|
||||
.setDetachedSignature(detachedSignature);
|
||||
.setAllowSymmetricDecryption(false)
|
||||
.setAllowedKeyIds(allowedKeyIds)
|
||||
.setDecryptMetadataOnly(decryptMetadataOnly)
|
||||
.setDetachedSignature(detachedSignature);
|
||||
|
||||
DecryptVerifyResult pgpResult = op.execute(input, cryptoInput, inputData, outputStream);
|
||||
|
||||
@@ -562,40 +563,55 @@ public class OpenPgpService extends RemoteService {
|
||||
Intent result = new Intent();
|
||||
|
||||
OpenPgpSignatureResult signatureResult = pgpResult.getSignatureResult();
|
||||
// TODO: currently RESULT_TYPE_UNENCRYPTED_UNSIGNED is never returned
|
||||
// instead an error is returned when no pgp data has been found
|
||||
int resultType = OpenPgpApi.RESULT_TYPE_UNENCRYPTED_UNSIGNED;
|
||||
if (signatureResult != null) {
|
||||
resultType |= OpenPgpApi.RESULT_TYPE_SIGNED;
|
||||
if (!signatureResult.isSignatureOnly()) {
|
||||
resultType |= OpenPgpApi.RESULT_TYPE_ENCRYPTED;
|
||||
}
|
||||
|
||||
result.putExtra(OpenPgpApi.RESULT_SIGNATURE, signatureResult);
|
||||
result.putExtra(OpenPgpApi.RESULT_SIGNATURE, signatureResult);
|
||||
|
||||
if (data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) < 5) {
|
||||
// SIGNATURE_KEY_REVOKED and SIGNATURE_KEY_EXPIRED have been added in version 5
|
||||
if (signatureResult.getStatus() == OpenPgpSignatureResult.SIGNATURE_KEY_REVOKED
|
||||
|| signatureResult.getStatus() == OpenPgpSignatureResult.SIGNATURE_KEY_EXPIRED) {
|
||||
signatureResult.setStatus(OpenPgpSignatureResult.SIGNATURE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
if (signatureResult.getStatus() == OpenPgpSignatureResult.SIGNATURE_KEY_MISSING) {
|
||||
// If signature is unknown we return an _additional_ PendingIntent
|
||||
// to retrieve the missing key
|
||||
result.putExtra(OpenPgpApi.RESULT_INTENT, getKeyserverPendingIntent(data, signatureResult.getKeyId()));
|
||||
} else {
|
||||
// If signature key is known, return PendingIntent to show key
|
||||
result.putExtra(OpenPgpApi.RESULT_INTENT, getShowKeyPendingIntent(signatureResult.getKeyId()));
|
||||
}
|
||||
if (signatureResult.getResult() == OpenPgpSignatureResult.RESULT_KEY_MISSING) {
|
||||
// If signature is unknown we return an _additional_ PendingIntent
|
||||
// to retrieve the missing key
|
||||
result.putExtra(OpenPgpApi.RESULT_INTENT, getKeyserverPendingIntent(data, signatureResult.getKeyId()));
|
||||
} else {
|
||||
resultType |= OpenPgpApi.RESULT_TYPE_ENCRYPTED;
|
||||
// If signature key is known, return PendingIntent to show key
|
||||
result.putExtra(OpenPgpApi.RESULT_INTENT, getShowKeyPendingIntent(signatureResult.getKeyId()));
|
||||
}
|
||||
result.putExtra(OpenPgpApi.RESULT_TYPE, resultType);
|
||||
|
||||
if (data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) < 5) {
|
||||
// RESULT_INVALID_KEY_REVOKED and RESULT_INVALID_KEY_EXPIRED have been added in version 5
|
||||
if (signatureResult.getResult() == OpenPgpSignatureResult.RESULT_INVALID_KEY_REVOKED
|
||||
|| signatureResult.getResult() == OpenPgpSignatureResult.RESULT_INVALID_KEY_EXPIRED) {
|
||||
signatureResult.setResult(OpenPgpSignatureResult.RESULT_INVALID_SIGNATURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) < 8) {
|
||||
// RESULT_INVALID_INSECURE has been added in version 8, fallback to RESULT_INVALID_SIGNATURE
|
||||
if (signatureResult.getResult() == OpenPgpSignatureResult.RESULT_INVALID_INSECURE) {
|
||||
signatureResult.setResult(OpenPgpSignatureResult.RESULT_INVALID_SIGNATURE);
|
||||
}
|
||||
|
||||
// RESULT_NO_SIGNATURE has been added in version 8, before the signatureResult was null
|
||||
if (signatureResult.getResult() == OpenPgpSignatureResult.RESULT_NO_SIGNATURE) {
|
||||
result.putExtra(OpenPgpApi.RESULT_SIGNATURE, (Parcelable[]) null);
|
||||
}
|
||||
|
||||
OpenPgpDecryptionResult decryptionResult = pgpResult.getDecryptionResult();
|
||||
if (decryptionResult.getResult() != OpenPgpDecryptionResult.RESULT_ENCRYPTED
|
||||
&& signatureResult.getResult() != OpenPgpSignatureResult.RESULT_NO_SIGNATURE) {
|
||||
// not encrypted and signed, set deprecated signatureOnly variable
|
||||
signatureResult.setSignatureOnly(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) >= 8) {
|
||||
OpenPgpDecryptionResult decryptionResult = pgpResult.getDecryptionResult();
|
||||
if (decryptionResult != null) {
|
||||
result.putExtra(OpenPgpApi.RESULT_DECRYPTION, decryptionResult);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) >= 4) {
|
||||
OpenPgpMetadata metadata = pgpResult.getDecryptMetadata();
|
||||
OpenPgpMetadata metadata = pgpResult.getDecryptionMetadata();
|
||||
if (metadata != null) {
|
||||
result.putExtra(OpenPgpApi.RESULT_METADATA, metadata);
|
||||
}
|
||||
@@ -647,6 +663,7 @@ public class OpenPgpService extends RemoteService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Intent getKeyImpl(Intent data) {
|
||||
|
||||
@@ -36,6 +36,7 @@ import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ViewAnimator;
|
||||
|
||||
import org.openintents.openpgp.OpenPgpDecryptionResult;
|
||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
@@ -208,37 +209,50 @@ public abstract class DecryptFragment extends Fragment implements LoaderManager.
|
||||
|
||||
mDecryptVerifyResult = decryptVerifyResult;
|
||||
mSignatureResult = decryptVerifyResult.getSignatureResult();
|
||||
OpenPgpDecryptionResult decryptionResult = decryptVerifyResult.getDecryptionResult();
|
||||
|
||||
mResultLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
// unsigned data
|
||||
if (mSignatureResult == null) {
|
||||
switch (decryptionResult.getResult()) {
|
||||
case OpenPgpDecryptionResult.RESULT_ENCRYPTED: {
|
||||
mEncryptionText.setText(R.string.decrypt_result_encrypted);
|
||||
KeyFormattingUtils.setStatusImage(getActivity(), mEncryptionIcon, mEncryptionText, State.ENCRYPTED);
|
||||
break;
|
||||
}
|
||||
|
||||
case OpenPgpDecryptionResult.RESULT_INSECURE: {
|
||||
mEncryptionText.setText(R.string.decrypt_result_insecure);
|
||||
KeyFormattingUtils.setStatusImage(getActivity(), mEncryptionIcon, mEncryptionText, State.INSECURE);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
case OpenPgpDecryptionResult.RESULT_NOT_ENCRYPTED: {
|
||||
mEncryptionText.setText(R.string.decrypt_result_not_encrypted);
|
||||
KeyFormattingUtils.setStatusImage(getActivity(), mEncryptionIcon, mEncryptionText, State.NOT_ENCRYPTED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mSignatureResult.getResult() == OpenPgpSignatureResult.RESULT_NO_SIGNATURE) {
|
||||
// no signature
|
||||
|
||||
setSignatureLayoutVisibility(View.GONE);
|
||||
|
||||
mSignatureText.setText(R.string.decrypt_result_no_signature);
|
||||
KeyFormattingUtils.setStatusImage(getActivity(), mSignatureIcon, mSignatureText, State.NOT_SIGNED);
|
||||
mEncryptionText.setText(R.string.decrypt_result_encrypted);
|
||||
KeyFormattingUtils.setStatusImage(getActivity(), mEncryptionIcon, mEncryptionText, State.ENCRYPTED);
|
||||
|
||||
getLoaderManager().destroyLoader(LOADER_ID_UNIFIED);
|
||||
|
||||
showErrorOverlay(false);
|
||||
|
||||
onVerifyLoaded(true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (mSignatureResult.isSignatureOnly()) {
|
||||
mEncryptionText.setText(R.string.decrypt_result_not_encrypted);
|
||||
KeyFormattingUtils.setStatusImage(getActivity(), mEncryptionIcon, mEncryptionText, State.NOT_ENCRYPTED);
|
||||
} else {
|
||||
mEncryptionText.setText(R.string.decrypt_result_encrypted);
|
||||
KeyFormattingUtils.setStatusImage(getActivity(), mEncryptionIcon, mEncryptionText, State.ENCRYPTED);
|
||||
}
|
||||
// signature present
|
||||
|
||||
getLoaderManager().restartLoader(LOADER_ID_UNIFIED, null, this);
|
||||
// after loader is restarted signature results are checked
|
||||
getLoaderManager().restartLoader(LOADER_ID_UNIFIED, null, this);
|
||||
}
|
||||
}
|
||||
|
||||
private void setSignatureLayoutVisibility(int visibility) {
|
||||
@@ -313,8 +327,9 @@ public abstract class DecryptFragment extends Fragment implements LoaderManager.
|
||||
|
||||
// NOTE: Don't use revoked and expired fields from database, they don't show
|
||||
// revoked/expired subkeys
|
||||
boolean isRevoked = mSignatureResult.getStatus() == OpenPgpSignatureResult.SIGNATURE_KEY_REVOKED;
|
||||
boolean isExpired = mSignatureResult.getStatus() == OpenPgpSignatureResult.SIGNATURE_KEY_EXPIRED;
|
||||
boolean isRevoked = mSignatureResult.getResult() == OpenPgpSignatureResult.RESULT_INVALID_KEY_REVOKED;
|
||||
boolean isExpired = mSignatureResult.getResult() == OpenPgpSignatureResult.RESULT_INVALID_KEY_EXPIRED;
|
||||
boolean isInsecure = mSignatureResult.getResult() == OpenPgpSignatureResult.RESULT_INVALID_INSECURE;
|
||||
boolean isVerified = data.getInt(INDEX_VERIFIED) > 0;
|
||||
boolean isYours = data.getInt(INDEX_HAS_ANY_SECRET) != 0;
|
||||
|
||||
@@ -338,6 +353,17 @@ public abstract class DecryptFragment extends Fragment implements LoaderManager.
|
||||
|
||||
onVerifyLoaded(true);
|
||||
|
||||
} else if (isInsecure) {
|
||||
mSignatureText.setText(R.string.decrypt_result_insecure_cryptography);
|
||||
KeyFormattingUtils.setStatusImage(getActivity(), mSignatureIcon, mSignatureText, State.INSECURE);
|
||||
|
||||
setSignatureLayoutVisibility(View.VISIBLE);
|
||||
setShowAction(signatureKeyId);
|
||||
|
||||
showErrorOverlay(false);
|
||||
|
||||
onVerifyLoaded(true);
|
||||
|
||||
} else if (isYours) {
|
||||
|
||||
mSignatureText.setText(R.string.decrypt_result_signature_secret);
|
||||
@@ -389,9 +415,9 @@ public abstract class DecryptFragment extends Fragment implements LoaderManager.
|
||||
|
||||
final long signatureKeyId = mSignatureResult.getKeyId();
|
||||
|
||||
int result = mSignatureResult.getStatus();
|
||||
if (result != OpenPgpSignatureResult.SIGNATURE_KEY_MISSING
|
||||
&& result != OpenPgpSignatureResult.SIGNATURE_ERROR) {
|
||||
int result = mSignatureResult.getResult();
|
||||
if (result != OpenPgpSignatureResult.RESULT_KEY_MISSING
|
||||
&& result != OpenPgpSignatureResult.RESULT_INVALID_SIGNATURE) {
|
||||
Log.e(Constants.TAG, "got missing status for non-missing key, shouldn't happen!");
|
||||
}
|
||||
|
||||
@@ -409,9 +435,9 @@ public abstract class DecryptFragment extends Fragment implements LoaderManager.
|
||||
getActivity(), mSignatureResult.getKeyId()));
|
||||
}
|
||||
|
||||
switch (mSignatureResult.getStatus()) {
|
||||
switch (mSignatureResult.getResult()) {
|
||||
|
||||
case OpenPgpSignatureResult.SIGNATURE_KEY_MISSING: {
|
||||
case OpenPgpSignatureResult.RESULT_KEY_MISSING: {
|
||||
mSignatureText.setText(R.string.decrypt_result_signature_missing_key);
|
||||
KeyFormattingUtils.setStatusImage(getActivity(), mSignatureIcon, mSignatureText, State.UNKNOWN_KEY);
|
||||
|
||||
@@ -433,7 +459,7 @@ public abstract class DecryptFragment extends Fragment implements LoaderManager.
|
||||
break;
|
||||
}
|
||||
|
||||
case OpenPgpSignatureResult.SIGNATURE_ERROR: {
|
||||
case OpenPgpSignatureResult.RESULT_INVALID_SIGNATURE: {
|
||||
mSignatureText.setText(R.string.decrypt_result_invalid_signature);
|
||||
KeyFormattingUtils.setStatusImage(getActivity(), mSignatureIcon, mSignatureText, State.INVALID);
|
||||
|
||||
|
||||
@@ -321,11 +321,11 @@ public class DecryptListFragment
|
||||
protected Drawable doInBackground(Void... params) {
|
||||
|
||||
Context context = getActivity();
|
||||
if (result.getDecryptMetadata() == null || context == null) {
|
||||
if (result.getDecryptionMetadata() == null || context == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String type = result.getDecryptMetadata().getMimeType();
|
||||
String type = result.getDecryptionMetadata().getMimeType();
|
||||
Uri outputUri = mOutputUris.get(uri);
|
||||
if (type == null || outputUri == null) {
|
||||
return null;
|
||||
@@ -368,7 +368,7 @@ public class DecryptListFragment
|
||||
OpenPgpSignatureResult sigResult = result.getSignatureResult();
|
||||
if (sigResult != null) {
|
||||
final long keyId = sigResult.getKeyId();
|
||||
if (sigResult.getStatus() != OpenPgpSignatureResult.SIGNATURE_KEY_MISSING) {
|
||||
if (sigResult.getResult() != OpenPgpSignatureResult.RESULT_KEY_MISSING) {
|
||||
onKeyClick = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
@@ -384,7 +384,7 @@ public class DecryptListFragment
|
||||
}
|
||||
}
|
||||
|
||||
if (result.success() && result.getDecryptMetadata() != null) {
|
||||
if (result.success() && result.getDecryptionMetadata() != null) {
|
||||
onFileClick = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
@@ -425,7 +425,7 @@ public class DecryptListFragment
|
||||
return;
|
||||
}
|
||||
|
||||
final OpenPgpMetadata metadata = result.getDecryptMetadata();
|
||||
final OpenPgpMetadata metadata = result.getDecryptionMetadata();
|
||||
|
||||
// text/plain is a special case where we extract the uri content into
|
||||
// the EXTRA_TEXT extra ourselves, and display a chooser which includes
|
||||
@@ -529,7 +529,7 @@ public class DecryptListFragment
|
||||
activity.startActivity(intent);
|
||||
return true;
|
||||
case R.id.decrypt_save:
|
||||
OpenPgpMetadata metadata = result.getDecryptMetadata();
|
||||
OpenPgpMetadata metadata = result.getDecryptionMetadata();
|
||||
if (metadata == null) {
|
||||
return true;
|
||||
}
|
||||
@@ -724,7 +724,7 @@ public class DecryptListFragment
|
||||
|
||||
KeyFormattingUtils.setStatus(mContext, holder, model.mResult);
|
||||
|
||||
final OpenPgpMetadata metadata = model.mResult.getDecryptMetadata();
|
||||
final OpenPgpMetadata metadata = model.mResult.getDecryptionMetadata();
|
||||
|
||||
String filename;
|
||||
if (metadata == null) {
|
||||
|
||||
@@ -50,12 +50,11 @@ import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.spongycastle.bcpg.CompressionAlgorithmTags;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.operations.results.SignEncryptResult;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpConstants;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpSecurityConstants;
|
||||
import org.sufficientlysecure.keychain.pgp.SignEncryptParcel;
|
||||
import org.sufficientlysecure.keychain.provider.TemporaryStorageProvider;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
@@ -553,14 +552,18 @@ public class EncryptFilesFragment
|
||||
data.addInputUris(mFilesAdapter.getAsArrayList());
|
||||
|
||||
if (mUseCompression) {
|
||||
data.setCompressionId(PgpConstants.sPreferredCompressionAlgorithms.get(0));
|
||||
data.setCompressionAlgorithm(
|
||||
PgpSecurityConstants.OpenKeychainCompressionAlgorithmTags.USE_DEFAULT);
|
||||
} else {
|
||||
data.setCompressionId(CompressionAlgorithmTags.UNCOMPRESSED);
|
||||
data.setCompressionAlgorithm(
|
||||
PgpSecurityConstants.OpenKeychainCompressionAlgorithmTags.UNCOMPRESSED);
|
||||
}
|
||||
data.setHiddenRecipients(mHiddenRecipients);
|
||||
data.setEnableAsciiArmorOutput(mAfterEncryptAction == AfterEncryptAction.COPY || mUseArmor);
|
||||
data.setSymmetricEncryptionAlgorithm(PgpConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_PREFERRED);
|
||||
data.setSignatureHashAlgorithm(PgpConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_PREFERRED);
|
||||
data.setSymmetricEncryptionAlgorithm(
|
||||
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_DEFAULT);
|
||||
data.setSignatureHashAlgorithm(
|
||||
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_DEFAULT);
|
||||
|
||||
EncryptActivity encryptActivity = (EncryptActivity) getActivity();
|
||||
EncryptModeFragment modeFragment = encryptActivity.getModeFragment();
|
||||
|
||||
@@ -33,12 +33,11 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.spongycastle.bcpg.CompressionAlgorithmTags;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.operations.results.SignEncryptResult;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpConstants;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpSecurityConstants;
|
||||
import org.sufficientlysecure.keychain.pgp.SignEncryptParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.ui.base.CachingCryptoOperationFragment;
|
||||
@@ -223,15 +222,17 @@ public class EncryptTextFragment
|
||||
data.setCleartextSignature(true);
|
||||
|
||||
if (mUseCompression) {
|
||||
data.setCompressionId(PgpConstants.sPreferredCompressionAlgorithms.get(0));
|
||||
data.setCompressionAlgorithm(
|
||||
PgpSecurityConstants.OpenKeychainCompressionAlgorithmTags.USE_DEFAULT);
|
||||
} else {
|
||||
data.setCompressionId(CompressionAlgorithmTags.UNCOMPRESSED);
|
||||
data.setCompressionAlgorithm(
|
||||
PgpSecurityConstants.OpenKeychainCompressionAlgorithmTags.UNCOMPRESSED);
|
||||
}
|
||||
data.setHiddenRecipients(mHiddenRecipients);
|
||||
data.setSymmetricEncryptionAlgorithm(
|
||||
PgpConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_PREFERRED);
|
||||
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_DEFAULT);
|
||||
data.setSignatureHashAlgorithm(
|
||||
PgpConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_PREFERRED);
|
||||
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_DEFAULT);
|
||||
|
||||
// Always use armor for messages
|
||||
data.setEnableAsciiArmorOutput(true);
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.openintents.openpgp.OpenPgpDecryptionResult;
|
||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
import org.spongycastle.asn1.ASN1ObjectIdentifier;
|
||||
import org.spongycastle.asn1.nist.NISTNamedCurves;
|
||||
@@ -40,7 +41,6 @@ import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Curve;
|
||||
import org.sufficientlysecure.keychain.ui.util.FormattingUtils;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -408,7 +408,8 @@ public class KeyFormattingUtils {
|
||||
UNVERIFIED,
|
||||
UNKNOWN_KEY,
|
||||
INVALID,
|
||||
NOT_SIGNED
|
||||
NOT_SIGNED,
|
||||
INSECURE
|
||||
}
|
||||
|
||||
public static void setStatusImage(Context context, ImageView statusIcon, State state) {
|
||||
@@ -443,18 +444,33 @@ public class KeyFormattingUtils {
|
||||
@SuppressWarnings("deprecation") // context.getDrawable is api lvl 21, need to use deprecated
|
||||
public static void setStatus(Context context, StatusHolder holder, DecryptVerifyResult result) {
|
||||
|
||||
OpenPgpSignatureResult signatureResult = result.getSignatureResult();
|
||||
|
||||
if (holder.hasEncrypt()) {
|
||||
OpenPgpDecryptionResult decryptionResult = result.getDecryptionResult();
|
||||
|
||||
int encText, encIcon, encColor;
|
||||
if (signatureResult != null && signatureResult.isSignatureOnly()) {
|
||||
encIcon = R.drawable.status_lock_open_24dp;
|
||||
encText = R.string.decrypt_result_not_encrypted;
|
||||
encColor = R.color.key_flag_red;
|
||||
} else {
|
||||
encIcon = R.drawable.status_lock_closed_24dp;
|
||||
encText = R.string.decrypt_result_encrypted;
|
||||
encColor = R.color.key_flag_green;
|
||||
|
||||
switch (decryptionResult.getResult()) {
|
||||
case OpenPgpDecryptionResult.RESULT_ENCRYPTED: {
|
||||
encText = R.string.decrypt_result_encrypted;
|
||||
encIcon = R.drawable.status_lock_closed_24dp;
|
||||
encColor = R.color.key_flag_green;
|
||||
break;
|
||||
}
|
||||
|
||||
case OpenPgpDecryptionResult.RESULT_INSECURE: {
|
||||
encText = R.string.decrypt_result_insecure;
|
||||
encIcon = R.drawable.status_signature_invalid_cutout_24dp;
|
||||
encColor = R.color.key_flag_red;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
case OpenPgpDecryptionResult.RESULT_NOT_ENCRYPTED: {
|
||||
encText = R.string.decrypt_result_not_encrypted;
|
||||
encIcon = R.drawable.status_lock_open_24dp;
|
||||
encColor = R.color.key_flag_red;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int encColorRes = context.getResources().getColor(encColor);
|
||||
@@ -464,22 +480,27 @@ public class KeyFormattingUtils {
|
||||
holder.getEncryptionStatusText().setTextColor(encColorRes);
|
||||
}
|
||||
|
||||
OpenPgpSignatureResult signatureResult = result.getSignatureResult();
|
||||
|
||||
int sigText, sigIcon, sigColor;
|
||||
int sigActionText, sigActionIcon;
|
||||
|
||||
if (signatureResult == null) {
|
||||
switch (signatureResult.getResult()) {
|
||||
|
||||
sigText = R.string.decrypt_result_no_signature;
|
||||
sigIcon = R.drawable.status_signature_invalid_cutout_24dp;
|
||||
sigColor = R.color.key_flag_gray;
|
||||
case OpenPgpSignatureResult.RESULT_NO_SIGNATURE: {
|
||||
// no signature
|
||||
|
||||
// won't be used, but makes compiler happy
|
||||
sigActionText = 0;
|
||||
sigActionIcon = 0;
|
||||
sigText = R.string.decrypt_result_no_signature;
|
||||
sigIcon = R.drawable.status_signature_invalid_cutout_24dp;
|
||||
sigColor = R.color.key_flag_gray;
|
||||
|
||||
} else switch (signatureResult.getStatus()) {
|
||||
// won't be used, but makes compiler happy
|
||||
sigActionText = 0;
|
||||
sigActionIcon = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case OpenPgpSignatureResult.SIGNATURE_SUCCESS_CERTIFIED: {
|
||||
case OpenPgpSignatureResult.RESULT_VALID_CONFIRMED: {
|
||||
sigText = R.string.decrypt_result_signature_certified;
|
||||
sigIcon = R.drawable.status_signature_verified_cutout_24dp;
|
||||
sigColor = R.color.key_flag_green;
|
||||
@@ -489,7 +510,7 @@ public class KeyFormattingUtils {
|
||||
break;
|
||||
}
|
||||
|
||||
case OpenPgpSignatureResult.SIGNATURE_SUCCESS_UNCERTIFIED: {
|
||||
case OpenPgpSignatureResult.RESULT_VALID_UNCONFIRMED: {
|
||||
sigText = R.string.decrypt_result_signature_uncertified;
|
||||
sigIcon = R.drawable.status_signature_unverified_cutout_24dp;
|
||||
sigColor = R.color.key_flag_orange;
|
||||
@@ -499,7 +520,7 @@ public class KeyFormattingUtils {
|
||||
break;
|
||||
}
|
||||
|
||||
case OpenPgpSignatureResult.SIGNATURE_KEY_REVOKED: {
|
||||
case OpenPgpSignatureResult.RESULT_INVALID_KEY_REVOKED: {
|
||||
sigText = R.string.decrypt_result_signature_revoked_key;
|
||||
sigIcon = R.drawable.status_signature_revoked_cutout_24dp;
|
||||
sigColor = R.color.key_flag_red;
|
||||
@@ -509,7 +530,7 @@ public class KeyFormattingUtils {
|
||||
break;
|
||||
}
|
||||
|
||||
case OpenPgpSignatureResult.SIGNATURE_KEY_EXPIRED: {
|
||||
case OpenPgpSignatureResult.RESULT_INVALID_KEY_EXPIRED: {
|
||||
sigText = R.string.decrypt_result_signature_expired_key;
|
||||
sigIcon = R.drawable.status_signature_expired_cutout_24dp;
|
||||
sigColor = R.color.key_flag_red;
|
||||
@@ -519,7 +540,7 @@ public class KeyFormattingUtils {
|
||||
break;
|
||||
}
|
||||
|
||||
case OpenPgpSignatureResult.SIGNATURE_KEY_MISSING: {
|
||||
case OpenPgpSignatureResult.RESULT_KEY_MISSING: {
|
||||
sigText = R.string.decrypt_result_signature_missing_key;
|
||||
sigIcon = R.drawable.status_signature_unknown_cutout_24dp;
|
||||
sigColor = R.color.key_flag_red;
|
||||
@@ -529,8 +550,18 @@ public class KeyFormattingUtils {
|
||||
break;
|
||||
}
|
||||
|
||||
case OpenPgpSignatureResult.RESULT_INVALID_INSECURE: {
|
||||
sigText = R.string.decrypt_result_insecure_cryptography;
|
||||
sigIcon = R.drawable.status_signature_invalid_cutout_24dp;
|
||||
sigColor = R.color.key_flag_red;
|
||||
|
||||
sigActionText = R.string.decrypt_result_action_show;
|
||||
sigActionIcon = R.drawable.ic_vpn_key_grey_24dp;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
case OpenPgpSignatureResult.SIGNATURE_ERROR: {
|
||||
case OpenPgpSignatureResult.RESULT_INVALID_SIGNATURE: {
|
||||
sigText = R.string.decrypt_result_invalid_signature;
|
||||
sigIcon = R.drawable.status_signature_invalid_cutout_24dp;
|
||||
sigColor = R.color.key_flag_red;
|
||||
@@ -548,7 +579,8 @@ public class KeyFormattingUtils {
|
||||
holder.getSignatureStatusText().setText(sigText);
|
||||
holder.getSignatureStatusText().setTextColor(sigColorRes);
|
||||
|
||||
if (signatureResult != null) {
|
||||
if (signatureResult.getResult() != OpenPgpSignatureResult.RESULT_NO_SIGNATURE) {
|
||||
// has a signature, thus display layouts
|
||||
|
||||
holder.getSignatureLayout().setVisibility(View.VISIBLE);
|
||||
|
||||
@@ -556,7 +588,7 @@ public class KeyFormattingUtils {
|
||||
holder.getSignatureAction().setCompoundDrawablesWithIntrinsicBounds(
|
||||
0, 0, sigActionIcon, 0);
|
||||
|
||||
String userId = signatureResult.getPrimaryUserId();
|
||||
String userId = result.getSignatureResult().getPrimaryUserId();
|
||||
KeyRing.UserId userIdSplit = KeyRing.splitUserId(userId);
|
||||
if (userIdSplit.name != null) {
|
||||
holder.getSignatureUserName().setText(userIdSplit.name);
|
||||
@@ -687,6 +719,24 @@ public class KeyFormattingUtils {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case INSECURE: {
|
||||
if (big) {
|
||||
statusIcon.setImageDrawable(
|
||||
context.getResources().getDrawable(R.drawable.status_signature_invalid_cutout_96dp));
|
||||
} else {
|
||||
statusIcon.setImageDrawable(
|
||||
context.getResources().getDrawable(R.drawable.status_signature_invalid_cutout_24dp));
|
||||
}
|
||||
if (color == KeyFormattingUtils.DEFAULT_COLOR) {
|
||||
color = R.color.key_flag_red;
|
||||
}
|
||||
statusIcon.setColorFilter(context.getResources().getColor(color),
|
||||
PorterDuff.Mode.SRC_IN);
|
||||
if (statusText != null) {
|
||||
statusText.setTextColor(context.getResources().getColor(color));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NOT_ENCRYPTED: {
|
||||
statusIcon.setImageDrawable(
|
||||
context.getResources().getDrawable(R.drawable.status_lock_open_24dp));
|
||||
|
||||
@@ -953,7 +953,7 @@
|
||||
<string name="msg_dc_clear_meta_size_unknown">Dateigröße unbekannt</string>
|
||||
<string name="msg_dc_clear_meta_time">Änderungszeit: %s</string>
|
||||
<string name="msg_dc_clear_signature_bad">Signaturprüfung NICHT OK!</string>
|
||||
<string name="msg_dc_error_unsupported_hash_algo">Nicht unterstützter und potentiell unsicherer Hash-Algorithmus!</string>
|
||||
<string name="msg_dc_insecure_hash_algo">Nicht unterstützter und potentiell unsicherer Hash-Algorithmus!</string>
|
||||
<string name="msg_dc_clear_signature_check">Signaturdaten werden überprüft</string>
|
||||
<string name="msg_dc_clear_signature_ok">Signaturprüfung OK</string>
|
||||
<string name="msg_dc_clear_signature">Speichere Signatur für später</string>
|
||||
@@ -962,7 +962,7 @@
|
||||
<string name="msg_dc_error_corrupt_data">Daten beschädigt!</string>
|
||||
<string name="msg_dc_error_extract_key">Unbekannter Fehler bei Schlüsselentsperrung!</string>
|
||||
<string name="msg_dc_error_integrity_check">Integritätsprüfungsfehler!</string>
|
||||
<string name="msg_dc_error_integrity_missing">Fehlende Integritätsprüfung Dies kann passieren, wenn die Verschlüsselungsanwendung veraltet ist oder durch einen Downgrade-Angriff.</string>
|
||||
<string name="msg_dc_insecure_mdc_missing">Fehlende Integritätsprüfung Dies kann passieren, wenn die Verschlüsselungsanwendung veraltet ist oder durch einen Downgrade-Angriff.</string>
|
||||
<string name="msg_dc_error_invalid_data">Kein gültiger OpenPGP-verschlüsselter oder -signierter Inhalt!</string>
|
||||
<string name="msg_dc_error_no_data">Keine verschlüsselten Daten in Datenstrom gefunden!</string>
|
||||
<string name="msg_dc_error_no_key">Keine verschlüsselten Daten mit bekanntem geheimen Schlüssel in Datenstrom gefunden!</string>
|
||||
@@ -981,7 +981,7 @@
|
||||
<string name="msg_dc_trail_sym">Anhang gefunden, symmetrisch verschlüsselte Daten</string>
|
||||
<string name="msg_dc_trail_unknown">Anhängende Daten unbekannter Art gefunden</string>
|
||||
<string name="msg_dc_unlocking">Geheimer Schlüssel wird entsperrt</string>
|
||||
<string name="msg_dc_old_symmetric_encryption_algo">Ein potentiell unsicherer Verschlüsselungsalgorithmus wurde verwendet!</string>
|
||||
<string name="msg_dc_insecure_symmetric_encryption_algo">Ein potentiell unsicherer Verschlüsselungsalgorithmus wurde verwendet!</string>
|
||||
<!--Messages for VerifySignedLiteralData operation-->
|
||||
<string name="msg_vl">Starte Signaturprüfung</string>
|
||||
<string name="msg_vl_error_no_siglist">Keine Signaturliste in signierten Literaldaten</string>
|
||||
|
||||
@@ -1007,7 +1007,7 @@
|
||||
<string name="msg_dc_clear_meta_size_unknown">Tamaño de fichero desconocido</string>
|
||||
<string name="msg_dc_clear_meta_time">Hora de la modificación: %s</string>
|
||||
<string name="msg_dc_clear_signature_bad">¡Comprobación de firma NO CORRECTA!</string>
|
||||
<string name="msg_dc_error_unsupported_hash_algo">¡Algoritmo de identificador criptográfico (hash) no soportado y potencialmente inseguro!</string>
|
||||
<string name="msg_dc_insecure_hash_algo">¡Algoritmo de identificador criptográfico (hash) no soportado y potencialmente inseguro!</string>
|
||||
<string name="msg_dc_clear_signature_check">Verificando datos de firma</string>
|
||||
<string name="msg_dc_clear_signature_ok">Comprobación de firma CORRECTA</string>
|
||||
<string name="msg_dc_clear_signature">Guardando datos de firma para más tarde</string>
|
||||
@@ -1016,7 +1016,7 @@
|
||||
<string name="msg_dc_error_corrupt_data">¡Los datos están corruptos!</string>
|
||||
<string name="msg_dc_error_extract_key">¡Error desconocido al desbloquear clave!</string>
|
||||
<string name="msg_dc_error_integrity_check">¡Error de comprobación de integridad!</string>
|
||||
<string name="msg_dc_error_integrity_missing">¡Verificación de integridad ausente! Esto puede ocurrir porque la aplicación de cifrado no está actualizada, o debido a un ataque desactualización.</string>
|
||||
<string name="msg_dc_insecure_mdc_missing">¡Verificación de integridad ausente! Esto puede ocurrir porque la aplicación de cifrado no está actualizada, o debido a un ataque desactualización.</string>
|
||||
<string name="msg_dc_error_invalid_data">¡No se encontraron datos firmados o cifrados con OpenPGP válidos!</string>
|
||||
<string name="msg_dc_error_io">¡Se encontró un error al leer los datos de entrada!</string>
|
||||
<string name="msg_dc_error_input">¡Error al abrir el flujo de datos de entrada!</string>
|
||||
@@ -1037,7 +1037,7 @@
|
||||
<string name="msg_dc_trail_sym">Se encontró huella, datos cifrados simétricamente</string>
|
||||
<string name="msg_dc_trail_unknown">Se encontró huella, datos de tipo desconocido</string>
|
||||
<string name="msg_dc_unlocking">Desbloqueando clave secreta (privada)</string>
|
||||
<string name="msg_dc_old_symmetric_encryption_algo">¡Se ha usado un algoritmo de cifrado potencialmente inseguro!</string>
|
||||
<string name="msg_dc_insecure_symmetric_encryption_algo">¡Se ha usado un algoritmo de cifrado potencialmente inseguro!</string>
|
||||
<!--Messages for VerifySignedLiteralData operation-->
|
||||
<string name="msg_vl">Comenzando comprobación de firma</string>
|
||||
<string name="msg_vl_error_no_siglist">No hay lista de firmas en los datos literales firmados</string>
|
||||
|
||||
@@ -841,7 +841,7 @@
|
||||
<string name="msg_dc_clear_meta_size_unknown">Agiri neurria ezezaguna da</string>
|
||||
<string name="msg_dc_clear_meta_time">Aldaketa ordua: %s</string>
|
||||
<string name="msg_dc_clear_signature_bad">Sinadura egiaztapena EZ ONGI!</string>
|
||||
<string name="msg_dc_error_unsupported_hash_algo">Hash algoritmo sostengatu gabea eta potentzialki segurtasun gabea!</string>
|
||||
<string name="msg_dc_insecure_hash_algo">Hash algoritmo sostengatu gabea eta potentzialki segurtasun gabea!</string>
|
||||
<string name="msg_dc_clear_signature_check">Sinadura datuak egiaztatzen</string>
|
||||
<string name="msg_dc_clear_signature_ok">Sinadura egiaztapena ONGI</string>
|
||||
<string name="msg_dc_clear_signature">Sinadura datuak gerorako gordetzen</string>
|
||||
@@ -864,7 +864,7 @@
|
||||
<string name="msg_dc">Dekriptaketa eragiketa abiatzen...</string>
|
||||
<string name="msg_dc_sym_skip">Datu simetrikoak ez daude ahalbidetuta, jauzi egiten...</string>
|
||||
<string name="msg_dc_unlocking">Giltza sekretua desblokeatzen</string>
|
||||
<string name="msg_dc_old_symmetric_encryption_algo">Potentzialki segurtasun gabea den enkriptaketa algoritmoa erabili da!</string>
|
||||
<string name="msg_dc_insecure_symmetric_encryption_algo">Potentzialki segurtasun gabea den enkriptaketa algoritmoa erabili da!</string>
|
||||
<!--Messages for VerifySignedLiteralData operation-->
|
||||
<string name="msg_vl">Sinadura egiaztapena abiatzen</string>
|
||||
<string name="msg_vl_error_wrong_key">Mezua ez dago giltza zuzenarekin sinatuta</string>
|
||||
|
||||
@@ -981,7 +981,7 @@
|
||||
<string name="msg_dc_clear_meta_size_unknown">La taille du fichier est inconnue</string>
|
||||
<string name="msg_dc_clear_meta_time">Heure de modification : %s</string>
|
||||
<string name="msg_dc_clear_signature_bad">La vérification de la signature n\'est PAS CORRECTE !</string>
|
||||
<string name="msg_dc_error_unsupported_hash_algo">Algorithme de hachage non pris en charge et potentiellement non sécurisé ! </string>
|
||||
<string name="msg_dc_insecure_hash_algo">Algorithme de hachage non pris en charge et potentiellement non sécurisé ! </string>
|
||||
<string name="msg_dc_clear_signature_check">Vérification des données de signature</string>
|
||||
<string name="msg_dc_clear_signature_ok">La vérification de la signature OK</string>
|
||||
<string name="msg_dc_clear_signature">Enregistrement des données de signature pour plus tard</string>
|
||||
@@ -990,7 +990,7 @@
|
||||
<string name="msg_dc_error_corrupt_data"> Les données sont corrompues !</string>
|
||||
<string name="msg_dc_error_extract_key">Erreur inconnue de déverrouillage de la clef !</string>
|
||||
<string name="msg_dc_error_integrity_check">Erreur de vérification de l\'intégrité !</string>
|
||||
<string name="msg_dc_error_integrity_missing">Vérification de l\'intégrité absente ! Ceci peut arriver car l\'application n\'est pas à jour, ou à cause d\'une attaque par mise à niveau inférieur.</string>
|
||||
<string name="msg_dc_insecure_mdc_missing">Vérification de l\'intégrité absente ! Ceci peut arriver car l\'application n\'est pas à jour, ou à cause d\'une attaque par mise à niveau inférieur.</string>
|
||||
<string name="msg_dc_error_invalid_data">Aucune donnée OpenPGP valide chiffrée ou signée n\'a été trouvée !</string>
|
||||
<string name="msg_dc_error_no_data">Aucune donnée chiffrée n\'a été trouvée dans le flux !</string>
|
||||
<string name="msg_dc_error_no_key">Aucune donnée chiffrée avec une clef secrète connue n\'a été trouvée dans le flux !</string>
|
||||
@@ -1009,7 +1009,7 @@
|
||||
<string name="msg_dc_trail_sym">Des données traînantes chiffrées symétriquement ont été rencontrées</string>
|
||||
<string name="msg_dc_trail_unknown">Des données traînantes de type inconnu ont été rencontrées</string>
|
||||
<string name="msg_dc_unlocking">Déverrouillage de la clef secrète</string>
|
||||
<string name="msg_dc_old_symmetric_encryption_algo">Un algorithme de chiffrement possiblement non sécurisé à été utilisé !</string>
|
||||
<string name="msg_dc_insecure_symmetric_encryption_algo">Un algorithme de chiffrement possiblement non sécurisé à été utilisé !</string>
|
||||
<!--Messages for VerifySignedLiteralData operation-->
|
||||
<string name="msg_vl">Lancement de la vérification de la signature</string>
|
||||
<string name="msg_vl_error_no_siglist">Aucune liste de signatures dans les données littérales signées</string>
|
||||
|
||||
@@ -905,7 +905,7 @@
|
||||
<string name="msg_dc_clear_meta_size_unknown">ファイルサイズが不明</string>
|
||||
<string name="msg_dc_clear_meta_time">更新日時: %s</string>
|
||||
<string name="msg_dc_clear_signature_bad">署名の確認がOKではありません!</string>
|
||||
<string name="msg_dc_error_unsupported_hash_algo">サポート外かつセキュアでない可能性があるハッシュアルゴリズム!</string>
|
||||
<string name="msg_dc_insecure_hash_algo">サポート外かつセキュアでない可能性があるハッシュアルゴリズム!</string>
|
||||
<string name="msg_dc_clear_signature_check">署名データの検証中</string>
|
||||
<string name="msg_dc_clear_signature_ok">署名の確認はOKです</string>
|
||||
<string name="msg_dc_clear_signature">後程署名データを保存します</string>
|
||||
@@ -913,7 +913,7 @@
|
||||
<string name="msg_dc_error_bad_passphrase">鍵のロック解除エラー、パスフレーズに問題があります!</string>
|
||||
<string name="msg_dc_error_extract_key">鍵のロック解除で不明なエラー!</string>
|
||||
<string name="msg_dc_error_integrity_check">完全性チェックエラー!</string>
|
||||
<string name="msg_dc_error_integrity_missing">完全聖チェックの欠落!これは暗号化アプリケーションが期限切れになった場合、もしくは暗号強度低下攻撃がある場合に発生します。</string>
|
||||
<string name="msg_dc_insecure_mdc_missing">完全聖チェックの欠落!これは暗号化アプリケーションが期限切れになった場合、もしくは暗号強度低下攻撃がある場合に発生します。</string>
|
||||
<string name="msg_dc_error_invalid_data">正常な署名データが見付からなかった!</string>
|
||||
<string name="msg_dc_error_io">操作中にIO例外に当たりました!</string>
|
||||
<string name="msg_dc_error_no_data">ストリーム中に暗号化されたデータが見付からなかった!</string>
|
||||
@@ -933,7 +933,7 @@
|
||||
<string name="msg_dc_trail_sym">追跡で遭遇、対称暗号化されたデータ</string>
|
||||
<string name="msg_dc_trail_unknown">追跡で未知のタイプのデータに遭遇</string>
|
||||
<string name="msg_dc_unlocking">秘密鍵のロック解除</string>
|
||||
<string name="msg_dc_old_symmetric_encryption_algo">セキュアでない可能性がある暗号化アルゴリズムが利用されています!</string>
|
||||
<string name="msg_dc_insecure_symmetric_encryption_algo">セキュアでない可能性がある暗号化アルゴリズムが利用されています!</string>
|
||||
<!--Messages for VerifySignedLiteralData operation-->
|
||||
<string name="msg_vl">署名の確認開始</string>
|
||||
<string name="msg_vl_error_no_siglist">署名済み固定データに署名リストがありません</string>
|
||||
|
||||
@@ -1007,7 +1007,7 @@
|
||||
<string name="msg_dc_clear_meta_size_unknown">Bestandsgrootte onbekend</string>
|
||||
<string name="msg_dc_clear_meta_time">Wijzigingstijd: %s</string>
|
||||
<string name="msg_dc_clear_signature_bad">Ondertekeningscontrole NIET OKÉ!</string>
|
||||
<string name="msg_dc_error_unsupported_hash_algo">Niet ondersteund en mogelijk onveilig hash-algoritme!</string>
|
||||
<string name="msg_dc_insecure_hash_algo">Niet ondersteund en mogelijk onveilig hash-algoritme!</string>
|
||||
<string name="msg_dc_clear_signature_check">Bezig met verifiëren van ondertekeningsgegevens</string>
|
||||
<string name="msg_dc_clear_signature_ok">Ondertekeningscontrole OKÉ</string>
|
||||
<string name="msg_dc_clear_signature">Bezig met opslaan van ondertekeningsgegevens voor later</string>
|
||||
@@ -1016,7 +1016,7 @@
|
||||
<string name="msg_dc_error_corrupt_data">Gegevens zijn corrupt!</string>
|
||||
<string name="msg_dc_error_extract_key">Onbekende fout bij ontgrendelen van sleutel!</string>
|
||||
<string name="msg_dc_error_integrity_check">Fout bij integriteitscontrole!</string>
|
||||
<string name="msg_dc_error_integrity_missing">Integriteitscheck ontbreekt! Dit kan gebeuren omdat de versleutelingsapplicatie verouderd is, of door een downgrade-aanval.</string>
|
||||
<string name="msg_dc_insecure_mdc_missing">Integriteitscheck ontbreekt! Dit kan gebeuren omdat de versleutelingsapplicatie verouderd is, of door een downgrade-aanval.</string>
|
||||
<string name="msg_dc_error_invalid_data">Geen geldige OpenPGP-versleutelde of ondertekende inhoud gevonden!</string>
|
||||
<string name="msg_dc_error_no_data">Geen versleutelde gegevens gevonden!</string>
|
||||
<string name="msg_dc_error_no_key">Geen versleutelde gegevens met bekende geheime sleutel gevonden!</string>
|
||||
@@ -1035,7 +1035,7 @@
|
||||
<string name="msg_dc_trail_sym">Achterlopende, symmetrisch versleutelde gegevens tegengekomen</string>
|
||||
<string name="msg_dc_trail_unknown">Achterlopende gegevens van onbekend type tegengekomen</string>
|
||||
<string name="msg_dc_unlocking">Bezig met ontgrendelen van geheime sleutel</string>
|
||||
<string name="msg_dc_old_symmetric_encryption_algo">Mogelijk onveilig versleutelingsalgoritme gebruikt!</string>
|
||||
<string name="msg_dc_insecure_symmetric_encryption_algo">Mogelijk onveilig versleutelingsalgoritme gebruikt!</string>
|
||||
<!--Messages for VerifySignedLiteralData operation-->
|
||||
<string name="msg_vl">Ondertekeningscontrole wordt gestart</string>
|
||||
<string name="msg_vl_error_no_siglist">Geen ondertekeningslijst in ondertekende letterlijke gegevens</string>
|
||||
|
||||
@@ -726,7 +726,7 @@
|
||||
<string name="msg_dc_clear_decompress">Распаковка сжатых данных</string>
|
||||
<string name="msg_dc_clear_meta_size_unknown">Неизвестный размер файла</string>
|
||||
<string name="msg_dc_clear_signature_bad">Проверка подписи НЕ ПРОЙДЕНА!</string>
|
||||
<string name="msg_dc_error_unsupported_hash_algo">Неподдерживаемый, и потенциально небезопасный алгоритм хэширования!</string>
|
||||
<string name="msg_dc_insecure_hash_algo">Неподдерживаемый, и потенциально небезопасный алгоритм хэширования!</string>
|
||||
<string name="msg_dc_clear_signature_check">Проверка подписи данных</string>
|
||||
<string name="msg_dc_clear_signature_ok">Проверка подписи ПРОЙДЕНА</string>
|
||||
<string name="msg_dc_clear_signature">Сохранение данных подписи</string>
|
||||
@@ -737,7 +737,7 @@
|
||||
<string name="msg_dc_ok">Расшифрование/проверка закончена</string>
|
||||
<string name="msg_dc_pass_cached">Использование фразы-пароля из кэша</string>
|
||||
<string name="msg_dc_unlocking">Разблокировка секретного ключа</string>
|
||||
<string name="msg_dc_old_symmetric_encryption_algo">Был использован потенциально небезопасный алгоритм шифрования!</string>
|
||||
<string name="msg_dc_insecure_symmetric_encryption_algo">Был использован потенциально небезопасный алгоритм шифрования!</string>
|
||||
<!--Messages for VerifySignedLiteralData operation-->
|
||||
<string name="msg_vl_clear_signature_check">Проверка подписи данных</string>
|
||||
<string name="msg_vl_ok">ОК</string>
|
||||
|
||||
@@ -915,7 +915,7 @@
|
||||
<string name="msg_dc_error_bad_passphrase">Грешка откључавања кључа, погрешна лозинка!</string>
|
||||
<string name="msg_dc_error_extract_key">Непозната грешка откључавања кључа!</string>
|
||||
<string name="msg_dc_error_integrity_check">Грешка провере интегритета!</string>
|
||||
<string name="msg_dc_error_integrity_missing">Недостаје провера интегритета! Ово може да се деси ако је апликација за шифровање застарела, или услед напада старијег издања.</string>
|
||||
<string name="msg_dc_insecure_mdc_missing">Недостаје провера интегритета! Ово може да се деси ако је апликација за шифровање застарела, или услед напада старијег издања.</string>
|
||||
<string name="msg_dc_error_invalid_data">Нису нађени исправни подаци потписа!</string>
|
||||
<string name="msg_dc_error_io">Наиђох на У/И изузетак током радње!</string>
|
||||
<string name="msg_dc_error_no_data">Шифровани подаци нису нађени у току!</string>
|
||||
|
||||
@@ -343,6 +343,7 @@
|
||||
<!-- results shown after decryption/verification -->
|
||||
<string name="decrypt_result_no_signature">"Not Signed"</string>
|
||||
<string name="decrypt_result_invalid_signature">"Invalid signature!"</string>
|
||||
<string name="decrypt_result_insecure_cryptography">"Invalid signature (Insecure Cryptography)!"</string>
|
||||
<string name="decrypt_result_signature_uncertified">"Signed by <b>unconfirmed</b> key"</string>
|
||||
<string name="decrypt_result_signature_secret">"Signed by your key"</string>
|
||||
<string name="decrypt_result_signature_certified">"Signed by confirmed key"</string>
|
||||
@@ -351,6 +352,7 @@
|
||||
<string name="decrypt_result_signature_missing_key">"Signed by <b>unknown public key</b>"</string>
|
||||
<string name="decrypt_result_encrypted">"Encrypted"</string>
|
||||
<string name="decrypt_result_not_encrypted">"Not Encrypted"</string>
|
||||
<string name="decrypt_result_insecure">"Insecure Encryption"</string>
|
||||
<string name="decrypt_result_action_show">"Show"</string>
|
||||
<string name="decrypt_result_action_Lookup">"Lookup"</string>
|
||||
<string name="decrypt_invalid_text">"Either the signature is invalid or the key has been revoked. You cannot be sure who wrote the text. Do you still want to display it?"</string>
|
||||
@@ -1132,7 +1134,6 @@
|
||||
<string name="msg_dc_clear_meta_size_unknown">"File size is unknown"</string>
|
||||
<string name="msg_dc_clear_meta_time">"Modification time: %s"</string>
|
||||
<string name="msg_dc_clear_signature_bad">"Signature check NOT OK!"</string>
|
||||
<string name="msg_dc_error_unsupported_hash_algo">"Unsupported and potentially insecure hash algorithm!"</string>
|
||||
<string name="msg_dc_clear_signature_check">"Verifying signature data"</string>
|
||||
<string name="msg_dc_clear_signature_ok">"Signature check OK"</string>
|
||||
<string name="msg_dc_clear_signature">"Saving signature data for later"</string>
|
||||
@@ -1142,7 +1143,6 @@
|
||||
<string name="msg_dc_error_corrupt_data">"Data is corrupt!"</string>
|
||||
<string name="msg_dc_error_extract_key">"Unknown error unlocking key!"</string>
|
||||
<string name="msg_dc_error_integrity_check">"Integrity check error!"</string>
|
||||
<string name="msg_dc_error_integrity_missing">"Missing integrity check! This can happen because the encrypting application is out of date, or from a downgrade attack."</string>
|
||||
<string name="msg_dc_error_invalid_data">"No valid OpenPGP encrypted or signed data found!"</string>
|
||||
<string name="msg_dc_error_io">"Encountered an error reading input data!"</string>
|
||||
<string name="msg_dc_error_input">"Error opening input data stream!"</string>
|
||||
@@ -1163,7 +1163,10 @@
|
||||
<string name="msg_dc_trail_sym">"Encountered trailing, symmetrically encrypted data"</string>
|
||||
<string name="msg_dc_trail_unknown">"Encountered trailing data of unknown type"</string>
|
||||
<string name="msg_dc_unlocking">"Unlocking secret key"</string>
|
||||
<string name="msg_dc_old_symmetric_encryption_algo">"Potentially insecure encryption algorithm has been used!"</string>
|
||||
<string name="msg_dc_insecure_symmetric_encryption_algo">"Insecure encryption algorithm has been used! This can happen because the application is out of date, or from an attack."</string>
|
||||
<string name="msg_dc_insecure_hash_algo">"Insecure hash algorithm has been used! This can happen because the application is out of date, or from an attack."</string>
|
||||
<string name="msg_dc_insecure_mdc_missing">"Missing the Modification Detection Code (MDC) packet! This can happen because the encrypting application is out of date, or from a downgrade attack."</string>
|
||||
<string name="msg_dc_insecure_key">"Insecure key: Either the bit length of RSA/DSA/ElGamal is too short or the ECC curve/algorithm is considered insecure! This can happen because the application is out of date, or from an attack."</string>
|
||||
|
||||
<!-- Messages for VerifySignedLiteralData operation -->
|
||||
<string name="msg_vl">"Starting signature check"</string>
|
||||
@@ -1194,7 +1197,6 @@
|
||||
<string name="msg_pse_compressing">"Preparing compression"</string>
|
||||
<string name="msg_pse_encrypting">"Encrypting data"</string>
|
||||
<string name="msg_pse_error_bad_passphrase">"Bad password!"</string>
|
||||
<string name="msg_pse_error_hash_algo">"Requested hashing algorithm is not supported by this key!"</string>
|
||||
<string name="msg_pse_error_io">"Encountered IO Exception during operation!"</string>
|
||||
<string name="msg_pse_error_key_sign">"Selected signing key cannot sign data!"</string>
|
||||
<string name="msg_pse_error_sign_key">"Error fetching signing key!"</string>
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.openintents.openpgp.OpenPgpDecryptionResult;
|
||||
import org.openintents.openpgp.OpenPgpMetadata;
|
||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
import org.robolectric.RobolectricGradleTestRunner;
|
||||
@@ -44,7 +45,6 @@ import org.spongycastle.bcpg.PacketTags;
|
||||
import org.spongycastle.bcpg.PublicKeyEncSessionPacket;
|
||||
import org.spongycastle.bcpg.sig.KeyFlags;
|
||||
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.spongycastle.openpgp.PGPEncryptedData;
|
||||
import org.sufficientlysecure.keychain.WorkaroundBuildConfig;
|
||||
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||
@@ -72,11 +72,12 @@ import static org.hamcrest.core.Is.is;
|
||||
@Config(constants = WorkaroundBuildConfig.class, sdk = 21, manifest = "src/main/AndroidManifest.xml")
|
||||
public class PgpEncryptDecryptTest {
|
||||
|
||||
static Passphrase mPassphrase = TestingUtils.genPassphrase(true);
|
||||
static Passphrase mSymmetricPassphrase = TestingUtils.genPassphrase(true);
|
||||
|
||||
static UncachedKeyRing mStaticRing1, mStaticRing2;
|
||||
static UncachedKeyRing mStaticRing1, mStaticRing2, mStaticRingInsecure;
|
||||
static Passphrase mKeyPhrase1 = TestingUtils.genPassphrase(true);
|
||||
static Passphrase mKeyPhrase2 = TestingUtils.genPassphrase(true);
|
||||
static Passphrase mKeyPhraseInsecure = TestingUtils.genPassphrase(true);
|
||||
|
||||
static PrintStream oldShadowStream;
|
||||
|
||||
@@ -91,13 +92,13 @@ public class PgpEncryptDecryptTest {
|
||||
{
|
||||
SaveKeyringParcel parcel = new SaveKeyringParcel();
|
||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||
Algorithm.RSA, 1024, null, KeyFlags.CERTIFY_OTHER, 0L));
|
||||
Algorithm.ECDSA, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.CERTIFY_OTHER, 0L));
|
||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||
Algorithm.DSA, 1024, null, KeyFlags.SIGN_DATA, 0L));
|
||||
Algorithm.ECDSA, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.SIGN_DATA, 0L));
|
||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||
Algorithm.ELGAMAL, 1024, null, KeyFlags.ENCRYPT_COMMS, 0L));
|
||||
Algorithm.ECDH, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.ENCRYPT_COMMS, 0L));
|
||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||
Algorithm.RSA, 1024, null, KeyFlags.ENCRYPT_COMMS, 0L));
|
||||
Algorithm.ECDH, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.ENCRYPT_COMMS, 0L));
|
||||
parcel.mAddUserIds.add("bloom");
|
||||
parcel.mNewUnlock = new ChangeUnlockParcel(mKeyPhrase1);
|
||||
|
||||
@@ -111,11 +112,11 @@ public class PgpEncryptDecryptTest {
|
||||
{
|
||||
SaveKeyringParcel parcel = new SaveKeyringParcel();
|
||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||
Algorithm.RSA, 1024, null, KeyFlags.CERTIFY_OTHER, 0L));
|
||||
Algorithm.ECDSA, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.CERTIFY_OTHER, 0L));
|
||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||
Algorithm.DSA, 1024, null, KeyFlags.SIGN_DATA, 0L));
|
||||
Algorithm.ECDSA, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.SIGN_DATA, 0L));
|
||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||
Algorithm.ELGAMAL, 1024, null, KeyFlags.ENCRYPT_COMMS, 0L));
|
||||
Algorithm.ECDH, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.ENCRYPT_COMMS, 0L));
|
||||
parcel.mAddUserIds.add("belle");
|
||||
parcel.mNewUnlock = new ChangeUnlockParcel(mKeyPhrase2);
|
||||
|
||||
@@ -126,6 +127,25 @@ public class PgpEncryptDecryptTest {
|
||||
mStaticRing2 = result.getRing();
|
||||
}
|
||||
|
||||
{
|
||||
// insecure (1024 bit) RSA key
|
||||
SaveKeyringParcel parcel = new SaveKeyringParcel();
|
||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||
Algorithm.RSA, 1024, null, KeyFlags.CERTIFY_OTHER, 0L));
|
||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||
Algorithm.RSA, 1024, null, KeyFlags.SIGN_DATA, 0L));
|
||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||
Algorithm.RSA, 1024, null, KeyFlags.ENCRYPT_COMMS, 0L));
|
||||
parcel.mAddUserIds.add("eve");
|
||||
parcel.mNewUnlock = new ChangeUnlockParcel(mKeyPhraseInsecure);
|
||||
|
||||
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
||||
Assert.assertTrue("initial test key creation must succeed", result.success());
|
||||
Assert.assertNotNull("initial test key creation must succeed", result.getRing());
|
||||
|
||||
mStaticRingInsecure = result.getRing();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Before
|
||||
@@ -158,8 +178,9 @@ public class PgpEncryptDecryptTest {
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
PgpSignEncryptInputParcel b = new PgpSignEncryptInputParcel();
|
||||
b.setSymmetricPassphrase(mPassphrase);
|
||||
b.setSymmetricEncryptionAlgorithm(PGPEncryptedData.AES_128);
|
||||
b.setSymmetricPassphrase(mSymmetricPassphrase);
|
||||
b.setSymmetricEncryptionAlgorithm(
|
||||
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
||||
|
||||
PgpSignEncryptResult result = op.execute(b, new CryptoInputParcel(new Date()),
|
||||
data, out);
|
||||
@@ -169,7 +190,7 @@ public class PgpEncryptDecryptTest {
|
||||
ciphertext = out.toByteArray();
|
||||
}
|
||||
|
||||
{ // decryption with same passphrase should yield the same result
|
||||
{ // decryption with same passphrase should yield the same plaintext
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(ciphertext);
|
||||
@@ -180,18 +201,21 @@ public class PgpEncryptDecryptTest {
|
||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
|
||||
input.setAllowSymmetricDecryption(true);
|
||||
DecryptVerifyResult result = op.execute(
|
||||
input, new CryptoInputParcel(mPassphrase), data, out);
|
||||
input, new CryptoInputParcel(mSymmetricPassphrase), data, out);
|
||||
|
||||
Assert.assertTrue("decryption must succeed", result.success());
|
||||
Assert.assertArrayEquals("decrypted ciphertext should equal plaintext",
|
||||
out.toByteArray(), plaintext.getBytes());
|
||||
Assert.assertNull("signature should be an error", result.getSignatureResult());
|
||||
Assert.assertEquals("decryptionResult should be RESULT_ENCRYPTED",
|
||||
OpenPgpDecryptionResult.RESULT_ENCRYPTED, result.getDecryptionResult().getResult());
|
||||
Assert.assertEquals("signatureResult should be RESULT_NO_SIGNATURE",
|
||||
OpenPgpSignatureResult.RESULT_NO_SIGNATURE, result.getSignatureResult().getResult());
|
||||
|
||||
CryptoInputParcel cryptoInput = result.getCachedCryptoInputParcel();
|
||||
Assert.assertEquals("cached session keys must be empty",
|
||||
0, cryptoInput.getCryptoData().size());
|
||||
|
||||
OpenPgpMetadata metadata = result.getDecryptMetadata();
|
||||
OpenPgpMetadata metadata = result.getDecryptionMetadata();
|
||||
Assert.assertEquals("filesize must be correct",
|
||||
out.toByteArray().length, metadata.getOriginalSize());
|
||||
}
|
||||
@@ -207,12 +231,15 @@ public class PgpEncryptDecryptTest {
|
||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
|
||||
input.setAllowSymmetricDecryption(true);
|
||||
DecryptVerifyResult result = op.execute(input,
|
||||
new CryptoInputParcel(new Passphrase(new String(mPassphrase.getCharArray()) + "x")),
|
||||
new CryptoInputParcel(new Passphrase(new String(mSymmetricPassphrase.getCharArray()) + "x")),
|
||||
data, out);
|
||||
|
||||
Assert.assertFalse("decryption must fail", result.success());
|
||||
Assert.assertEquals("decrypted plaintext should be empty", 0, out.size());
|
||||
Assert.assertNull("signature should be an error", result.getSignatureResult());
|
||||
Assert.assertNull("decryptionResult should be null",
|
||||
result.getDecryptionResult());
|
||||
Assert.assertNull("signatureResult should be null",
|
||||
result.getSignatureResult());
|
||||
}
|
||||
|
||||
{ // decryption with an unset passphrase should fail
|
||||
@@ -230,7 +257,10 @@ public class PgpEncryptDecryptTest {
|
||||
|
||||
Assert.assertFalse("decryption must fail", result.success());
|
||||
Assert.assertEquals("decrypted plaintext should be empty", 0, out.size());
|
||||
Assert.assertNull("signature should be an error", result.getSignatureResult());
|
||||
Assert.assertNull("decryptionResult should be null",
|
||||
result.getDecryptionResult());
|
||||
Assert.assertNull("signatureResult should be null",
|
||||
result.getSignatureResult());
|
||||
}
|
||||
|
||||
{ // decryption if symmetric decryption isn't allowed should fail
|
||||
@@ -248,7 +278,10 @@ public class PgpEncryptDecryptTest {
|
||||
|
||||
Assert.assertFalse("decryption must fail", result.success());
|
||||
Assert.assertEquals("decrypted plaintext should be empty", 0, out.size());
|
||||
Assert.assertNull("signature should be an error", result.getSignatureResult());
|
||||
Assert.assertNull("decryptionResult should be null",
|
||||
result.getDecryptionResult());
|
||||
Assert.assertNull("signatureResult should be null",
|
||||
result.getSignatureResult());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -270,7 +303,8 @@ public class PgpEncryptDecryptTest {
|
||||
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel();
|
||||
|
||||
input.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
|
||||
input.setSymmetricEncryptionAlgorithm(PGPEncryptedData.AES_128);
|
||||
input.setSymmetricEncryptionAlgorithm(
|
||||
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
||||
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(new Date()),
|
||||
data, out);
|
||||
Assert.assertTrue("encryption must succeed", result.success());
|
||||
@@ -291,13 +325,16 @@ public class PgpEncryptDecryptTest {
|
||||
Assert.assertTrue("decryption with provided passphrase must succeed", result.success());
|
||||
Assert.assertArrayEquals("decrypted ciphertext with provided passphrase should equal plaintext",
|
||||
out.toByteArray(), plaintext.getBytes());
|
||||
Assert.assertNull("signature be empty", result.getSignatureResult());
|
||||
Assert.assertEquals("decryptionResult should be RESULT_ENCRYPTED",
|
||||
OpenPgpDecryptionResult.RESULT_ENCRYPTED, result.getDecryptionResult().getResult());
|
||||
Assert.assertEquals("signatureResult should be RESULT_NO_SIGNATURE",
|
||||
OpenPgpSignatureResult.RESULT_NO_SIGNATURE, result.getSignatureResult().getResult());
|
||||
|
||||
CryptoInputParcel cryptoInput = result.getCachedCryptoInputParcel();
|
||||
Assert.assertEquals("must have one cached session key",
|
||||
1, cryptoInput.getCryptoData().size());
|
||||
|
||||
OpenPgpMetadata metadata = result.getDecryptMetadata();
|
||||
OpenPgpMetadata metadata = result.getDecryptionMetadata();
|
||||
Assert.assertEquals("filesize must be correct",
|
||||
out.toByteArray().length, metadata.getOriginalSize());
|
||||
|
||||
@@ -321,7 +358,10 @@ public class PgpEncryptDecryptTest {
|
||||
Assert.assertTrue("decryption with cached passphrase must succeed", result.success());
|
||||
Assert.assertArrayEquals("decrypted ciphertext with cached passphrase should equal plaintext",
|
||||
out.toByteArray(), plaintext.getBytes());
|
||||
Assert.assertNull("signature should be empty", result.getSignatureResult());
|
||||
Assert.assertEquals("decryptionResult should be RESULT_ENCRYPTED",
|
||||
OpenPgpDecryptionResult.RESULT_ENCRYPTED, result.getDecryptionResult().getResult());
|
||||
Assert.assertEquals("signatureResult should be RESULT_NO_SIGNATURE",
|
||||
OpenPgpSignatureResult.RESULT_NO_SIGNATURE, result.getSignatureResult().getResult());
|
||||
}
|
||||
|
||||
{ // decryption with no passphrase provided should return status pending
|
||||
@@ -361,7 +401,8 @@ public class PgpEncryptDecryptTest {
|
||||
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel();
|
||||
|
||||
input.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
|
||||
input.setSymmetricEncryptionAlgorithm(PGPEncryptedData.AES_128);
|
||||
input.setSymmetricEncryptionAlgorithm(
|
||||
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
||||
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(new Date()),
|
||||
data, out);
|
||||
Assert.assertTrue("encryption must succeed", result.success());
|
||||
@@ -417,7 +458,8 @@ public class PgpEncryptDecryptTest {
|
||||
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel();
|
||||
|
||||
input.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
|
||||
input.setSymmetricEncryptionAlgorithm(PGPEncryptedData.AES_128);
|
||||
input.setSymmetricEncryptionAlgorithm(
|
||||
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
||||
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(new Date()),
|
||||
data, out);
|
||||
Assert.assertTrue("encryption must succeed", result.success());
|
||||
@@ -461,7 +503,8 @@ public class PgpEncryptDecryptTest {
|
||||
mStaticRing1.getMasterKeyId(),
|
||||
mStaticRing2.getMasterKeyId()
|
||||
});
|
||||
b.setSymmetricEncryptionAlgorithm(PGPEncryptedData.AES_128);
|
||||
b.setSymmetricEncryptionAlgorithm(
|
||||
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
||||
|
||||
PgpSignEncryptResult result = op.execute(b, new CryptoInputParcel(new Date()),
|
||||
data, out);
|
||||
@@ -484,9 +527,12 @@ public class PgpEncryptDecryptTest {
|
||||
Assert.assertTrue("decryption with cached passphrase must succeed for the first key", result.success());
|
||||
Assert.assertArrayEquals("decrypted ciphertext with cached passphrase should equal plaintext",
|
||||
out.toByteArray(), plaintext.getBytes());
|
||||
Assert.assertNull("signature should be empty", result.getSignatureResult());
|
||||
Assert.assertEquals("decryptionResult should be RESULT_ENCRYPTED",
|
||||
OpenPgpDecryptionResult.RESULT_ENCRYPTED, result.getDecryptionResult().getResult());
|
||||
Assert.assertEquals("signatureResult should be RESULT_NO_SIGNATURE",
|
||||
OpenPgpSignatureResult.RESULT_NO_SIGNATURE, result.getSignatureResult().getResult());
|
||||
|
||||
OpenPgpMetadata metadata = result.getDecryptMetadata();
|
||||
OpenPgpMetadata metadata = result.getDecryptionMetadata();
|
||||
Assert.assertEquals("filesize must be correct",
|
||||
out.toByteArray().length, metadata.getOriginalSize());
|
||||
}
|
||||
@@ -512,7 +558,10 @@ public class PgpEncryptDecryptTest {
|
||||
Assert.assertArrayEquals("decrypted ciphertext with cached passphrase should equal plaintext",
|
||||
out.toByteArray(), plaintext.getBytes());
|
||||
Assert.assertTrue("other key was skipped", result.getLog().containsType(LogType.MSG_DC_ASKIP_NOT_ALLOWED));
|
||||
Assert.assertNull("signature should be empty", result.getSignatureResult());
|
||||
Assert.assertEquals("decryptionResult should be RESULT_ENCRYPTED",
|
||||
OpenPgpDecryptionResult.RESULT_ENCRYPTED, result.getDecryptionResult().getResult());
|
||||
Assert.assertEquals("signatureResult should be RESULT_NO_SIGNATURE",
|
||||
OpenPgpSignatureResult.RESULT_NO_SIGNATURE, result.getSignatureResult().getResult());
|
||||
}
|
||||
|
||||
{ // decryption should fail if no key is allowed
|
||||
@@ -553,7 +602,10 @@ public class PgpEncryptDecryptTest {
|
||||
Assert.assertTrue("decryption with cached passphrase must succeed", result.success());
|
||||
Assert.assertArrayEquals("decrypted ciphertext with cached passphrase should equal plaintext",
|
||||
out.toByteArray(), plaintext.getBytes());
|
||||
Assert.assertNull("signature should be empty", result.getSignatureResult());
|
||||
Assert.assertEquals("decryptionResult should be RESULT_ENCRYPTED",
|
||||
OpenPgpDecryptionResult.RESULT_ENCRYPTED, result.getDecryptionResult().getResult());
|
||||
Assert.assertEquals("signatureResult should be RESULT_NO_SIGNATURE",
|
||||
OpenPgpSignatureResult.RESULT_NO_SIGNATURE, result.getSignatureResult().getResult());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -580,7 +632,8 @@ public class PgpEncryptDecryptTest {
|
||||
});
|
||||
b.setSignatureMasterKeyId(mStaticRing1.getMasterKeyId());
|
||||
b.setSignatureSubKeyId(KeyringTestingHelper.getSubkeyId(mStaticRing1, 1));
|
||||
b.setSymmetricEncryptionAlgorithm(PGPEncryptedData.AES_128);
|
||||
b.setSymmetricEncryptionAlgorithm(
|
||||
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
||||
|
||||
PgpSignEncryptResult result = op.execute(b,
|
||||
new CryptoInputParcel(new Date(), mKeyPhrase1), data, out);
|
||||
@@ -604,9 +657,9 @@ public class PgpEncryptDecryptTest {
|
||||
Assert.assertArrayEquals("decrypted ciphertext with cached passphrase should equal plaintext",
|
||||
out.toByteArray(), plaintext.getBytes());
|
||||
Assert.assertEquals("signature should be verified and certified",
|
||||
OpenPgpSignatureResult.SIGNATURE_SUCCESS_CERTIFIED, result.getSignatureResult().getStatus());
|
||||
OpenPgpSignatureResult.RESULT_VALID_CONFIRMED, result.getSignatureResult().getResult());
|
||||
|
||||
OpenPgpMetadata metadata = result.getDecryptMetadata();
|
||||
OpenPgpMetadata metadata = result.getDecryptionMetadata();
|
||||
Assert.assertEquals("filesize must be correct",
|
||||
out.toByteArray().length, metadata.getOriginalSize());
|
||||
}
|
||||
@@ -631,8 +684,8 @@ public class PgpEncryptDecryptTest {
|
||||
Assert.assertArrayEquals("decrypted ciphertext with cached passphrase should equal plaintext",
|
||||
out.toByteArray(), plaintext.getBytes());
|
||||
Assert.assertEquals("signature key should be missing",
|
||||
OpenPgpSignatureResult.SIGNATURE_KEY_MISSING,
|
||||
result.getSignatureResult().getStatus());
|
||||
OpenPgpSignatureResult.RESULT_KEY_MISSING,
|
||||
result.getSignatureResult().getResult());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -659,7 +712,8 @@ public class PgpEncryptDecryptTest {
|
||||
PgpSignEncryptInputParcel b = new PgpSignEncryptInputParcel();
|
||||
|
||||
b.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
|
||||
b.setSymmetricEncryptionAlgorithm(PGPEncryptedData.AES_128);
|
||||
b.setSymmetricEncryptionAlgorithm(
|
||||
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
||||
// this only works with ascii armored output!
|
||||
b.setEnableAsciiArmorOutput(true);
|
||||
b.setCharset("iso-2022-jp");
|
||||
@@ -687,11 +741,84 @@ public class PgpEncryptDecryptTest {
|
||||
"iso-2022-jp", result.getCharset());
|
||||
Assert.assertEquals("decrypted ciphertext should equal plaintext",
|
||||
new String(out.toByteArray(), result.getCharset()), plaintext);
|
||||
Assert.assertNull("signature be empty", result.getSignatureResult());
|
||||
Assert.assertEquals("decryptionResult should be RESULT_ENCRYPTED",
|
||||
OpenPgpDecryptionResult.RESULT_ENCRYPTED, result.getDecryptionResult().getResult());
|
||||
Assert.assertEquals("signatureResult should be RESULT_NO_SIGNATURE",
|
||||
OpenPgpSignatureResult.RESULT_NO_SIGNATURE, result.getSignatureResult().getResult());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsymmetricInsecureEncryptDecrypt() {
|
||||
|
||||
// insecure symmetric algo
|
||||
subtestInsecureEncryptDecrypt(mStaticRing1, mKeyPhrase1,
|
||||
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.DES, true);
|
||||
// don't use MDC
|
||||
subtestInsecureEncryptDecrypt(mStaticRing1, mKeyPhrase1,
|
||||
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_256, false);
|
||||
// TODO: test not working!
|
||||
// insecure key (1024 bit RSA)
|
||||
// subtestInsecureEncryptDecrypt(mStaticRingInsecure, mKeyPhraseInsecure,
|
||||
// PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_256, true);
|
||||
|
||||
}
|
||||
|
||||
private void subtestInsecureEncryptDecrypt(UncachedKeyRing key, Passphrase passphrase,
|
||||
int algorithm, boolean isIntegrityProtected) {
|
||||
String plaintext = "dies ist ein plaintext ☭" + TestingUtils.genPassphrase(true);
|
||||
byte[] ciphertext;
|
||||
|
||||
{ // encrypt data with insecure key
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new ProviderHelper(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel();
|
||||
|
||||
input.setEncryptionMasterKeyIds(new long[]{key.getMasterKeyId()})
|
||||
.setSymmetricEncryptionAlgorithm(algorithm)
|
||||
.setIntegrityProtected(isIntegrityProtected);
|
||||
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(new Date()),
|
||||
data, out);
|
||||
Assert.assertTrue("encryption must succeed", result.success());
|
||||
|
||||
ciphertext = out.toByteArray();
|
||||
}
|
||||
|
||||
{ // decryption with provided passphrase should yield insecure status
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(ciphertext);
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
PgpDecryptVerify op = operationWithFakePassphraseCache(null, null, null);
|
||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
|
||||
DecryptVerifyResult result = op.execute(input, new CryptoInputParcel(passphrase), data, out);
|
||||
|
||||
Assert.assertTrue("decryption with provided passphrase must succeed", result.success());
|
||||
Assert.assertArrayEquals("decrypted ciphertext with provided passphrase should equal plaintext",
|
||||
out.toByteArray(), plaintext.getBytes());
|
||||
Assert.assertEquals("decryptionResult should be RESULT_INSECURE",
|
||||
OpenPgpDecryptionResult.RESULT_INSECURE, result.getDecryptionResult().getResult());
|
||||
Assert.assertEquals("signatureResult should be RESULT_NO_SIGNATURE",
|
||||
OpenPgpSignatureResult.RESULT_NO_SIGNATURE, result.getSignatureResult().getResult());
|
||||
|
||||
CryptoInputParcel cryptoInput = result.getCachedCryptoInputParcel();
|
||||
Assert.assertEquals("must have one cached session key",
|
||||
1, cryptoInput.getCryptoData().size());
|
||||
|
||||
OpenPgpMetadata metadata = result.getDecryptionMetadata();
|
||||
Assert.assertEquals("filesize must be correct",
|
||||
out.toByteArray().length, metadata.getOriginalSize());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private PgpDecryptVerify operationWithFakePassphraseCache(
|
||||
final Passphrase passphrase, final Long checkMasterKeyId, final Long checkSubKeyId) {
|
||||
|
||||
|
||||
@@ -102,11 +102,11 @@ public class UncachedKeyringCanonicalizeTest {
|
||||
|
||||
SaveKeyringParcel parcel = new SaveKeyringParcel();
|
||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||
Algorithm.RSA, 1024, null, KeyFlags.CERTIFY_OTHER, 0L));
|
||||
Algorithm.ECDSA, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.CERTIFY_OTHER, 0L));
|
||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||
Algorithm.RSA, 1024, null, KeyFlags.SIGN_DATA, 0L));
|
||||
Algorithm.ECDSA, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.SIGN_DATA, 0L));
|
||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||
Algorithm.RSA, 1024, null, KeyFlags.ENCRYPT_COMMS, 0L));
|
||||
Algorithm.ECDH, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.ENCRYPT_COMMS, 0L));
|
||||
|
||||
parcel.mAddUserIds.add("twi");
|
||||
parcel.mAddUserIds.add("pink");
|
||||
|
||||
@@ -101,9 +101,9 @@ public class UncachedKeyringMergeTest {
|
||||
{
|
||||
SaveKeyringParcel parcel = new SaveKeyringParcel();
|
||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||
Algorithm.RSA, 1024, null, KeyFlags.CERTIFY_OTHER, 0L));
|
||||
Algorithm.ECDSA, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.CERTIFY_OTHER, 0L));
|
||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||
Algorithm.RSA, 1024, null, KeyFlags.SIGN_DATA, 0L));
|
||||
Algorithm.ECDSA, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.SIGN_DATA, 0L));
|
||||
|
||||
parcel.mAddUserIds.add("twi");
|
||||
parcel.mAddUserIds.add("pink");
|
||||
@@ -127,7 +127,7 @@ public class UncachedKeyringMergeTest {
|
||||
{
|
||||
SaveKeyringParcel parcel = new SaveKeyringParcel();
|
||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||
Algorithm.RSA, 1024, null, KeyFlags.CERTIFY_OTHER, 0L));
|
||||
Algorithm.ECDSA, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.CERTIFY_OTHER, 0L));
|
||||
|
||||
parcel.mAddUserIds.add("shy");
|
||||
// passphrase is tested in PgpKeyOperationTest, just use empty here
|
||||
|
||||
@@ -57,11 +57,11 @@ public class UncachedKeyringTest {
|
||||
|
||||
SaveKeyringParcel parcel = new SaveKeyringParcel();
|
||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||
Algorithm.RSA, 1024, null, KeyFlags.CERTIFY_OTHER, 0L));
|
||||
Algorithm.ECDSA, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.CERTIFY_OTHER, 0L));
|
||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||
Algorithm.RSA, 1024, null, KeyFlags.SIGN_DATA, 0L));
|
||||
Algorithm.ECDSA, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.SIGN_DATA, 0L));
|
||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||
Algorithm.RSA, 1024, null, KeyFlags.ENCRYPT_COMMS, 0L));
|
||||
Algorithm.ECDH, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.ENCRYPT_COMMS, 0L));
|
||||
|
||||
parcel.mAddUserIds.add("twi");
|
||||
parcel.mAddUserIds.add("pink");
|
||||
|
||||
2
extern/openpgp-api-lib
vendored
2
extern/openpgp-api-lib
vendored
Submodule extern/openpgp-api-lib updated: 5a24bb3428...b42636ec3e
Reference in New Issue
Block a user