Update libsignal-service-java

This commit is contained in:
AsamK 2023-07-14 19:25:32 +02:00
parent 2487fff44a
commit 02d4cb4a14
8 changed files with 116 additions and 41 deletions

View file

@ -15,6 +15,18 @@
{ {
"name":"[J" "name":"[J"
}, },
{
"name":"[Lcom.fasterxml.jackson.databind.deser.Deserializers;"
},
{
"name":"[Lcom.fasterxml.jackson.databind.deser.KeyDeserializers;"
},
{
"name":"[Lcom.fasterxml.jackson.databind.deser.ValueInstantiators;"
},
{
"name":"[Lcom.fasterxml.jackson.databind.ser.Serializers;"
},
{ {
"name":"[Lcom.zaxxer.hikari.util.ConcurrentBag$IConcurrentBagEntry;" "name":"[Lcom.zaxxer.hikari.util.ConcurrentBag$IConcurrentBagEntry;"
}, },
@ -68,6 +80,12 @@
{ {
"name":"char[]" "name":"char[]"
}, },
{
"name":"com.fasterxml.jackson.annotation.JsonIgnore"
},
{
"name":"com.fasterxml.jackson.annotation.JsonProperty"
},
{ {
"name":"com.fasterxml.jackson.databind.ext.Java7HandlersImpl", "name":"com.fasterxml.jackson.databind.ext.Java7HandlersImpl",
"methods":[{"name":"<init>","parameterTypes":[] }] "methods":[{"name":"<init>","parameterTypes":[] }]
@ -257,6 +275,9 @@
"allDeclaredFields":true, "allDeclaredFields":true,
"allDeclaredMethods":true "allDeclaredMethods":true
}, },
{
"name":"java.lang.Object"
},
{ {
"name":"java.lang.Record", "name":"java.lang.Record",
"allDeclaredFields":true, "allDeclaredFields":true,
@ -286,10 +307,18 @@
"name":"java.lang.constant.ConstantDesc", "name":"java.lang.constant.ConstantDesc",
"queryAllDeclaredMethods":true "queryAllDeclaredMethods":true
}, },
{
"name":"java.lang.reflect.Executable",
"methods":[{"name":"getParameters","parameterTypes":[] }]
},
{ {
"name":"java.lang.reflect.Method", "name":"java.lang.reflect.Method",
"methods":[{"name":"isDefault","parameterTypes":[] }] "methods":[{"name":"isDefault","parameterTypes":[] }]
}, },
{
"name":"java.lang.reflect.Parameter",
"methods":[{"name":"getName","parameterTypes":[] }]
},
{ {
"name":"java.lang.reflect.RecordComponent", "name":"java.lang.reflect.RecordComponent",
"methods":[{"name":"getName","parameterTypes":[] }, {"name":"getType","parameterTypes":[] }] "methods":[{"name":"getName","parameterTypes":[] }, {"name":"getType","parameterTypes":[] }]
@ -424,6 +453,50 @@
{ {
"name":"javax.smartcardio.CardPermission" "name":"javax.smartcardio.CardPermission"
}, },
{
"name":"kotlin.Any"
},
{
"name":"kotlin.Boolean"
},
{
"name":"kotlin.ByteArray"
},
{
"name":"kotlin.Int"
},
{
"name":"kotlin.Long"
},
{
"name":"kotlin.Metadata",
"queryAllDeclaredMethods":true,
"methods":[{"name":"bv","parameterTypes":[] }, {"name":"d1","parameterTypes":[] }, {"name":"d2","parameterTypes":[] }, {"name":"k","parameterTypes":[] }, {"name":"mv","parameterTypes":[] }, {"name":"pn","parameterTypes":[] }, {"name":"xi","parameterTypes":[] }, {"name":"xs","parameterTypes":[] }]
},
{
"name":"kotlin.SafePublicationLazyImpl",
"fields":[{"name":"_value"}]
},
{
"name":"kotlin.String"
},
{
"name":"kotlin.collections.List"
},
{
"name":"kotlin.collections.MutableList"
},
{
"name":"kotlin.jvm.internal.DefaultConstructorMarker"
},
{
"name":"kotlin.reflect.jvm.internal.ReflectionFactoryImpl",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"kotlin.reflect.jvm.internal.impl.resolve.scopes.DescriptorKindFilter",
"allPublicFields":true
},
{ {
"name":"libcore.io.Memory" "name":"libcore.io.Memory"
}, },
@ -2230,6 +2303,7 @@
"allDeclaredFields":true, "allDeclaredFields":true,
"allDeclaredMethods":true, "allDeclaredMethods":true,
"allDeclaredConstructors":true, "allDeclaredConstructors":true,
"allDeclaredClasses":true,
"methods":[{"name":"getDestinationDeviceId","parameterTypes":[] }] "methods":[{"name":"getDestinationDeviceId","parameterTypes":[] }]
}, },
{ {
@ -2237,6 +2311,7 @@
"allDeclaredFields":true, "allDeclaredFields":true,
"allDeclaredMethods":true, "allDeclaredMethods":true,
"allDeclaredConstructors":true, "allDeclaredConstructors":true,
"allDeclaredClasses":true,
"methods":[{"name":"getDestination","parameterTypes":[] }, {"name":"getMessages","parameterTypes":[] }, {"name":"getTimestamp","parameterTypes":[] }, {"name":"isOnline","parameterTypes":[] }, {"name":"isUrgent","parameterTypes":[] }] "methods":[{"name":"getDestination","parameterTypes":[] }, {"name":"getMessages","parameterTypes":[] }, {"name":"getTimestamp","parameterTypes":[] }, {"name":"isOnline","parameterTypes":[] }, {"name":"isUrgent","parameterTypes":[] }]
}, },
{ {
@ -2372,7 +2447,7 @@
}, },
{ {
"name":"org.whispersystems.signalservice.internal.push.SignalServiceProtos$AttachmentPointer", "name":"org.whispersystems.signalservice.internal.push.SignalServiceProtos$AttachmentPointer",
"fields":[{"name":"attachmentIdentifierCase_"}, {"name":"attachmentIdentifier_"}, {"name":"bitField0_"}, {"name":"blurHash_"}, {"name":"caption_"}, {"name":"cdnNumber_"}, {"name":"contentType_"}, {"name":"digest_"}, {"name":"fileName_"}, {"name":"flags_"}, {"name":"height_"}, {"name":"key_"}, {"name":"size_"}, {"name":"thumbnail_"}, {"name":"uploadTimestamp_"}, {"name":"width_"}] "fields":[{"name":"attachmentIdentifierCase_"}, {"name":"attachmentIdentifier_"}, {"name":"bitField0_"}, {"name":"blurHash_"}, {"name":"caption_"}, {"name":"cdnNumber_"}, {"name":"contentType_"}, {"name":"digest_"}, {"name":"fileName_"}, {"name":"flags_"}, {"name":"height_"}, {"name":"incrementalDigest_"}, {"name":"key_"}, {"name":"size_"}, {"name":"thumbnail_"}, {"name":"uploadTimestamp_"}, {"name":"width_"}]
}, },
{ {
"name":"org.whispersystems.signalservice.internal.push.SignalServiceProtos$BodyRange", "name":"org.whispersystems.signalservice.internal.push.SignalServiceProtos$BodyRange",

View file

@ -6,6 +6,10 @@
"pattern":"\\QMETA-INF/services/ch.qos.logback.classic.spi.Configurator\\E" "pattern":"\\QMETA-INF/services/ch.qos.logback.classic.spi.Configurator\\E"
}, { }, {
"pattern":"\\QMETA-INF/services/java.sql.Driver\\E" "pattern":"\\QMETA-INF/services/java.sql.Driver\\E"
}, {
"pattern":"\\QMETA-INF/services/kotlin.reflect.jvm.internal.impl.builtins.BuiltInsLoader\\E"
}, {
"pattern":"\\QMETA-INF/services/kotlin.reflect.jvm.internal.impl.resolve.ExternalOverridabilityCondition\\E"
}, { }, {
"pattern":"\\QMETA-INF/services/org.freedesktop.dbus.spi.transport.ITransportProvider\\E" "pattern":"\\QMETA-INF/services/org.freedesktop.dbus.spi.transport.ITransportProvider\\E"
}, { }, {
@ -140,6 +144,20 @@
"pattern":"\\Qcom/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_XK\\E" "pattern":"\\Qcom/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_XK\\E"
}, { }, {
"pattern":"\\Qjni/x86_64-Linux/libjffi-1.2.so\\E" "pattern":"\\Qjni/x86_64-Linux/libjffi-1.2.so\\E"
}, {
"pattern":"\\Qkotlin/annotation/annotation.kotlin_builtins\\E"
}, {
"pattern":"\\Qkotlin/collections/collections.kotlin_builtins\\E"
}, {
"pattern":"\\Qkotlin/coroutines/coroutines.kotlin_builtins\\E"
}, {
"pattern":"\\Qkotlin/internal/internal.kotlin_builtins\\E"
}, {
"pattern":"\\Qkotlin/kotlin.kotlin_builtins\\E"
}, {
"pattern":"\\Qkotlin/ranges/ranges.kotlin_builtins\\E"
}, {
"pattern":"\\Qkotlin/reflect/reflect.kotlin_builtins\\E"
}, { }, {
"pattern":"\\Qlibsignal_jni.dylib\\E" "pattern":"\\Qlibsignal_jni.dylib\\E"
}, { }, {

View file

@ -5,14 +5,15 @@ import org.asamk.signal.manager.api.Pair;
import org.signal.libsignal.protocol.InvalidKeyException; import org.signal.libsignal.protocol.InvalidKeyException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.whispersystems.signalservice.api.KbsPinData;
import org.whispersystems.signalservice.api.KeyBackupService; import org.whispersystems.signalservice.api.KeyBackupService;
import org.whispersystems.signalservice.api.KeyBackupServicePinException; import org.whispersystems.signalservice.api.KeyBackupServicePinException;
import org.whispersystems.signalservice.api.KeyBackupSystemNoDataException; import org.whispersystems.signalservice.api.SvrNoDataException;
import org.whispersystems.signalservice.api.SvrPinData;
import org.whispersystems.signalservice.api.kbs.MasterKey; import org.whispersystems.signalservice.api.kbs.MasterKey;
import org.whispersystems.signalservice.api.kbs.PinHashUtil; import org.whispersystems.signalservice.api.kbs.PinHashUtil;
import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException; import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException;
import org.whispersystems.signalservice.internal.contacts.entities.TokenResponse; import org.whispersystems.signalservice.internal.contacts.entities.TokenResponse;
import org.whispersystems.signalservice.internal.push.AuthCredentials;
import org.whispersystems.signalservice.internal.push.LockedException; import org.whispersystems.signalservice.internal.push.LockedException;
import java.io.IOException; import java.io.IOException;
@ -70,26 +71,27 @@ public class PinHelper {
} }
} }
public KbsPinData getRegistrationLockData( public SvrPinData getRegistrationLockData(
String pin, LockedException e String pin, LockedException e
) throws IOException, IncorrectPinException { ) throws IOException, IncorrectPinException {
var basicStorageCredentials = e.getBasicStorageCredentials(); var basicStorageCredentials = e.getSvr1Credentials();
if (basicStorageCredentials == null) { if (basicStorageCredentials == null) {
return null; return null;
} }
try { try {
return getRegistrationLockData(pin, basicStorageCredentials); return getRegistrationLockData(pin, basicStorageCredentials);
} catch (KeyBackupSystemNoDataException ex) { } catch (SvrNoDataException ex) {
throw new IOException(e); throw new IOException(e);
} catch (KeyBackupServicePinException ex) { } catch (KeyBackupServicePinException ex) {
throw new IncorrectPinException(ex.getTriesRemaining()); throw new IncorrectPinException(ex.getTriesRemaining());
} }
} }
private KbsPinData getRegistrationLockData( private SvrPinData getRegistrationLockData(
String pin, String basicStorageCredentials String pin, AuthCredentials authCredentials
) throws IOException, KeyBackupSystemNoDataException, KeyBackupServicePinException { ) throws IOException, SvrNoDataException, KeyBackupServicePinException {
final var basicStorageCredentials = authCredentials.asBasic();
var tokenResponsePair = getTokenResponse(basicStorageCredentials); var tokenResponsePair = getTokenResponse(basicStorageCredentials);
final var tokenResponse = tokenResponsePair.first(); final var tokenResponse = tokenResponsePair.first();
final var keyBackupService = tokenResponsePair.second(); final var keyBackupService = tokenResponsePair.second();
@ -113,12 +115,12 @@ public class PinHelper {
throw new IOException("KBS Account locked, maximum pin attempts reached."); throw new IOException("KBS Account locked, maximum pin attempts reached.");
} }
private KbsPinData restoreMasterKey( private SvrPinData restoreMasterKey(
String pin, String pin,
String basicStorageCredentials, String basicStorageCredentials,
TokenResponse tokenResponse, TokenResponse tokenResponse,
final KeyBackupService keyBackupService final KeyBackupService keyBackupService
) throws IOException, KeyBackupSystemNoDataException, KeyBackupServicePinException { ) throws IOException, SvrNoDataException, KeyBackupServicePinException {
if (pin == null) return null; if (pin == null) return null;
if (basicStorageCredentials == null) { if (basicStorageCredentials == null) {

View file

@ -163,6 +163,7 @@ public class RecipientHelper {
useCompat, useCompat,
Optional.empty(), Optional.empty(),
serviceEnvironmentConfig.getCdsiMrenclave(), serviceEnvironmentConfig.getCdsiMrenclave(),
null,
token -> { token -> {
// Not storing for partial refresh // Not storing for partial refresh
}); });

View file

@ -51,8 +51,6 @@ import org.whispersystems.signalservice.internal.util.DynamicCredentialsProvider
import java.io.IOException; import java.io.IOException;
import java.util.function.Consumer; import java.util.function.Consumer;
import static org.asamk.signal.manager.config.ServiceConfig.PREKEY_MAXIMUM_ID;
public class RegistrationManagerImpl implements RegistrationManager { public class RegistrationManagerImpl implements RegistrationManager {
private final static Logger logger = LoggerFactory.getLogger(RegistrationManagerImpl.class); private final static Logger logger = LoggerFactory.getLogger(RegistrationManagerImpl.class);
@ -267,28 +265,14 @@ public class RegistrationManagerImpl implements RegistrationManager {
final var keyPair = accountData.getIdentityKeyPair(); final var keyPair = accountData.getIdentityKeyPair();
final var preKeyMetadata = accountData.getPreKeyMetadata(); final var preKeyMetadata = accountData.getPreKeyMetadata();
final var preKeyIdOffset = preKeyMetadata.getPreKeyIdOffset();
final var oneTimeEcPreKeys = KeyUtils.generatePreKeyRecords(preKeyIdOffset);
final var nextSignedPreKeyId = preKeyMetadata.getNextSignedPreKeyId(); final var nextSignedPreKeyId = preKeyMetadata.getNextSignedPreKeyId();
final var signedPreKey = KeyUtils.generateSignedPreKeyRecord(nextSignedPreKeyId, keyPair); final var signedPreKey = KeyUtils.generateSignedPreKeyRecord(nextSignedPreKeyId, keyPair);
final var privateKey = keyPair.getPrivateKey(); final var privateKey = keyPair.getPrivateKey();
final var kyberPreKeyIdOffset = preKeyMetadata.getKyberPreKeyIdOffset(); final var kyberPreKeyIdOffset = preKeyMetadata.getKyberPreKeyIdOffset();
final var oneTimeKyberPreKeys = KeyUtils.generateKyberPreKeyRecords(kyberPreKeyIdOffset, privateKey); final var lastResortKyberPreKey = KeyUtils.generateKyberPreKeyRecord(kyberPreKeyIdOffset, privateKey);
final var lastResortKyberPreKeyId = (kyberPreKeyIdOffset + oneTimeKyberPreKeys.size()) % PREKEY_MAXIMUM_ID;
final var lastResortKyberPreKey = KeyUtils.generateKyberPreKeyRecord(lastResortKyberPreKeyId, privateKey);
return new PreKeyCollection(keyPair, return new PreKeyCollection(keyPair.getPublicKey(), signedPreKey, lastResortKyberPreKey);
nextSignedPreKeyId,
preKeyIdOffset,
lastResortKyberPreKeyId,
kyberPreKeyIdOffset,
serviceIdType,
keyPair.getPublicKey(),
signedPreKey,
oneTimeEcPreKeys,
lastResortKyberPreKey,
oneTimeKyberPreKeys);
} }
@Override @Override

View file

@ -303,18 +303,14 @@ public class SignalAccount implements Closeable {
private void setPreKeys(ServiceIdType serviceIdType, PreKeyCollection preKeyCollection) { private void setPreKeys(ServiceIdType serviceIdType, PreKeyCollection preKeyCollection) {
final var accountData = getAccountData(serviceIdType); final var accountData = getAccountData(serviceIdType);
final var preKeyMetadata = accountData.getPreKeyMetadata(); final var preKeyMetadata = accountData.getPreKeyMetadata();
preKeyMetadata.nextSignedPreKeyId = preKeyCollection.getNextSignedPreKeyId(); preKeyMetadata.nextSignedPreKeyId = preKeyCollection.getSignedPreKey().getId();
preKeyMetadata.preKeyIdOffset = preKeyCollection.getEcOneTimePreKeyIdOffset(); preKeyMetadata.kyberPreKeyIdOffset = preKeyCollection.getLastResortKyberPreKey().getId();
preKeyMetadata.kyberPreKeyIdOffset = preKeyCollection.getOneTimeKyberPreKeyIdOffset();
preKeyMetadata.activeLastResortKyberPreKeyId = preKeyCollection.getLastResortKyberPreKeyId();
accountData.getPreKeyStore().removeAllPreKeys(); accountData.getPreKeyStore().removeAllPreKeys();
accountData.getSignedPreKeyStore().removeAllSignedPreKeys(); accountData.getSignedPreKeyStore().removeAllSignedPreKeys();
accountData.getKyberPreKeyStore().removeAllKyberPreKeys(); accountData.getKyberPreKeyStore().removeAllKyberPreKeys();
addPreKeys(serviceIdType, preKeyCollection.getOneTimeEcPreKeys());
addSignedPreKey(serviceIdType, preKeyCollection.getSignedPreKey()); addSignedPreKey(serviceIdType, preKeyCollection.getSignedPreKey());
addKyberPreKeys(serviceIdType, preKeyCollection.getOneTimeKyberPreKeys());
addLastResortKyberPreKey(serviceIdType, preKeyCollection.getLastResortKyberPreKey()); addLastResortKyberPreKey(serviceIdType, preKeyCollection.getLastResortKyberPreKey());
save(); save();
@ -1335,13 +1331,14 @@ public class SignalAccount implements Closeable {
public AccountAttributes getAccountAttributes(String registrationLock) { public AccountAttributes getAccountAttributes(String registrationLock) {
return new AccountAttributes(null, return new AccountAttributes(null,
getLocalRegistrationId(), getLocalRegistrationId(),
false,
false,
true, true,
null,
registrationLock != null ? registrationLock : getRegistrationLock(), registrationLock != null ? registrationLock : getRegistrationLock(),
getSelfUnidentifiedAccessKey(), getSelfUnidentifiedAccessKey(),
isUnrestrictedUnidentifiedAccess(), isUnrestrictedUnidentifiedAccess(),
getAccountCapabilities(),
isDiscoverableByPhoneNumber(), isDiscoverableByPhoneNumber(),
getAccountCapabilities(),
encryptedDeviceName, encryptedDeviceName,
getLocalPniRegistrationId(), getLocalPniRegistrationId(),
null); // TODO recoveryPassword? null); // TODO recoveryPassword?

View file

@ -7,7 +7,6 @@ import org.asamk.signal.manager.api.Pair;
import org.asamk.signal.manager.api.PinLockedException; import org.asamk.signal.manager.api.PinLockedException;
import org.asamk.signal.manager.api.RateLimitException; import org.asamk.signal.manager.api.RateLimitException;
import org.asamk.signal.manager.helper.PinHelper; import org.asamk.signal.manager.helper.PinHelper;
import org.whispersystems.signalservice.api.KbsPinData;
import org.whispersystems.signalservice.api.SignalServiceAccountManager; import org.whispersystems.signalservice.api.SignalServiceAccountManager;
import org.whispersystems.signalservice.api.kbs.MasterKey; import org.whispersystems.signalservice.api.kbs.MasterKey;
import org.whispersystems.signalservice.api.push.exceptions.NoSuchSessionException; import org.whispersystems.signalservice.api.push.exceptions.NoSuchSessionException;
@ -116,8 +115,7 @@ public class NumberVerificationUtils {
throw new PinLockedException(e.getTimeRemaining()); throw new PinLockedException(e.getTimeRemaining());
} }
KbsPinData registrationLockData; final var registrationLockData = pinHelper.getRegistrationLockData(pin, e);
registrationLockData = pinHelper.getRegistrationLockData(pin, e);
if (registrationLockData == null) { if (registrationLockData == null) {
throw e; throw e;
} }

View file

@ -16,7 +16,7 @@ dependencyResolutionManagement {
library("logback", "ch.qos.logback", "logback-classic").version("1.4.8") library("logback", "ch.qos.logback", "logback-classic").version("1.4.8")
library("signalservice", "com.github.turasa", "signal-service-java").version("2.15.3_unofficial_74") library("signalservice", "com.github.turasa", "signal-service-java").version("2.15.3_unofficial_75")
library("protobuf", "com.google.protobuf", "protobuf-javalite").version("3.23.0") library("protobuf", "com.google.protobuf", "protobuf-javalite").version("3.23.0")
library("sqlite", "org.xerial", "sqlite-jdbc").version("3.42.0.0") library("sqlite", "org.xerial", "sqlite-jdbc").version("3.42.0.0")
library("hikari", "com.zaxxer", "HikariCP").version("5.0.1") library("hikari", "com.zaxxer", "HikariCP").version("5.0.1")