mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
Rearrange too long lines
This commit is contained in:
parent
d5983b324f
commit
82e5d14fb1
@ -684,7 +684,8 @@ public class PgpDecryptVerify {
|
||||
}
|
||||
|
||||
private static boolean verifyPrimaryKeyBinding(PGPSignatureSubpacketVector pkts,
|
||||
PGPPublicKey masterPublicKey, PGPPublicKey signingPublicKey) {
|
||||
PGPPublicKey masterPublicKey,
|
||||
PGPPublicKey signingPublicKey) {
|
||||
boolean validPrimaryKeyBinding = false;
|
||||
JcaPGPContentVerifierBuilderProvider contentVerifierBuilderProvider =
|
||||
new JcaPGPContentVerifierBuilderProvider()
|
||||
|
@ -51,9 +51,9 @@ public class PgpHelper {
|
||||
".*?(-----BEGIN PGP MESSAGE-----.*?-----END PGP MESSAGE-----).*", Pattern.DOTALL);
|
||||
|
||||
public static final Pattern PGP_CLEARTEXT_SIGNATURE = Pattern
|
||||
.compile(
|
||||
".*?(-----BEGIN PGP SIGNED MESSAGE-----.*?-----BEGIN PGP SIGNATURE-----.*?-----END PGP SIGNATURE-----).*",
|
||||
Pattern.DOTALL);
|
||||
.compile(".*?(-----BEGIN PGP SIGNED MESSAGE-----.*?-----" +
|
||||
"BEGIN PGP SIGNATURE-----.*?-----END PGP SIGNATURE-----).*",
|
||||
Pattern.DOTALL);
|
||||
|
||||
public static final Pattern PGP_PUBLIC_KEY = Pattern.compile(
|
||||
".*?(-----BEGIN PGP PUBLIC KEY BLOCK-----.*?-----END PGP PUBLIC KEY BLOCK-----).*",
|
||||
|
@ -168,7 +168,8 @@ public class PgpImportExport {
|
||||
return returnData;
|
||||
}
|
||||
|
||||
public Bundle exportKeyRings(ArrayList<Long> publicKeyRingMasterIds, ArrayList<Long> secretKeyRingMasterIds,
|
||||
public Bundle exportKeyRings(ArrayList<Long> publicKeyRingMasterIds,
|
||||
ArrayList<Long> secretKeyRingMasterIds,
|
||||
OutputStream outStream) throws PgpGeneralException,
|
||||
PGPException, IOException {
|
||||
Bundle returnData = new Bundle();
|
||||
|
@ -196,8 +196,8 @@ public class PgpKeyOperation {
|
||||
}
|
||||
|
||||
public PGPSecretKeyRing changeSecretKeyPassphrase(PGPSecretKeyRing keyRing, String oldPassPhrase,
|
||||
String newPassPhrase) throws IOException, PGPException,
|
||||
NoSuchProviderException {
|
||||
String newPassPhrase)
|
||||
throws IOException, PGPException, NoSuchProviderException {
|
||||
|
||||
updateProgress(R.string.progress_building_key, 0, 100);
|
||||
if (oldPassPhrase == null) {
|
||||
@ -270,13 +270,16 @@ public class PgpKeyOperation {
|
||||
GregorianCalendar expiryDate = keysExpiryDates.get(0);
|
||||
//note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c
|
||||
//here we purposefully ignore partial days in each date - long type has no fractional part!
|
||||
long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000);
|
||||
if (numDays <= 0)
|
||||
long numDays = (expiryDate.getTimeInMillis() / 86400000) -
|
||||
(creationDate.getTimeInMillis() / 86400000);
|
||||
if (numDays <= 0) {
|
||||
throw new PgpGeneralMsgIdException(R.string.error_expiry_must_come_after_creation);
|
||||
}
|
||||
hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400);
|
||||
} else {
|
||||
hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding,
|
||||
//this happens anyway
|
||||
hashedPacketsGen.setKeyExpirationTime(false, 0);
|
||||
// do this explicitly, although since we're rebuilding,
|
||||
// this happens anyway
|
||||
}
|
||||
|
||||
updateProgress(R.string.progress_building_master_key, 30, 100);
|
||||
@ -342,15 +345,16 @@ public class PgpKeyOperation {
|
||||
GregorianCalendar expiryDate = keysExpiryDates.get(i);
|
||||
//note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c
|
||||
//here we purposefully ignore partial days in each date - long type has no fractional part!
|
||||
long numDays =
|
||||
(expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000);
|
||||
long numDays = (expiryDate.getTimeInMillis() / 86400000) -
|
||||
(creationDate.getTimeInMillis() / 86400000);
|
||||
if (numDays <= 0) {
|
||||
throw new PgpGeneralMsgIdException(R.string.error_expiry_must_come_after_creation);
|
||||
}
|
||||
hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400);
|
||||
} else {
|
||||
hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding,
|
||||
//this happens anyway
|
||||
hashedPacketsGen.setKeyExpirationTime(false, 0);
|
||||
// do this explicitly, although since we're rebuilding,
|
||||
// this happens anyway
|
||||
}
|
||||
|
||||
keyGen.addSubKey(subKeyPair, hashedPacketsGen.generate(), unhashedPacketsGen.generate());
|
||||
@ -447,22 +451,28 @@ public class PgpKeyOperation {
|
||||
GregorianCalendar expiryDate = saveParcel.keysExpiryDates.get(0);
|
||||
//note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c
|
||||
//here we purposefully ignore partial days in each date - long type has no fractional part!
|
||||
long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000);
|
||||
if (numDays <= 0)
|
||||
long numDays = (expiryDate.getTimeInMillis() / 86400000) -
|
||||
(creationDate.getTimeInMillis() / 86400000);
|
||||
if (numDays <= 0) {
|
||||
throw new PgpGeneralMsgIdException(R.string.error_expiry_must_come_after_creation);
|
||||
}
|
||||
hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400);
|
||||
} else {
|
||||
hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding,
|
||||
//this happens anyway
|
||||
hashedPacketsGen.setKeyExpirationTime(false, 0);
|
||||
// do this explicitly, although since we're rebuilding,
|
||||
// this happens anyway
|
||||
}
|
||||
|
||||
if (saveParcel.primaryIDChanged || !saveParcel.originalIDs.get(0).equals(saveParcel.userIDs.get(0))) {
|
||||
if (saveParcel.primaryIDChanged ||
|
||||
!saveParcel.originalIDs.get(0).equals(saveParcel.userIDs.get(0))) {
|
||||
anyIDChanged = true;
|
||||
ArrayList<Pair<String, PGPSignature>> sigList = new ArrayList<Pair<String, PGPSignature>>();
|
||||
for (String userId : saveParcel.userIDs) {
|
||||
String origID = saveParcel.originalIDs.get(userIDIndex);
|
||||
if ((origID.equals(userId) && !saveParcel.newIDs[userIDIndex]) && !userId.equals(saveParcel.originalPrimaryID) && userIDIndex != 0) {
|
||||
Iterator<PGPSignature> origSigs = masterPublicKey.getSignaturesForID(origID); //TODO: make sure this iterator only has signatures we are interested in
|
||||
if (origID.equals(userId) && !saveParcel.newIDs[userIDIndex] &&
|
||||
!userId.equals(saveParcel.originalPrimaryID) && userIDIndex != 0) {
|
||||
Iterator<PGPSignature> origSigs = masterPublicKey.getSignaturesForID(origID);
|
||||
// TODO: make sure this iterator only has signatures we are interested in
|
||||
while (origSigs.hasNext()) {
|
||||
PGPSignature origSig = origSigs.next();
|
||||
sigList.add(new Pair<String, PGPSignature>(origID, origSig));
|
||||
@ -487,7 +497,8 @@ public class PgpKeyOperation {
|
||||
userIDIndex++;
|
||||
}
|
||||
for (Pair<String, PGPSignature> toAdd : sigList) {
|
||||
masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, toAdd.first, toAdd.second);
|
||||
masterPublicKey =
|
||||
PGPPublicKey.addCertification(masterPublicKey, toAdd.first, toAdd.second);
|
||||
}
|
||||
} else {
|
||||
for (String userId : saveParcel.userIDs) {
|
||||
@ -508,7 +519,8 @@ public class PgpKeyOperation {
|
||||
if (!saveParcel.newIDs[userIDIndex]) {
|
||||
masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID);
|
||||
}
|
||||
masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification);
|
||||
masterPublicKey =
|
||||
PGPPublicKey.addCertification(masterPublicKey, userId, certification);
|
||||
}
|
||||
userIDIndex++;
|
||||
}
|
||||
@ -520,7 +532,8 @@ public class PgpKeyOperation {
|
||||
for (String userId : saveParcel.userIDs) {
|
||||
String origID = saveParcel.originalIDs.get(userIDIndex);
|
||||
if (!(origID.equals(saveParcel.originalPrimaryID) && !saveParcel.primaryIDChanged)) {
|
||||
Iterator<PGPSignature> sigs = masterPublicKey.getSignaturesForID(userId); //TODO: make sure this iterator only has signatures we are interested in
|
||||
Iterator<PGPSignature> sigs = masterPublicKey.getSignaturesForID(userId);
|
||||
// TODO: make sure this iterator only has signatures we are interested in
|
||||
while (sigs.hasNext()) {
|
||||
PGPSignature sig = sigs.next();
|
||||
sigList.add(new Pair<String, PGPSignature>(userId, sig));
|
||||
@ -605,23 +618,27 @@ public class PgpKeyOperation {
|
||||
GregorianCalendar creationDate = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
|
||||
creationDate.setTime(subPublicKey.getCreationTime());
|
||||
GregorianCalendar expiryDate = saveParcel.keysExpiryDates.get(i);
|
||||
//note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c
|
||||
//here we purposefully ignore partial days in each date - long type has no fractional part!
|
||||
long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000);
|
||||
if (numDays <= 0)
|
||||
// note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c
|
||||
// here we purposefully ignore partial days in each date - long type has
|
||||
// no fractional part!
|
||||
long numDays = (expiryDate.getTimeInMillis() / 86400000) -
|
||||
(creationDate.getTimeInMillis() / 86400000);
|
||||
if (numDays <= 0) {
|
||||
throw new PgpGeneralMsgIdException(R.string.error_expiry_must_come_after_creation);
|
||||
}
|
||||
hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400);
|
||||
} else {
|
||||
hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding,
|
||||
//this happens anyway
|
||||
hashedPacketsGen.setKeyExpirationTime(false, 0);
|
||||
// do this explicitly, although since we're rebuilding,
|
||||
// this happens anyway
|
||||
}
|
||||
|
||||
keyGen.addSubKey(subKeyPair, hashedPacketsGen.generate(), unhashedPacketsGen.generate());
|
||||
//certifications will be discarded if the key is changed, because I think, for a start,
|
||||
//they will be invalid. Binding certs are regenerated anyway, and other certs which
|
||||
//need to be kept are on IDs and attributes
|
||||
//TODO: don't let revoked keys be edited, other than removed - changing one would result in the
|
||||
//revocation being wrong?
|
||||
// certifications will be discarded if the key is changed, because I think, for a start,
|
||||
// they will be invalid. Binding certs are regenerated anyway, and other certs which
|
||||
// need to be kept are on IDs and attributes
|
||||
// TODO: don't let revoked keys be edited, other than removed - changing one would
|
||||
// result in the revocation being wrong?
|
||||
}
|
||||
}
|
||||
|
||||
@ -660,8 +677,10 @@ public class PgpKeyOperation {
|
||||
Log.d(Constants.TAG, " ------- in private key -------");
|
||||
|
||||
for(String uid : new IterableIterator<String>(secretKeyRing.getPublicKey().getUserIDs())) {
|
||||
for(PGPSignature sig : new IterableIterator<PGPSignature>(secretKeyRing.getPublicKey().getSignaturesForID(uid))) {
|
||||
Log.d(Constants.TAG, "sig: " + PgpKeyHelper.convertKeyIdToHex(sig.getKeyID()) + " for " + uid);
|
||||
for(PGPSignature sig : new IterableIterator<PGPSignature>(
|
||||
secretKeyRing.getPublicKey().getSignaturesForID(uid))) {
|
||||
Log.d(Constants.TAG, "sig: " +
|
||||
PgpKeyHelper.convertKeyIdToHex(sig.getKeyID()) + " for " + uid);
|
||||
}
|
||||
|
||||
}
|
||||
@ -669,8 +688,10 @@ public class PgpKeyOperation {
|
||||
Log.d(Constants.TAG, " ------- in public key -------");
|
||||
|
||||
for(String uid : new IterableIterator<String>(publicKeyRing.getPublicKey().getUserIDs())) {
|
||||
for(PGPSignature sig : new IterableIterator<PGPSignature>(publicKeyRing.getPublicKey().getSignaturesForID(uid))) {
|
||||
Log.d(Constants.TAG, "sig: " + PgpKeyHelper.convertKeyIdToHex(sig.getKeyID()) + " for " + uid);
|
||||
for(PGPSignature sig : new IterableIterator<PGPSignature>(
|
||||
publicKeyRing.getPublicKey().getSignaturesForID(uid))) {
|
||||
Log.d(Constants.TAG, "sig: " +
|
||||
PgpKeyHelper.convertKeyIdToHex(sig.getKeyID()) + " for " + uid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -689,9 +710,10 @@ public class PgpKeyOperation {
|
||||
* @param passphrase Passphrase of the secret key
|
||||
* @return A keyring with added certifications
|
||||
*/
|
||||
public PGPPublicKey certifyKey(PGPSecretKey certificationKey, PGPPublicKey publicKey, List<String> userIds, String passphrase)
|
||||
public PGPPublicKey certifyKey(PGPSecretKey certificationKey, PGPPublicKey publicKey,
|
||||
List<String> userIds, String passphrase)
|
||||
throws PgpGeneralMsgIdException, NoSuchAlgorithmException, NoSuchProviderException,
|
||||
PGPException, SignatureException {
|
||||
PGPException, SignatureException {
|
||||
|
||||
// create a signatureGenerator from the supplied masterKeyId and passphrase
|
||||
PGPSignatureGenerator signatureGenerator; {
|
||||
|
@ -83,9 +83,10 @@ public class PgpToX509 {
|
||||
* @throws Exception
|
||||
* @author Bruno Harbulot
|
||||
*/
|
||||
public static X509Certificate createSelfSignedCert(PublicKey pubKey, PrivateKey privKey,
|
||||
X509Name subject, Date startDate, Date endDate, String subjAltNameURI)
|
||||
throws InvalidKeyException, IllegalStateException, NoSuchAlgorithmException,
|
||||
public static X509Certificate createSelfSignedCert(
|
||||
PublicKey pubKey, PrivateKey privKey, X509Name subject, Date startDate, Date endDate,
|
||||
String subjAltNameURI)
|
||||
throws InvalidKeyException, IllegalStateException, NoSuchAlgorithmException,
|
||||
SignatureException, CertificateException, NoSuchProviderException {
|
||||
|
||||
X509V3CertificateGenerator certGenerator = new X509V3CertificateGenerator();
|
||||
@ -182,10 +183,10 @@ public class PgpToX509 {
|
||||
/**
|
||||
* Creates a self-signed certificate from a PGP Secret Key.
|
||||
*
|
||||
* @param pgpSecKey PGP Secret Key (from which one can extract the public and private keys and other
|
||||
* attributes).
|
||||
* @param pgpPrivKey PGP Private Key corresponding to the Secret Key (password callbacks should be done
|
||||
* before calling this method)
|
||||
* @param pgpSecKey PGP Secret Key (from which one can extract the public and private
|
||||
* keys and other attributes).
|
||||
* @param pgpPrivKey PGP Private Key corresponding to the Secret Key (password callbacks
|
||||
* should be done before calling this method)
|
||||
* @param subjAltNameURI optional URI to embed in the subject alternative-name
|
||||
* @return self-signed certificate
|
||||
* @throws PGPException
|
||||
@ -196,9 +197,9 @@ public class PgpToX509 {
|
||||
* @throws CertificateException
|
||||
* @author Bruno Harbulot
|
||||
*/
|
||||
public static X509Certificate createSelfSignedCert(PGPSecretKey pgpSecKey,
|
||||
PGPPrivateKey pgpPrivKey, String subjAltNameURI) throws PGPException,
|
||||
NoSuchProviderException, InvalidKeyException, NoSuchAlgorithmException,
|
||||
public static X509Certificate createSelfSignedCert(
|
||||
PGPSecretKey pgpSecKey, PGPPrivateKey pgpPrivKey, String subjAltNameURI)
|
||||
throws PGPException, NoSuchProviderException, InvalidKeyException, NoSuchAlgorithmException,
|
||||
SignatureException, CertificateException {
|
||||
// get public key from secret key
|
||||
PGPPublicKey pgpPubKey = pgpSecKey.getPublicKey();
|
||||
|
@ -283,12 +283,14 @@ public class KeychainContract {
|
||||
/**
|
||||
* Use if multiple items get returned
|
||||
*/
|
||||
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.thialfihar.apg.api_app.accounts";
|
||||
public static final String CONTENT_TYPE =
|
||||
"vnd.android.cursor.dir/vnd.thialfihar.apg.api_app.accounts";
|
||||
|
||||
/**
|
||||
* Use if a single item is returned
|
||||
*/
|
||||
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.api_app.account";
|
||||
public static final String CONTENT_ITEM_TYPE =
|
||||
"vnd.android.cursor.item/vnd.thialfihar.apg.api_app.account";
|
||||
|
||||
public static Uri buildBaseUri(String packageName) {
|
||||
return CONTENT_URI.buildUpon().appendEncodedPath(packageName).appendPath(PATH_ACCOUNTS)
|
||||
|
@ -296,8 +296,8 @@ public class ProviderHelper {
|
||||
/**
|
||||
* Build ContentProviderOperation to add PGPPublicKey to database corresponding to a keyRing
|
||||
*/
|
||||
private static ContentProviderOperation buildPublicKeyOperations(Context context,
|
||||
long keyRingRowId, PGPPublicKey key, int rank) throws IOException {
|
||||
private static ContentProviderOperation buildPublicKeyOperations(
|
||||
Context context, long keyRingRowId, PGPPublicKey key, int rank) throws IOException {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(Keys.KEY_ID, key.getKeyID());
|
||||
values.put(Keys.IS_MASTER_KEY, key.isMasterKey());
|
||||
@ -324,8 +324,8 @@ public class ProviderHelper {
|
||||
/**
|
||||
* Build ContentProviderOperation to add PublicUserIds to database corresponding to a keyRing
|
||||
*/
|
||||
private static ContentProviderOperation buildPublicUserIdOperations(Context context,
|
||||
long keyRingRowId, String userId, int rank) {
|
||||
private static ContentProviderOperation buildPublicUserIdOperations(
|
||||
Context context, long keyRingRowId, String userId, int rank) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(UserIds.KEY_RING_ROW_ID, keyRingRowId);
|
||||
values.put(UserIds.USER_ID, userId);
|
||||
@ -339,8 +339,8 @@ public class ProviderHelper {
|
||||
/**
|
||||
* Build ContentProviderOperation to add PGPSecretKey to database corresponding to a keyRing
|
||||
*/
|
||||
private static ContentProviderOperation buildSecretKeyOperations(Context context,
|
||||
long keyRingRowId, PGPSecretKey key, int rank) throws IOException {
|
||||
private static ContentProviderOperation buildSecretKeyOperations(
|
||||
Context context, long keyRingRowId, PGPSecretKey key, int rank) throws IOException {
|
||||
ContentValues values = new ContentValues();
|
||||
|
||||
boolean hasPrivate = true;
|
||||
@ -376,8 +376,8 @@ public class ProviderHelper {
|
||||
/**
|
||||
* Build ContentProviderOperation to add SecretUserIds to database corresponding to a keyRing
|
||||
*/
|
||||
private static ContentProviderOperation buildSecretUserIdOperations(Context context,
|
||||
long keyRingRowId, String userId, int rank) {
|
||||
private static ContentProviderOperation buildSecretUserIdOperations(
|
||||
Context context, long keyRingRowId, String userId, int rank) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(UserIds.KEY_RING_ROW_ID, keyRingRowId);
|
||||
values.put(UserIds.USER_ID, userId);
|
||||
|
@ -188,7 +188,8 @@ public class OpenPgpService extends RemoteService {
|
||||
}
|
||||
|
||||
private Intent encryptAndSignImpl(Intent data, ParcelFileDescriptor input,
|
||||
ParcelFileDescriptor output, AccountSettings accSettings, boolean sign) {
|
||||
ParcelFileDescriptor output, AccountSettings accSettings,
|
||||
boolean sign) {
|
||||
try {
|
||||
boolean asciiArmor = data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
|
||||
|
||||
@ -292,7 +293,8 @@ public class OpenPgpService extends RemoteService {
|
||||
|
||||
PgpDecryptVerify.Builder builder = new PgpDecryptVerify.Builder(this, inputData, os);
|
||||
builder.allowSymmetricDecryption(false) // no support for symmetric encryption
|
||||
.allowedKeyIds(allowedKeyIds) // allow only private keys associated with accounts of this app
|
||||
.allowedKeyIds(allowedKeyIds) // allow only private keys associated with
|
||||
// accounts of this app
|
||||
.passphrase(passphrase);
|
||||
|
||||
// TODO: currently does not support binary signed-only content
|
||||
@ -300,9 +302,11 @@ public class OpenPgpService extends RemoteService {
|
||||
|
||||
if (PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) {
|
||||
// get PendingIntent for passphrase input, add it to given params and return to client
|
||||
Intent passphraseBundle = getPassphraseBundleIntent(data, decryptVerifyResult.getKeyIdPassphraseNeeded());
|
||||
Intent passphraseBundle =
|
||||
getPassphraseBundleIntent(data, decryptVerifyResult.getKeyIdPassphraseNeeded());
|
||||
return passphraseBundle;
|
||||
} else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) {
|
||||
} else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED ==
|
||||
decryptVerifyResult.getStatus()) {
|
||||
throw new PgpGeneralException("Decryption of symmetric content not supported by API!");
|
||||
}
|
||||
|
||||
@ -455,7 +459,8 @@ public class OpenPgpService extends RemoteService {
|
||||
} else if (OpenPgpApi.ACTION_DECRYPT_VERIFY.equals(action)) {
|
||||
String currentPkg = getCurrentCallingPackage();
|
||||
Set<Long> allowedKeyIds =
|
||||
ProviderHelper.getAllKeyIdsForApp(mContext, KeychainContract.ApiAccounts.buildBaseUri(currentPkg));
|
||||
ProviderHelper.getAllKeyIdsForApp(mContext,
|
||||
KeychainContract.ApiAccounts.buildBaseUri(currentPkg));
|
||||
return decryptAndVerifyImpl(data, input, output, allowedKeyIds);
|
||||
} else if (OpenPgpApi.ACTION_GET_KEY.equals(action)) {
|
||||
return getKeyImpl(data);
|
||||
|
@ -243,7 +243,8 @@ public abstract class RemoteService extends Service {
|
||||
return true;
|
||||
} else {
|
||||
throw new WrongPackageSignatureException(
|
||||
"PACKAGE NOT ALLOWED! Signature wrong! (Signature not equals signature from database)");
|
||||
"PACKAGE NOT ALLOWED! Signature wrong! (Signature not " +
|
||||
"equals signature from database)");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,8 @@ public class AccountSettingsFragment extends Fragment implements
|
||||
this.mAccSettings = accountSettings;
|
||||
|
||||
mAccNameView.setText(accountSettings.getAccountName());
|
||||
Uri keyUri = KeychainContract.KeyRings.buildSecretKeyRingsByMasterKeyIdUri(String.valueOf(accountSettings.getKeyId()));
|
||||
Uri keyUri = KeychainContract.KeyRings.buildSecretKeyRingsByMasterKeyIdUri(
|
||||
String.valueOf(accountSettings.getKeyId()));
|
||||
mSelectKeyFragment.selectKey(keyUri);
|
||||
mEncryptionAlgorithm.setSelection(mEncryptionAdapter.getPosition(accountSettings
|
||||
.getEncryptionAlgorithm()));
|
||||
|
@ -485,10 +485,13 @@ public class KeychainIntentService extends IntentService
|
||||
ProviderHelper.saveKeyRing(this, keyRing);
|
||||
setProgress(R.string.progress_done, 100, 100);
|
||||
} else {
|
||||
PgpKeyOperation keyOperations = new PgpKeyOperation(new ProgressScaler(this, 0, 90, 100));
|
||||
PGPSecretKeyRing privkey = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(this, masterKeyId);
|
||||
PGPPublicKeyRing pubkey = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(this, masterKeyId);
|
||||
PgpKeyOperation.Pair<PGPSecretKeyRing,PGPPublicKeyRing> pair =
|
||||
PgpKeyOperation keyOperations =
|
||||
new PgpKeyOperation(new ProgressScaler(this, 0, 90, 100));
|
||||
PGPSecretKeyRing privkey =
|
||||
ProviderHelper.getPGPSecretKeyRingByMasterKeyId(this, masterKeyId);
|
||||
PGPPublicKeyRing pubkey =
|
||||
ProviderHelper.getPGPPublicKeyRingByMasterKeyId(this, masterKeyId);
|
||||
PgpKeyOperation.Pair<PGPSecretKeyRing, PGPPublicKeyRing> pair =
|
||||
keyOperations.buildSecretKey(privkey, pubkey, saveParams);
|
||||
setProgress(R.string.progress_saving_key_ring, 90, 100);
|
||||
ProviderHelper.saveKeyRing(this, pair.first);
|
||||
@ -745,11 +748,14 @@ public class KeychainIntentService extends IntentService
|
||||
|
||||
// verify downloaded key by comparing fingerprints
|
||||
if (entry.getFingerPrintHex() != null) {
|
||||
String downloadedKeyFp = PgpKeyHelper.convertFingerprintToHex(downloadedKey.getPublicKey().getFingerprint());
|
||||
String downloadedKeyFp = PgpKeyHelper.convertFingerprintToHex(
|
||||
downloadedKey.getPublicKey().getFingerprint());
|
||||
if (downloadedKeyFp.equals(entry.getFingerPrintHex())) {
|
||||
Log.d(Constants.TAG, "fingerprint of downloaded key is the same as the requested fingerprint!");
|
||||
Log.d(Constants.TAG, "fingerprint of downloaded key is the same as " +
|
||||
"the requested fingerprint!");
|
||||
} else {
|
||||
throw new PgpGeneralException("fingerprint of downloaded key is NOT the same as the requested fingerprint!");
|
||||
throw new PgpGeneralException("fingerprint of downloaded key is " +
|
||||
"NOT the same as the requested fingerprint!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,8 @@ public class CertifyKeyActivity extends ActionBarActivity implements
|
||||
fingerprintBlob = ProviderHelper.getFingerprint(this, mDataUri);
|
||||
}
|
||||
String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob);
|
||||
((TextView) findViewById(R.id.fingerprint)).setText(PgpKeyHelper.colorizeFingerprint(fingerprint));
|
||||
((TextView) findViewById(R.id.fingerprint))
|
||||
.setText(PgpKeyHelper.colorizeFingerprint(fingerprint));
|
||||
}
|
||||
break;
|
||||
case LOADER_ID_USER_IDS:
|
||||
|
@ -77,8 +77,10 @@ public class DecryptActivity extends DrawerActivity {
|
||||
// Handle intent actions, maybe changes the bundles
|
||||
handleActions(getIntent());
|
||||
|
||||
mTabsAdapter.addTab(DecryptMessageFragment.class, mMessageFragmentBundle, getString(R.string.label_message));
|
||||
mTabsAdapter.addTab(DecryptFileFragment.class, mFileFragmentBundle, getString(R.string.label_file));
|
||||
mTabsAdapter.addTab(DecryptMessageFragment.class,
|
||||
mMessageFragmentBundle, getString(R.string.label_message));
|
||||
mTabsAdapter.addTab(DecryptFileFragment.class,
|
||||
mFileFragmentBundle, getString(R.string.label_file));
|
||||
mViewPager.setCurrentItem(mSwitchToTab);
|
||||
}
|
||||
|
||||
@ -164,7 +166,8 @@ public class DecryptActivity extends DrawerActivity {
|
||||
mSwitchToTab = PAGER_TAB_FILE;
|
||||
} else {
|
||||
Log.e(Constants.TAG,
|
||||
"Direct binary data without actual file in filesystem is not supported. Please use the Remote Service API!");
|
||||
"Direct binary data without actual file in filesystem is not supported. " +
|
||||
"Please use the Remote Service API!");
|
||||
Toast.makeText(this, R.string.error_only_files_are_supported, Toast.LENGTH_LONG)
|
||||
.show();
|
||||
// end activity
|
||||
|
@ -200,7 +200,8 @@ public class DecryptFileFragment extends DecryptFragment {
|
||||
|
||||
if (PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) {
|
||||
showPassphraseDialog(decryptVerifyResult.getKeyIdPassphraseNeeded());
|
||||
} else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) {
|
||||
} else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED ==
|
||||
decryptVerifyResult.getStatus()) {
|
||||
showPassphraseDialog(Id.key.symmetric);
|
||||
} else {
|
||||
AppMsg.makeText(getActivity(), R.string.decryption_successful,
|
||||
|
@ -154,7 +154,8 @@ public class DecryptMessageFragment extends DecryptFragment {
|
||||
|
||||
if (PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) {
|
||||
showPassphraseDialog(decryptVerifyResult.getKeyIdPassphraseNeeded());
|
||||
} else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) {
|
||||
} else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED ==
|
||||
decryptVerifyResult.getStatus()) {
|
||||
showPassphraseDialog(Id.key.symmetric);
|
||||
} else {
|
||||
AppMsg.makeText(getActivity(), R.string.decryption_successful,
|
||||
|
@ -125,7 +125,6 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
||||
|
||||
public void somethingChanged() {
|
||||
ActivityCompat.invalidateOptionsMenu(this);
|
||||
//Toast.makeText(this, "Needs saving: " + Boolean.toString(mNeedsSaving) + "(" + Boolean.toString(mUserIdsView.needsSaving()) + ", " + Boolean.toString(mKeysView.needsSaving()) + ")", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
public void onDeleted(Editor e, boolean wasNewItem) {
|
||||
@ -329,7 +328,9 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
cancelClicked(); //TODO: why isn't this triggered on my tablet - one of many ui problems I've had with this device. A code compatibility issue or a Samsung fail?
|
||||
cancelClicked();
|
||||
// TODO: why isn't this triggered on my tablet - one of many ui problems
|
||||
// I've had with this device. A code compatibility issue or a Samsung fail?
|
||||
return true;
|
||||
case R.id.menu_key_edit_cancel:
|
||||
cancelClicked();
|
||||
@ -340,8 +341,8 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
||||
} else {
|
||||
long masterKeyId = ProviderHelper.getMasterKeyId(this, mDataUri);
|
||||
long[] ids = new long[] {masterKeyId};
|
||||
mExportHelper.showExportKeysDialog(ids, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC,
|
||||
null);
|
||||
mExportHelper.showExportKeysDialog(
|
||||
ids, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC, null);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
|
@ -155,12 +155,16 @@ public class EncryptActivity extends DrawerActivity implements
|
||||
// Handle intent actions
|
||||
handleActions(getIntent());
|
||||
|
||||
mTabsAdapterMode.addTab(EncryptAsymmetricFragment.class, mAsymmetricFragmentBundle, getString(R.string.label_asymmetric));
|
||||
mTabsAdapterMode.addTab(EncryptSymmetricFragment.class, mSymmetricFragmentBundle, getString(R.string.label_symmetric));
|
||||
mTabsAdapterMode.addTab(EncryptAsymmetricFragment.class,
|
||||
mAsymmetricFragmentBundle, getString(R.string.label_asymmetric));
|
||||
mTabsAdapterMode.addTab(EncryptSymmetricFragment.class,
|
||||
mSymmetricFragmentBundle, getString(R.string.label_symmetric));
|
||||
mViewPagerMode.setCurrentItem(mSwitchToMode);
|
||||
|
||||
mTabsAdapterContent.addTab(EncryptMessageFragment.class, mMessageFragmentBundle, getString(R.string.label_message));
|
||||
mTabsAdapterContent.addTab(EncryptFileFragment.class, mFileFragmentBundle, getString(R.string.label_file));
|
||||
mTabsAdapterContent.addTab(EncryptMessageFragment.class,
|
||||
mMessageFragmentBundle, getString(R.string.label_message));
|
||||
mTabsAdapterContent.addTab(EncryptFileFragment.class,
|
||||
mFileFragmentBundle, getString(R.string.label_file));
|
||||
mViewPagerContent.setCurrentItem(mSwitchToContent);
|
||||
}
|
||||
|
||||
@ -212,8 +216,10 @@ public class EncryptActivity extends DrawerActivity implements
|
||||
long[] encryptionKeyIds = extras.getLongArray(EXTRA_ENCRYPTION_KEY_IDS);
|
||||
|
||||
// preselect keys given by intent
|
||||
mAsymmetricFragmentBundle.putLongArray(EncryptAsymmetricFragment.ARG_ENCRYPTION_KEY_IDS, encryptionKeyIds);
|
||||
mAsymmetricFragmentBundle.putLong(EncryptAsymmetricFragment.ARG_SIGNATURE_KEY_ID, signatureKeyId);
|
||||
mAsymmetricFragmentBundle.putLongArray(EncryptAsymmetricFragment.ARG_ENCRYPTION_KEY_IDS,
|
||||
encryptionKeyIds);
|
||||
mAsymmetricFragmentBundle.putLong(EncryptAsymmetricFragment.ARG_SIGNATURE_KEY_ID,
|
||||
signatureKeyId);
|
||||
mSwitchToMode = PAGER_MODE_ASYMMETRIC;
|
||||
|
||||
/**
|
||||
@ -234,7 +240,8 @@ public class EncryptActivity extends DrawerActivity implements
|
||||
mSwitchToContent = PAGER_CONTENT_FILE;
|
||||
} else {
|
||||
Log.e(Constants.TAG,
|
||||
"Direct binary data without actual file in filesystem is not supported by Intents. Please use the Remote Service API!");
|
||||
"Direct binary data without actual file in filesystem is not supported " +
|
||||
"by Intents. Please use the Remote Service API!");
|
||||
Toast.makeText(this, R.string.error_only_files_are_supported, Toast.LENGTH_LONG)
|
||||
.show();
|
||||
// end activity
|
||||
|
@ -253,8 +253,9 @@ public class EncryptFileFragment extends Fragment {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mEncryptInterface.getSignatureKey() != 0
|
||||
&& PassphraseCacheService.getCachedPassphrase(getActivity(), mEncryptInterface.getSignatureKey()) == null) {
|
||||
if (mEncryptInterface.getSignatureKey() != 0 &&
|
||||
PassphraseCacheService.getCachedPassphrase(getActivity(),
|
||||
mEncryptInterface.getSignatureKey()) == null) {
|
||||
showPassphraseDialog();
|
||||
|
||||
return;
|
||||
@ -283,8 +284,10 @@ public class EncryptFileFragment extends Fragment {
|
||||
}
|
||||
data.putString(KeychainIntentService.ENCRYPT_SYMMETRIC_PASSPHRASE, passphrase);
|
||||
} else {
|
||||
data.putLong(KeychainIntentService.ENCRYPT_SIGNATURE_KEY_ID, mEncryptInterface.getSignatureKey());
|
||||
data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, mEncryptInterface.getEncryptionKeys());
|
||||
data.putLong(KeychainIntentService.ENCRYPT_SIGNATURE_KEY_ID,
|
||||
mEncryptInterface.getSignatureKey());
|
||||
data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS,
|
||||
mEncryptInterface.getEncryptionKeys());
|
||||
}
|
||||
|
||||
Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename="
|
||||
|
@ -150,8 +150,9 @@ public class EncryptMessageFragment extends Fragment {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mEncryptInterface.getSignatureKey() != 0
|
||||
&& PassphraseCacheService.getCachedPassphrase(getActivity(), mEncryptInterface.getSignatureKey()) == null) {
|
||||
if (mEncryptInterface.getSignatureKey() != 0 &&
|
||||
PassphraseCacheService.getCachedPassphrase(getActivity(),
|
||||
mEncryptInterface.getSignatureKey()) == null) {
|
||||
showPassphraseDialog(toClipboard);
|
||||
|
||||
return;
|
||||
@ -182,8 +183,10 @@ public class EncryptMessageFragment extends Fragment {
|
||||
}
|
||||
data.putString(KeychainIntentService.ENCRYPT_SYMMETRIC_PASSPHRASE, passphrase);
|
||||
} else {
|
||||
data.putLong(KeychainIntentService.ENCRYPT_SIGNATURE_KEY_ID, mEncryptInterface.getSignatureKey());
|
||||
data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, mEncryptInterface.getEncryptionKeys());
|
||||
data.putLong(KeychainIntentService.ENCRYPT_SIGNATURE_KEY_ID,
|
||||
mEncryptInterface.getSignatureKey());
|
||||
data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS,
|
||||
mEncryptInterface.getEncryptionKeys());
|
||||
|
||||
boolean signOnly = (mEncryptInterface.getEncryptionKeys() == null
|
||||
|| mEncryptInterface.getEncryptionKeys().length == 0);
|
||||
|
@ -168,7 +168,8 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa
|
||||
}
|
||||
} else {
|
||||
Log.e(Constants.TAG,
|
||||
"IMPORT_KEY_FROM_KEYSERVER action needs to contain the 'query', 'key_id', or 'fingerprint' extra!");
|
||||
"IMPORT_KEY_FROM_KEYSERVER action needs to contain the 'query', 'key_id', or " +
|
||||
"'fingerprint' extra!");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -233,7 +234,7 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa
|
||||
* onNavigationItemSelected() should check whether the Fragment is already in existence
|
||||
* inside your Activity."
|
||||
* <p/>
|
||||
* from http://stackoverflow.com/questions/10983396/fragment-oncreateview-and-onactivitycreated-called-twice/14295474#14295474
|
||||
* from http://bit.ly/1dBYThO
|
||||
* <p/>
|
||||
* In our case, if we start ImportKeysActivity with parameters to directly search using a fingerprint,
|
||||
* the fragment would be loaded twice resulting in the query being empty after the second load.
|
||||
@ -337,7 +338,8 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa
|
||||
// } else {
|
||||
// status.putString(
|
||||
// EXTRA_ERROR,
|
||||
// "Scanned fingerprint does NOT match the fingerprint of the received key. You shouldnt trust this key.");
|
||||
// "Scanned fingerprint does NOT match the fingerprint of the received key. " +
|
||||
// "You shouldnt trust this key.");
|
||||
// }
|
||||
// }
|
||||
// } catch (QueryException e) {
|
||||
|
@ -66,11 +66,13 @@ public class KeyListActivity extends DrawerActivity {
|
||||
|
||||
return true;
|
||||
case R.id.menu_key_list_export_public:
|
||||
mExportHelper.showExportKeysDialog(null, Id.type.public_key, Constants.Path.APP_DIR_FILE_PUB, null);
|
||||
mExportHelper.showExportKeysDialog(null,
|
||||
Id.type.public_key, Constants.Path.APP_DIR_FILE_PUB, null);
|
||||
|
||||
return true;
|
||||
case R.id.menu_key_list_secret_export:
|
||||
mExportHelper.showExportKeysDialog(null, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC, null);
|
||||
mExportHelper.showExportKeysDialog(null, Id.type.secret_key,
|
||||
Constants.Path.APP_DIR_FILE_SEC, null);
|
||||
|
||||
return true;
|
||||
default:
|
||||
|
@ -190,12 +190,15 @@ public class KeyListFragment extends Fragment
|
||||
ProviderHelper.getPublicKeyRingsRowIds(getActivity());
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
if (allPubRowIds.contains(ids[i])) {
|
||||
masterKeyIds[i] = ProviderHelper.getPublicMasterKeyId(getActivity(), ids[i]);
|
||||
masterKeyIds[i] =
|
||||
ProviderHelper.getPublicMasterKeyId(getActivity(), ids[i]);
|
||||
} else {
|
||||
masterKeyIds[i] = ProviderHelper.getSecretMasterKeyId(getActivity(), ids[i]);
|
||||
masterKeyIds[i] =
|
||||
ProviderHelper.getSecretMasterKeyId(getActivity(), ids[i]);
|
||||
}
|
||||
}
|
||||
ExportHelper mExportHelper = new ExportHelper((ActionBarActivity) getActivity());
|
||||
ExportHelper mExportHelper =
|
||||
new ExportHelper((ActionBarActivity) getActivity());
|
||||
mExportHelper
|
||||
.showExportKeysDialog(masterKeyIds, Id.type.public_key,
|
||||
Constants.Path.APP_DIR_FILE_PUB,
|
||||
|
@ -124,7 +124,8 @@ public class ViewKeyActivity extends ActionBarActivity {
|
||||
return true;
|
||||
case R.id.menu_key_view_export_file:
|
||||
long masterKeyId =
|
||||
ProviderHelper.getPublicMasterKeyId(this, Long.valueOf(mDataUri.getLastPathSegment()));
|
||||
ProviderHelper.getPublicMasterKeyId(this,
|
||||
Long.valueOf(mDataUri.getLastPathSegment()));
|
||||
long[] ids = new long[] {masterKeyId};
|
||||
mExportHelper.showExportKeysDialog(ids, Id.type.public_key,
|
||||
Constants.Path.APP_DIR_FILE_PUB, null);
|
||||
|
@ -267,6 +267,8 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
||||
* Based on <a href="http://tools.ietf.org/html/rfc2440#section-9.1">OpenPGP Message Format</a>
|
||||
*/
|
||||
public static String getAlgorithmFromId(int algorithmId) {
|
||||
return (ALGORITHM_IDS.get(algorithmId) != null ? ALGORITHM_IDS.get(algorithmId) : ALGORITHM_IDS.get(-1));
|
||||
return (ALGORITHM_IDS.get(algorithmId) != null ?
|
||||
ALGORITHM_IDS.get(algorithmId) :
|
||||
ALGORITHM_IDS.get(-1));
|
||||
}
|
||||
}
|
||||
|
@ -166,9 +166,10 @@ public class DeleteKeyDialogFragment extends DialogFragment {
|
||||
masterKeyId = cursor.getLong(0);
|
||||
keyType = cursor.getLong(1);
|
||||
|
||||
Log.d(Constants.TAG, "masterKeyId: " + masterKeyId
|
||||
+ ", keyType:" + (keyType == KeychainContract.KeyTypes.PUBLIC ? "Public" : "Private"));
|
||||
|
||||
Log.d(Constants.TAG, "masterKeyId: " + masterKeyId +
|
||||
", keyType:" +
|
||||
(keyType == KeychainContract.KeyTypes.PUBLIC ?
|
||||
"Public" : "Private"));
|
||||
|
||||
if (keyType == KeychainContract.KeyTypes.SECRET) {
|
||||
if (mCheckDeleteSecret.isChecked() || mIsSingleSelection) {
|
||||
@ -176,7 +177,8 @@ public class DeleteKeyDialogFragment extends DialogFragment {
|
||||
String.valueOf(masterKeyId), true);
|
||||
}
|
||||
} else {
|
||||
ProviderHelper.deleteUnifiedKeyRing(activity, String.valueOf(masterKeyId), false);
|
||||
ProviderHelper.deleteUnifiedKeyRing(activity,
|
||||
String.valueOf(masterKeyId), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class ShareQrCodeDialogFragment extends DialogFragment {
|
||||
content = keyringArmored.get(0);
|
||||
|
||||
// OnClickListener are set in onResume to prevent automatic dismissing of Dialogs
|
||||
// http://stackoverflow.com/questions/2620444/how-to-prevent-a-dialog-from-closing-when-a-button-is-clicked
|
||||
// http://bit.ly/O5vfaR
|
||||
alert.setPositiveButton(R.string.btn_next, null);
|
||||
alert.setNegativeButton(android.R.string.cancel, null);
|
||||
|
||||
|
@ -94,11 +94,13 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
|
||||
GregorianCalendar date = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
|
||||
date.set(year, monthOfYear, dayOfMonth);
|
||||
if (mOriginalExpiryDate != null) {
|
||||
long numDays = (date.getTimeInMillis() / 86400000) - (mOriginalExpiryDate.getTimeInMillis() / 86400000);
|
||||
if (numDays == 0)
|
||||
long numDays = (date.getTimeInMillis() / 86400000) -
|
||||
(mOriginalExpiryDate.getTimeInMillis() / 86400000);
|
||||
if (numDays == 0) {
|
||||
setExpiryDate(mOriginalExpiryDate);
|
||||
else
|
||||
} else {
|
||||
setExpiryDate(date);
|
||||
}
|
||||
} else {
|
||||
setExpiryDate(date);
|
||||
}
|
||||
@ -316,11 +318,16 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
|
||||
}
|
||||
|
||||
public int getUsage() {
|
||||
mUsage = (mUsage & ~KeyFlags.CERTIFY_OTHER) | (mChkCertify.isChecked() ? KeyFlags.CERTIFY_OTHER : 0);
|
||||
mUsage = (mUsage & ~KeyFlags.SIGN_DATA) | (mChkSign.isChecked() ? KeyFlags.SIGN_DATA : 0);
|
||||
mUsage = (mUsage & ~KeyFlags.ENCRYPT_COMMS) | (mChkEncrypt.isChecked() ? KeyFlags.ENCRYPT_COMMS : 0);
|
||||
mUsage = (mUsage & ~KeyFlags.ENCRYPT_STORAGE) | (mChkEncrypt.isChecked() ? KeyFlags.ENCRYPT_STORAGE : 0);
|
||||
mUsage = (mUsage & ~KeyFlags.AUTHENTICATION) | (mChkAuthenticate.isChecked() ? KeyFlags.AUTHENTICATION : 0);
|
||||
mUsage = (mUsage & ~KeyFlags.CERTIFY_OTHER) |
|
||||
(mChkCertify.isChecked() ? KeyFlags.CERTIFY_OTHER : 0);
|
||||
mUsage = (mUsage & ~KeyFlags.SIGN_DATA) |
|
||||
(mChkSign.isChecked() ? KeyFlags.SIGN_DATA : 0);
|
||||
mUsage = (mUsage & ~KeyFlags.ENCRYPT_COMMS) |
|
||||
(mChkEncrypt.isChecked() ? KeyFlags.ENCRYPT_COMMS : 0);
|
||||
mUsage = (mUsage & ~KeyFlags.ENCRYPT_STORAGE) |
|
||||
(mChkEncrypt.isChecked() ? KeyFlags.ENCRYPT_STORAGE : 0);
|
||||
mUsage = (mUsage & ~KeyFlags.AUTHENTICATION) |
|
||||
(mChkAuthenticate.isChecked() ? KeyFlags.AUTHENTICATION : 0);
|
||||
|
||||
return mUsage;
|
||||
}
|
||||
|
@ -69,20 +69,22 @@ public class HkpKeyServer extends KeyServer {
|
||||
/**
|
||||
* pub:%keyid%:%algo%:%keylen%:%creationdate%:%expirationdate%:%flags%
|
||||
* <ul>
|
||||
* <li>%<b>keyid</b>% = this is either the fingerprint or the key ID of the key. Either the 16-digit or 8-digit
|
||||
* key IDs are acceptable, but obviously the fingerprint is best.</li>
|
||||
* <li>%<b>keyid</b>% = this is either the fingerprint or the key ID of the key.
|
||||
* Either the 16-digit or 8-digit key IDs are acceptable, but obviously the fingerprint is best.
|
||||
* </li>
|
||||
* <li>%<b>algo</b>% = the algorithm number, (i.e. 1==RSA, 17==DSA, etc).
|
||||
* See <a href="http://tools.ietf.org/html/rfc2440#section-9.1">RFC-2440</a></li>
|
||||
* <li>%<b>keylen</b>% = the key length (i.e. 1024, 2048, 4096, etc.)</li>
|
||||
* <li>%<b>creationdate</b>% = creation date of the key in standard
|
||||
* <a href="http://tools.ietf.org/html/rfc2440#section-9.1">RFC-2440</a> form (i.e. number of seconds since
|
||||
* 1/1/1970 UTC time)</li>
|
||||
* <a href="http://tools.ietf.org/html/rfc2440#section-9.1">RFC-2440</a> form (i.e. number of
|
||||
* seconds since 1/1/1970 UTC time)</li>
|
||||
* <li>%<b>expirationdate</b>% = expiration date of the key in standard
|
||||
* <a href="http://tools.ietf.org/html/rfc2440#section-9.1">RFC-2440</a> form (i.e. number of seconds since
|
||||
* 1/1/1970 UTC time)</li>
|
||||
* <li>%<b>flags</b>% = letter codes to indicate details of the key, if any. Flags may be in any order. The
|
||||
* meaning of "disabled" is implementation-specific. Note that individual flags may be unimplemented, so
|
||||
* the absence of a given flag does not necessarily mean the absence of the detail.
|
||||
* <a href="http://tools.ietf.org/html/rfc2440#section-9.1">RFC-2440</a> form (i.e. number of
|
||||
* seconds since 1/1/1970 UTC time)</li>
|
||||
* <li>%<b>flags</b>% = letter codes to indicate details of the key, if any. Flags may be in any
|
||||
* order. The meaning of "disabled" is implementation-specific. Note that individual flags may
|
||||
* be unimplemented, so the absence of a given flag does not necessarily mean the absence of the
|
||||
* detail.
|
||||
* <ul>
|
||||
* <li>r == revoked</li>
|
||||
* <li>d == disabled</li>
|
||||
@ -91,7 +93,8 @@ public class HkpKeyServer extends KeyServer {
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* @see <a href="http://tools.ietf.org/html/draft-shaw-openpgp-hkp-00#section-5.2">5.2. Machine Readable Indexes</a>
|
||||
* @see <a href="http://tools.ietf.org/html/draft-shaw-openpgp-hkp-00#section-5.2">
|
||||
* 5.2. Machine Readable Indexes</a>
|
||||
* in Internet-Draft OpenPGP HTTP Keyserver Protocol Document
|
||||
*/
|
||||
public static final Pattern PUB_KEY_LINE = Pattern
|
||||
@ -102,17 +105,19 @@ public class HkpKeyServer extends KeyServer {
|
||||
/**
|
||||
* uid:%escaped uid string%:%creationdate%:%expirationdate%:%flags%
|
||||
* <ul>
|
||||
* <li>%<b>escaped uid string</b>% = the user ID string, with HTTP %-escaping for anything that isn't 7-bit
|
||||
* safe as well as for the ":" character. Any other characters may be escaped, as desired.</li>
|
||||
* <li>%<b>escaped uid string</b>% = the user ID string, with HTTP %-escaping for anything that
|
||||
* isn't 7-bit safe as well as for the ":" character. Any other characters may be escaped, as
|
||||
* desired.</li>
|
||||
* <li>%<b>creationdate</b>% = creation date of the key in standard
|
||||
* <a href="http://tools.ietf.org/html/rfc2440#section-9.1">RFC-2440</a> form (i.e. number of seconds since
|
||||
* 1/1/1970 UTC time)</li>
|
||||
* <a href="http://tools.ietf.org/html/rfc2440#section-9.1">RFC-2440</a> form (i.e. number of
|
||||
* seconds since 1/1/1970 UTC time)</li>
|
||||
* <li>%<b>expirationdate</b>% = expiration date of the key in standard
|
||||
* <a href="http://tools.ietf.org/html/rfc2440#section-9.1">RFC-2440</a> form (i.e. number of seconds since
|
||||
* 1/1/1970 UTC time)</li>
|
||||
* <li>%<b>flags</b>% = letter codes to indicate details of the key, if any. Flags may be in any order. The
|
||||
* meaning of "disabled" is implementation-specific. Note that individual flags may be unimplemented, so
|
||||
* the absence of a given flag does not necessarily mean the absence of the detail.
|
||||
* <a href="http://tools.ietf.org/html/rfc2440#section-9.1">RFC-2440</a> form (i.e. number of
|
||||
* seconds since 1/1/1970 UTC time)</li>
|
||||
* <li>%<b>flags</b>% = letter codes to indicate details of the key, if any. Flags may be in any
|
||||
* order. The meaning of "disabled" is implementation-specific. Note that individual flags may
|
||||
* be unimplemented, so the absence of a given flag does not necessarily mean the absence of
|
||||
* the detail.
|
||||
* <ul>
|
||||
* <li>r == revoked</li>
|
||||
* <li>d == disabled</li>
|
||||
@ -244,8 +249,7 @@ public class HkpKeyServer extends KeyServer {
|
||||
entry.setAlgorithm(ImportKeysListEntry.getAlgorithmFromId(algorithmId));
|
||||
|
||||
// group 1 contains the full fingerprint (v4) or the long key id if available
|
||||
// see https://bitbucket.org/skskeyserver/sks-keyserver/pull-request/12/fixes-for-machine-readable-indexes/diff
|
||||
// and https://github.com/openpgp-keychain/openpgp-keychain/issues/259#issuecomment-38168176
|
||||
// see http://bit.ly/1d4bxbk and http://bit.ly/1gD1wwr
|
||||
String fingerprintOrKeyId = matcher.group(1);
|
||||
if (fingerprintOrKeyId.length() > 16) {
|
||||
entry.setFingerPrintHex(fingerprintOrKeyId.toLowerCase(Locale.US));
|
||||
|
Loading…
Reference in New Issue
Block a user