Search in sources :

Example 6 with VerificationFailedException

use of org.signal.zkgroup.VerificationFailedException in project Signal-Android by signalapp.

the class SignalCallManager method peekGroupCall.

public void peekGroupCall(@NonNull RecipientId id) {
    if (callManager == null) {
        Log.i(TAG, "Unable to peekGroupCall, call manager is null");
        return;
    }
    networkExecutor.execute(() -> {
        try {
            Recipient group = Recipient.resolved(id);
            GroupId.V2 groupId = group.requireGroupId().requireV2();
            GroupExternalCredential credential = GroupManager.getGroupExternalCredential(context, groupId);
            List<GroupCall.GroupMemberInfo> members = Stream.of(GroupManager.getUuidCipherTexts(context, groupId)).map(entry -> new GroupCall.GroupMemberInfo(entry.getKey(), entry.getValue().serialize())).toList();
            callManager.peekGroupCall(SignalStore.internalValues().groupCallingServer(), credential.getTokenBytes().toByteArray(), members, peekInfo -> {
                Long threadId = SignalDatabase.threads().getThreadIdFor(group.getId());
                if (threadId != null) {
                    SignalDatabase.sms().updatePreviousGroupCall(threadId, peekInfo.getEraId(), peekInfo.getJoinedMembers(), WebRtcUtil.isCallFull(peekInfo));
                    ApplicationDependencies.getMessageNotifier().updateNotification(context, threadId, true, 0, BubbleUtil.BubbleState.HIDDEN);
                    EventBus.getDefault().postSticky(new GroupCallPeekEvent(id, peekInfo.getEraId(), peekInfo.getDeviceCount(), peekInfo.getMaxDevices()));
                }
            });
        } catch (IOException | VerificationFailedException | CallException e) {
            Log.e(TAG, "error peeking from active conversation", e);
        }
    });
}
Also used : SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) SignalAudioManager(org.thoughtcrime.securesms.webrtc.audio.SignalAudioManager) SignalServiceAccountManager(org.whispersystems.signalservice.api.SignalServiceAccountManager) NetworkRoute(org.signal.ringrtc.NetworkRoute) BubbleUtil(org.thoughtcrime.securesms.util.BubbleUtil) SendMessageResult(org.whispersystems.signalservice.api.messages.SendMessageResult) CallingResponse(org.whispersystems.signalservice.api.messages.calls.CallingResponse) TurnServerInfo(org.whispersystems.signalservice.api.messages.calls.TurnServerInfo) NonNull(androidx.annotation.NonNull) RecipientUtil(org.thoughtcrime.securesms.recipients.RecipientUtil) CallException(org.signal.ringrtc.CallException) WebRtcCallActivity(org.thoughtcrime.securesms.WebRtcCallActivity) CallManager(org.signal.ringrtc.CallManager) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) NetworkUtil(org.thoughtcrime.securesms.util.NetworkUtil) Recipient(org.thoughtcrime.securesms.recipients.Recipient) IDLE(org.thoughtcrime.securesms.events.WebRtcViewModel.GroupCallState.IDLE) SignalExecutors(org.signal.core.util.concurrent.SignalExecutors) WebRtcUtil.getUrgencyFromCallUrgency(org.thoughtcrime.securesms.service.webrtc.WebRtcUtil.getUrgencyFromCallUrgency) GroupExternalCredential(org.signal.storageservice.protos.groups.GroupExternalCredential) ACI(org.whispersystems.signalservice.api.push.ACI) HttpHeader(org.signal.ringrtc.HttpHeader) ApplicationDependencies(org.thoughtcrime.securesms.dependencies.ApplicationDependencies) Collection(java.util.Collection) GroupCallUpdateSendJob(org.thoughtcrime.securesms.jobs.GroupCallUpdateSendJob) Set(java.util.Set) UnidentifiedAccessUtil(org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil) UUID(java.util.UUID) GroupDatabase(org.thoughtcrime.securesms.database.GroupDatabase) UNTRUSTED_IDENTITY(org.thoughtcrime.securesms.events.WebRtcViewModel.State.UNTRUSTED_IDENTITY) Collectors(java.util.stream.Collectors) Executors(java.util.concurrent.Executors) InvalidInputException(org.signal.zkgroup.InvalidInputException) GroupCall(org.signal.ringrtc.GroupCall) Log(org.signal.core.util.logging.Log) List(java.util.List) Nullable(androidx.annotation.Nullable) Application(android.app.Application) GroupId(org.thoughtcrime.securesms.groups.GroupId) CallId(org.signal.ringrtc.CallId) CameraEventListener(org.thoughtcrime.securesms.ringrtc.CameraEventListener) Context(android.content.Context) RecipientAccessList(org.thoughtcrime.securesms.util.RecipientAccessList) SignalDatabase(org.thoughtcrime.securesms.database.SignalDatabase) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) Stream(com.annimon.stream.Stream) Remote(org.signal.ringrtc.Remote) Util(org.thoughtcrime.securesms.util.Util) VerificationFailedException(org.signal.zkgroup.VerificationFailedException) Intent(android.content.Intent) AppForegroundObserver(org.thoughtcrime.securesms.util.AppForegroundObserver) RetrieveProfileJob(org.thoughtcrime.securesms.jobs.RetrieveProfileJob) NETWORK_FAILURE(org.thoughtcrime.securesms.events.WebRtcViewModel.State.NETWORK_FAILURE) OfferMessage(org.whispersystems.signalservice.api.messages.calls.OfferMessage) LockManager(org.thoughtcrime.securesms.webrtc.locks.LockManager) TextSecurePreferences(org.thoughtcrime.securesms.util.TextSecurePreferences) OpaqueMessage(org.whispersystems.signalservice.api.messages.calls.OpaqueMessage) GroupManager(org.thoughtcrime.securesms.groups.GroupManager) CameraState(org.thoughtcrime.securesms.ringrtc.CameraState) Pair(org.whispersystems.libsignal.util.Pair) EventBus(org.greenrobot.eventbus.EventBus) SignalServiceCallMessage(org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage) Build(android.os.Build) LinkedList(java.util.LinkedList) GroupSendUtil(org.thoughtcrime.securesms.messages.GroupSendUtil) WebRtcServiceState(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState) ExecutorService(java.util.concurrent.ExecutorService) SignalServiceMessageSender(org.whispersystems.signalservice.api.SignalServiceMessageSender) PeerConnection(org.webrtc.PeerConnection) Executor(java.util.concurrent.Executor) WebRtcViewModel(org.thoughtcrime.securesms.events.WebRtcViewModel) IOException(java.io.IOException) NO_SUCH_USER(org.thoughtcrime.securesms.events.WebRtcViewModel.State.NO_SUCH_USER) GroupCallPeekEvent(org.thoughtcrime.securesms.events.GroupCallPeekEvent) Optional(org.whispersystems.libsignal.util.guava.Optional) UnregisteredUserException(org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException) GroupIdentifier(org.signal.zkgroup.groups.GroupIdentifier) UntrustedIdentityException(org.whispersystems.signalservice.api.crypto.UntrustedIdentityException) CALL_INCOMING(org.thoughtcrime.securesms.events.WebRtcViewModel.State.CALL_INCOMING) ResultReceiver(android.os.ResultReceiver) Collections(java.util.Collections) GroupCallPeekEvent(org.thoughtcrime.securesms.events.GroupCallPeekEvent) CallException(org.signal.ringrtc.CallException) Recipient(org.thoughtcrime.securesms.recipients.Recipient) IOException(java.io.IOException) GroupExternalCredential(org.signal.storageservice.protos.groups.GroupExternalCredential) GroupId(org.thoughtcrime.securesms.groups.GroupId) VerificationFailedException(org.signal.zkgroup.VerificationFailedException)

Example 7 with VerificationFailedException

use of org.signal.zkgroup.VerificationFailedException in project Signal-Android by signalapp.

the class SignalCallManager method peekGroupCallForRingingCheck.

public void peekGroupCallForRingingCheck(@NonNull GroupCallRingCheckInfo info) {
    if (callManager == null) {
        Log.i(TAG, "Unable to peekGroupCall, call manager is null");
        return;
    }
    networkExecutor.execute(() -> {
        try {
            Recipient group = Recipient.resolved(info.getRecipientId());
            GroupId.V2 groupId = group.requireGroupId().requireV2();
            GroupExternalCredential credential = GroupManager.getGroupExternalCredential(context, groupId);
            List<GroupCall.GroupMemberInfo> members = GroupManager.getUuidCipherTexts(context, groupId).entrySet().stream().map(entry -> new GroupCall.GroupMemberInfo(entry.getKey(), entry.getValue().serialize())).collect(Collectors.toList());
            callManager.peekGroupCall(SignalStore.internalValues().groupCallingServer(), credential.getTokenBytes().toByteArray(), members, peekInfo -> {
                receivedGroupCallPeekForRingingCheck(info, peekInfo.getDeviceCount());
            });
        } catch (IOException | VerificationFailedException | CallException e) {
            Log.e(TAG, "error peeking for ringing check", e);
        }
    });
}
Also used : SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) SignalAudioManager(org.thoughtcrime.securesms.webrtc.audio.SignalAudioManager) SignalServiceAccountManager(org.whispersystems.signalservice.api.SignalServiceAccountManager) NetworkRoute(org.signal.ringrtc.NetworkRoute) BubbleUtil(org.thoughtcrime.securesms.util.BubbleUtil) SendMessageResult(org.whispersystems.signalservice.api.messages.SendMessageResult) CallingResponse(org.whispersystems.signalservice.api.messages.calls.CallingResponse) TurnServerInfo(org.whispersystems.signalservice.api.messages.calls.TurnServerInfo) NonNull(androidx.annotation.NonNull) RecipientUtil(org.thoughtcrime.securesms.recipients.RecipientUtil) CallException(org.signal.ringrtc.CallException) WebRtcCallActivity(org.thoughtcrime.securesms.WebRtcCallActivity) CallManager(org.signal.ringrtc.CallManager) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) NetworkUtil(org.thoughtcrime.securesms.util.NetworkUtil) Recipient(org.thoughtcrime.securesms.recipients.Recipient) IDLE(org.thoughtcrime.securesms.events.WebRtcViewModel.GroupCallState.IDLE) SignalExecutors(org.signal.core.util.concurrent.SignalExecutors) WebRtcUtil.getUrgencyFromCallUrgency(org.thoughtcrime.securesms.service.webrtc.WebRtcUtil.getUrgencyFromCallUrgency) GroupExternalCredential(org.signal.storageservice.protos.groups.GroupExternalCredential) ACI(org.whispersystems.signalservice.api.push.ACI) HttpHeader(org.signal.ringrtc.HttpHeader) ApplicationDependencies(org.thoughtcrime.securesms.dependencies.ApplicationDependencies) Collection(java.util.Collection) GroupCallUpdateSendJob(org.thoughtcrime.securesms.jobs.GroupCallUpdateSendJob) Set(java.util.Set) UnidentifiedAccessUtil(org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil) UUID(java.util.UUID) GroupDatabase(org.thoughtcrime.securesms.database.GroupDatabase) UNTRUSTED_IDENTITY(org.thoughtcrime.securesms.events.WebRtcViewModel.State.UNTRUSTED_IDENTITY) Collectors(java.util.stream.Collectors) Executors(java.util.concurrent.Executors) InvalidInputException(org.signal.zkgroup.InvalidInputException) GroupCall(org.signal.ringrtc.GroupCall) Log(org.signal.core.util.logging.Log) List(java.util.List) Nullable(androidx.annotation.Nullable) Application(android.app.Application) GroupId(org.thoughtcrime.securesms.groups.GroupId) CallId(org.signal.ringrtc.CallId) CameraEventListener(org.thoughtcrime.securesms.ringrtc.CameraEventListener) Context(android.content.Context) RecipientAccessList(org.thoughtcrime.securesms.util.RecipientAccessList) SignalDatabase(org.thoughtcrime.securesms.database.SignalDatabase) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) Stream(com.annimon.stream.Stream) Remote(org.signal.ringrtc.Remote) Util(org.thoughtcrime.securesms.util.Util) VerificationFailedException(org.signal.zkgroup.VerificationFailedException) Intent(android.content.Intent) AppForegroundObserver(org.thoughtcrime.securesms.util.AppForegroundObserver) RetrieveProfileJob(org.thoughtcrime.securesms.jobs.RetrieveProfileJob) NETWORK_FAILURE(org.thoughtcrime.securesms.events.WebRtcViewModel.State.NETWORK_FAILURE) OfferMessage(org.whispersystems.signalservice.api.messages.calls.OfferMessage) LockManager(org.thoughtcrime.securesms.webrtc.locks.LockManager) TextSecurePreferences(org.thoughtcrime.securesms.util.TextSecurePreferences) OpaqueMessage(org.whispersystems.signalservice.api.messages.calls.OpaqueMessage) GroupManager(org.thoughtcrime.securesms.groups.GroupManager) CameraState(org.thoughtcrime.securesms.ringrtc.CameraState) Pair(org.whispersystems.libsignal.util.Pair) EventBus(org.greenrobot.eventbus.EventBus) SignalServiceCallMessage(org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage) Build(android.os.Build) LinkedList(java.util.LinkedList) GroupSendUtil(org.thoughtcrime.securesms.messages.GroupSendUtil) WebRtcServiceState(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState) ExecutorService(java.util.concurrent.ExecutorService) SignalServiceMessageSender(org.whispersystems.signalservice.api.SignalServiceMessageSender) PeerConnection(org.webrtc.PeerConnection) Executor(java.util.concurrent.Executor) WebRtcViewModel(org.thoughtcrime.securesms.events.WebRtcViewModel) IOException(java.io.IOException) NO_SUCH_USER(org.thoughtcrime.securesms.events.WebRtcViewModel.State.NO_SUCH_USER) GroupCallPeekEvent(org.thoughtcrime.securesms.events.GroupCallPeekEvent) Optional(org.whispersystems.libsignal.util.guava.Optional) UnregisteredUserException(org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException) GroupIdentifier(org.signal.zkgroup.groups.GroupIdentifier) UntrustedIdentityException(org.whispersystems.signalservice.api.crypto.UntrustedIdentityException) CALL_INCOMING(org.thoughtcrime.securesms.events.WebRtcViewModel.State.CALL_INCOMING) ResultReceiver(android.os.ResultReceiver) Collections(java.util.Collections) CallException(org.signal.ringrtc.CallException) Recipient(org.thoughtcrime.securesms.recipients.Recipient) IOException(java.io.IOException) GroupExternalCredential(org.signal.storageservice.protos.groups.GroupExternalCredential) GroupId(org.thoughtcrime.securesms.groups.GroupId) VerificationFailedException(org.signal.zkgroup.VerificationFailedException)

Example 8 with VerificationFailedException

use of org.signal.zkgroup.VerificationFailedException in project Signal-Android by signalapp.

the class GroupsV2Api method uploadAvatar.

public String uploadAvatar(byte[] avatar, GroupSecretParams groupSecretParams, GroupsV2AuthorizationString authorization) throws IOException {
    AvatarUploadAttributes form = socket.getGroupsV2AvatarUploadForm(authorization.toString());
    byte[] cipherText;
    try {
        cipherText = new ClientZkGroupCipher(groupSecretParams).encryptBlob(GroupAttributeBlob.newBuilder().setAvatar(ByteString.copyFrom(avatar)).build().toByteArray());
    } catch (VerificationFailedException e) {
        throw new AssertionError(e);
    }
    socket.uploadGroupV2Avatar(cipherText, form);
    return form.getKey();
}
Also used : AvatarUploadAttributes(org.signal.storageservice.protos.groups.AvatarUploadAttributes) ClientZkGroupCipher(org.signal.zkgroup.groups.ClientZkGroupCipher) VerificationFailedException(org.signal.zkgroup.VerificationFailedException)

Example 9 with VerificationFailedException

use of org.signal.zkgroup.VerificationFailedException in project Signal-Android by signalapp.

the class SubscriptionReceiptRequestResponseJob method generateRequestContext.

private static ReceiptCredentialRequestContext generateRequestContext() {
    Log.d(TAG, "Generating request credentials context for token redemption...", true);
    SecureRandom secureRandom = new SecureRandom();
    byte[] randomBytes = Util.getSecretBytes(ReceiptSerial.SIZE);
    try {
        ReceiptSerial receiptSerial = new ReceiptSerial(randomBytes);
        ClientZkReceiptOperations operations = ApplicationDependencies.getClientZkReceiptOperations();
        return operations.createReceiptCredentialRequestContext(secureRandom, receiptSerial);
    } catch (InvalidInputException | VerificationFailedException e) {
        Log.e(TAG, "Failed to create credential.", e);
        throw new AssertionError(e);
    }
}
Also used : InvalidInputException(org.signal.zkgroup.InvalidInputException) ReceiptSerial(org.signal.zkgroup.receipts.ReceiptSerial) ClientZkReceiptOperations(org.signal.zkgroup.receipts.ClientZkReceiptOperations) SecureRandom(java.security.SecureRandom) VerificationFailedException(org.signal.zkgroup.VerificationFailedException)

Example 10 with VerificationFailedException

use of org.signal.zkgroup.VerificationFailedException in project Signal-Android by signalapp.

the class LinkPreviewRepository method fetchGroupLinkPreview.

private static RequestController fetchGroupLinkPreview(@NonNull Context context, @NonNull String groupUrl, @NonNull Callback callback) {
    SignalExecutors.UNBOUNDED.execute(() -> {
        try {
            GroupInviteLinkUrl groupInviteLinkUrl = GroupInviteLinkUrl.fromUri(groupUrl);
            if (groupInviteLinkUrl == null) {
                throw new AssertionError();
            }
            GroupMasterKey groupMasterKey = groupInviteLinkUrl.getGroupMasterKey();
            GroupId.V2 groupId = GroupId.v2(groupMasterKey);
            Optional<GroupDatabase.GroupRecord> group = SignalDatabase.groups().getGroup(groupId);
            if (group.isPresent()) {
                Log.i(TAG, "Creating preview for locally available group");
                GroupDatabase.GroupRecord groupRecord = group.get();
                String title = groupRecord.getTitle();
                int memberCount = groupRecord.getMembers().size();
                String description = getMemberCountDescription(context, memberCount);
                Optional<Attachment> thumbnail = Optional.absent();
                if (AvatarHelper.hasAvatar(context, groupRecord.getRecipientId())) {
                    Recipient recipient = Recipient.resolved(groupRecord.getRecipientId());
                    Bitmap bitmap = AvatarUtil.loadIconBitmapSquareNoCache(context, recipient, 512, 512);
                    thumbnail = bitmapToAttachment(bitmap, Bitmap.CompressFormat.WEBP, MediaUtil.IMAGE_WEBP);
                }
                callback.onSuccess(new LinkPreview(groupUrl, title, description, 0, thumbnail));
            } else {
                Log.i(TAG, "Group is not locally available for preview generation, fetching from server");
                DecryptedGroupJoinInfo joinInfo = GroupManager.getGroupJoinInfoFromServer(context, groupMasterKey, groupInviteLinkUrl.getPassword());
                String description = getMemberCountDescription(context, joinInfo.getMemberCount());
                Optional<Attachment> thumbnail = Optional.absent();
                byte[] avatarBytes = AvatarGroupsV2DownloadJob.downloadGroupAvatarBytes(context, groupMasterKey, joinInfo.getAvatar());
                if (avatarBytes != null) {
                    Bitmap bitmap = BitmapFactory.decodeByteArray(avatarBytes, 0, avatarBytes.length);
                    thumbnail = bitmapToAttachment(bitmap, Bitmap.CompressFormat.WEBP, MediaUtil.IMAGE_WEBP);
                    if (bitmap != null)
                        bitmap.recycle();
                }
                callback.onSuccess(new LinkPreview(groupUrl, joinInfo.getTitle(), description, 0, thumbnail));
            }
        } catch (ExecutionException | InterruptedException | IOException | VerificationFailedException e) {
            Log.w(TAG, "Failed to fetch group link preview.", e);
            callback.onError(Error.PREVIEW_NOT_AVAILABLE);
        } catch (GroupInviteLinkUrl.InvalidGroupLinkException | GroupInviteLinkUrl.UnknownGroupLinkVersionException e) {
            Log.w(TAG, "Bad group link.", e);
            callback.onError(Error.PREVIEW_NOT_AVAILABLE);
        } catch (GroupLinkNotActiveException e) {
            Log.w(TAG, "Group link not active.", e);
            callback.onError(Error.GROUP_LINK_INACTIVE);
        }
    });
    return () -> Log.i(TAG, "Cancelled group link preview fetch -- no effect.");
}
Also used : Attachment(org.thoughtcrime.securesms.attachments.Attachment) UriAttachment(org.thoughtcrime.securesms.attachments.UriAttachment) Bitmap(android.graphics.Bitmap) GroupDatabase(org.thoughtcrime.securesms.database.GroupDatabase) ExecutionException(java.util.concurrent.ExecutionException) DecryptedGroupJoinInfo(org.signal.storageservice.protos.groups.local.DecryptedGroupJoinInfo) GroupInviteLinkUrl(org.thoughtcrime.securesms.groups.v2.GroupInviteLinkUrl) GroupMasterKey(org.signal.zkgroup.groups.GroupMasterKey) Recipient(org.thoughtcrime.securesms.recipients.Recipient) IOException(java.io.IOException) GroupId(org.thoughtcrime.securesms.groups.GroupId) VerificationFailedException(org.signal.zkgroup.VerificationFailedException) GroupLinkNotActiveException(org.whispersystems.signalservice.api.groupsv2.GroupLinkNotActiveException)

Aggregations

VerificationFailedException (org.signal.zkgroup.VerificationFailedException)18 IOException (java.io.IOException)10 Recipient (org.thoughtcrime.securesms.recipients.Recipient)8 NonNull (androidx.annotation.NonNull)6 GroupCall (org.signal.ringrtc.GroupCall)6 GroupExternalCredential (org.signal.storageservice.protos.groups.GroupExternalCredential)6 InvalidInputException (org.signal.zkgroup.InvalidInputException)6 GroupDatabase (org.thoughtcrime.securesms.database.GroupDatabase)5 GroupId (org.thoughtcrime.securesms.groups.GroupId)5 Application (android.app.Application)4 Context (android.content.Context)4 Intent (android.content.Intent)4 Build (android.os.Build)4 ResultReceiver (android.os.ResultReceiver)4 Nullable (androidx.annotation.Nullable)4 Stream (com.annimon.stream.Stream)4 Collection (java.util.Collection)4 Collections (java.util.Collections)4 LinkedList (java.util.LinkedList)4 List (java.util.List)4