Search in sources :

Example 16 with VerificationFailedException

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

the class GroupsV2Operations_decrypt_change_Test method groupCandidate.

GroupCandidate groupCandidate(UUID uuid, ProfileKey profileKey) {
    try {
        ClientZkProfileOperations profileOperations = clientZkOperations.getProfileOperations();
        ProfileKeyCommitment commitment = profileKey.getCommitment(uuid);
        ProfileKeyCredentialRequestContext requestContext = profileOperations.createProfileKeyCredentialRequestContext(uuid, profileKey);
        ProfileKeyCredentialRequest request = requestContext.getRequest();
        ProfileKeyCredentialResponse profileKeyCredentialResponse = server.getProfileKeyCredentialResponse(request, uuid, commitment);
        ProfileKeyCredential profileKeyCredential = profileOperations.receiveProfileKeyCredential(requestContext, profileKeyCredentialResponse);
        GroupCandidate groupCandidate = new GroupCandidate(uuid, Optional.of(profileKeyCredential));
        ProfileKeyCredentialPresentation presentation = profileOperations.createProfileKeyCredentialPresentation(groupSecretParams, profileKeyCredential);
        server.assertProfileKeyCredentialPresentation(groupSecretParams.getPublicParams(), presentation);
        return groupCandidate;
    } catch (VerificationFailedException e) {
        throw new AssertionError(e);
    }
}
Also used : ProfileKeyCredentialResponse(org.signal.zkgroup.profiles.ProfileKeyCredentialResponse) ProfileKeyCredential(org.signal.zkgroup.profiles.ProfileKeyCredential) ClientZkProfileOperations(org.signal.zkgroup.profiles.ClientZkProfileOperations) ProfileKeyCredentialRequest(org.signal.zkgroup.profiles.ProfileKeyCredentialRequest) ProfileKeyCredentialPresentation(org.signal.zkgroup.profiles.ProfileKeyCredentialPresentation) ProfileKeyCommitment(org.signal.zkgroup.profiles.ProfileKeyCommitment) ProfileKeyCredentialRequestContext(org.signal.zkgroup.profiles.ProfileKeyCredentialRequestContext) VerificationFailedException(org.signal.zkgroup.VerificationFailedException)

Example 17 with VerificationFailedException

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

the class SignalCallManager method requestMembershipProof.

@Override
public void requestMembershipProof(@NonNull final GroupCall groupCall) {
    Log.i(TAG, "requestMembershipProof():");
    Recipient recipient = serviceState.getCallInfoState().getCallRecipient();
    if (!recipient.isPushV2Group()) {
        Log.i(TAG, "Request membership proof for non-group");
        return;
    }
    GroupCall currentGroupCall = serviceState.getCallInfoState().getGroupCall();
    if (currentGroupCall == null || currentGroupCall.hashCode() != groupCall.hashCode()) {
        Log.i(TAG, "Skipping group membership proof request, requested group call does not match current group call");
        return;
    }
    networkExecutor.execute(() -> {
        try {
            GroupExternalCredential credential = GroupManager.getGroupExternalCredential(context, recipient.getGroupId().get().requireV2());
            process((s, p) -> p.handleGroupRequestMembershipProof(s, groupCall.hashCode(), credential.getTokenBytes().toByteArray()));
        } catch (IOException e) {
            Log.w(TAG, "Unable to get group membership proof from service", e);
            onEnded(groupCall, GroupCall.GroupCallEndReason.SFU_CLIENT_FAILED_TO_JOIN);
        } catch (VerificationFailedException e) {
            Log.w(TAG, "Unable to verify group membership proof", e);
            onEnded(groupCall, GroupCall.GroupCallEndReason.DEVICE_EXPLICITLY_DISCONNECTED);
        }
    });
}
Also used : GroupCall(org.signal.ringrtc.GroupCall) Recipient(org.thoughtcrime.securesms.recipients.Recipient) IOException(java.io.IOException) GroupExternalCredential(org.signal.storageservice.protos.groups.GroupExternalCredential) VerificationFailedException(org.signal.zkgroup.VerificationFailedException)

Example 18 with VerificationFailedException

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

the class GroupManagerV2 method createGroupOnServer.

@WorkerThread
@NonNull
private DecryptedGroup createGroupOnServer(@NonNull GroupSecretParams groupSecretParams, @Nullable String name, @Nullable byte[] avatar, @NonNull Collection<RecipientId> members, @NonNull Member.Role memberRole, int disappearingMessageTimerSeconds) throws GroupChangeFailedException, IOException, MembershipNotSuitableForV2Exception, GroupAlreadyExistsException {
    if (!GroupsV2CapabilityChecker.allAndSelfHaveUuidAndSupportGroupsV2(members)) {
        throw new MembershipNotSuitableForV2Exception("At least one potential new member does not support GV2 capability or we don't have their UUID");
    }
    GroupCandidate self = groupCandidateHelper.recipientIdToCandidate(Recipient.self().getId());
    Set<GroupCandidate> candidates = new HashSet<>(groupCandidateHelper.recipientIdsToCandidates(members));
    if (SignalStore.internalValues().gv2ForceInvites()) {
        Log.w(TAG, "Forcing GV2 invites due to internal setting");
        candidates = GroupCandidate.withoutProfileKeyCredentials(candidates);
    }
    if (!self.hasProfileKeyCredential()) {
        Log.w(TAG, "Cannot create a V2 group as self does not have a versioned profile");
        throw new MembershipNotSuitableForV2Exception("Cannot create a V2 group as self does not have a versioned profile");
    }
    GroupsV2Operations.NewGroup newGroup = groupsV2Operations.createNewGroup(groupSecretParams, name, Optional.fromNullable(avatar), self, candidates, memberRole, disappearingMessageTimerSeconds);
    try {
        groupsV2Api.putNewGroup(newGroup, authorization.getAuthorizationForToday(selfAci, groupSecretParams));
        DecryptedGroup decryptedGroup = groupsV2Api.getGroup(groupSecretParams, ApplicationDependencies.getGroupsV2Authorization().getAuthorizationForToday(selfAci, groupSecretParams));
        if (decryptedGroup == null) {
            throw new GroupChangeFailedException();
        }
        return decryptedGroup;
    } catch (VerificationFailedException | InvalidGroupStateException e) {
        throw new GroupChangeFailedException(e);
    } catch (GroupExistsException e) {
        throw new GroupAlreadyExistsException(e);
    }
}
Also used : GroupExistsException(org.whispersystems.signalservice.internal.push.exceptions.GroupExistsException) GroupCandidate(org.whispersystems.signalservice.api.groupsv2.GroupCandidate) VerificationFailedException(org.signal.zkgroup.VerificationFailedException) InvalidGroupStateException(org.whispersystems.signalservice.api.groupsv2.InvalidGroupStateException) GroupsV2Operations(org.whispersystems.signalservice.api.groupsv2.GroupsV2Operations) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) HashSet(java.util.HashSet) WorkerThread(androidx.annotation.WorkerThread) NonNull(androidx.annotation.NonNull)

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