diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-02-01 16:17:33 +0100 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-02-01 16:17:33 +0100 |
commit | 5359205b5081134b31656696d426f8ed9a522679 (patch) | |
tree | 8df89db3971010e6d988bc9fbfa68b5495c81ee1 /OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java | |
parent | 4c8809042fcdf1a69ecd303e32ed66783eaae39c (diff) | |
download | open-keychain-5359205b5081134b31656696d426f8ed9a522679.tar.gz open-keychain-5359205b5081134b31656696d426f8ed9a522679.tar.bz2 open-keychain-5359205b5081134b31656696d426f8ed9a522679.zip |
Fix layout, add API notes to README, register fingerprint URIs, some reformatting (sry)
Diffstat (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java')
-rw-r--r-- | OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java index 7ab7aae3f..3fc63cda1 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java @@ -42,17 +42,6 @@ import android.content.Context; public class PgpKeyHelper { - /** - * Returns the last 9 chars of a fingerprint - * - * @param fingerprint - * String containing short or long fingerprint - * @return - */ - public static String shortifyFingerprint(String fingerprint) { - return fingerprint.substring(41); - } - public static Date getCreationDate(PGPPublicKey key) { return key.getCreationTime(); } @@ -175,10 +164,6 @@ public class PgpKeyHelper { return true; } - public static boolean isExpired(PGPSecretKey key) { - return isExpired(key.getPublicKey()); - } - public static Vector<PGPSecretKey> getUsableCertificationKeys(PGPSecretKeyRing keyRing) { Vector<PGPSecretKey> usableKeys = new Vector<PGPSecretKey>(); Vector<PGPSecretKey> signingKeys = getCertificationKeys(keyRing); @@ -460,12 +445,12 @@ public class PgpKeyHelper { * @param fp * @return */ - public static String convertFingerprintToHex(byte[] fp) { + public static String convertFingerprintToHex(byte[] fp, boolean chunked) { String fingerPrint = ""; for (int i = 0; i < fp.length; ++i) { - if (i != 0 && i % 10 == 0) { + if (chunked && i != 0 && i % 10 == 0) { fingerPrint += " "; - } else if (i != 0 && i % 2 == 0) { + } else if (chunked && i != 0 && i % 2 == 0) { fingerPrint += " "; } String chunk = Integer.toHexString((fp[i] + 256) % 256).toUpperCase(Locale.US); @@ -491,21 +476,21 @@ public class PgpKeyHelper { key = secretKey.getPublicKey(); } - return convertFingerprintToHex(key.getFingerprint()); + return convertFingerprintToHex(key.getFingerprint(), true); } public static boolean isSecretKeyPrivateEmpty(PGPSecretKey secretKey) { return secretKey.isPrivateKeyEmpty(); } - public static boolean isSecretKeyPrivateEmpty(Context context, long keyId) { - PGPSecretKey secretKey = ProviderHelper.getPGPSecretKeyByKeyId(context, keyId); - if (secretKey == null) { - Log.e(Constants.TAG, "Key could not be found!"); - return false; // could be a public key, assume it is not empty - } - return isSecretKeyPrivateEmpty(secretKey); - } +// public static boolean isSecretKeyPrivateEmpty(Context context, long keyId) { +// PGPSecretKey secretKey = ProviderHelper.getPGPSecretKeyByKeyId(context, keyId); +// if (secretKey == null) { +// Log.e(Constants.TAG, "Key could not be found!"); +// return false; // could be a public key, assume it is not empty +// } +// return isSecretKeyPrivateEmpty(secretKey); +// } public static String convertKeyIdToHex(long keyId) { String fingerPrint = Long.toHexString(keyId & 0xffffffffL).toUpperCase(Locale.US); |