use of org.whispersystems.libsignal.state.SignedPreKeyRecord in project Signal-Android by WhisperSystems.
the class RotateSignedPreKeyJob method onRun.
@Override
public void onRun(MasterSecret masterSecret) throws Exception {
Log.w(TAG, "Rotating signed prekey...");
IdentityKeyPair identityKey = IdentityKeyUtil.getIdentityKeyPair(context);
SignedPreKeyRecord signedPreKeyRecord = PreKeyUtil.generateSignedPreKey(context, identityKey, false);
accountManager.setSignedPreKey(signedPreKeyRecord);
PreKeyUtil.setActiveSignedPreKeyId(context, signedPreKeyRecord.getId());
TextSecurePreferences.setSignedPreKeyRegistered(context, true);
TextSecurePreferences.setSignedPreKeyFailureCount(context, 0);
ApplicationContext.getInstance(context).getJobManager().add(new CleanPreKeysJob(context));
}
use of org.whispersystems.libsignal.state.SignedPreKeyRecord in project Signal-Android by WhisperSystems.
the class RegistrationService method handleCommonRegistration.
private void handleCommonRegistration(SignalServiceAccountManager accountManager, String number, String password, String signalingKey, boolean supportsGcm) throws IOException {
setState(new RegistrationState(RegistrationState.STATE_GENERATING_KEYS, number));
Recipient self = RecipientFactory.getRecipientsFromString(this, number, false).getPrimaryRecipient();
IdentityKeyPair identityKey = IdentityKeyUtil.getIdentityKeyPair(this);
List<PreKeyRecord> records = PreKeyUtil.generatePreKeys(this);
PreKeyRecord lastResort = PreKeyUtil.generateLastResortKey(this);
SignedPreKeyRecord signedPreKey = PreKeyUtil.generateSignedPreKey(this, identityKey, true);
accountManager.setPreKeys(identityKey.getPublicKey(), lastResort, signedPreKey, records);
setState(new RegistrationState(RegistrationState.STATE_GCM_REGISTERING, number));
if (supportsGcm) {
String gcmRegistrationId = GoogleCloudMessaging.getInstance(this).register(GcmRefreshJob.REGISTRATION_ID);
accountManager.setGcmId(Optional.of(gcmRegistrationId));
TextSecurePreferences.setGcmRegistrationId(this, gcmRegistrationId);
TextSecurePreferences.setGcmDisabled(this, false);
} else {
TextSecurePreferences.setGcmDisabled(this, true);
}
TextSecurePreferences.setWebsocketRegistered(this, true);
DatabaseFactory.getIdentityDatabase(this).saveIdentity(self.getRecipientId(), identityKey.getPublicKey());
DirectoryHelper.refreshDirectory(this, accountManager, number);
DirectoryRefreshListener.schedule(this);
RotateSignedPreKeyListener.schedule(this);
}
use of org.whispersystems.libsignal.state.SignedPreKeyRecord in project Signal-Android by WhisperSystems.
the class TextSecurePreKeyStore method migrateRecords.
public void migrateRecords() {
synchronized (FILE_LOCK) {
File preKeyRecords = getPreKeyDirectory();
for (File preKeyRecord : preKeyRecords.listFiles()) {
try {
int preKeyId = Integer.parseInt(preKeyRecord.getName());
PreKeyRecord record = loadPreKey(preKeyId);
storePreKey(preKeyId, record);
} catch (InvalidKeyIdException | NumberFormatException e) {
Log.w(TAG, e);
}
}
File signedPreKeyRecords = getSignedPreKeyDirectory();
for (File signedPreKeyRecord : signedPreKeyRecords.listFiles()) {
try {
int signedPreKeyId = Integer.parseInt(signedPreKeyRecord.getName());
SignedPreKeyRecord record = loadSignedPreKey(signedPreKeyId);
storeSignedPreKey(signedPreKeyId, record);
} catch (InvalidKeyIdException | NumberFormatException e) {
Log.w(TAG, e);
}
}
}
}
Aggregations