mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 20:15:21 +00:00
Fix backup MAC checking.
if(MessageDigest.isEqual(ourMac, theirMac) was always returning false since ourMac was of length 32 and theirMac was of length 10.
This commit is contained in:
parent
8c3d50c6dc
commit
787bcf7752
@ -283,7 +283,7 @@ public class FullBackupImporter extends FullBackupBase {
|
|||||||
|
|
||||||
out.close();
|
out.close();
|
||||||
|
|
||||||
byte[] ourMac = mac.doFinal();
|
byte[] ourMac = ByteUtil.trim(mac.doFinal(), 10);
|
||||||
byte[] theirMac = new byte[10];
|
byte[] theirMac = new byte[10];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -293,7 +293,7 @@ public class FullBackupImporter extends FullBackupBase {
|
|||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MessageDigest.isEqual(ourMac, theirMac)) {
|
if (!MessageDigest.isEqual(ourMac, theirMac)) {
|
||||||
//destination.delete();
|
//destination.delete();
|
||||||
throw new IOException("Bad MAC");
|
throw new IOException("Bad MAC");
|
||||||
}
|
}
|
||||||
@ -314,9 +314,9 @@ public class FullBackupImporter extends FullBackupBase {
|
|||||||
System.arraycopy(frame, frame.length - 10, theirMac, 0, theirMac.length);
|
System.arraycopy(frame, frame.length - 10, theirMac, 0, theirMac.length);
|
||||||
|
|
||||||
mac.update(frame, 0, frame.length - 10);
|
mac.update(frame, 0, frame.length - 10);
|
||||||
byte[] ourMac = mac.doFinal();
|
byte[] ourMac = ByteUtil.trim(mac.doFinal(), 10);
|
||||||
|
|
||||||
if (MessageDigest.isEqual(ourMac, theirMac)) {
|
if (!MessageDigest.isEqual(ourMac, theirMac)) {
|
||||||
throw new IOException("Bad MAC");
|
throw new IOException("Bad MAC");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user