forked from signalapp/Signal-Android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for 'bad encrypted message' errors.
1) There was a regression in the outgoing multipart transport logic, such that the same 'identifier' byte would be used for all messages (0). This now works correctly. 2) Added some additional heuristics on the receiving side. Now mutlipart containers are only valid for 1hr, and are considered invalid if the container size is different from the multipart message size.
- Loading branch information
Showing
3 changed files
with
59 additions
and
21 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/org/thoughtcrime/securesms/sms/MultipartSmsIdentifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.thoughtcrime.securesms.sms; | ||
|
||
|
||
import java.util.HashMap; | ||
|
||
public class MultipartSmsIdentifier { | ||
|
||
private static final MultipartSmsIdentifier instance = new MultipartSmsIdentifier(); | ||
|
||
public static MultipartSmsIdentifier getInstance() { | ||
return instance; | ||
} | ||
|
||
private final HashMap<String, Integer> idMap = new HashMap<String, Integer>(); | ||
|
||
public synchronized byte getIdForRecipient(String recipient) { | ||
Integer currentId; | ||
|
||
if (idMap.containsKey(recipient)) { | ||
currentId = idMap.get(recipient); | ||
idMap.remove(recipient); | ||
} else { | ||
currentId = 0; | ||
} | ||
|
||
byte id = currentId.byteValue(); | ||
idMap.put(recipient, (currentId + 1) % 255); | ||
|
||
return id; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters