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:
Yassine El Khadiri 2018-10-30 22:13:33 +01:00 committed by Greyson Parrelli
parent 8c3d50c6dc
commit 787bcf7752

View File

@ -283,7 +283,7 @@ public class FullBackupImporter extends FullBackupBase {
out.close();
byte[] ourMac = mac.doFinal();
byte[] ourMac = ByteUtil.trim(mac.doFinal(), 10);
byte[] theirMac = new byte[10];
try {
@ -293,7 +293,7 @@ public class FullBackupImporter extends FullBackupBase {
throw new IOException(e);
}
if (MessageDigest.isEqual(ourMac, theirMac)) {
if (!MessageDigest.isEqual(ourMac, theirMac)) {
//destination.delete();
throw new IOException("Bad MAC");
}
@ -314,9 +314,9 @@ public class FullBackupImporter extends FullBackupBase {
System.arraycopy(frame, frame.length - 10, theirMac, 0, theirMac.length);
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");
}