forked from mirror/monocles_chat
use less entropy in SASL2 device id
(cherry picked from commit 1e0904a48db4fd85c02381c07062042cba1a765a)
This commit is contained in:
parent
2bd17e80b1
commit
1285c73454
2 changed files with 20 additions and 1 deletions
|
@ -5,6 +5,7 @@ import android.content.Intent;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.R;
|
||||
|
@ -31,6 +32,23 @@ public class AccountUtils {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static String publicDeviceId(final Account account) {
|
||||
final UUID uuid;
|
||||
try {
|
||||
uuid = UUID.fromString(account.getUuid());
|
||||
} catch (final IllegalArgumentException e) {
|
||||
return account.getUuid();
|
||||
}
|
||||
final UUID publicDeviceId = getUuid(uuid.getLeastSignificantBits(), uuid.getLeastSignificantBits());
|
||||
return publicDeviceId.toString();
|
||||
}
|
||||
|
||||
protected static UUID getUuid(final long msb, final long lsb) {
|
||||
final long msb0 = (msb & 0xffffffffffff0fffL) | 4; // set version
|
||||
final long lsb0 = (lsb & 0x3fffffffffffffffL) | 0x8000000000000000L; // set variant
|
||||
return new UUID(msb0, lsb0);
|
||||
}
|
||||
|
||||
public static List<String> getEnabledAccounts(final XmppConnectionService service) {
|
||||
ArrayList<String> accounts = new ArrayList<>();
|
||||
for (Account account : service.getAccounts()) {
|
||||
|
|
|
@ -78,6 +78,7 @@ import eu.siacs.conversations.services.MemorizingTrustManager;
|
|||
import eu.siacs.conversations.services.MessageArchiveService;
|
||||
import eu.siacs.conversations.services.NotificationService;
|
||||
import eu.siacs.conversations.services.XmppConnectionService;
|
||||
import eu.siacs.conversations.utils.AccountUtils;
|
||||
import eu.siacs.conversations.utils.CryptoHelper;
|
||||
import eu.siacs.conversations.utils.Patterns;
|
||||
import eu.siacs.conversations.utils.PhoneHelper;
|
||||
|
@ -1593,7 +1594,7 @@ public class XmppConnection implements Runnable {
|
|||
authenticate.addChild("initial-response").setContent(firstMessage);
|
||||
}
|
||||
final Element userAgent = authenticate.addChild("user-agent");
|
||||
userAgent.setAttribute("id", account.getUuid());
|
||||
userAgent.setAttribute("id", AccountUtils.publicDeviceId(account));
|
||||
userAgent
|
||||
.addChild("software")
|
||||
.setContent(mXmppConnectionService.getString(R.string.app_name));
|
||||
|
|
Loading…
Add table
Reference in a new issue