1
0
mirror of https://github.com/etesync/android synced 2025-01-11 00:01:12 +00:00

CryptoManager: add an HMAC_SIZE (in bytes) constant.

This commit is contained in:
Tom Hacohen 2017-04-12 13:43:06 +01:00
parent 56996b98c4
commit d80cce9aad
2 changed files with 5 additions and 3 deletions

View File

@ -35,6 +35,8 @@ public class Crypto {
}
public static class CryptoManager {
final static int HMAC_SIZE = 256 / 8; // hmac256 in bytes
private SecureRandom _random = null;
@Getter
private final byte version;

View File

@ -19,6 +19,7 @@ import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;
import static com.etesync.syncadapter.journalmanager.Crypto.CryptoManager.HMAC_SIZE;
import static com.etesync.syncadapter.journalmanager.Crypto.sha256;
import static com.etesync.syncadapter.journalmanager.Crypto.toHex;
@ -93,7 +94,6 @@ public class JournalManager extends BaseManager {
@Getter
private int version = -1;
final private transient int hmacSize = 256 / 8; // hmac256 in bytes
private transient byte[] hmac = null;
@SuppressWarnings("unused")
@ -108,8 +108,8 @@ public class JournalManager extends BaseManager {
}
private void processFromJson() {
hmac = Arrays.copyOfRange(getContent(), 0, hmacSize);
setContent(Arrays.copyOfRange(getContent(), hmacSize, getContent().length));
hmac = Arrays.copyOfRange(getContent(), 0, HMAC_SIZE);
setContent(Arrays.copyOfRange(getContent(), HMAC_SIZE, getContent().length));
}
void verify(Crypto.CryptoManager crypto) throws Exceptions.IntegrityException {