Merge branch 'PEMA-43' into 1.1.260

1.1.260
Dirk Zimmermann 4 months ago
commit 3c77778a6a

@ -7,8 +7,10 @@
objects = {
/* Begin PBXBuildFile section */
436AE4D728C9CA2300456A54 /* PEPObjCAdapterConfigurationProtocol+Echo.h in Headers */ = {isa = PBXBuildFile; fileRef = 436AE4D628C9CA1D00456A54 /* PEPObjCAdapterConfigurationProtocol+Echo.h */; settings = {ATTRIBUTES = (Public, ); }; };
436AE4D828C9CA2400456A54 /* PEPObjCAdapterConfigurationProtocol+Echo.h in Headers */ = {isa = PBXBuildFile; fileRef = 436AE4D628C9CA1D00456A54 /* PEPObjCAdapterConfigurationProtocol+Echo.h */; settings = {ATTRIBUTES = (Public, ); }; };
436AE4D728C9CA2300456A54 /* PEPObjCAdapterEchoConfigurationProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 436AE4D628C9CA1D00456A54 /* PEPObjCAdapterEchoConfigurationProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
436AE4D828C9CA2400456A54 /* PEPObjCAdapterEchoConfigurationProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 436AE4D628C9CA1D00456A54 /* PEPObjCAdapterEchoConfigurationProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
43D1E4C628D3123C0081FA7F /* PEPObjCAdapterMediaKeysConfigurationProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 43D1E4C528D312360081FA7F /* PEPObjCAdapterMediaKeysConfigurationProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
43D1E4C728D3123D0081FA7F /* PEPObjCAdapterMediaKeysConfigurationProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 43D1E4C528D312360081FA7F /* PEPObjCAdapterMediaKeysConfigurationProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
4E23E6E92681C7CD00B8F4C2 /* PEPObjCAdapterProtocols_macOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E23E6E82681C7CD00B8F4C2 /* PEPObjCAdapterProtocols_macOS.h */; };
4E23E6F12681C7D600B8F4C2 /* PEPSessionProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 4EEB4CC22680DCAC00161040 /* PEPSessionProtocol.h */; };
4E23E6F22681C7D600B8F4C2 /* PEPObjCAdapterConfigurationProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 4EEB4CC12680DCAC00161040 /* PEPObjCAdapterConfigurationProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -19,7 +21,8 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
436AE4D628C9CA1D00456A54 /* PEPObjCAdapterConfigurationProtocol+Echo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PEPObjCAdapterConfigurationProtocol+Echo.h"; sourceTree = "<group>"; };
436AE4D628C9CA1D00456A54 /* PEPObjCAdapterEchoConfigurationProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPObjCAdapterEchoConfigurationProtocol.h; sourceTree = "<group>"; };
43D1E4C528D312360081FA7F /* PEPObjCAdapterMediaKeysConfigurationProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPObjCAdapterMediaKeysConfigurationProtocol.h; sourceTree = "<group>"; };
4E23E6CE2681B70400B8F4C2 /* libPEPObjCAdapterTypes_macOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libPEPObjCAdapterTypes_macOS.a; sourceTree = BUILT_PRODUCTS_DIR; };
4E23E6E62681C7CD00B8F4C2 /* libPEPObjCAdapterProtocols_macOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPEPObjCAdapterProtocols_macOS.a; sourceTree = BUILT_PRODUCTS_DIR; };
4E23E6E82681C7CD00B8F4C2 /* PEPObjCAdapterProtocols_macOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPObjCAdapterProtocols_macOS.h; sourceTree = "<group>"; };
@ -104,8 +107,9 @@
4EEB4CC02680DCAC00161040 /* PublicHeaders */ = {
isa = PBXGroup;
children = (
436AE4D628C9CA1D00456A54 /* PEPObjCAdapterEchoConfigurationProtocol.h */,
43D1E4C528D312360081FA7F /* PEPObjCAdapterMediaKeysConfigurationProtocol.h */,
4EEB4CC12680DCAC00161040 /* PEPObjCAdapterConfigurationProtocol.h */,
436AE4D628C9CA1D00456A54 /* PEPObjCAdapterConfigurationProtocol+Echo.h */,
4EEB4CC22680DCAC00161040 /* PEPSessionProtocol.h */,
);
path = PublicHeaders;
@ -118,9 +122,10 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
436AE4D728C9CA2300456A54 /* PEPObjCAdapterConfigurationProtocol+Echo.h in Headers */,
436AE4D728C9CA2300456A54 /* PEPObjCAdapterEchoConfigurationProtocol.h in Headers */,
4E23E6E92681C7CD00B8F4C2 /* PEPObjCAdapterProtocols_macOS.h in Headers */,
4E23E6F12681C7D600B8F4C2 /* PEPSessionProtocol.h in Headers */,
43D1E4C628D3123C0081FA7F /* PEPObjCAdapterMediaKeysConfigurationProtocol.h in Headers */,
4E23E6F22681C7D600B8F4C2 /* PEPObjCAdapterConfigurationProtocol.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -130,7 +135,8 @@
buildActionMask = 2147483647;
files = (
4E23E7112681D65F00B8F4C2 /* PEPObjCAdapterConfigurationProtocol.h in Headers */,
436AE4D828C9CA2400456A54 /* PEPObjCAdapterConfigurationProtocol+Echo.h in Headers */,
436AE4D828C9CA2400456A54 /* PEPObjCAdapterEchoConfigurationProtocol.h in Headers */,
43D1E4C728D3123D0081FA7F /* PEPObjCAdapterMediaKeysConfigurationProtocol.h in Headers */,
4E23E7122681D65F00B8F4C2 /* PEPSessionProtocol.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;

@ -8,11 +8,12 @@
#import <Foundation/Foundation.h>
#import "PEPObjCAdapterConfigurationProtocol+Echo.h"
#import "PEPObjCAdapterEchoConfigurationProtocol.h"
#import "PEPObjCAdapterMediaKeysConfigurationProtocol.h"
NS_ASSUME_NONNULL_BEGIN
@protocol PEPObjCAdapterConfigurationProtocol <PEPObjCAdapterEchoConfigurationProtocol>
@protocol PEPObjCAdapterConfigurationProtocol <PEPObjCAdapterEchoConfigurationProtocol, PEPObjCAdapterMediaKeysConfigurationProtocol>
/// Sets Engine config for unecryptedSubjectEnabled to the given value on all Sessions created by
/// this adapter.

@ -1,5 +1,5 @@
//
// PEPObjCAdapterConfigurationProtocol+Echo.h
// PEPObjCAdapterEchoConfigurationProtocol.h
// PEPObjCAdapterProtocols
//
// Created by Dirk Zimmermann on 08.09.22.
@ -8,6 +8,10 @@
#ifndef PEPObjCAdapterConfigurationProtocol_Echo_h
#define PEPObjCAdapterConfigurationProtocol_Echo_h
NS_ASSUME_NONNULL_BEGIN
/// Echo protocol configuration across all sessions, including existing ones.
///
/// @see https://dev.pep.foundation/Engine/Echo%20Protocol
@protocol PEPObjCAdapterEchoConfigurationProtocol <NSObject>
@ -23,4 +27,6 @@
@end
NS_ASSUME_NONNULL_END
#endif /* PEPObjCAdapterConfigurationProtocol_Echo_h */

@ -0,0 +1,26 @@
//
// PEPObjCAdapterMediaKeysConfigurationProtocol.h
// PEPObjCAdapterProtocols
//
// Created by Dirk Zimmermann on 15.09.22.
//
#ifndef PEPObjCAdapterConfigurationProtocol_MediaKeys_h
#define PEPObjCAdapterConfigurationProtocol_MediaKeys_h
#import "PEPMediaKeyPair.h"
NS_ASSUME_NONNULL_BEGIN
/// Media keys configuration across all sessions, including existing ones.
///
/// @see https://dev.pep.foundation/Engine/Media%20keys
@protocol PEPObjCAdapterMediaKeysConfigurationProtocol <NSObject>
+ (void)configureMediaKeys:(NSArray<PEPMediaKeyPair *> *)mediaKeys;
@end
NS_ASSUME_NONNULL_END
#endif /* PEPObjCAdapterConfigurationProtocol_MediaKeys_h */

@ -229,9 +229,6 @@ extern NSString *const _Nonnull PEPObjCAdapterErrorDomain;
/// Wraps `disable_all_sync_channels` (sync_api.h).
- (BOOL)disableAllSyncChannels:(NSError * _Nullable * _Nullable)error;
- (BOOL)configureMediaKeys:(NSArray<PEPMediaKeyPair *> *)mediaKeys
error:(NSError * _Nullable * _Nullable)error;
@end
NS_ASSUME_NONNULL_END

@ -389,6 +389,7 @@
4396CEC9218721F900FDD398 /* PEPInternalSessionTestSendMessageDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PEPInternalSessionTestSendMessageDelegate.h; sourceTree = "<group>"; };
43AD0E2E22E99ECE00D46F56 /* PEPInternalConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPInternalConstants.h; sourceTree = "<group>"; };
43AD0E2F22E99ECE00D46F56 /* PEPInternalConstants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPInternalConstants.m; sourceTree = "<group>"; };
43D1E4C828D317290081FA7F /* PEPObjCAdapter+ReadMediaKeyConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PEPObjCAdapter+ReadMediaKeyConfig.h"; sourceTree = "<group>"; };
43D2D5EE2632B0FA00088BDC /* XCTestCase+PEPSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "XCTestCase+PEPSession.h"; sourceTree = "<group>"; };
43D2D5F02632B0FA00088BDC /* XCTestCase+PEPSession.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "XCTestCase+PEPSession.m"; sourceTree = "<group>"; };
43DED784203C25E200D45CD6 /* NSError+PEP.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSError+PEP.h"; sourceTree = "<group>"; };
@ -589,6 +590,7 @@
43209B291ECC2ACD007E7E2E /* PEPCSVScanner.m */,
43209B2E1ECC2ACD007E7E2E /* PEPObjCAdapter+ReadConfig.h */,
4379C1B928C9D24A00977A32 /* PEPObjCAdapter+ReadEchoConfig.h */,
43D1E4C828D317290081FA7F /* PEPObjCAdapter+ReadMediaKeyConfig.h */,
43209B301ECC2ACD007E7E2E /* PEPObjCAdapter.m */,
43209B311ECC2ACD007E7E2E /* PEPQueue.h */,
43209B321ECC2ACD007E7E2E /* PEPQueue.m */,

@ -337,7 +337,9 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Media Key / Echo Protocol
- (BOOL)configureMediaKeys:(NSArray<PEPMediaKeyPair *> *)mediaKeys
/// Wraps `config_media_keys`.
/// @Note The media keys can be nil, which should make the session not use any media keys.
- (BOOL)configureMediaKeys:(NSArray<PEPMediaKeyPair *> * _Nullable)mediaKeys
error:(NSError * _Nullable * _Nullable)error;
- (void)configureEchoProtocolEnabled:(BOOL)enabled;

@ -1031,23 +1031,33 @@ static NSDictionary *stringToRating;
#pragma mark - Media Key / Echo Protocol
- (BOOL)configureMediaKeys:(NSArray<PEPMediaKeyPair *> * _Nonnull)mediaKeys
error:(NSError * _Nullable * _Nullable)error
stringpair_list_t *stringListFromMediaKeys(NSArray<PEPMediaKeyPair *> *mediaKeys)
{
if (error) {
*error = nil;
}
stringpair_list_t *engineList = NULL;
stringpair_list_t *engineListStart = NULL;
stringpair_list_t *engineList = new_stringpair_list(NULL);
for (PEPMediaKeyPair *pair in mediaKeys) {
stringpair_t *engineStringPair = new_stringpair([pair.pattern UTF8String],
[pair.fingerprint UTF8String]);
stringpair_list_add(engineList, engineStringPair);
[pair.fingerprint UTF8String]);
engineList = stringpair_list_add(engineList, engineStringPair);
if (engineListStart == NULL) {
engineListStart = engineList;
}
}
PEP_STATUS status = config_media_keys(self.session, engineList);
return engineListStart;
}
- (BOOL)configureMediaKeys:(NSArray<PEPMediaKeyPair *> *)mediaKeys
error:(NSError * _Nullable * _Nullable)error
{
if (error) {
*error = nil;
}
free_stringpair_list(engineList);
PEP_STATUS status = config_media_keys(self.session, stringListFromMediaKeys(mediaKeys));
if ([NSError setError:error fromPEPStatus:(PEPStatus) status]) {
return NO;

@ -0,0 +1,26 @@
//
// PEPObjCAdapter+ReadMediaKeyConfig.h
// pEpObjCAdapter
//
// Created by Dirk Zimmermann on 15.09.22.
// Copyright © 2022 p≡p. All rights reserved.
//
#ifndef PEPObjCAdapter_ReadMediaKeyConfig_h
#define PEPObjCAdapter_ReadMediaKeyConfig_h
#import "PEPObjCAdapter.h"
NS_ASSUME_NONNULL_BEGIN
@class PEPMediaKeyPair;
@interface PEPObjCAdapter (ReadMediaKeyConfig)
+ (NSArray<PEPMediaKeyPair *> * _Nullable)mediaKeys;
@end
NS_ASSUME_NONNULL_END
#endif /* PEPObjCAdapter_ReadMediaKeyConfig_h */

@ -43,6 +43,8 @@ static id<PEPPassphraseProviderProtocol> s_passphraseProvider = nil;
static BOOL s_echoProtocolEnabled = YES;
static BOOL s_echoInOutgoingMessageRatingPreviewEnabled = YES;
static NSArray<PEPMediaKeyPair *> *s_mediaKeys = nil;
@implementation PEPObjCAdapter
#pragma mark - SUBJECT PROTECTION
@ -132,6 +134,19 @@ static BOOL s_echoInOutgoingMessageRatingPreviewEnabled = YES;
return s_echoInOutgoingMessageRatingPreviewEnabled;
}
#pragma mark - Media Keys
+ (void)configureMediaKeys:(nonnull NSArray<PEPMediaKeyPair *> *)mediaKeys
{
NSArray *ourCopy = [NSArray arrayWithArray:mediaKeys];
s_mediaKeys = ourCopy;
}
+ (NSArray<PEPMediaKeyPair *> *)mediaKeys
{
return s_mediaKeys;
}
#pragma mark - DB PATHS
+ (void)initialize

@ -659,17 +659,4 @@ successCallback:(void (^)(NSString *log))successCallback
return [session disableAllSyncChannels:error];
}
- (BOOL)configureMediaKeys:(NSArray<PEPMediaKeyPair *> *)mediaKeys
error:(NSError * _Nullable * _Nullable)error
{
PEPInternalSession *session = [PEPSessionProvider session];
if (session == nil) {
if (error) {
*error = [NSError errorWithPEPStatusInternal:PEP_UNKNOWN_ERROR];
}
return NO;
}
return [session configureMediaKeys:mediaKeys error:error];
}
@end

@ -10,6 +10,7 @@
#import "PEPObjCAdapter+ReadConfig.h"
#import "PEPObjCAdapter+ReadEchoConfig.h"
#import "PEPObjCAdapter+ReadMediaKeyConfig.h"
#import "PEPInternalSession.h"
#import "PEPCopyableThread.h"
#import "Logger.h"
@ -93,6 +94,7 @@ static PEPInternalSession *s_sessionForMainThread = nil;
[self setPassiveModeOnSession:session];
[self setPassphraseForNewKeysOnSession:session];
[self configureEchoProtocolOnSession:session];
[self configureMediaKeysOnSession:session];
}
+ (void)setConfigUnEncryptedSubjectOnSession:(PEPInternalSession *)session
@ -132,6 +134,24 @@ static PEPInternalSession *s_sessionForMainThread = nil;
[session configureEchoInOutgoingMessageRatingPreviewEnabled:echoInOutgoing];
}
+ (void)configureMediaKeysOnSession:(PEPInternalSession *)session
{
NSArray<PEPMediaKeyPair *> *mediaKeys = [PEPObjCAdapter mediaKeys];
NSError *error = nil;
BOOL success = [session configureMediaKeys:mediaKeys error:&error];
if (!success) {
if (error) {
LogError(@"Could not configure the media keys: %@\n media keys: %@",
error,
mediaKeys);
} else {
LogError(@"Could not configure the media keys %@", mediaKeys);
}
}
}
#pragma mark -
/**

@ -394,11 +394,19 @@
fingerprint:@"97B69752A72FC5036971F5C83AC51FA45F01DA6C"]
];
PEPSession *asyncSession = [PEPSession new];
[PEPObjCAdapter configureMediaKeys:mediaKeys];
NSError *error = nil;
[asyncSession configureMediaKeys:mediaKeys error:&error];
XCTAssertNil(error);
NSString *fprAlice = @"4ABE3AAF59AC32CFE4F86500A9411D176FF00E97";
// Note: This should lead to an updateIdentity, which in turn leads to checking
// the media keys.
[self
checkImportingKeyFilePath:@"6FF00E97_sec.asc"
address:@"pep.test.alice@pep-project.org"
userID:@"alice_user_id"
fingerPrint:fprAlice];
[PEPObjCAdapter configureMediaKeys:mediaKeys];
}
#pragma mark - Helpers

Loading…
Cancel
Save