fix silly bug in signing key fingerprint calculation for display

This was causing the first byte of the signature to be chopped off, so
therefore it would not validate since the fingerprint of the cert from
the net connection had the right fingerprint, but it was compared to the
stored, truncated version.

This also means that the database version needs to be bumped to trigger an
upgrade so that the bad 62 char fingerprints are removed from the database.
This commit is contained in:
Hans-Christoph Steiner 2014-04-25 22:46:24 -04:00
parent aa1b9e6696
commit 649bfa10b7
2 changed files with 4 additions and 4 deletions

View File

@ -178,7 +178,7 @@ public final class Utils {
// return a fingerprint formatted for display
public static String formatFingerprint(String fingerprint) {
if (fingerprint.length() != 62) // SHA-256 is 62 hex chars
if (fingerprint.length() != 64) // SHA-256 is 64 hex chars
return "BAD FINGERPRINT";
String displayFP = fingerprint.substring(0, 2);
for (int i = 2; i < fingerprint.length(); i = i + 2)
@ -218,7 +218,7 @@ public final class Utils {
digest.update(key);
byte[] fingerprint = digest.digest();
Formatter formatter = new Formatter(new StringBuilder());
for (int i = 1; i < fingerprint.length; i++) {
for (int i = 0; i < fingerprint.length; i++) {
formatter.format("%02X", fingerprint[i]);
}
ret = formatter.toString();

View File

@ -96,7 +96,7 @@ public class DBHelper extends SQLiteOpenHelper {
+ "versionName TEXT NOT NULL "
+ " );";
private static final int DB_VERSION = 43;
private static final int DB_VERSION = 44;
private Context context;
@ -322,7 +322,7 @@ public class DBHelper extends SQLiteOpenHelper {
* calculate its fingerprint and save it to the database.
*/
private void addFingerprintToRepo(SQLiteDatabase db, int oldVersion) {
if (oldVersion < 29) {
if (oldVersion < 44) {
if (!columnExists(db, TABLE_REPO, "fingerprint"))
db.execSQL("alter table " + TABLE_REPO + " add column fingerprint text");
List<Repo> oldrepos = new ArrayList<Repo>();