mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Update libsignal-service-java
Uses new device link endpoint Fixes #1399
This commit is contained in:
parent
22103736a7
commit
727f90d2e1
6 changed files with 48 additions and 32 deletions
|
@ -247,6 +247,7 @@
|
|||
{
|
||||
"name":"java.lang.Record",
|
||||
"allDeclaredFields":true,
|
||||
"allDeclaredClasses":true,
|
||||
"queryAllDeclaredMethods":true
|
||||
},
|
||||
{
|
||||
|
@ -297,7 +298,7 @@
|
|||
},
|
||||
{
|
||||
"name":"java.lang.reflect.RecordComponent",
|
||||
"methods":[{"name":"getName","parameterTypes":[] }, {"name":"getType","parameterTypes":[] }]
|
||||
"methods":[{"name":"getAccessor","parameterTypes":[] }, {"name":"getName","parameterTypes":[] }, {"name":"getType","parameterTypes":[] }]
|
||||
},
|
||||
{
|
||||
"name":"java.net.NetPermission"
|
||||
|
@ -2436,6 +2437,13 @@
|
|||
"name":"org.whispersystems.signalservice.internal.push.KyberPreKeyEntity$KEMPublicKeySerializer",
|
||||
"methods":[{"name":"<init>","parameterTypes":[] }]
|
||||
},
|
||||
{
|
||||
"name":"org.whispersystems.signalservice.internal.push.LinkDeviceRequest",
|
||||
"allDeclaredFields":true,
|
||||
"allDeclaredClasses":true,
|
||||
"queryAllDeclaredMethods":true,
|
||||
"methods":[{"name":"accountAttributes","parameterTypes":[] }, {"name":"aciPqLastResortPreKey","parameterTypes":[] }, {"name":"aciSignedPreKey","parameterTypes":[] }, {"name":"pniPqLastResortPreKey","parameterTypes":[] }, {"name":"pniSignedPreKey","parameterTypes":[] }, {"name":"verificationCode","parameterTypes":[] }]
|
||||
},
|
||||
{
|
||||
"name":"org.whispersystems.signalservice.internal.push.MismatchedDevices",
|
||||
"allDeclaredFields":true,
|
||||
|
|
|
@ -36,7 +36,6 @@ import org.whispersystems.signalservice.api.push.ServiceIdType;
|
|||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException;
|
||||
import org.whispersystems.signalservice.api.util.DeviceNameUtil;
|
||||
import org.whispersystems.signalservice.internal.push.ConfirmCodeMessage;
|
||||
import org.whispersystems.signalservice.internal.util.DynamicCredentialsProvider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -45,7 +44,7 @@ import java.nio.channels.OverlappingFileLockException;
|
|||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static org.asamk.signal.manager.config.ServiceConfig.getCapabilities;
|
||||
import static org.asamk.signal.manager.util.KeyUtils.generatePreKeysForType;
|
||||
|
||||
public class ProvisioningManagerImpl implements ProvisioningManager {
|
||||
|
||||
|
@ -140,20 +139,21 @@ public class ProvisioningManagerImpl implements ProvisioningManager {
|
|||
encryptedDeviceName,
|
||||
ret.getAciIdentity(),
|
||||
ret.getPniIdentity(),
|
||||
profileKey);
|
||||
profileKey,
|
||||
ret.getMasterKey());
|
||||
|
||||
account.getConfigurationStore().setReadReceipts(ret.isReadReceipts());
|
||||
|
||||
final var aciPreKeys = generatePreKeysForType(account.getAccountData(ServiceIdType.ACI));
|
||||
final var pniPreKeys = generatePreKeysForType(account.getAccountData(ServiceIdType.PNI));
|
||||
|
||||
logger.debug("Finishing new device registration");
|
||||
var deviceId = accountManager.finishNewDeviceRegistration(ret.getProvisioningCode(),
|
||||
new ConfirmCodeMessage(false,
|
||||
true,
|
||||
account.getAccountData(ServiceIdType.ACI).getLocalRegistrationId(),
|
||||
account.getAccountData(ServiceIdType.PNI).getLocalRegistrationId(),
|
||||
encryptedDeviceName,
|
||||
getCapabilities(false)));
|
||||
account.getAccountAttributes(null),
|
||||
aciPreKeys,
|
||||
pniPreKeys);
|
||||
|
||||
account.finishLinking(deviceId);
|
||||
account.finishLinking(deviceId, aciPreKeys, pniPreKeys);
|
||||
|
||||
ManagerImpl m = null;
|
||||
try {
|
||||
|
|
|
@ -51,6 +51,8 @@ import org.whispersystems.signalservice.internal.util.DynamicCredentialsProvider
|
|||
import java.io.IOException;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static org.asamk.signal.manager.util.KeyUtils.generatePreKeysForType;
|
||||
|
||||
public class RegistrationManagerImpl implements RegistrationManager {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(RegistrationManagerImpl.class);
|
||||
|
@ -133,8 +135,8 @@ public class RegistrationManagerImpl implements RegistrationManager {
|
|||
account.setPniIdentityKeyPair(KeyUtils.generateIdentityKeyPair());
|
||||
}
|
||||
|
||||
final var aciPreKeys = generatePreKeysForType(ServiceIdType.ACI);
|
||||
final var pniPreKeys = generatePreKeysForType(ServiceIdType.PNI);
|
||||
final var aciPreKeys = generatePreKeysForType(account.getAccountData(ServiceIdType.ACI));
|
||||
final var pniPreKeys = generatePreKeysForType(account.getAccountData(ServiceIdType.PNI));
|
||||
final var result = NumberVerificationUtils.verifyNumber(account.getSessionId(account.getNumber()),
|
||||
verificationCode,
|
||||
pin,
|
||||
|
@ -248,21 +250,6 @@ public class RegistrationManagerImpl implements RegistrationManager {
|
|||
true));
|
||||
}
|
||||
|
||||
private PreKeyCollection generatePreKeysForType(ServiceIdType serviceIdType) {
|
||||
final var accountData = account.getAccountData(serviceIdType);
|
||||
final var keyPair = accountData.getIdentityKeyPair();
|
||||
final var preKeyMetadata = accountData.getPreKeyMetadata();
|
||||
|
||||
final var nextSignedPreKeyId = preKeyMetadata.getNextSignedPreKeyId();
|
||||
final var signedPreKey = KeyUtils.generateSignedPreKeyRecord(nextSignedPreKeyId, keyPair.getPrivateKey());
|
||||
|
||||
final var privateKey = keyPair.getPrivateKey();
|
||||
final var kyberPreKeyIdOffset = preKeyMetadata.getNextKyberPreKeyId();
|
||||
final var lastResortKyberPreKey = KeyUtils.generateKyberPreKeyRecord(kyberPreKeyIdOffset, privateKey);
|
||||
|
||||
return new PreKeyCollection(keyPair.getPublicKey(), signedPreKey, lastResortKyberPreKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
if (account != null) {
|
||||
|
|
|
@ -273,7 +273,8 @@ public class SignalAccount implements Closeable {
|
|||
final String encryptedDeviceName,
|
||||
final IdentityKeyPair aciIdentity,
|
||||
final IdentityKeyPair pniIdentity,
|
||||
final ProfileKey profileKey
|
||||
final ProfileKey profileKey,
|
||||
final MasterKey masterKey
|
||||
) {
|
||||
this.deviceId = 0;
|
||||
this.number = number;
|
||||
|
@ -288,7 +289,7 @@ public class SignalAccount implements Closeable {
|
|||
this.registered = false;
|
||||
this.isMultiDevice = true;
|
||||
getKeyValueStore().storeEntry(lastReceiveTimestamp, 0L);
|
||||
this.pinMasterKey = null;
|
||||
this.pinMasterKey = masterKey;
|
||||
getKeyValueStore().storeEntry(storageManifestVersion, -1L);
|
||||
this.setStorageManifest(null);
|
||||
this.storageKey = null;
|
||||
|
@ -302,9 +303,13 @@ public class SignalAccount implements Closeable {
|
|||
save();
|
||||
}
|
||||
|
||||
public void finishLinking(final int deviceId) {
|
||||
public void finishLinking(
|
||||
final int deviceId, final PreKeyCollection aciPreKeys, final PreKeyCollection pniPreKeys
|
||||
) {
|
||||
this.registered = true;
|
||||
this.deviceId = deviceId;
|
||||
setPreKeys(ServiceIdType.ACI, aciPreKeys);
|
||||
setPreKeys(ServiceIdType.PNI, pniPreKeys);
|
||||
save();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.asamk.signal.manager.util;
|
||||
|
||||
import org.asamk.signal.manager.storage.SignalAccount;
|
||||
import org.signal.libsignal.protocol.IdentityKey;
|
||||
import org.signal.libsignal.protocol.IdentityKeyPair;
|
||||
import org.signal.libsignal.protocol.InvalidKeyException;
|
||||
|
@ -12,6 +13,7 @@ import org.signal.libsignal.protocol.state.PreKeyRecord;
|
|||
import org.signal.libsignal.protocol.state.SignedPreKeyRecord;
|
||||
import org.signal.libsignal.zkgroup.InvalidInputException;
|
||||
import org.signal.libsignal.zkgroup.profiles.ProfileKey;
|
||||
import org.whispersystems.signalservice.api.account.PreKeyCollection;
|
||||
import org.whispersystems.signalservice.api.kbs.MasterKey;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
|
@ -125,4 +127,18 @@ public class KeyUtils {
|
|||
public static int getRandomInt(int bound) {
|
||||
return secureRandom.nextInt(bound);
|
||||
}
|
||||
|
||||
public static PreKeyCollection generatePreKeysForType(final SignalAccount.AccountData<?> accountData) {
|
||||
final var keyPair = accountData.getIdentityKeyPair();
|
||||
final var preKeyMetadata = accountData.getPreKeyMetadata();
|
||||
|
||||
final var nextSignedPreKeyId = preKeyMetadata.getNextSignedPreKeyId();
|
||||
final var signedPreKey = generateSignedPreKeyRecord(nextSignedPreKeyId, keyPair.getPrivateKey());
|
||||
|
||||
final var privateKey = keyPair.getPrivateKey();
|
||||
final var kyberPreKeyIdOffset = preKeyMetadata.getNextKyberPreKeyId();
|
||||
final var lastResortKyberPreKey = generateKyberPreKeyRecord(kyberPreKeyIdOffset, privateKey);
|
||||
|
||||
return new PreKeyCollection(keyPair.getPublicKey(), signedPreKey, lastResortKyberPreKey);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ dependencyResolutionManagement {
|
|||
library("logback", "ch.qos.logback", "logback-classic").version("1.4.11")
|
||||
|
||||
|
||||
library("signalservice", "com.github.turasa", "signal-service-java").version("2.15.3_unofficial_89")
|
||||
library("signalservice", "com.github.turasa", "signal-service-java").version("2.15.3_unofficial_90")
|
||||
library("sqlite", "org.xerial", "sqlite-jdbc").version("3.44.0.0")
|
||||
library("hikari", "com.zaxxer", "HikariCP").version("5.1.0")
|
||||
library("junit.jupiter", "org.junit.jupiter", "junit-jupiter").version("5.10.1")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue