use of org.thoughtcrime.securesms.crypto.storage.SignalIdentityKeyStore in project Signal-Android by WhisperSystems.
the class SafetyNumberChangeRepository method trustOrVerifyChangedRecipientsInternal.
@WorkerThread
private TrustAndVerifyResult trustOrVerifyChangedRecipientsInternal(@NonNull List<ChangedRecipient> changedRecipients) {
SignalIdentityKeyStore identityStore = ApplicationDependencies.getProtocolStore().aci().identities();
try (SignalSessionLock.Lock unused = ReentrantSessionLock.INSTANCE.acquire()) {
for (ChangedRecipient changedRecipient : changedRecipients) {
IdentityRecord identityRecord = changedRecipient.getIdentityRecord();
if (changedRecipient.isUnverified()) {
Log.d(TAG, "Setting " + identityRecord.getRecipientId() + " as verified");
ApplicationDependencies.getProtocolStore().aci().identities().setVerified(identityRecord.getRecipientId(), identityRecord.getIdentityKey(), IdentityDatabase.VerifiedStatus.DEFAULT);
} else {
Log.d(TAG, "Setting " + identityRecord.getRecipientId() + " as approved");
identityStore.setApproval(identityRecord.getRecipientId(), true);
}
}
}
return TrustAndVerifyResult.trustAndVerify(changedRecipients);
}
use of org.thoughtcrime.securesms.crypto.storage.SignalIdentityKeyStore in project Signal-Android by WhisperSystems.
the class UntrustedSendDialog method onClick.
@Override
public void onClick(DialogInterface dialog, int which) {
final SignalIdentityKeyStore identityStore = ApplicationDependencies.getProtocolStore().aci().identities();
SimpleTask.run(() -> {
try (SignalSessionLock.Lock unused = ReentrantSessionLock.INSTANCE.acquire()) {
for (IdentityRecord identityRecord : untrustedRecords) {
identityStore.setApproval(identityRecord.getRecipientId(), true);
}
}
return null;
}, unused -> resendListener.onResendMessage());
}
use of org.thoughtcrime.securesms.crypto.storage.SignalIdentityKeyStore in project Signal-Android by WhisperSystems.
the class ApplicationDependencyProvider method provideProtocolStore.
@Override
@NonNull
public SignalServiceDataStoreImpl provideProtocolStore() {
ACI localAci = SignalStore.account().getAci();
PNI localPni = SignalStore.account().getPni();
if (localAci == null) {
throw new IllegalStateException("No ACI set!");
}
if (localPni == null) {
throw new IllegalStateException("No PNI set!");
}
if (!SignalStore.account().hasPniIdentityKey()) {
SignalStore.account().generatePniIdentityKeyIfNecessary();
CreateSignedPreKeyJob.enqueueIfNeeded();
}
SignalBaseIdentityKeyStore baseIdentityStore = new SignalBaseIdentityKeyStore(context);
SignalServiceAccountDataStoreImpl aciStore = new SignalServiceAccountDataStoreImpl(context, new TextSecurePreKeyStore(localAci), new SignalIdentityKeyStore(baseIdentityStore, () -> SignalStore.account().getAciIdentityKey()), new TextSecureSessionStore(localAci), new SignalSenderKeyStore(context));
SignalServiceAccountDataStoreImpl pniStore = new SignalServiceAccountDataStoreImpl(context, new TextSecurePreKeyStore(localPni), new SignalIdentityKeyStore(baseIdentityStore, () -> SignalStore.account().getPniIdentityKey()), new TextSecureSessionStore(localPni), new SignalSenderKeyStore(context));
return new SignalServiceDataStoreImpl(context, aciStore, pniStore);
}
use of org.thoughtcrime.securesms.crypto.storage.SignalIdentityKeyStore in project Signal-Android by WhisperSystems.
the class IdentityUtil method processVerifiedMessage.
public static void processVerifiedMessage(Context context, VerifiedMessage verifiedMessage) {
try (SignalSessionLock.Lock unused = ReentrantSessionLock.INSTANCE.acquire()) {
SignalIdentityKeyStore identityStore = ApplicationDependencies.getProtocolStore().aci().identities();
Recipient recipient = Recipient.externalPush(verifiedMessage.getDestination());
Optional<IdentityRecord> identityRecord = identityStore.getIdentityRecord(recipient.getId());
if (!identityRecord.isPresent() && verifiedMessage.getVerified() == VerifiedMessage.VerifiedState.DEFAULT) {
Log.w(TAG, "No existing record for default status");
return;
}
if (verifiedMessage.getVerified() == VerifiedMessage.VerifiedState.DEFAULT && identityRecord.isPresent() && identityRecord.get().getIdentityKey().equals(verifiedMessage.getIdentityKey()) && identityRecord.get().getVerifiedStatus() != IdentityDatabase.VerifiedStatus.DEFAULT) {
identityStore.setVerified(recipient.getId(), identityRecord.get().getIdentityKey(), IdentityDatabase.VerifiedStatus.DEFAULT);
markIdentityVerified(context, recipient, false, true);
}
if (verifiedMessage.getVerified() == VerifiedMessage.VerifiedState.VERIFIED && (!identityRecord.isPresent() || (identityRecord.isPresent() && !identityRecord.get().getIdentityKey().equals(verifiedMessage.getIdentityKey())) || (identityRecord.isPresent() && identityRecord.get().getVerifiedStatus() != IdentityDatabase.VerifiedStatus.VERIFIED))) {
saveIdentity(verifiedMessage.getDestination().getIdentifier(), verifiedMessage.getIdentityKey());
identityStore.setVerified(recipient.getId(), verifiedMessage.getIdentityKey(), IdentityDatabase.VerifiedStatus.VERIFIED);
markIdentityVerified(context, recipient, true, true);
}
}
}
Aggregations