From 838a9ce1069c8556d76127dc7b1a99553221044c Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 6 Dec 2024 16:34:07 +0200 Subject: [PATCH] hicli/profile: check device signature for own cross-signing keys --- pkg/hicli/profile.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/hicli/profile.go b/pkg/hicli/profile.go index 592d49e..5149794 100644 --- a/pkg/hicli/profile.go +++ b/pkg/hicli/profile.go @@ -140,12 +140,14 @@ func (h *HiClient) GetProfileView(ctx context.Context, roomID id.RoomID, userID addError(fmt.Errorf("failed to get devices: %w", err)) return } - if ownUserSigningKey != "" && theirMasterKey.Key != "" { + if userID == h.Account.UserID { + resp.UserTrusted, err = h.CryptoStore.IsKeySignedBy(ctx, userID, theirMasterKey.Key, userID, h.Crypto.OwnIdentity().SigningKey) + } else if ownUserSigningKey != "" && theirMasterKey.Key != "" { resp.UserTrusted, err = h.CryptoStore.IsKeySignedBy(ctx, userID, theirMasterKey.Key, h.Account.UserID, ownUserSigningKey) - if err != nil { - log.Err(err).Msg("Failed to check if user is trusted") - addError(fmt.Errorf("failed to check if user is trusted: %w", err)) - } + } + if err != nil { + log.Err(err).Msg("Failed to check if user is trusted") + addError(fmt.Errorf("failed to check if user is trusted: %w", err)) } resp.Devices = make([]*ProfileViewDevice, len(devices)) i := 0