From 6b7aa2767a07fae02538b5b02bee9698fa1d3b15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 20 Jun 2014 15:58:32 +0200 Subject: [PATCH] Fix keybase import --- .../keychain/keyimport/KeybaseKeyserver.java | 3 ++- .../org/sufficientlysecure/keychain/pgp/PgpImportExport.java | 2 ++ .../java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserver.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserver.java index 2f14d77a8..bf886cc6c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserver.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserver.java @@ -29,6 +29,7 @@ import java.net.HttpURLConnection; import java.net.URL; import java.net.URLEncoder; import java.util.ArrayList; +import java.util.Locale; public class KeybaseKeyserver extends Keyserver { public static final String ORIGIN = "keybase:keybase.io"; @@ -94,7 +95,7 @@ public class KeybaseKeyserver extends Keyserver { String keybaseId = JWalk.getString(match, "components", "username", "val"); String fullName = JWalk.getString(match, "components", "full_name", "val"); String fingerprint = JWalk.getString(match, "components", "key_fingerprint", "val"); - fingerprint = fingerprint.replace(" ", "").toUpperCase(); // not strictly necessary but doesn't hurt + fingerprint = fingerprint.replace(" ", "").toLowerCase(Locale.US); // not strictly necessary but doesn't hurt entry.setFingerprintHex(fingerprint); entry.setKeyIdHex("0x" + fingerprint.substring(Math.max(0, fingerprint.length() - 16))); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java index 7544f7b86..c50d92f7a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java @@ -139,6 +139,8 @@ public class PgpImportExport { String expectedFp = entry.getExpectedFingerprint(); if(expectedFp != null) { if(!PgpKeyHelper.convertFingerprintToHex(key.getFingerprint()).equals(expectedFp)) { + Log.d(Constants.TAG, "fingerprint: " + PgpKeyHelper.convertFingerprintToHex(key.getFingerprint())); + Log.d(Constants.TAG, "expected fingerprint: " + expectedFp); Log.e(Constants.TAG, "Actual key fingerprint is not the same as expected!"); badKeys += 1; continue; 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 291b07639..1ba028006 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java @@ -104,7 +104,7 @@ public class PgpKeyHelper { * @return */ public static String convertFingerprintToHex(byte[] fingerprint) { - String hexString = Hex.toHexString(fingerprint); + String hexString = Hex.toHexString(fingerprint).toLowerCase(Locale.US); return hexString; }