From d75ea3f9e5b891e2dced2bb7cc0700c35f5bb7d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 4 Feb 2014 14:20:49 +0100 Subject: Certify not sign a key, added as button, does not belong to menu --- .../keychain/service/KeychainIntentService.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 657d40a5a..ddb53736a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -54,7 +54,6 @@ import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry; import org.sufficientlysecure.keychain.util.HkpKeyServer; import org.sufficientlysecure.keychain.util.InputData; import org.sufficientlysecure.keychain.util.Log; -import org.sufficientlysecure.keychain.util.PositionAwareInputStream; import org.sufficientlysecure.keychain.util.ProgressDialogUpdater; import android.app.IntentService; @@ -96,7 +95,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial public static final String ACTION_UPLOAD_KEYRING = Constants.INTENT_PREFIX + "UPLOAD_KEYRING"; public static final String ACTION_DOWNLOAD_AND_IMPORT_KEYS = Constants.INTENT_PREFIX + "QUERY_KEYRING"; - public static final String ACTION_SIGN_KEYRING = Constants.INTENT_PREFIX + "SIGN_KEYRING"; + public static final String ACTION_CERTIFY_KEYRING = Constants.INTENT_PREFIX + "SIGN_KEYRING"; /* keys for data bundle */ @@ -163,8 +162,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial public static final String DOWNLOAD_KEY_LIST = "query_key_id"; // sign key - public static final String SIGN_KEY_MASTER_KEY_ID = "sign_key_master_key_id"; - public static final String SIGN_KEY_PUB_KEY_ID = "sign_key_pub_key_id"; + public static final String CERTIFY_KEY_MASTER_KEY_ID = "sign_key_master_key_id"; + public static final String CERTIFY_KEY_PUB_KEY_ID = "sign_key_pub_key_id"; /* * possible data keys as result send over messenger @@ -777,19 +776,19 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - } else if (ACTION_SIGN_KEYRING.equals(action)) { + } else if (ACTION_CERTIFY_KEYRING.equals(action)) { try { /* Input */ - long masterKeyId = data.getLong(SIGN_KEY_MASTER_KEY_ID); - long pubKeyId = data.getLong(SIGN_KEY_PUB_KEY_ID); + long masterKeyId = data.getLong(CERTIFY_KEY_MASTER_KEY_ID); + long pubKeyId = data.getLong(CERTIFY_KEY_PUB_KEY_ID); /* Operation */ String signaturePassPhrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId); PgpKeyOperation keyOperation = new PgpKeyOperation(this, this); - PGPPublicKeyRing signedPubKeyRing = keyOperation.signKey(masterKeyId, pubKeyId, + PGPPublicKeyRing signedPubKeyRing = keyOperation.certifyKey(masterKeyId, pubKeyId, signaturePassPhrase); // store the signed key in our local cache -- cgit v1.2.3 From d090d4d332c9b1f5174890de531e2cc6936c038b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 4 Feb 2014 19:53:50 +0100 Subject: work on lookup key, fix some illegal state exceptions with hack --- .../sufficientlysecure/keychain/service/KeychainIntentService.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index ddb53736a..870e45ea5 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -123,7 +123,6 @@ public class KeychainIntentService extends IntentService implements ProgressDial public static final String DECRYPT_RETURN_BYTES = "return_binary"; public static final String DECRYPT_CIPHERTEXT_BYTES = "ciphertext_bytes"; public static final String DECRYPT_ASSUME_SYMMETRIC = "assume_symmetric"; - public static final String DECRYPT_LOOKUP_UNKNOWN_KEY = "lookup_unknownKey"; // save keyring public static final String SAVE_KEYRING_NEW_PASSPHRASE = "new_passphrase"; @@ -188,7 +187,6 @@ public class KeychainIntentService extends IntentService implements ProgressDial public static final String RESULT_SIGNATURE_SUCCESS = "signature_success"; public static final String RESULT_SIGNATURE_UNKNOWN = "signature_unknown"; - public static final String RESULT_SIGNATURE_LOOKUP_KEY = "lookup_key"; // import public static final String RESULT_IMPORT_ADDED = "added"; @@ -395,8 +393,6 @@ public class KeychainIntentService extends IntentService implements ProgressDial boolean returnBytes = data.getBoolean(DECRYPT_RETURN_BYTES); boolean assumeSymmetricEncryption = data.getBoolean(DECRYPT_ASSUME_SYMMETRIC); - boolean lookupUnknownKey = data.getBoolean(DECRYPT_LOOKUP_UNKNOWN_KEY); - InputStream inStream = null; long inLength = -1; InputData inputData = null; @@ -472,7 +468,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial // verification of signatures PgpOperation operation = new PgpOperation(this, this, inputData, outStream); if (signedOnly) { - resultData = operation.verifyText(lookupUnknownKey); + resultData = operation.verifyText(); } else { resultData = operation.decryptAndVerify( PassphraseCacheService.getCachedPassphrase(this, secretKeyId), -- cgit v1.2.3 From acad2ba95723a940467e89a07e91498188a88745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 14 Feb 2014 13:40:24 +0100 Subject: PendingIntent to handle user input --- .../org/sufficientlysecure/keychain/service/KeychainIntentService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 870e45ea5..1de9ab985 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -235,7 +235,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial String action = intent.getAction(); - // execute action from extra bundle + // executeServiceMethod action from extra bundle if (ACTION_ENCRYPT_SIGN.equals(action)) { try { /* Input */ -- cgit v1.2.3 From 1710f4416f8363a43fb7174c54b61c6c18248eab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 19 Feb 2014 00:18:52 +0100 Subject: Use builder pattern for sign and encrypt --- .../keychain/service/KeychainIntentService.java | 49 ++++++++++++++-------- 1 file changed, 32 insertions(+), 17 deletions(-) (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 1de9ab985..8d8f4e796 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -46,7 +46,8 @@ import org.sufficientlysecure.keychain.pgp.PgpConversionHelper; import org.sufficientlysecure.keychain.pgp.PgpHelper; import org.sufficientlysecure.keychain.pgp.PgpImportExport; import org.sufficientlysecure.keychain.pgp.PgpKeyOperation; -import org.sufficientlysecure.keychain.pgp.PgpOperation; +import org.sufficientlysecure.keychain.pgp.PgpOperationIncoming; +import org.sufficientlysecure.keychain.pgp.PgpOperationOutgoing; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.provider.KeychainContract.DataStream; import org.sufficientlysecure.keychain.provider.ProviderHelper; @@ -316,27 +317,41 @@ public class KeychainIntentService extends IntentService implements ProgressDial } /* Operation */ - PgpOperation operation = new PgpOperation(this, this, inputData, outStream); + PgpOperationOutgoing.Builder builder = + new PgpOperationOutgoing.Builder(this, inputData, outStream); + builder.progress(this); + if (generateSignature) { Log.d(Constants.TAG, "generating signature..."); - operation.generateSignature(useAsciiArmor, false, secretKeyId, - PassphraseCacheService.getCachedPassphrase(this, secretKeyId), - Preferences.getPreferences(this).getDefaultHashAlgorithm(), Preferences - .getPreferences(this).getForceV3Signatures()); + builder.enableAsciiArmorOutput(useAsciiArmor) + .signatureForceV3(Preferences.getPreferences(this).getForceV3Signatures()) + .signatureKeyId(secretKeyId) + .signatureHashAlgorithm(Preferences.getPreferences(this).getDefaultHashAlgorithm()) + .signaturePassphrase(PassphraseCacheService.getCachedPassphrase(this, secretKeyId)); + + builder.build().generateSignature(); } else if (signOnly) { Log.d(Constants.TAG, "sign only..."); - operation.signText(secretKeyId, PassphraseCacheService.getCachedPassphrase( - this, secretKeyId), Preferences.getPreferences(this) - .getDefaultHashAlgorithm(), Preferences.getPreferences(this) - .getForceV3Signatures()); + builder.enableAsciiArmorOutput(useAsciiArmor) + .signatureForceV3(Preferences.getPreferences(this).getForceV3Signatures()) + .signatureKeyId(secretKeyId) + .signatureHashAlgorithm(Preferences.getPreferences(this).getDefaultHashAlgorithm()) + .signaturePassphrase(PassphraseCacheService.getCachedPassphrase(this, secretKeyId)); + + builder.build().signAndEncrypt(); } else { Log.d(Constants.TAG, "encrypt..."); - operation.signAndEncrypt(useAsciiArmor, compressionId, encryptionKeyIds, - encryptionPassphrase, Preferences.getPreferences(this) - .getDefaultEncryptionAlgorithm(), secretKeyId, Preferences - .getPreferences(this).getDefaultHashAlgorithm(), Preferences - .getPreferences(this).getForceV3Signatures(), - PassphraseCacheService.getCachedPassphrase(this, secretKeyId)); + builder.enableAsciiArmorOutput(useAsciiArmor) + .compressionId(compressionId) + .symmetricEncryptionAlgorithm(Preferences.getPreferences(this).getDefaultEncryptionAlgorithm()) + .signatureForceV3(Preferences.getPreferences(this).getForceV3Signatures()) + .encryptionKeyIds(encryptionKeyIds) + .encryptionPassphrase(encryptionPassphrase) + .signatureKeyId(secretKeyId) + .signatureHashAlgorithm(Preferences.getPreferences(this).getDefaultHashAlgorithm()) + .signaturePassphrase(PassphraseCacheService.getCachedPassphrase(this, secretKeyId)); + + builder.build().signAndEncrypt(); } outStream.close(); @@ -466,7 +481,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial // verifyText and decrypt returning additional resultData values for the // verification of signatures - PgpOperation operation = new PgpOperation(this, this, inputData, outStream); + PgpOperationIncoming operation = new PgpOperationIncoming(this, this, inputData, outStream); if (signedOnly) { resultData = operation.verifyText(); } else { -- cgit v1.2.3 From b952af90e6b5a3007f4d1230e1ec78a0d90cbc29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 19 Feb 2014 13:04:29 +0100 Subject: Builder pattern for PgpOperationIncoming --- .../keychain/service/KeychainIntentService.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 8d8f4e796..422ce010c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -481,13 +481,16 @@ public class KeychainIntentService extends IntentService implements ProgressDial // verifyText and decrypt returning additional resultData values for the // verification of signatures - PgpOperationIncoming operation = new PgpOperationIncoming(this, this, inputData, outStream); + PgpOperationIncoming.Builder builder = new PgpOperationIncoming.Builder(this, inputData, outStream); + builder.progress(this); + if (signedOnly) { - resultData = operation.verifyText(); + resultData = builder.build().verifyText(); } else { - resultData = operation.decryptAndVerify( - PassphraseCacheService.getCachedPassphrase(this, secretKeyId), - assumeSymmetricEncryption); + builder.assumeSymmetric(assumeSymmetricEncryption) + .passphrase(PassphraseCacheService.getCachedPassphrase(this, secretKeyId)); + + resultData = builder.build().decryptAndVerify(); } outStream.close(); -- cgit v1.2.3 From aaddd26b51a9d3a8e230a704cb33de8e9a5bcbef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 21 Feb 2014 02:31:30 +0100 Subject: verification of cleartext signatures works --- .../keychain/service/KeychainIntentService.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 422ce010c..4ce1569f0 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -120,7 +120,6 @@ public class KeychainIntentService extends IntentService implements ProgressDial public static final String ENCRYPT_PROVIDER_URI = "provider_uri"; // decrypt/verify - public static final String DECRYPT_SIGNED_ONLY = "signed_only"; public static final String DECRYPT_RETURN_BYTES = "return_binary"; public static final String DECRYPT_CIPHERTEXT_BYTES = "ciphertext_bytes"; public static final String DECRYPT_ASSUME_SYMMETRIC = "assume_symmetric"; @@ -185,6 +184,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial public static final String RESULT_SIGNATURE = "signature"; public static final String RESULT_SIGNATURE_KEY_ID = "signature_key_id"; public static final String RESULT_SIGNATURE_USER_ID = "signature_user_id"; + public static final String RESULT_CLEARTEXT_SIGNATURE_ONLY = "signature_only"; public static final String RESULT_SIGNATURE_SUCCESS = "signature_success"; public static final String RESULT_SIGNATURE_UNKNOWN = "signature_unknown"; @@ -338,7 +338,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial .signatureHashAlgorithm(Preferences.getPreferences(this).getDefaultHashAlgorithm()) .signaturePassphrase(PassphraseCacheService.getCachedPassphrase(this, secretKeyId)); - builder.build().signAndEncrypt(); + builder.build().signEncrypt(); } else { Log.d(Constants.TAG, "encrypt..."); builder.enableAsciiArmorOutput(useAsciiArmor) @@ -351,7 +351,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial .signatureHashAlgorithm(Preferences.getPreferences(this).getDefaultHashAlgorithm()) .signaturePassphrase(PassphraseCacheService.getCachedPassphrase(this, secretKeyId)); - builder.build().signAndEncrypt(); + builder.build().signEncrypt(); } outStream.close(); @@ -404,7 +404,6 @@ public class KeychainIntentService extends IntentService implements ProgressDial long secretKeyId = data.getLong(ENCRYPT_SECRET_KEY_ID); byte[] bytes = data.getByteArray(DECRYPT_CIPHERTEXT_BYTES); - boolean signedOnly = data.getBoolean(DECRYPT_SIGNED_ONLY); boolean returnBytes = data.getBoolean(DECRYPT_RETURN_BYTES); boolean assumeSymmetricEncryption = data.getBoolean(DECRYPT_ASSUME_SYMMETRIC); @@ -484,14 +483,10 @@ public class KeychainIntentService extends IntentService implements ProgressDial PgpOperationIncoming.Builder builder = new PgpOperationIncoming.Builder(this, inputData, outStream); builder.progress(this); - if (signedOnly) { - resultData = builder.build().verifyText(); - } else { - builder.assumeSymmetric(assumeSymmetricEncryption) - .passphrase(PassphraseCacheService.getCachedPassphrase(this, secretKeyId)); + builder.assumeSymmetric(assumeSymmetricEncryption) + .passphrase(PassphraseCacheService.getCachedPassphrase(this, secretKeyId)); - resultData = builder.build().decryptAndVerify(); - } + resultData = builder.build().decryptVerify(); outStream.close(); -- cgit v1.2.3 From fb0816c1267de978a3be51a7bd9c640dfce7ad80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 21 Feb 2014 02:40:44 +0100 Subject: internal renaming, cleanup --- .../keychain/service/KeychainIntentService.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 4ce1569f0..3904a91d8 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -43,11 +43,11 @@ import org.sufficientlysecure.keychain.helper.FileHelper; import org.sufficientlysecure.keychain.helper.OtherHelper; import org.sufficientlysecure.keychain.helper.Preferences; import org.sufficientlysecure.keychain.pgp.PgpConversionHelper; +import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify; import org.sufficientlysecure.keychain.pgp.PgpHelper; import org.sufficientlysecure.keychain.pgp.PgpImportExport; import org.sufficientlysecure.keychain.pgp.PgpKeyOperation; -import org.sufficientlysecure.keychain.pgp.PgpOperationIncoming; -import org.sufficientlysecure.keychain.pgp.PgpOperationOutgoing; +import org.sufficientlysecure.keychain.pgp.PgpSignEncrypt; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.provider.KeychainContract.DataStream; import org.sufficientlysecure.keychain.provider.ProviderHelper; @@ -317,8 +317,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial } /* Operation */ - PgpOperationOutgoing.Builder builder = - new PgpOperationOutgoing.Builder(this, inputData, outStream); + PgpSignEncrypt.Builder builder = + new PgpSignEncrypt.Builder(this, inputData, outStream); builder.progress(this); if (generateSignature) { @@ -338,7 +338,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial .signatureHashAlgorithm(Preferences.getPreferences(this).getDefaultHashAlgorithm()) .signaturePassphrase(PassphraseCacheService.getCachedPassphrase(this, secretKeyId)); - builder.build().signEncrypt(); + builder.build().execute(); } else { Log.d(Constants.TAG, "encrypt..."); builder.enableAsciiArmorOutput(useAsciiArmor) @@ -351,7 +351,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial .signatureHashAlgorithm(Preferences.getPreferences(this).getDefaultHashAlgorithm()) .signaturePassphrase(PassphraseCacheService.getCachedPassphrase(this, secretKeyId)); - builder.build().signEncrypt(); + builder.build().execute(); } outStream.close(); @@ -480,13 +480,13 @@ public class KeychainIntentService extends IntentService implements ProgressDial // verifyText and decrypt returning additional resultData values for the // verification of signatures - PgpOperationIncoming.Builder builder = new PgpOperationIncoming.Builder(this, inputData, outStream); + PgpDecryptVerify.Builder builder = new PgpDecryptVerify.Builder(this, inputData, outStream); builder.progress(this); builder.assumeSymmetric(assumeSymmetricEncryption) .passphrase(PassphraseCacheService.getCachedPassphrase(this, secretKeyId)); - resultData = builder.build().decryptVerify(); + resultData = builder.build().execute(); outStream.close(); -- cgit v1.2.3