aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure
diff options
context:
space:
mode:
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyFormattingUtils.java11
1 files changed, 4 insertions, 7 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 2dea885a7..47cbc88ca 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
@@ -218,14 +218,11 @@ public class KeyFormattingUtils {
public static String convertFingerprintToHex(byte[] fingerprint) {
// 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);
+ if (fingerprint.length != 16 && fingerprint.length != 20) {
+ throw new RuntimeException("No valid v3 or v4 fingerprint!");
}
+
+ return Hex.toHexString(fingerprint).toLowerCase(Locale.ENGLISH);
}
public static long getKeyIdFromFingerprint(byte[] fingerprint) {