diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-04-19 21:56:15 +0200 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-04-19 21:56:15 +0200 |
commit | 7017a01bdb68d2cd7351dfa05825676217e42532 (patch) | |
tree | 2e73c5d8027ce4b9e262baeaddf8b84a6297882f /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java | |
parent | 0383822585e60bd206742f50966bb1584ee2dfd9 (diff) | |
download | open-keychain-7017a01bdb68d2cd7351dfa05825676217e42532.tar.gz open-keychain-7017a01bdb68d2cd7351dfa05825676217e42532.tar.bz2 open-keychain-7017a01bdb68d2cd7351dfa05825676217e42532.zip |
More code cleanup
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java | 37 |
1 files changed, 31 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 77a11165d..f90250f57 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java @@ -392,15 +392,29 @@ public class PgpKeyHelper { return isCertificationKey(key.getPublicKey()); } - public static String getAlgorithmInfo(PGPPublicKey key) { - return getAlgorithmInfo(key.getAlgorithm(), key.getBitStrength()); + public static String getAlgorithmInfo(Context context, PGPPublicKey key) { + return getAlgorithmInfo(context, key.getAlgorithm(), key.getBitStrength()); } - public static String getAlgorithmInfo(PGPSecretKey key) { - return getAlgorithmInfo(key.getPublicKey()); + public static String getAlgorithmInfo(Context context, PGPSecretKey key) { + return getAlgorithmInfo(context, key.getPublicKey()); } - public static String getAlgorithmInfo(int algorithm, int keySize) { + /** + * TODO: Only used in HkpKeyServer. Get rid of this one! + */ + public static String getAlgorithmInfo(int algorithm) { + return getAlgorithmInfo(null, algorithm, 0); + } + + public static String getAlgorithmInfo(Context context, int algorithm) { + return getAlgorithmInfo(context, algorithm, 0); + } + + /** + * Based on <a href="http://tools.ietf.org/html/rfc2440#section-9.1">OpenPGP Message Format</a> + */ + public static String getAlgorithmInfo(Context context, int algorithm, int keySize) { String algorithmStr; switch (algorithm) { @@ -421,8 +435,19 @@ public class PgpKeyHelper { break; } + case PGPPublicKey.ECDSA: + case PGPPublicKey.ECDH: { + algorithmStr = "ECC"; + break; + } + default: { - algorithmStr = "Unknown"; + if (context != null) { + algorithmStr = context.getResources().getString(R.string.unknown_algorithm); + } else { + // TODO + algorithmStr = "unknown"; + } break; } } |