mirror of
https://github.com/etesync/android
synced 2025-05-29 04:08:48 +00:00
CryptoManager: add an HMAC_SIZE (in bytes) constant.
This commit is contained in:
parent
56996b98c4
commit
d80cce9aad
@ -35,6 +35,8 @@ public class Crypto {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class CryptoManager {
|
public static class CryptoManager {
|
||||||
|
final static int HMAC_SIZE = 256 / 8; // hmac256 in bytes
|
||||||
|
|
||||||
private SecureRandom _random = null;
|
private SecureRandom _random = null;
|
||||||
@Getter
|
@Getter
|
||||||
private final byte version;
|
private final byte version;
|
||||||
|
@ -19,6 +19,7 @@ import okhttp3.RequestBody;
|
|||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import okhttp3.ResponseBody;
|
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.sha256;
|
||||||
import static com.etesync.syncadapter.journalmanager.Crypto.toHex;
|
import static com.etesync.syncadapter.journalmanager.Crypto.toHex;
|
||||||
|
|
||||||
@ -93,7 +94,6 @@ public class JournalManager extends BaseManager {
|
|||||||
@Getter
|
@Getter
|
||||||
private int version = -1;
|
private int version = -1;
|
||||||
|
|
||||||
final private transient int hmacSize = 256 / 8; // hmac256 in bytes
|
|
||||||
private transient byte[] hmac = null;
|
private transient byte[] hmac = null;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@ -108,8 +108,8 @@ public class JournalManager extends BaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void processFromJson() {
|
private void processFromJson() {
|
||||||
hmac = Arrays.copyOfRange(getContent(), 0, hmacSize);
|
hmac = Arrays.copyOfRange(getContent(), 0, HMAC_SIZE);
|
||||||
setContent(Arrays.copyOfRange(getContent(), hmacSize, getContent().length));
|
setContent(Arrays.copyOfRange(getContent(), HMAC_SIZE, getContent().length));
|
||||||
}
|
}
|
||||||
|
|
||||||
void verify(Crypto.CryptoManager crypto) throws Exceptions.IntegrityException {
|
void verify(Crypto.CryptoManager crypto) throws Exceptions.IntegrityException {
|
||||||
|
Loading…
Reference in New Issue
Block a user