Update libsignal-service-java

This commit is contained in:
AsamK 2023-02-19 14:06:20 +01:00
parent 426b59d13e
commit 3606fb67bb
9 changed files with 34 additions and 70 deletions

View file

@ -7,7 +7,6 @@ import org.signal.libsignal.protocol.ecc.ECPublicKey;
import org.whispersystems.signalservice.api.push.TrustStore;
import org.whispersystems.signalservice.internal.configuration.SignalCdnUrl;
import org.whispersystems.signalservice.internal.configuration.SignalCdsiUrl;
import org.whispersystems.signalservice.internal.configuration.SignalContactDiscoveryUrl;
import org.whispersystems.signalservice.internal.configuration.SignalKeyBackupServiceUrl;
import org.whispersystems.signalservice.internal.configuration.SignalProxy;
import org.whispersystems.signalservice.internal.configuration.SignalServiceConfiguration;
@ -27,8 +26,7 @@ class LiveConfig {
private final static byte[] UNIDENTIFIED_SENDER_TRUST_ROOT = Base64.getDecoder()
.decode("BXu6QIKVz5MA8gstzfOgRQGqyLqOwNKHL6INkv3IHWMF");
private final static String CDS_MRENCLAVE = "74778bb0f93ae1f78c26e67152bab0bbeb693cd56d1bb9b4e9244157acc58081";
private final static String CDSI_MRENCLAVE = "ef4787a56a154ac6d009138cac17155acd23cfe4329281252365dd7c252e7fbf";
private final static String CDSI_MRENCLAVE = "0f6fd79cdfdaa5b2e6337f534d3baf999318b0c462a7ac1f41297a3e4b424a57";
private final static String KEY_BACKUP_ENCLAVE_NAME = "e18376436159cda3ad7a45d9320e382e4a497f26b0dca34d8eab0bd0139483b5";
private final static byte[] KEY_BACKUP_SERVICE_ID = Hex.decode(
@ -42,7 +40,6 @@ class LiveConfig {
private final static String URL = "https://chat.signal.org";
private final static String CDN_URL = "https://cdn.signal.org";
private final static String CDN2_URL = "https://cdn2.signal.org";
private final static String SIGNAL_CONTACT_DISCOVERY_URL = "https://api.directory.signal.org";
private final static String SIGNAL_KEY_BACKUP_URL = "https://api.backup.signal.org";
private final static String STORAGE_URL = "https://storage.signal.org";
private final static String SIGNAL_CDSI_URL = "https://cdsi.signal.org";
@ -62,17 +59,13 @@ class LiveConfig {
new SignalCdnUrl[]{new SignalCdnUrl(CDN_URL, TRUST_STORE)},
2,
new SignalCdnUrl[]{new SignalCdnUrl(CDN2_URL, TRUST_STORE)}),
new SignalContactDiscoveryUrl[]{
new SignalContactDiscoveryUrl(SIGNAL_CONTACT_DISCOVERY_URL, TRUST_STORE)
},
new SignalKeyBackupServiceUrl[]{new SignalKeyBackupServiceUrl(SIGNAL_KEY_BACKUP_URL, TRUST_STORE)},
new SignalStorageUrl[]{new SignalStorageUrl(STORAGE_URL, TRUST_STORE)},
new SignalCdsiUrl[]{new SignalCdsiUrl(SIGNAL_CDSI_URL, TRUST_STORE)},
interceptors,
dns,
proxy,
zkGroupServerPublicParams,
true);
zkGroupServerPublicParams);
}
static ECPublicKey getUnidentifiedSenderTrustRoot() {
@ -93,10 +86,6 @@ class LiveConfig {
FALLBACK_KEY_BACKUP_MRENCLAVE));
}
static String getCdsMrenclave() {
return CDS_MRENCLAVE;
}
static String getCdsiMrenclave() {
return CDSI_MRENCLAVE;
}

View file

@ -90,14 +90,12 @@ public class ServiceConfig {
LiveConfig.getUnidentifiedSenderTrustRoot(),
LiveConfig.createKeyBackupConfig(),
LiveConfig.createFallbackKeyBackupConfigs(),
LiveConfig.getCdsMrenclave(),
LiveConfig.getCdsiMrenclave());
case STAGING -> new ServiceEnvironmentConfig(serviceEnvironment,
StagingConfig.createDefaultServiceConfiguration(interceptors),
StagingConfig.getUnidentifiedSenderTrustRoot(),
StagingConfig.createKeyBackupConfig(),
StagingConfig.createFallbackKeyBackupConfigs(),
StagingConfig.getCdsMrenclave(),
StagingConfig.getCdsiMrenclave());
};
}

View file

@ -15,7 +15,6 @@ public class ServiceEnvironmentConfig {
private final KeyBackupConfig keyBackupConfig;
private final Collection<KeyBackupConfig> fallbackKeyBackupConfigs;
private final String cdsMrenclave;
private final String cdsiMrenclave;
public ServiceEnvironmentConfig(
@ -24,7 +23,6 @@ public class ServiceEnvironmentConfig {
final ECPublicKey unidentifiedSenderTrustRoot,
final KeyBackupConfig keyBackupConfig,
final Collection<KeyBackupConfig> fallbackKeyBackupConfigs,
final String cdsMrenclave,
final String cdsiMrenclave
) {
this.type = type;
@ -32,7 +30,6 @@ public class ServiceEnvironmentConfig {
this.unidentifiedSenderTrustRoot = unidentifiedSenderTrustRoot;
this.keyBackupConfig = keyBackupConfig;
this.fallbackKeyBackupConfigs = fallbackKeyBackupConfigs;
this.cdsMrenclave = cdsMrenclave;
this.cdsiMrenclave = cdsiMrenclave;
}
@ -56,10 +53,6 @@ public class ServiceEnvironmentConfig {
return fallbackKeyBackupConfigs;
}
public String getCdsMrenclave() {
return cdsMrenclave;
}
public String getCdsiMrenclave() {
return cdsiMrenclave;
}

View file

@ -7,7 +7,6 @@ import org.signal.libsignal.protocol.ecc.ECPublicKey;
import org.whispersystems.signalservice.api.push.TrustStore;
import org.whispersystems.signalservice.internal.configuration.SignalCdnUrl;
import org.whispersystems.signalservice.internal.configuration.SignalCdsiUrl;
import org.whispersystems.signalservice.internal.configuration.SignalContactDiscoveryUrl;
import org.whispersystems.signalservice.internal.configuration.SignalKeyBackupServiceUrl;
import org.whispersystems.signalservice.internal.configuration.SignalProxy;
import org.whispersystems.signalservice.internal.configuration.SignalServiceConfiguration;
@ -27,8 +26,7 @@ class StagingConfig {
private final static byte[] UNIDENTIFIED_SENDER_TRUST_ROOT = Base64.getDecoder()
.decode("BbqY1DzohE4NUZoVF+L18oUPrK3kILllLEJh2UnPSsEx");
private final static String CDS_MRENCLAVE = "74778bb0f93ae1f78c26e67152bab0bbeb693cd56d1bb9b4e9244157acc58081";
private final static String CDSI_MRENCLAVE = "ef4787a56a154ac6d009138cac17155acd23cfe4329281252365dd7c252e7fbf";
private final static String CDSI_MRENCLAVE = "0f6fd79cdfdaa5b2e6337f534d3baf999318b0c462a7ac1f41297a3e4b424a57";
private final static String KEY_BACKUP_ENCLAVE_NAME = "39963b736823d5780be96ab174869a9499d56d66497aa8f9b2244f777ebc366b";
private final static byte[] KEY_BACKUP_SERVICE_ID = Hex.decode(
@ -42,7 +40,6 @@ class StagingConfig {
private final static String URL = "https://chat.staging.signal.org";
private final static String CDN_URL = "https://cdn-staging.signal.org";
private final static String CDN2_URL = "https://cdn2-staging.signal.org";
private final static String SIGNAL_CONTACT_DISCOVERY_URL = "https://api-staging.directory.signal.org";
private final static String SIGNAL_KEY_BACKUP_URL = "https://api-staging.backup.signal.org";
private final static String STORAGE_URL = "https://storage-staging.signal.org";
private final static String SIGNAL_CDSI_URL = "https://cdsi.staging.signal.org";
@ -62,17 +59,13 @@ class StagingConfig {
new SignalCdnUrl[]{new SignalCdnUrl(CDN_URL, TRUST_STORE)},
2,
new SignalCdnUrl[]{new SignalCdnUrl(CDN2_URL, TRUST_STORE)}),
new SignalContactDiscoveryUrl[]{
new SignalContactDiscoveryUrl(SIGNAL_CONTACT_DISCOVERY_URL, TRUST_STORE)
},
new SignalKeyBackupServiceUrl[]{new SignalKeyBackupServiceUrl(SIGNAL_KEY_BACKUP_URL, TRUST_STORE)},
new SignalStorageUrl[]{new SignalStorageUrl(STORAGE_URL, TRUST_STORE)},
new SignalCdsiUrl[]{new SignalCdsiUrl(SIGNAL_CDSI_URL, TRUST_STORE)},
interceptors,
dns,
proxy,
zkGroupServerPublicParams,
true);
zkGroupServerPublicParams);
}
static ECPublicKey getUnidentifiedSenderTrustRoot() {
@ -93,10 +86,6 @@ class StagingConfig {
FALLBACK_KEY_BACKUP_MRENCLAVE));
}
static String getCdsMrenclave() {
return CDS_MRENCLAVE;
}
static String getCdsiMrenclave() {
return CDSI_MRENCLAVE;
}

View file

@ -3,11 +3,9 @@ package org.asamk.signal.manager.helper;
import org.asamk.signal.manager.SignalDependencies;
import org.asamk.signal.manager.api.RecipientIdentifier;
import org.asamk.signal.manager.api.UnregisteredRecipientException;
import org.asamk.signal.manager.config.ServiceConfig;
import org.asamk.signal.manager.config.ServiceEnvironmentConfig;
import org.asamk.signal.manager.storage.SignalAccount;
import org.asamk.signal.manager.storage.recipients.RecipientId;
import org.signal.libsignal.protocol.InvalidKeyException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.whispersystems.signalservice.api.push.ACI;
@ -15,12 +13,8 @@ import org.whispersystems.signalservice.api.push.PNI;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.services.CdsiV2Service;
import org.whispersystems.signalservice.internal.contacts.crypto.Quote;
import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedQuoteException;
import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException;
import java.io.IOException;
import java.security.SignatureException;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@ -108,13 +102,7 @@ public class RecipientHelper {
}
public Map<String, RegisteredUser> getRegisteredUsers(final Set<String> numbers) throws IOException {
Map<String, RegisteredUser> registeredUsers;
try {
registeredUsers = getRegisteredUsersV2(numbers, true);
} catch (IOException e) {
logger.warn("CDSI request failed, trying fallback to CDS", e);
registeredUsers = getRegisteredUsersV1(numbers);
}
Map<String, RegisteredUser> registeredUsers = getRegisteredUsersV2(numbers, true);
// Store numbers as recipients, so we have the number/uuid association
registeredUsers.forEach((number, u) -> account.getRecipientTrustedResolver()
@ -137,23 +125,6 @@ public class RecipientHelper {
return user.getServiceId();
}
private Map<String, RegisteredUser> getRegisteredUsersV1(final Set<String> numbers) throws IOException {
final Map<String, ACI> response;
try {
response = dependencies.getAccountManager()
.getRegisteredUsers(ServiceConfig.getIasKeyStore(),
numbers,
serviceEnvironmentConfig.getCdsMrenclave());
} catch (Quote.InvalidQuoteFormatException | UnauthenticatedQuoteException | SignatureException |
UnauthenticatedResponseException | InvalidKeyException | NumberFormatException e) {
throw new IOException(e);
}
final var registeredUsers = new HashMap<String, RegisteredUser>();
response.forEach((key, value) -> registeredUsers.put(key,
new RegisteredUser(Optional.of(value), Optional.empty())));
return registeredUsers;
}
private Map<String, RegisteredUser> getRegisteredUsersV2(
final Set<String> numbers, boolean useCompat
) throws IOException {
@ -183,7 +154,7 @@ public class RecipientHelper {
}
private ACI getRegisteredUserByUsername(String username) throws IOException {
return dependencies.getAccountManager().getAciByUsername(username);
return dependencies.getAccountManager().getAciByUsernameHash(username);
}
public record RegisteredUser(Optional<ACI> aci, Optional<PNI> pni) {

View file

@ -96,8 +96,9 @@ public class MessageCacheUtils {
uuid,
destinationUuid == null ? UuidUtil.UNKNOWN_UUID.toString() : destinationUuid,
isUrgent,
updatedPni == null ? "" : updatedPni,
isStory);
isStory,
null,
updatedPni == null ? "" : updatedPni);
}
}