mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-25 09:28:51 +00:00
Introduce registration-time ID for detecting stale sessions.
1) At registration time, a client generates a random ID and transmits to the the server. 2) The server provides that registration ID to any client that requests a prekey. 3) Clients include that registration ID in any PreKeyWhisperMessage. 4) Clients include that registration ID in their sendMessage API call to the server. 5) The server verifies that the registration ID included in an API call is the same as the current registration ID for the destination device. Otherwise, it notifies the sender that their session is stale.
This commit is contained in:
@@ -88,6 +88,14 @@ public class Util {
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static int generateRegistrationId() {
|
||||
try {
|
||||
return SecureRandom.getInstance("SHA1PRNG").nextInt(16380) + 1;
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getSecret(int size) {
|
||||
try {
|
||||
byte[] secret = new byte[size];
|
||||
|
||||
Reference in New Issue
Block a user