Fix keybase import

This commit is contained in:
Dominik Schürmann 2014-06-20 15:58:32 +02:00
parent f0b8261ad3
commit 6b7aa2767a
3 changed files with 5 additions and 2 deletions

View File

@ -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)));

View File

@ -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;

View File

@ -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;
}