aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2015-05-10 12:11:35 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2015-05-10 12:11:35 +0200
commite4b7920edcc04bed6524929b85ef1acb2c6a01d6 (patch)
treeb160c097c2403e6c14e2206391b74ad5f6e96b03 /OpenKeychain
parent0a29f6d3acdb36e8e27640624634edcaea7fb8e6 (diff)
downloadopen-keychain-e4b7920edcc04bed6524929b85ef1acb2c6a01d6.tar.gz
open-keychain-e4b7920edcc04bed6524929b85ef1acb2c6a01d6.tar.bz2
open-keychain-e4b7920edcc04bed6524929b85ef1acb2c6a01d6.zip
Fix crash with v3 key fingerprints
Diffstat (limited to 'OpenKeychain')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyFormattingUtils.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyFormattingUtils.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyFormattingUtils.java
index 91a7d361a..2dea885a7 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyFormattingUtils.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyFormattingUtils.java
@@ -216,7 +216,16 @@ public class KeyFormattingUtils {
* @return
*/
public static String convertFingerprintToHex(byte[] fingerprint) {
- return Hex.toHexString(fingerprint, 0, 20).toLowerCase(Locale.ENGLISH);
+ // NOTE: Even though v3 keys are not imported we need to support both fingerprints for
+ // display/comparison before import
+ // Also better cut of unneeded parts, e.g., for fingerprints returned from YubiKeys
+ if (fingerprint.length < 20) {
+ // v3 key fingerprint with 128 bit (MD5)
+ return Hex.toHexString(fingerprint, 0, 16).toLowerCase(Locale.ENGLISH);
+ } else {
+ // v4 key fingerprint with 160 bit (SHA1)
+ return Hex.toHexString(fingerprint, 0, 20).toLowerCase(Locale.ENGLISH);
+ }
}
public static long getKeyIdFromFingerprint(byte[] fingerprint) {