Update libsignal-service

This commit is contained in:
AsamK 2024-03-07 17:44:19 +01:00
parent 5e17fe8414
commit ee39733978
12 changed files with 19 additions and 50 deletions

View file

@ -152,10 +152,7 @@ public class Profile {
}
public enum Capability {
storage,
gv1Migration,
senderKey,
announcementGroup;
storage;
public static Capability valueOfOrNull(String value) {
try {

View file

@ -1,5 +1,6 @@
package org.asamk.signal.manager.config;
import org.signal.libsignal.net.Network.Environment;
import org.signal.libsignal.protocol.InvalidKeyException;
import org.signal.libsignal.protocol.ecc.Curve;
import org.signal.libsignal.protocol.ecc.ECPublicKey;
@ -28,7 +29,6 @@ class LiveConfig {
.decode("BXu6QIKVz5MA8gstzfOgRQGqyLqOwNKHL6INkv3IHWMF");
private static final String CDSI_MRENCLAVE = "0f6fd79cdfdaa5b2e6337f534d3baf999318b0c462a7ac1f41297a3e4b424a57";
private static final String SVR2_MRENCLAVE = "a6622ad4656e1abcd0bc0ff17c229477747d2ded0495c4ebee7ed35c1789fa97";
private static final String SVR2_MRENCLAVE_DEPRECATED = "6ee1042f9e20f880326686dd4ba50c25359f01e9f733eeba4382bca001d45094";
private static final String URL = "https://chat.signal.org";
private static final String CDN_URL = "https://cdn.signal.org";
@ -49,6 +49,8 @@ class LiveConfig {
private static final byte[] backupServerPublicParams = Base64.getDecoder()
.decode("AJwNSU55fsFCbgaxGRD11wO1juAs8Yr5GF8FPlGzzvdJJIKH5/4CC7ZJSOe3yL2vturVaRU2Cx0n751Vt8wkj1bozK3CBV1UokxV09GWf+hdVImLGjXGYLLhnI1J2TWEe7iWHyb553EEnRb5oxr9n3lUbNAJuRmFM7hrr0Al0F0wrDD4S8lo2mGaXe0MJCOM166F8oYRQqpFeEHfiLnxA1O8ZLh7vMdv4g9jI5phpRBTsJ5IjiJrWeP0zdIGHEssUeprDZ9OUJ14m0v61eYJMKsf59Bn+mAT2a7YfB+Don9O");
private static Environment LIBSIGNAL_NET_ENV = Environment.PRODUCTION;
static SignalServiceConfiguration createDefaultServiceConfiguration(
final List<Interceptor> interceptors
) {
@ -78,10 +80,11 @@ class LiveConfig {
static ServiceEnvironmentConfig getServiceEnvironmentConfig(List<Interceptor> interceptors) {
return new ServiceEnvironmentConfig(LIVE,
LIBSIGNAL_NET_ENV,
createDefaultServiceConfiguration(interceptors),
getUnidentifiedSenderTrustRoot(),
CDSI_MRENCLAVE,
List.of(SVR2_MRENCLAVE, SVR2_MRENCLAVE_DEPRECATED));
List.of(SVR2_MRENCLAVE));
}
private LiveConfig() {

View file

@ -1,6 +1,7 @@
package org.asamk.signal.manager.config;
import org.asamk.signal.manager.api.ServiceEnvironment;
import org.signal.libsignal.net.Network;
import org.signal.libsignal.protocol.ecc.ECPublicKey;
import org.whispersystems.signalservice.internal.configuration.SignalServiceConfiguration;
@ -8,6 +9,7 @@ import java.util.List;
public record ServiceEnvironmentConfig(
ServiceEnvironment type,
Network.Environment netEnvironment,
SignalServiceConfiguration signalServiceConfiguration,
ECPublicKey unidentifiedSenderTrustRoot,
String cdsiMrenclave,

View file

@ -1,5 +1,6 @@
package org.asamk.signal.manager.config;
import org.signal.libsignal.net.Network;
import org.signal.libsignal.protocol.InvalidKeyException;
import org.signal.libsignal.protocol.ecc.Curve;
import org.signal.libsignal.protocol.ecc.ECPublicKey;
@ -28,7 +29,6 @@ class StagingConfig {
.decode("BbqY1DzohE4NUZoVF+L18oUPrK3kILllLEJh2UnPSsEx");
private static final String CDSI_MRENCLAVE = "0f6fd79cdfdaa5b2e6337f534d3baf999318b0c462a7ac1f41297a3e4b424a57";
private static final String SVR2_MRENCLAVE = "acb1973aa0bbbd14b3b4e06f145497d948fd4a98efc500fcce363b3b743ec482";
private static final String SVR2_MRENCLAVE_DEPRECATED = "a8a261420a6bb9b61aa25bf8a79e8bd20d7652531feb3381cbffd446d270be95";
private static final String URL = "https://chat.staging.signal.org";
private static final String CDN_URL = "https://cdn-staging.signal.org";
@ -49,6 +49,8 @@ class StagingConfig {
private static final byte[] backupServerPublicParams = Base64.getDecoder()
.decode("AHYrGb9IfugAAJiPKp+mdXUx+OL9zBolPYHYQz6GI1gWjpEu5me3zVNSvmYY4zWboZHif+HG1sDHSuvwFd0QszSwuSF4X4kRP3fJREdTZ5MCR0n55zUppTwfHRW2S4sdQ0JGz7YDQIJCufYSKh0pGNEHL6hv79Agrdnr4momr3oXdnkpVBIp3HWAQ6IbXQVSG18X36GaicI1vdT0UFmTwU2KTneluC2eyL9c5ff8PcmiS+YcLzh0OKYQXB5ZfQ06d6DiINvDQLy75zcfUOniLAj0lGJiHxGczin/RXisKSR8");
private static Network.Environment LIBSIGNAL_NET_ENV = Network.Environment.STAGING;
static SignalServiceConfiguration createDefaultServiceConfiguration(
final List<Interceptor> interceptors
) {
@ -78,10 +80,11 @@ class StagingConfig {
static ServiceEnvironmentConfig getServiceEnvironmentConfig(List<Interceptor> interceptors) {
return new ServiceEnvironmentConfig(STAGING,
LIBSIGNAL_NET_ENV,
createDefaultServiceConfiguration(interceptors),
getUnidentifiedSenderTrustRoot(),
CDSI_MRENCLAVE,
List.of(SVR2_MRENCLAVE, SVR2_MRENCLAVE_DEPRECATED));
List.of(SVR2_MRENCLAVE));
}
private StagingConfig() {

View file

@ -22,7 +22,6 @@ import org.asamk.signal.manager.api.GroupId;
import org.asamk.signal.manager.api.GroupNotFoundException;
import org.asamk.signal.manager.api.MessageEnvelope;
import org.asamk.signal.manager.api.Pair;
import org.asamk.signal.manager.api.Profile;
import org.asamk.signal.manager.api.ReceiveConfig;
import org.asamk.signal.manager.api.StickerPackId;
import org.asamk.signal.manager.api.TrustLevel;
@ -161,24 +160,11 @@ public final class IncomingMessageHandler {
if (context.getContactHelper().isContactBlocked(sender)) {
logger.debug("Received invalid message from blocked contact, ignoring.");
} else {
final var senderProfile = context.getProfileHelper().getRecipientProfile(sender);
final var selfProfile = context.getProfileHelper().getSelfProfile();
var serviceId = ServiceId.parseOrNull(e.getSender());
if (serviceId == null) {
// Workaround for libsignal-client issue #492
serviceId = account.getRecipientAddressResolver()
.resolveRecipientAddress(sender)
.serviceId()
.orElse(null);
}
if (serviceId != null) {
final var isSelf = sender.equals(account.getSelfRecipientId())
&& e.getSenderDevice() == account.getDeviceId();
final var isSenderSenderKeyCapable = senderProfile != null && senderProfile.getCapabilities()
.contains(Profile.Capability.senderKey);
final var isSelfSenderKeyCapable = selfProfile != null && selfProfile.getCapabilities()
.contains(Profile.Capability.senderKey);
if (!isSelf && isSenderSenderKeyCapable && isSelfSenderKeyCapable) {
if (!isSelf) {
logger.debug("Received invalid message, requesting message resend.");
actions.add(new SendRetryMessageRequestAction(sender, serviceId, e, envelope, destination));
} else {

View file

@ -213,6 +213,7 @@ public class RecipientHelper {
token,
serviceEnvironmentConfig.cdsiMrenclave(),
null,
dependencies.getServiceEnvironmentConfig().netEnvironment(),
newToken -> {
if (isPartialRefresh) {
account.getCdsiStore().updateAfterPartialCdsQuery(newNumbers);

View file

@ -523,21 +523,9 @@ public class SendHelper {
}
private Set<RecipientId> getSenderKeyCapableRecipientIds(final Set<RecipientId> recipientIds) {
final var selfProfile = context.getProfileHelper().getSelfProfile();
if (selfProfile == null || !selfProfile.getCapabilities().contains(Profile.Capability.senderKey)) {
logger.debug("Not all of our devices support sender key. Using legacy.");
return Set.of();
}
final var senderKeyTargets = new HashSet<RecipientId>();
final var recipientList = new ArrayList<>(recipientIds);
final var profiles = context.getProfileHelper().getRecipientProfiles(recipientList).iterator();
for (final var recipientId : recipientList) {
final var profile = profiles.next();
if (profile == null || !profile.getCapabilities().contains(Profile.Capability.senderKey)) {
continue;
}
final var access = context.getUnidentifiedAccessHelper().getAccessFor(recipientId);
if (access.isEmpty() || access.get().getTargetUnidentifiedAccess().isEmpty()) {
continue;

View file

@ -189,7 +189,8 @@ public class SignalDependencies {
Optional.empty(),
executor,
ServiceConfig.MAX_ENVELOPE_SIZE,
pushServiceSocket));
pushServiceSocket,
false));
}
public List<SecureValueRecovery> getSecureValueRecoveryV2() {

View file

@ -895,9 +895,6 @@ public class SignalAccount implements Closeable {
if (profile != null) {
final var capabilities = new HashSet<Profile.Capability>();
if (profile.getCapabilities() != null) {
if (profile.getCapabilities().gv1Migration) {
capabilities.add(Profile.Capability.gv1Migration);
}
if (profile.getCapabilities().storage) {
capabilities.add(Profile.Capability.storage);
}

View file

@ -94,7 +94,7 @@ public class LegacySignalProfile {
@JsonProperty
public boolean storage;
@JsonProperty
@JsonIgnore
public boolean gv1Migration;
}
}

View file

@ -76,18 +76,9 @@ public class ProfileUtils {
public static HashSet<Profile.Capability> getCapabilities(final SignalServiceProfile encryptedProfile) {
final var capabilities = new HashSet<Profile.Capability>();
if (encryptedProfile.getCapabilities().isGv1Migration()) {
capabilities.add(Profile.Capability.gv1Migration);
}
if (encryptedProfile.getCapabilities().isStorage()) {
capabilities.add(Profile.Capability.storage);
}
if (encryptedProfile.getCapabilities().isSenderKey()) {
capabilities.add(Profile.Capability.senderKey);
}
if (encryptedProfile.getCapabilities().isAnnouncementGroup()) {
capabilities.add(Profile.Capability.announcementGroup);
}
return capabilities;
}

View file

@ -15,7 +15,7 @@ dependencyResolutionManagement {
library("slf4j.jul", "org.slf4j", "jul-to-slf4j").versionRef("slf4j")
library("logback", "ch.qos.logback", "logback-classic").version("1.5.0")
library("signalservice", "com.github.turasa", "signal-service-java").version("2.15.3_unofficial_97")
library("signalservice", "com.github.turasa", "signal-service-java").version("2.15.3_unofficial_98")
library("sqlite", "org.xerial", "sqlite-jdbc").version("3.45.1.0")
library("hikari", "com.zaxxer", "HikariCP").version("5.1.0")
library("junit.jupiter", "org.junit.jupiter", "junit-jupiter").version("5.10.2")