From 2069f20f50b808fad8fea3639e82eadd0d9bd9e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 11 Apr 2014 21:40:12 +0200 Subject: [PATCH] Clarify use of methods in PgpKeyHelper --- .../org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java | 6 +++--- .../org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java | 4 ++-- .../keychain/service/KeychainIntentService.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java index 82136ac1b..d36dd8efe 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java @@ -199,7 +199,7 @@ public class PgpKeyHelper { return getExpiryDate(key.getPublicKey()); } - public static PGPPublicKey getEncryptPublicKey(PGPPublicKeyRing keyRing) { + public static PGPPublicKey getFirstEncryptSubkey(PGPPublicKeyRing keyRing) { Vector encryptKeys = getUsableEncryptKeys(keyRing); if (encryptKeys.size() == 0) { Log.e(Constants.TAG, "encryptKeys is null!"); @@ -208,7 +208,7 @@ public class PgpKeyHelper { return encryptKeys.get(0); } - public static PGPSecretKey getCertificationKey(PGPSecretKeyRing keyRing) { + public static PGPSecretKey getFirstCertificationSubkey(PGPSecretKeyRing keyRing) { Vector signingKeys = getUsableCertificationKeys(keyRing); if (signingKeys.size() == 0) { return null; @@ -216,7 +216,7 @@ public class PgpKeyHelper { return signingKeys.get(0); } - public static PGPSecretKey getSigningKey(PGPSecretKeyRing keyRing) { + public static PGPSecretKey getFirstSigningSubkey(PGPSecretKeyRing keyRing) { Vector signingKeys = getUsableSigningKeys(keyRing); if (signingKeys.size() == 0) { return null; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java index 418433427..16b060c10 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java @@ -289,7 +289,7 @@ public class PgpSignEncrypt { throw new NoSigningKeyException(); // throw new PgpGeneralException(mContext.getString(R.string.error_signature_failed)); } - signingKey = PgpKeyHelper.getSigningKey(signingKeyRing); + signingKey = PgpKeyHelper.getFirstSigningSubkey(signingKeyRing); if (signingKey == null) { throw new NoSigningKeyException(); // throw new PgpGeneralException(mContext.getString(R.string.error_signature_failed)); @@ -337,7 +337,7 @@ public class PgpSignEncrypt { for (long id : mEncryptionMasterKeyIds) { try { PGPPublicKeyRing keyRing = mProviderHelper.getPGPPublicKeyRing(id); - PGPPublicKey key = PgpKeyHelper.getEncryptPublicKey(keyRing); + PGPPublicKey key = PgpKeyHelper.getFirstEncryptSubkey(keyRing); if (key != null) { JcePublicKeyKeyEncryptionMethodGenerator pubKeyEncryptionGenerator = new JcePublicKeyKeyEncryptionMethodGenerator(key); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index d54bc7de6..1ca143be0 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -833,7 +833,7 @@ public class KeychainIntentService extends IntentService Log.e(Constants.TAG, "key not found!", e); // TODO: throw exception here! } - PGPSecretKey certificationKey = PgpKeyHelper.getCertificationKey(secretKeyRing); + PGPSecretKey certificationKey = PgpKeyHelper.getFirstCertificationSubkey(secretKeyRing); publicKey = keyOperation.certifyKey(certificationKey, publicKey, userIds, signaturePassphrase); publicRing = PGPPublicKeyRing.insertPublicKey(publicRing, publicKey);