|
|
|
@ -16,14 +16,12 @@
|
|
|
|
|
*/
|
|
|
|
|
package org.thoughtcrime.securesms.protocol;
|
|
|
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.util.Base64;
|
|
|
|
|
|
|
|
|
|
import java.security.MessageDigest;
|
|
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
|
|
import java.security.SecureRandom;
|
|
|
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.util.Base64;
|
|
|
|
|
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Calculates prefixes that identify a message as
|
|
|
|
|
* being part of an encrypted session. The idea was to
|
|
|
|
@ -64,15 +62,10 @@ public abstract class WirePrefix {
|
|
|
|
|
String prefix = message.substring(0, PREFIX_SIZE);
|
|
|
|
|
message = message.substring(PREFIX_SIZE);
|
|
|
|
|
|
|
|
|
|
Log.w("Prefix", "Calculating on message: " + message + "**");
|
|
|
|
|
|
|
|
|
|
String calculatedPrefix = calculatePrefix((prefixType + message).getBytes(), PREFIX_BYTES);
|
|
|
|
|
|
|
|
|
|
assert(calculatedPrefix.length() == PREFIX_SIZE);
|
|
|
|
|
|
|
|
|
|
Log.w("Prefix", "Received prefix: " + prefix);
|
|
|
|
|
Log.w("Prefix", "Calculated prefix: " + calculatedPrefix);
|
|
|
|
|
|
|
|
|
|
return prefix.equals(calculatedPrefix);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|