Skip to content

Commit

Permalink
Revert "Merge pull request #7430 from vector-im/andy/user_trust"
Browse files Browse the repository at this point in the history
This reverts commit 7f5d3b4, reversing
changes made to 5a3adde.
  • Loading branch information
Anderas committed Mar 22, 2023
1 parent 3569c61 commit b33f29e
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 264 deletions.
30 changes: 25 additions & 5 deletions Riot/Categories/MXRoom+Riot.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#import "AvatarGenerator.h"
#import "MatrixKit.h"
#import "GeneratedInterface-Swift.h"

#import <objc/runtime.h>

@implementation MXRoom (Riot)
Expand Down Expand Up @@ -331,10 +331,30 @@ - (void)encryptionTrustLevelForUserId:(NSString*)userId onComplete:(void (^)(Use
{
[self.mxSession.crypto trustLevelSummaryForUserIds:@[userId] forceDownload:NO success:^(MXUsersTrustLevelSummary *usersTrustLevelSummary) {

MXCrossSigningInfo *crossSigningInfo = [self.mxSession.crypto.crossSigning crossSigningKeysForUser:userId];
EncryptionTrustLevel *encryption = [[EncryptionTrustLevel alloc] init];
UserEncryptionTrustLevel userEncryptionTrustLevel = [encryption userTrustLevelWithCrossSigning:crossSigningInfo
devicesTrust:usersTrustLevelSummary.devicesTrust];
UserEncryptionTrustLevel userEncryptionTrustLevel;
double trustedDevicesPercentage = usersTrustLevelSummary.trustedDevicesProgress.fractionCompleted;

if (trustedDevicesPercentage >= 1.0)
{
userEncryptionTrustLevel = UserEncryptionTrustLevelTrusted;
}
else if (trustedDevicesPercentage == 0.0)
{
// Verify if the user has the user has cross-signing enabled
if ([self.mxSession.crypto.crossSigning crossSigningKeysForUser:userId])
{
userEncryptionTrustLevel = UserEncryptionTrustLevelNotVerified;
}
else
{
userEncryptionTrustLevel = UserEncryptionTrustLevelNoCrossSigning;
}
}
else
{
userEncryptionTrustLevel = UserEncryptionTrustLevelWarning;
}

onComplete(userEncryptionTrustLevel);

} failure:^(NSError *error) {
Expand Down
12 changes: 11 additions & 1 deletion Riot/Categories/MXRoomSummary+Riot.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@
*/

#import "MatrixKit.h"
#import "RoomEncryptionTrustLevel.h"

/**
RoomEncryptionTrustLevel represents the trust level in an encrypted room.
*/
typedef NS_ENUM(NSUInteger, RoomEncryptionTrustLevel) {
RoomEncryptionTrustLevelTrusted,
RoomEncryptionTrustLevelWarning,
RoomEncryptionTrustLevelNormal,
RoomEncryptionTrustLevelUnknown
};


/**
Define a `MXRoomSummary` category at Riot level.
Expand Down
29 changes: 23 additions & 6 deletions Riot/Categories/MXRoomSummary+Riot.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,32 @@ - (void)setRoomAvatarImageIn:(MXKImageView*)mxkImageView

- (RoomEncryptionTrustLevel)roomEncryptionTrustLevel
{
MXUsersTrustLevelSummary *trust = self.trust;
if (!trust)
RoomEncryptionTrustLevel roomEncryptionTrustLevel = RoomEncryptionTrustLevelUnknown;
if (self.trust)
{
MXLogError(@"[MXRoomSummary] roomEncryptionTrustLevel: trust is missing");
return RoomEncryptionTrustLevelUnknown;
double trustedUsersPercentage = self.trust.trustedUsersProgress.fractionCompleted;
double trustedDevicesPercentage = self.trust.trustedDevicesProgress.fractionCompleted;

if (trustedUsersPercentage >= 1.0)
{
if (trustedDevicesPercentage >= 1.0)
{
roomEncryptionTrustLevel = RoomEncryptionTrustLevelTrusted;
}
else
{
roomEncryptionTrustLevel = RoomEncryptionTrustLevelWarning;
}
}
else
{
roomEncryptionTrustLevel = RoomEncryptionTrustLevelNormal;
}

roomEncryptionTrustLevel = roomEncryptionTrustLevel;
}

EncryptionTrustLevel *encryption = [[EncryptionTrustLevel alloc] init];
return [encryption roomTrustLevelWithSummary:trust];
return roomEncryptionTrustLevel;
}

- (BOOL)isJoined
Expand Down
49 changes: 0 additions & 49 deletions Riot/Modules/Encryption/EncryptionTrustLevel.swift

This file was deleted.

25 changes: 0 additions & 25 deletions Riot/Modules/Encryption/RoomEncryptionTrustLevel.h

This file was deleted.

4 changes: 2 additions & 2 deletions Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ - (EventEncryptionDecoration)encryptionDecorationForEvent:(MXEvent*)event roomSt
// Only show a warning badge if there are trust issues.
if (event.sender)
{
BOOL isUserVerified = [session.crypto isUserVerified:event.sender];
MXUserTrustLevel *userTrustLevel = [session.crypto trustLevelForUser:event.sender];
MXDeviceInfo *deviceInfo = [session.crypto eventDeviceInfo:event];

if (isUserVerified && !deviceInfo.trustLevel.isVerified)
if (userTrustLevel.isVerified && !deviceInfo.trustLevel.isVerified)
{
return EventEncryptionDecorationUntrustedDevice;
}
Expand Down
1 change: 0 additions & 1 deletion Riot/SupportingFiles/Riot-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#import "RoomBubbleCellData.h"
#import "MXKRoomBubbleTableViewCell+Riot.h"
#import "UserEncryptionTrustLevel.h"
#import "RoomEncryptionTrustLevel.h"
#import "RoomReactionsViewSizer.h"
#import "RoomEncryptedDataBubbleCell.h"
#import "LegacyAppDelegate.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#import "AvatarGenerator.h"
#import "BuildInfo.h"
#import "ShareItemSender.h"
#import "UserEncryptionTrustLevel.h"
#import "RoomEncryptionTrustLevel.h"

// MatrixKit imports
#import "MatrixKit-Bridging-Header.h"
1 change: 0 additions & 1 deletion RiotShareExtension/target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,3 @@ targets:
- "**/*.md" # excludes all files with the .md extension
- path: ../Riot/Modules/Room/TimelineCells/Styles/RoomTimelineStyleIdentifier.swift
- path: ../Riot/Modules/VoiceBroadcast/VoiceBroadcastSDK/MatrixSDK
- path: ../Riot/Modules/Encryption/EncryptionTrustLevel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ class QRLoginService: NSObject, QRLoginServiceProtocol {

MXLog.debug("[QRLoginService] Marking the received master key as trusted")
let mskVerificationResult = await withCheckedContinuation { (continuation: CheckedContinuation<Bool, Never>) in
session.crypto.setUserVerificationForUserId(session.myUserId) {
session.crypto.setUserVerification(true, forUser: session.myUserId) {
MXLog.debug("[QRLoginService] Successfully marked the received master key as trusted")
continuation.resume(returning: true)
} failure: { error in
Expand Down
171 changes: 0 additions & 171 deletions RiotTests/Modules/Encryption/EncryptionTrustLevelTests.swift

This file was deleted.

0 comments on commit b33f29e

Please sign in to comment.