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);
}
public void removeRegistrationPin() throws IOException {
// Remove KBS Pin
context.getPinHelper().removeRegistrationLockPin();
+ dependencies.getAccountManager().disableRegistrationLock();
account.setRegistrationLockPin(null);
}
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;
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() {
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;
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) {
}
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) {
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;
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