mirror of
https://github.com/etesync/android
synced 2025-06-13 19:48:50 +00:00
Enforce all hmac/mac to always be lower case.
This commit is contained in:
parent
80bb0d6a70
commit
dcb3429884
@ -120,9 +120,13 @@ public class Helpers {
|
|||||||
try {
|
try {
|
||||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||||
byte[] hash = digest.digest(base);
|
byte[] hash = digest.digest(base);
|
||||||
return Hex.toHexString(hash);
|
return toHex(hash);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String toHex(byte[] bytes) {
|
||||||
|
return Hex.toHexString(bytes).toLowerCase();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ public class JournalEntryManager extends BaseManager {
|
|||||||
uuid = previous.getUuid();
|
uuid = previous.getUuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Hex.toHexString(calculateHmac(keyBase64, uuid));
|
return Helpers.toHex(calculateHmac(keyBase64, uuid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ import okhttp3.Response;
|
|||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
|
|
||||||
import static at.bitfire.davdroid.journalmanager.Helpers.sha256;
|
import static at.bitfire.davdroid.journalmanager.Helpers.sha256;
|
||||||
|
import static at.bitfire.davdroid.journalmanager.Helpers.toHex;
|
||||||
|
|
||||||
public class JournalManager extends BaseManager {
|
public class JournalManager extends BaseManager {
|
||||||
final static private Type journalType = new TypeToken<List<Journal>>() {
|
final static private Type journalType = new TypeToken<List<Journal>>() {
|
||||||
@ -104,7 +105,7 @@ public class JournalManager extends BaseManager {
|
|||||||
|
|
||||||
byte[] correctHash = calculateHmac(keyBase64);
|
byte[] correctHash = calculateHmac(keyBase64);
|
||||||
if (!Arrays.areEqual(hmac, correctHash)) {
|
if (!Arrays.areEqual(hmac, correctHash)) {
|
||||||
throw new Exceptions.IntegrityException("Bad HMAC. " + Hex.toHexString(hmac) + " != " + Hex.toHexString(correctHash));
|
throw new Exceptions.IntegrityException("Bad HMAC. " + toHex(hmac) + " != " + toHex(correctHash));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user