kopia lustrzana https://github.com/ryukoposting/Signal-Android
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.fork-5.53.8
rodzic
8c3d50c6dc
commit
787bcf7752
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue