mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Ignore failures from SVR v1 pin
This commit is contained in:
parent
400dcf2899
commit
5cc20ace1f
4 changed files with 17 additions and 30 deletions
|
@ -416,12 +416,14 @@ public class AccountHelper {
|
|||
var masterKey = account.getOrCreatePinMasterKey();
|
||||
|
||||
context.getPinHelper().migrateRegistrationLockPin(account.getRegistrationLockPin(), masterKey);
|
||||
dependencies.getAccountManager().enableRegistrationLock(masterKey);
|
||||
}
|
||||
|
||||
public void setRegistrationPin(String pin) throws IOException {
|
||||
var masterKey = account.getOrCreatePinMasterKey();
|
||||
|
||||
context.getPinHelper().setRegistrationLockPin(pin, masterKey);
|
||||
dependencies.getAccountManager().enableRegistrationLock(masterKey);
|
||||
|
||||
account.setRegistrationLockPin(pin);
|
||||
}
|
||||
|
@ -429,6 +431,7 @@ public class AccountHelper {
|
|||
public void removeRegistrationPin() throws IOException {
|
||||
// Remove KBS Pin
|
||||
context.getPinHelper().removeRegistrationLockPin();
|
||||
dependencies.getAccountManager().disableRegistrationLock();
|
||||
|
||||
account.setRegistrationLockPin(null);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.asamk.signal.manager.storage.AttachmentStore;
|
|||
import org.asamk.signal.manager.storage.AvatarStore;
|
||||
import org.asamk.signal.manager.storage.SignalAccount;
|
||||
import org.asamk.signal.manager.storage.stickerPacks.StickerPackStore;
|
||||
import org.whispersystems.signalservice.api.svr.SecureValueRecoveryV1;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
@ -115,9 +116,9 @@ public class Context {
|
|||
|
||||
PinHelper getPinHelper() {
|
||||
return getOrCreate(() -> pinHelper,
|
||||
() -> pinHelper = new PinHelper(dependencies.getKeyBackupService(),
|
||||
dependencies.getFallbackKeyBackupServices(),
|
||||
dependencies.getSecureValueRecoveryV2()));
|
||||
() -> pinHelper = new PinHelper(new SecureValueRecoveryV1(dependencies.getKeyBackupService()),
|
||||
dependencies.getSecureValueRecoveryV2(),
|
||||
dependencies.getFallbackKeyBackupServices()));
|
||||
}
|
||||
|
||||
public PreKeyHelper getPreKeyHelper() {
|
||||
|
|
|
@ -5,11 +5,9 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.whispersystems.signalservice.api.KeyBackupService;
|
||||
import org.whispersystems.signalservice.api.kbs.MasterKey;
|
||||
import org.whispersystems.signalservice.api.kbs.PinHashUtil;
|
||||
import org.whispersystems.signalservice.api.svr.SecureValueRecovery;
|
||||
import org.whispersystems.signalservice.api.svr.SecureValueRecoveryV1;
|
||||
import org.whispersystems.signalservice.api.svr.SecureValueRecoveryV2;
|
||||
import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException;
|
||||
import org.whispersystems.signalservice.internal.push.AuthCredentials;
|
||||
import org.whispersystems.signalservice.internal.push.LockedException;
|
||||
|
||||
|
@ -20,35 +18,24 @@ public class PinHelper {
|
|||
|
||||
private final static Logger logger = LoggerFactory.getLogger(PinHelper.class);
|
||||
|
||||
private final KeyBackupService keyBackupService;
|
||||
private final SecureValueRecoveryV1 secureValueRecoveryV1;
|
||||
private final SecureValueRecoveryV2 secureValueRecoveryV2;
|
||||
private final Collection<KeyBackupService> fallbackKeyBackupServices;
|
||||
|
||||
public PinHelper(
|
||||
final KeyBackupService keyBackupService,
|
||||
final Collection<KeyBackupService> fallbackKeyBackupServices,
|
||||
SecureValueRecoveryV2 secureValueRecoveryV2
|
||||
final SecureValueRecoveryV1 secureValueRecoveryV1,
|
||||
final SecureValueRecoveryV2 secureValueRecoveryV2,
|
||||
final Collection<KeyBackupService> fallbackKeyBackupServices
|
||||
) {
|
||||
this.keyBackupService = keyBackupService;
|
||||
this.fallbackKeyBackupServices = fallbackKeyBackupServices;
|
||||
this.secureValueRecoveryV1 = new SecureValueRecoveryV1(keyBackupService);
|
||||
this.secureValueRecoveryV1 = secureValueRecoveryV1;
|
||||
this.secureValueRecoveryV2 = secureValueRecoveryV2;
|
||||
}
|
||||
|
||||
public void setRegistrationLockPin(
|
||||
String pin, MasterKey masterKey
|
||||
) throws IOException {
|
||||
final var pinChangeSession = keyBackupService.newPinChangeSession();
|
||||
final var hashedPin = PinHashUtil.hashPin(pin, pinChangeSession.hashSalt());
|
||||
|
||||
try {
|
||||
pinChangeSession.setPin(hashedPin, masterKey);
|
||||
} catch (UnauthenticatedResponseException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
pinChangeSession.enableRegistrationLock(masterKey);
|
||||
|
||||
secureValueRecoveryV1.setPin(pin, masterKey).execute();
|
||||
final var backupResponse = secureValueRecoveryV2.setPin(pin, masterKey).execute();
|
||||
if (backupResponse instanceof SecureValueRecovery.BackupResponse.Success) {
|
||||
} else if (backupResponse instanceof SecureValueRecovery.BackupResponse.ServerRejected) {
|
||||
|
@ -80,14 +67,7 @@ public class PinHelper {
|
|||
}
|
||||
|
||||
public void removeRegistrationLockPin() throws IOException {
|
||||
final var pinChangeSession = keyBackupService.newPinChangeSession();
|
||||
pinChangeSession.disableRegistrationLock();
|
||||
try {
|
||||
pinChangeSession.removePin();
|
||||
} catch (UnauthenticatedResponseException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
|
||||
secureValueRecoveryV1.deleteData();
|
||||
final var deleteResponse = secureValueRecoveryV2.deleteData();
|
||||
if (deleteResponse instanceof SecureValueRecovery.DeleteResponse.Success) {
|
||||
} else if (deleteResponse instanceof SecureValueRecovery.DeleteResponse.ServerRejected) {
|
||||
|
|
|
@ -45,6 +45,7 @@ import org.whispersystems.signalservice.api.push.ServiceIdType;
|
|||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.AlreadyVerifiedException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.DeprecatedVersionException;
|
||||
import org.whispersystems.signalservice.api.svr.SecureValueRecoveryV1;
|
||||
import org.whispersystems.signalservice.internal.push.VerifyAccountResponse;
|
||||
import org.whispersystems.signalservice.internal.util.DynamicCredentialsProvider;
|
||||
|
||||
|
@ -108,7 +109,9 @@ public class RegistrationManagerImpl implements RegistrationManager {
|
|||
10))
|
||||
.toList();
|
||||
final var secureValueRecoveryV2 = accountManager.getSecureValueRecoveryV2(serviceEnvironmentConfig.svr2Mrenclave());
|
||||
this.pinHelper = new PinHelper(keyBackupService, fallbackKeyBackupServices, secureValueRecoveryV2);
|
||||
this.pinHelper = new PinHelper(new SecureValueRecoveryV1(keyBackupService),
|
||||
secureValueRecoveryV2,
|
||||
fallbackKeyBackupServices);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue