Browse Source

IOSAD-181 Make async the default

IOSAD-181
Dirk Zimmermann 2 years ago
parent
commit
284878149a
9 changed files with 821 additions and 1584 deletions
  1. +0
    -244
      PEPObjCAdapterFramework/PEPAsyncSession.h
  2. +8
    -16
      pEpObjCAdapter.xcodeproj/project.pbxproj
  3. +0
    -661
      pEpObjCAdapter/PEPAsyncSession.m
  4. +598
    -358
      pEpObjCAdapter/PEPSession.m
  5. +0
    -1
      pEpObjCAdapterFramework/PEPObjCAdapterFramework.h
  6. +11
    -19
      pEpObjCAdapterFramework/PEPSession.h
  7. +171
    -256
      pEpObjCAdapterFramework/PEPSessionProtocol.h
  8. +29
    -27
      pEpObjCTests/PEPAsyncSessionTest.m
  9. +4
    -2
      pEpObjCTests/PepTests.m

+ 0
- 244
PEPObjCAdapterFramework/PEPAsyncSession.h View File

@ -1,244 +0,0 @@
//
// PEPAsyncSession.h
// PEPObjCAdapterFramework
//
// Created by Dirk Zimmermann on 17.07.20.
// Copyright © 2020 pp. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "PEPEngineTypes.h"
#import "PEPTypes.h"
@class PEPMessage;
@class PEPIdentity;
@class PEPLanguage;
NS_ASSUME_NONNULL_BEGIN
@interface PEPAsyncSession : NSObject
/// You must call this method once before your process gets terminated to be able to gracefully shutdown.
/// You must not make any calls to PEPSession in between the last call to `cleanup()` and getting terminated.
///
/// Only for performance reasons: call this method only if you have to.
+ (void)cleanup;
- (void)decryptMessage:(PEPMessage *)message
flags:(PEPDecryptFlags)flags
extraKeys:(PEPStringList * _Nullable)extraKeys
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPMessage *srcMessage,
PEPMessage *dstMessage,
PEPStringList *keyList,
PEPRating rating,
PEPDecryptFlags flags))successCallback;
- (void)reEvaluateMessage:(PEPMessage *)message
xKeyList:(PEPStringList *_Nullable)xKeyList
originalRating:(PEPRating)originalRating
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPRating rating))successCallback;
/// Encrypt a message with explicit encryption format.
- (void)encryptMessage:(PEPMessage *)message
extraKeys:(PEPStringList * _Nullable)extraKeys
encFormat:(PEPEncFormat)encFormat
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPMessage *srcMessage,
PEPMessage *destMessage))successCallback;
/// Encrypt a message with the default encryption format.
- (void)encryptMessage:(PEPMessage *)message
extraKeys:(PEPStringList * _Nullable)extraKeys
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPMessage *srcMessage,
PEPMessage *destMessage))successCallback;
/// Encrypt a message to an own identity.
- (void)encryptMessage:(PEPMessage *)message
forSelf:(PEPIdentity *)ownIdentity
extraKeys:(PEPStringList * _Nullable)extraKeys
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPMessage *srcMessage,
PEPMessage *destMessage))successCallback;
/// Encrypt a message to a fingerprint.
- (void)encryptMessage:(PEPMessage *)message
toFpr:(NSString *)toFpr
encFormat:(PEPEncFormat)encFormat
flags:(PEPDecryptFlags)flags
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPMessage *srcMessage,
PEPMessage *destMessage))successCallback;
- (void)outgoingRatingForMessage:(PEPMessage *)theMessage
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPRating rating))successCallback;
- (void)ratingForIdentity:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPRating rating))successCallback;
- (void)trustwordsForFingerprint:(NSString *)fingerprint
languageID:(NSString *)languageID
shortened:(BOOL)shortened
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(NSArray<NSString *> *trustwords))successCallback;
- (void)mySelf:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPIdentity *identity))successCallback;
- (void)updateIdentity:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPIdentity *identity))successCallback;
- (void)trustPersonalKey:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
- (void)keyMistrusted:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
- (void)keyResetTrust:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
- (void)enableSyncForIdentity:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
- (void)disableSyncForIdentity:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
- (void)queryKeySyncEnabledForIdentity:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(BOOL enabled))successCallback;
- (void)importKey:(NSString *)keydata
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(NSArray<PEPIdentity *> *identities))successCallback;
- (void)logTitle:(NSString *)title
entity:(NSString *)entity
description:(NSString * _Nullable)description
comment:(NSString * _Nullable)comment
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
- (void)getLog:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(NSString *log))successCallback;
- (void)getTrustwordsIdentity1:(PEPIdentity *)identity1
identity2:(PEPIdentity *)identity2
language:(NSString * _Nullable)language
full:(BOOL)full
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(NSString *trustwords))successCallback;
- (void)getTrustwordsFpr1:(NSString *)fpr1
fpr2:(NSString *)fpr2
language:(NSString * _Nullable)language
full:(BOOL)full
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(NSString *trustwords))successCallback;
- (void)languageList:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(NSArray<PEPLanguage *> *languages))successCallback;
- (void)isPEPUser:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(BOOL enabled))successCallback;
- (void)setOwnKey:(PEPIdentity *)identity
fingerprint:(NSString *)fingerprint
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
- (void)deliverHandshakeResult:(PEPSyncHandshakeResult)result
identitiesSharing:(NSArray<PEPIdentity *> * _Nullable)identitiesSharing
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
- (void)trustOwnKeyIdentity:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
- (void)keyReset:(PEPIdentity *)identity
fingerprint:(NSString * _Nullable)fingerprint
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
- (void)leaveDeviceGroup:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
- (void)keyResetAllOwnKeys:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
// MARK: - Configuration
/// Wraps the engine's `config_passive_mode`.
/// @note That there's absolutely no error handling.
- (void)configurePassiveModeEnabled:(BOOL)enabled;
/// Add a passphrase for secret keys to the cache.
///
/// You can add as many passphrases to the cache as needed by calling this method.
/// Every passphrase is valid for 10 min (default, compile-time configurable),
/// after that it gets removed from memory. The maximum count of passphrases is 20.
/// Setting the 21st replaces the 1st.
/// On error, `NO` is returned and the (optional) parameter `error`
/// is set to the error that occurred.
/// On every engine call that returns PEPStatusPassphraseRequired, or PEPStatusWrongPassphrase,
/// the adapter will automatically repeat the call after setting the next cached passphrase
/// (using the engine's `config_passphrase`). The first attempet as always with an empty password.
/// This will be repeated until the call either succeeds, or until
/// the adapter runs out of usable passwords.
/// When the adapter runs out of passwords to try, PEPStatusWrongPassphrase will be thrown.
/// If the engine indicates PEPStatusPassphraseRequired, and there are no passwords,
/// the adapter will throw PEPStatusPassphraseRequired.
/// The passphrase can have a "maximum number of code points of 250", which is
/// approximated by checking the string length.
/// If the passphrase exceeds this limit, the adapter throws PEPAdapterErrorPassphraseTooLong
/// with a domain of PEPObjCAdapterErrorDomain.
/// @Throws PEPAdapterErrorPassphraseTooLong (with a domain of PEPObjCAdapterErrorDomain)
/// or PEPStatusOutOfMemory (with PEPObjCAdapterEngineStatusErrorDomain)
- (BOOL)configurePassphrase:(NSString * _Nonnull)passphrase
error:(NSError * _Nullable * _Nullable)error;
/// Sets a passphrase (with a maximum of 250 code points) for
/// (own) secret keys generated from now on.
///
/// For setting a passphrase, `enable` must be set to `YES`,
/// in which case the `passphrase` should contain an actual passphrase.
/// A `nil` `passphrase` with `enable` set to `YES` is undefined.
/// The passphrase can be unset by setting `enable` to `NO`
/// (with or without passphrase, this gets (assumedly)
/// ignored in this case, but has to be verified).
/// Uses the engine's `config_passphrase_for_new_keys`.
/// @Throws PEPAdapterErrorPassphraseTooLong (with a domain of PEPObjCAdapterErrorDomain)
/// or PEPStatusOutOfMemory (with PEPObjCAdapterEngineStatusErrorDomain)
/// @deprecated
- (BOOL)configurePassphraseForNewKeys:(NSString * _Nullable)passphrase
enable:(BOOL)enable error:(NSError * _Nullable * _Nullable)error
__deprecated;
// MARK: - Methods that can be executed syncronously
/// Converts a string like "cannot_decrypt" into its equivalent PEPRating_cannot_decrypt.
- (PEPRating)ratingFromString:(NSString * _Nonnull)string;
/// Converts a pEp rating like PEPRating_cannot_decrypt
/// into its equivalent string "cannot_decrypt".
- (NSString * _Nonnull)stringFromRating:(PEPRating)rating;
/// Wraps color_from_rating.
- (PEPColor)colorFromRating:(PEPRating)rating;
@end
NS_ASSUME_NONNULL_END

+ 8
- 16
pEpObjCAdapter.xcodeproj/project.pbxproj View File

@ -30,8 +30,8 @@
433DFBB824A61D4B00AB373B /* PEPInternalSession+PassphraseCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 433DFBB624A61D4B00AB373B /* PEPInternalSession+PassphraseCache.m */; };
433DFBBC24A73AD400AB373B /* PEPSessionProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = 433DFBBB24A73AD400AB373B /* PEPSessionProtocol.m */; };
434226811D4F60000083ED79 /* PepTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 434226801D4F60000083ED79 /* PepTests.m */; };
434707F624C210CA00E05485 /* PEPAsyncSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 434707F424C210CA00E05485 /* PEPAsyncSession.h */; settings = {ATTRIBUTES = (Public, ); }; };
434707F724C210CA00E05485 /* PEPAsyncSession.m in Sources */ = {isa = PBXBuildFile; fileRef = 434707F524C210CA00E05485 /* PEPAsyncSession.m */; };
434707F624C210CA00E05485 /* PEPSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 434707F424C210CA00E05485 /* PEPSession.h */; settings = {ATTRIBUTES = (Public, ); }; };
434707F724C210CA00E05485 /* PEPSession.m in Sources */ = {isa = PBXBuildFile; fileRef = 434707F524C210CA00E05485 /* PEPSession.m */; };
434707F924C30E9700E05485 /* PEPAsyncSessionTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 434707F824C30E9700E05485 /* PEPAsyncSessionTest.m */; };
4349CD6F24AC73FC00A22A13 /* NSString+NormalizePassphrase.h in Headers */ = {isa = PBXBuildFile; fileRef = 4349CD6D24AC73FC00A22A13 /* NSString+NormalizePassphrase.h */; };
4349CD7024AC73FC00A22A13 /* NSString+NormalizePassphrase.m in Sources */ = {isa = PBXBuildFile; fileRef = 4349CD6E24AC73FC00A22A13 /* NSString+NormalizePassphrase.m */; };
@ -39,7 +39,6 @@
43589EF724A4A3B70079BEA2 /* PEPPassphraseCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 43589EF524A4A3B70079BEA2 /* PEPPassphraseCache.h */; };
43589EF924A4A3B70079BEA2 /* PEPPassphraseCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 43589EF624A4A3B70079BEA2 /* PEPPassphraseCache.m */; };
43589EFB24A4ACFC0079BEA2 /* PEPPassphraseCacheTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 43589EFA24A4ACFC0079BEA2 /* PEPPassphraseCacheTest.m */; };
435C0C8C22291FFB0025C6B5 /* PEPSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 15206CC51F8E078B003FF880 /* PEPSession.h */; settings = {ATTRIBUTES = (Public, ); }; };
435C0C9922292C080025C6B5 /* PEPMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = 435796E11FB5E51A00395A9E /* PEPMessage.h */; settings = {ATTRIBUTES = (Public, ); }; };
435C0CA222292E7C0025C6B5 /* PEPTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 435C0CA022292E7C0025C6B5 /* PEPTypes.h */; settings = {ATTRIBUTES = (Public, ); }; };
435C0CAC222930340025C6B5 /* PEPConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 435C0CAA222930340025C6B5 /* PEPConstants.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -58,7 +57,6 @@
435F5170222046C2006EB11F /* NSDictionary+Debug.m in Sources */ = {isa = PBXBuildFile; fileRef = 43953B3420C91E2B001C7DDB /* NSDictionary+Debug.m */; };
435F5171222046C2006EB11F /* PEPCopyableThread.m in Sources */ = {isa = PBXBuildFile; fileRef = 1508AEAE1F8792AC001D5230 /* PEPCopyableThread.m */; };
435F5172222046C2006EB11F /* PEPSessionProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 15206CA91F8BA183003FF880 /* PEPSessionProvider.m */; };
435F5173222046C2006EB11F /* PEPSession.m in Sources */ = {isa = PBXBuildFile; fileRef = 15206CC61F8E078B003FF880 /* PEPSession.m */; };
435F5174222046C2006EB11F /* PEPIdentity.m in Sources */ = {isa = PBXBuildFile; fileRef = 433E28901FA741DE00E359B3 /* PEPIdentity.m */; };
435F5175222046C2006EB11F /* PEPMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = 435796E21FB5E51A00395A9E /* PEPMessage.m */; };
435F5176222046C2006EB11F /* PEPAttachment.m in Sources */ = {isa = PBXBuildFile; fileRef = 439D91A4208479EE003F6AC2 /* PEPAttachment.m */; };
@ -146,8 +144,6 @@
1508AEAE1F8792AC001D5230 /* PEPCopyableThread.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPCopyableThread.m; sourceTree = "<group>"; };
15206CA81F8BA183003FF880 /* PEPSessionProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPSessionProvider.h; sourceTree = "<group>"; };
15206CA91F8BA183003FF880 /* PEPSessionProvider.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPSessionProvider.m; sourceTree = "<group>"; };
15206CC51F8E078B003FF880 /* PEPSession.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPSession.h; sourceTree = "<group>"; };
15206CC61F8E078B003FF880 /* PEPSession.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPSession.m; sourceTree = "<group>"; };
152A9C462010F50400F962ED /* PEPInternalSessionTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPInternalSessionTest.m; sourceTree = "<group>"; };
152D58EE201B6DB200036219 /* PEPMessageUtilTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPMessageUtilTest.m; sourceTree = "<group>"; };
155674EC22B82D710097930C /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
@ -194,8 +190,8 @@
433DFBBB24A73AD400AB373B /* PEPSessionProtocol.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPSessionProtocol.m; sourceTree = "<group>"; };
433E28901FA741DE00E359B3 /* PEPIdentity.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPIdentity.m; sourceTree = "<group>"; };
434226801D4F60000083ED79 /* PepTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PepTests.m; sourceTree = "<group>"; };
434707F424C210CA00E05485 /* PEPAsyncSession.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPAsyncSession.h; sourceTree = "<group>"; };
434707F524C210CA00E05485 /* PEPAsyncSession.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPAsyncSession.m; sourceTree = "<group>"; };
434707F424C210CA00E05485 /* PEPSession.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPSession.h; sourceTree = "<group>"; };
434707F524C210CA00E05485 /* PEPSession.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPSession.m; sourceTree = "<group>"; };
434707F824C30E9700E05485 /* PEPAsyncSessionTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPAsyncSessionTest.m; sourceTree = "<group>"; };
4349CD6D24AC73FC00A22A13 /* NSString+NormalizePassphrase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSString+NormalizePassphrase.h"; sourceTree = "<group>"; };
4349CD6E24AC73FC00A22A13 /* NSString+NormalizePassphrase.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSString+NormalizePassphrase.m"; sourceTree = "<group>"; };
@ -384,7 +380,6 @@
1508AEAE1F8792AC001D5230 /* PEPCopyableThread.m */,
15206CA81F8BA183003FF880 /* PEPSessionProvider.h */,
15206CA91F8BA183003FF880 /* PEPSessionProvider.m */,
15206CC61F8E078B003FF880 /* PEPSession.m */,
433E28901FA741DE00E359B3 /* PEPIdentity.m */,
435796E21FB5E51A00395A9E /* PEPMessage.m */,
439D91A4208479EE003F6AC2 /* PEPAttachment.m */,
@ -412,7 +407,7 @@
433DFBB624A61D4B00AB373B /* PEPInternalSession+PassphraseCache.m */,
4349CD6D24AC73FC00A22A13 /* NSString+NormalizePassphrase.h */,
4349CD6E24AC73FC00A22A13 /* NSString+NormalizePassphrase.m */,
434707F524C210CA00E05485 /* PEPAsyncSession.m */,
434707F524C210CA00E05485 /* PEPSession.m */,
436C9A3124DC48B600007A3D /* PEPPassphraseUtil.h */,
436C9A3224DC48B600007A3D /* PEPPassphraseUtil.m */,
);
@ -431,7 +426,7 @@
43E3985C221D7E56008E7983 /* PEPObjCAdapterFramework */ = {
isa = PBXGroup;
children = (
434707F424C210CA00E05485 /* PEPAsyncSession.h */,
434707F424C210CA00E05485 /* PEPSession.h */,
430CD9BA2292AEDD00AAC37F /* PEPNotifyHandshakeDelegate.h */,
430CD9B52292ADAC00AAC37F /* PEPSendMessageDelegate.h */,
430CD9B02292AC4900AAC37F /* PEPSync.h */,
@ -442,7 +437,6 @@
435C0CAA222930340025C6B5 /* PEPConstants.h */,
435C0CAB222930340025C6B5 /* PEPConstants.m */,
435796E11FB5E51A00395A9E /* PEPMessage.h */,
15206CC51F8E078B003FF880 /* PEPSession.h */,
43209B2F1ECC2ACD007E7E2E /* PEPObjCAdapter.h */,
435C0CA022292E7C0025C6B5 /* PEPTypes.h */,
43FF2ECC2226AE7E000D9567 /* PEPEngineTypes.h */,
@ -502,10 +496,9 @@
43AD0E3022E99ECE00D46F56 /* PEPInternalConstants.h in Headers */,
430CD9B62292ADAC00AAC37F /* PEPSendMessageDelegate.h in Headers */,
43E3985F221D7E56008E7983 /* PEPObjCAdapterFramework.h in Headers */,
435C0C8C22291FFB0025C6B5 /* PEPSession.h in Headers */,
435C0CAC222930340025C6B5 /* PEPConstants.h in Headers */,
4349CD6F24AC73FC00A22A13 /* NSString+NormalizePassphrase.h in Headers */,
434707F624C210CA00E05485 /* PEPAsyncSession.h in Headers */,
434707F624C210CA00E05485 /* PEPSession.h in Headers */,
43FF2ED12226AFE9000D9567 /* PEPEngineTypes.h in Headers */,
430CD9B12292AC4900AAC37F /* PEPSync.h in Headers */,
435F519022204A67006EB11F /* PEPSessionProtocol.h in Headers */,
@ -696,7 +689,6 @@
435F517B222046C2006EB11F /* NSMutableDictionary+PEP.m in Sources */,
435F516A222046C2006EB11F /* PEPLanguage.m in Sources */,
435F516F222046C2006EB11F /* NSDictionary+CommType.m in Sources */,
435F5173222046C2006EB11F /* PEPSession.m in Sources */,
435F5168222046C2006EB11F /* NSArray+Extension.m in Sources */,
435F516E222046C2006EB11F /* PEPInternalSession.m in Sources */,
435F5172222046C2006EB11F /* PEPSessionProvider.m in Sources */,
@ -709,7 +701,7 @@
435F5171222046C2006EB11F /* PEPCopyableThread.m in Sources */,
43589EF924A4A3B70079BEA2 /* PEPPassphraseCache.m in Sources */,
435F5175222046C2006EB11F /* PEPMessage.m in Sources */,
434707F724C210CA00E05485 /* PEPAsyncSession.m in Sources */,
434707F724C210CA00E05485 /* PEPSession.m in Sources */,
435F5174222046C2006EB11F /* PEPIdentity.m in Sources */,
435F517A222046C2006EB11F /* NSObject+Extension.m in Sources */,
435F517D222046C2006EB11F /* PEPSync.m in Sources */,


+ 0
- 661
pEpObjCAdapter/PEPAsyncSession.m View File

@ -1,661 +0,0 @@
//
// PEPAsyncSession.m
// PEPObjCAdapterFramework
//
// Created by Dirk Zimmermann on 17.07.20.
// Copyright © 2020 pp. All rights reserved.
//
#import "PEPAsyncSession.h"
#import "PEPMessage.h"
#import "PEPEngineTypes.h"
#import "PEPInternalSession.h"
#import "NSNumber+PEPRating.h"
#import "PEPIdentity.h"
#import "PEPSessionProvider.h"
#import "PEPInternalConstants.h"
#import "NSError+PEP+Internal.h"
static dispatch_queue_t queue;
@interface PEPAsyncSession ()
@end
@implementation PEPAsyncSession
+ (void)initialize
{
if (self == [PEPAsyncSession class]) {
dispatch_queue_attr_t attr = DISPATCH_QUEUE_SERIAL;
attr = dispatch_queue_attr_make_with_qos_class(attr, QOS_CLASS_USER_INITIATED, -1);
queue = dispatch_queue_create("PEPAsyncSession.queue", attr);
}
}
+ (void)cleanup
{
[PEPSessionProvider cleanup];
}
- (void)decryptMessage:(PEPMessage *)message
flags:(PEPDecryptFlags)flags
extraKeys:(PEPStringList * _Nullable)extraKeys
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPMessage *srcMessage,
PEPMessage *dstMessage,
PEPStringList *keyList,
PEPRating rating,
PEPDecryptFlags flags))successCallback
{
dispatch_async(queue, ^{
PEPMessage *theMessage = [[PEPMessage alloc] initWithMessage:message];
PEPDecryptFlags theFlags = flags;
PEPRating theRating;
PEPStringList *theExtraKeys = extraKeys;
PEPStatus status;
NSError *error = nil;
PEPMessage *newMessage = [[PEPSessionProvider session] decryptMessage:theMessage
flags:&theFlags
rating:&theRating
extraKeys:&theExtraKeys
status:&status
error:&error];
if (newMessage) {
successCallback(theMessage, newMessage, theExtraKeys, theRating, theFlags);
} else {
errorCallback(error);
}
});
}
- (void)reEvaluateMessage:(PEPMessage *)message
xKeyList:(PEPStringList *_Nullable)xKeyList
originalRating:(PEPRating)originalRating
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPRating rating))successCallback
{
dispatch_async(queue, ^{
PEPRating theRating = originalRating;
NSError *error = nil;
BOOL result = [[PEPSessionProvider session]
reEvaluateMessage:message
xKeyList:xKeyList
rating:&theRating
status:nil
error:&error];
if (result) {
successCallback(theRating);
} else {
errorCallback(error);
}
});
}
- (void)encryptMessage:(PEPMessage *)message
extraKeys:(PEPStringList * _Nullable)extraKeys
encFormat:(PEPEncFormat)encFormat
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPMessage *srcMessage,
PEPMessage *destMessage))successCallback
{
dispatch_async(queue, ^{
PEPMessage *theMessage = [[PEPMessage alloc] initWithMessage:message];
NSError *error = nil;
PEPMessage *destMessage = [[PEPSessionProvider session]
encryptMessage:theMessage
extraKeys:extraKeys
encFormat:encFormat
status:nil
error:&error];
if (destMessage) {
successCallback(theMessage, destMessage);
} else {
errorCallback(error);
}
});
}
- (void)encryptMessage:(PEPMessage *)message
extraKeys:(PEPStringList * _Nullable)extraKeys
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPMessage *srcMessage,
PEPMessage *destMessage))successCallback
{
dispatch_async(queue, ^{
PEPMessage *theMessage = [[PEPMessage alloc] initWithMessage:message];
NSError *error = nil;
PEPMessage *destMessage = [[PEPSessionProvider session]
encryptMessage:theMessage
extraKeys:extraKeys
status:nil
error:&error];
if (destMessage) {
successCallback(theMessage, destMessage);
} else {
errorCallback(error);
}
});
}
- (void)encryptMessage:(PEPMessage *)message
forSelf:(PEPIdentity *)ownIdentity
extraKeys:(PEPStringList * _Nullable)extraKeys
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPMessage *srcMessage,
PEPMessage *destMessage))successCallback
{
dispatch_async(queue, ^{
PEPMessage *theMessage = [[PEPMessage alloc] initWithMessage:message];
NSError *error = nil;
PEPMessage *destMessage = [[PEPSessionProvider session]
encryptMessage:theMessage
forSelf:ownIdentity
extraKeys:extraKeys
status:nil
error:&error];
if (destMessage) {
successCallback(theMessage, destMessage);
} else {
errorCallback(error);
}
});
}
- (void)encryptMessage:(PEPMessage *)message
toFpr:(NSString *)toFpr
encFormat:(PEPEncFormat)encFormat
flags:(PEPDecryptFlags)flags
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPMessage *srcMessage,
PEPMessage *destMessage))successCallback
{
dispatch_async(queue, ^{
PEPMessage *theMessage = [[PEPMessage alloc] initWithMessage:message];
NSError *error = nil;
PEPMessage *destMessage = [[PEPSessionProvider session]
encryptMessage:theMessage
toFpr:toFpr
encFormat:encFormat
flags:flags
status:nil
error:&error];
if (destMessage) {
successCallback(theMessage, destMessage);
} else {
errorCallback(error);
}
});
}
- (void)outgoingRatingForMessage:(PEPMessage *)theMessage
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPRating rating))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
NSNumber *ratingNum = [[PEPSessionProvider session]
outgoingRatingForMessage:theMessage
error:&error];
if (ratingNum) {
successCallback(ratingNum.pEpRating);
} else {
errorCallback(error);
}
});
}
- (void)ratingForIdentity:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPRating rating))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
NSNumber *ratingNum = [[PEPSessionProvider session]
ratingForIdentity:identity
error:&error];
if (ratingNum) {
successCallback(ratingNum.pEpRating);
} else {
errorCallback(error);
}
});
}
- (void)trustwordsForFingerprint:(NSString *)fingerprint
languageID:(NSString *)languageID
shortened:(BOOL)shortened
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(NSArray<NSString *> *trustwords))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
NSArray *trustwords = [[PEPSessionProvider session]
trustwordsForFingerprint:fingerprint
languageID:languageID
shortened:shortened
error:&error];
if (!error) {
successCallback(trustwords);
} else {
errorCallback(error);
}
});
}
- (void)mySelf:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPIdentity *identity))successCallback
{
__block PEPIdentity *theIdentity = [[PEPIdentity alloc] initWithIdentity:identity];
dispatch_async(queue, ^{
NSError *error = nil;
BOOL success = [[PEPSessionProvider session] mySelf:theIdentity error:&error];
if (success) {
successCallback(theIdentity);
} else {
errorCallback(error);
}
});
}
- (void)updateIdentity:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPIdentity *identity))successCallback
{
__block PEPIdentity *theIdentity = [[PEPIdentity alloc] initWithIdentity:identity];
dispatch_async(queue, ^{
NSError *error = nil;
BOOL success = [[PEPSessionProvider session] updateIdentity:theIdentity error:&error];
if (success) {
successCallback(theIdentity);
} else {
errorCallback(error);
}
});
}
- (void)trustPersonalKey:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
BOOL success = [[PEPSessionProvider session] trustPersonalKey:identity error:&error];
if (success) {
successCallback();
} else {
errorCallback(error);
}
});
}
- (void)keyMistrusted:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
BOOL success = [[PEPSessionProvider session] keyMistrusted:identity error:&error];
if (success) {
successCallback();
} else {
errorCallback(error);
}
});
}
- (void)keyResetTrust:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
BOOL success = [[PEPSessionProvider session] keyResetTrust:identity error:&error];
if (success) {
successCallback();
} else {
errorCallback(error);
}
});
}
- (void)enableSyncForIdentity:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
BOOL success = [[PEPSessionProvider session] enableSyncForIdentity:identity error:&error];
if (success) {
successCallback();
} else {
errorCallback(error);
}
});
}
- (void)disableSyncForIdentity:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
BOOL success = [[PEPSessionProvider session] disableSyncForIdentity:identity error:&error];
if (success) {
successCallback();
} else {
errorCallback(error);
}
});
}
- (void)queryKeySyncEnabledForIdentity:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(BOOL enabled))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
NSNumber *boolNum = [[PEPSessionProvider session]
queryKeySyncEnabledForIdentity:identity
error:&error];
if (boolNum) {
successCallback(boolNum.boolValue);
} else {
errorCallback(error);
}
});
}
- (void)importKey:(NSString *)keydata
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(NSArray<PEPIdentity *> *identities))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
NSArray *identities = [[PEPSessionProvider session] importKey:keydata error:&error];
if (identities) {
successCallback(identities);
} else {
errorCallback(error);
}
});
}
- (void)logTitle:(NSString *)title
entity:(NSString *)entity
description:(NSString * _Nullable)description
comment:(NSString * _Nullable)comment
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
BOOL success = [[PEPSessionProvider session] logTitle:title
entity:entity
description:description
comment:comment
error:&error];
if (success) {
successCallback();
} else {
errorCallback(error);
}
});
}
- (void)getLog:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(NSString *log))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
NSString *log = [[PEPSessionProvider session] getLogWithError:&error];
if (log) {
successCallback(log);
} else {
errorCallback(error);
}
});
}
- (void)getTrustwordsIdentity1:(PEPIdentity *)identity1
identity2:(PEPIdentity *)identity2
language:(NSString * _Nullable)language
full:(BOOL)full
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(NSString *trustwords))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
NSString *trustwords = [[PEPSessionProvider session] getTrustwordsIdentity1:identity1
identity2:identity2
language:language
full:full
error:&error];
if (trustwords) {
successCallback(trustwords);
} else {
errorCallback(error);
}
});
}
- (void)getTrustwordsFpr1:(NSString *)fpr1
fpr2:(NSString *)fpr2
language:(NSString * _Nullable)language
full:(BOOL)full
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(NSString *trustwords))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
NSString *trustwords = [[PEPSessionProvider session] getTrustwordsFpr1:fpr1
fpr2:fpr2
language:language
full:full
error:&error];
if (trustwords) {
successCallback(trustwords);
} else {
errorCallback(error);
}
});
}
- (void)languageList:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(NSArray<PEPLanguage *> *languages))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
NSArray *languages = [[PEPSessionProvider session] languageListWithError:&error];
if (languages) {
successCallback(languages);
} else {
errorCallback(error);
}
});
}
- (void)isPEPUser:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(BOOL enabled))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
NSNumber *ispEpUserNum = [[PEPSessionProvider session] isPEPUser:identity error:&error];
if (ispEpUserNum) {
successCallback(ispEpUserNum.boolValue);
} else {
errorCallback(error);
}
});
}
- (void)setOwnKey:(PEPIdentity *)identity
fingerprint:(NSString *)fingerprint
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
BOOL success = [[PEPSessionProvider session] setOwnKey:identity
fingerprint:fingerprint
error:&error];
if (success) {
successCallback();
} else {
errorCallback(error);
}
});
}
- (void)deliverHandshakeResult:(PEPSyncHandshakeResult)result
identitiesSharing:(NSArray<PEPIdentity *> * _Nullable)identitiesSharing
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
BOOL success = [[PEPSessionProvider session] deliverHandshakeResult:result
identitiesSharing:identitiesSharing
error:&error];
if (success) {
successCallback();
} else {
errorCallback(error);
}
});
}
- (void)trustOwnKeyIdentity:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
BOOL success = [[PEPSessionProvider session] trustOwnKeyIdentity:identity error:&error];
if (success) {
successCallback();
} else {
errorCallback(error);
}
});
}
- (void)keyReset:(PEPIdentity *)identity
fingerprint:(NSString * _Nullable)fingerprint
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
BOOL success = [[PEPSessionProvider session] keyReset:identity
fingerprint:fingerprint
error:&error];
if (success) {
successCallback();
} else {
errorCallback(error);
}
});
}
- (void)leaveDeviceGroup:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
BOOL success = [[PEPSessionProvider session] leaveDeviceGroup:&error];
if (success) {
successCallback();
} else {
errorCallback(error);
}
});
}
- (void)keyResetAllOwnKeys:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
BOOL success = [[PEPSessionProvider session] keyResetAllOwnKeysError:&error];
if (success) {
successCallback();
} else {
errorCallback(error);
}
});
}
// MARK: - Configuration
- (void)configurePassiveModeEnabled:(BOOL)enabled
{
return [[PEPSessionProvider session] configurePassiveModeEnabled:enabled];
}
- (BOOL)configurePassphrase:(NSString * _Nonnull)passphrase
error:(NSError * _Nullable __autoreleasing * _Nullable)error {
PEPInternalSession *session = [PEPSessionProvider session];
if (session == nil) {
if (error) {
*error = [NSError errorWithPEPStatusInternal:PEP_UNKNOWN_ERROR];
}
return NO;
}
return [session configurePassphrase:passphrase error:error];
}
- (BOOL)configurePassphraseForNewKeys:(NSString * _Nullable)passphrase
enable:(BOOL)enable
error:(NSError * _Nullable __autoreleasing * _Nullable)error {
PEPInternalSession *session = [PEPSessionProvider session];
if (session == nil) {
if (error) {
*error = [NSError errorWithPEPStatusInternal:PEP_UNKNOWN_ERROR];
}
return NO;
}
return [session configurePassphraseForNewKeys:passphrase enable:enable error:error];
}
// MARK: - Methods that can be executed syncronously
- (PEPRating)ratingFromString:(NSString * _Nonnull)string
{
PEPInternalSession *session = [PEPSessionProvider session];
if (session == nil) {
return PEPRatingUndefined;
}
return [session ratingFromString:string];
}
- (NSString * _Nonnull)stringFromRating:(PEPRating)rating
{
PEPInternalSession *session = [PEPSessionProvider session];
if (session == nil) {
return kUndefined;
}
return [session stringFromRating:rating];
}
- (PEPColor)colorFromRating:(PEPRating)rating
{
PEPInternalSession *session = [PEPSessionProvider session];
if (session == nil) {
return PEPColorNoColor;
}
return [session colorFromRating:rating];
}
@end

+ 598
- 358
pEpObjCAdapter/PEPSession.m
File diff suppressed because it is too large
View File


+ 0
- 1
pEpObjCAdapterFramework/PEPObjCAdapterFramework.h View File

@ -22,7 +22,6 @@ FOUNDATION_EXPORT const unsigned char PEPObjCAdapterFrameworkVersionString[];
#import "PEPTypes.h"
#import "PEPObjCAdapter.h"
#import "PEPSession.h"
#import "PEPAsyncSession.h"
#import "PEPMessage.h"
#import "PEPConstants.h"
#import "NSNumber+PEPRating.h"


+ 11
- 19
pEpObjCAdapterFramework/PEPSession.h View File

@ -1,33 +1,25 @@
//
// PEPSession.h
// pEpObjCAdapter
// PEPObjCAdapterFramework
//
// Created by Andreas Buff on 11.10.17.
// Copyright © 2017 pp. All rights reserved.
// Created by Dirk Zimmermann on 17.07.20.
// Copyright © 2020 pp. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "PEPEngineTypes.h"
#import "PEPTypes.h"
#import "PEPSessionProtocol.h"
/**
Fake session to handle to the client.
@class PEPMessage;
@class PEPIdentity;
@class PEPLanguage;
Assures all calls are handled on the correct internal session for the thread it is called on.
You can instantiate and use this session how often and wherever you want. Also over multiple threads.
NS_ASSUME_NONNULL_BEGIN
Note: You must call `cleanup()` once before your process gets terminated to be able to gracefully shutdown.
It is the clients responsibility not to make any calls to PEPSession in between the last call
to `cleanup()` and getting terminated.
*/
@interface PEPSession : NSObject <PEPSessionProtocol>
/**
You must call this method once before your process gets terminated to be able to gracefully shutdown.
You must not make any calls to PEPSession in between the last call to `cleanup()` and getting terminated.
Only for performance reasons: call this method only if you have to.
*/
+ (void)cleanup;
@end
NS_ASSUME_NONNULL_END

+ 171
- 256
pEpObjCAdapterFramework/PEPSessionProtocol.h View File

@ -15,6 +15,8 @@
@class PEPIdentity;
@class PEPMessage;
NS_ASSUME_NONNULL_BEGIN
/// Domain for errors indicated by the pEp engine.
extern NSString * const _Nonnull PEPObjCAdapterEngineStatusErrorDomain;
@ -23,272 +25,171 @@ extern NSString * const _Nonnull PEPObjCAdapterErrorDomain;
@protocol PEPSessionProtocol <NSObject>
/** Decrypt a message */
- (PEPMessage * _Nullable)decryptMessage:(PEPMessage * _Nonnull)message
flags:(PEPDecryptFlags * _Nullable)flags
rating:(PEPRating * _Nullable)rating
extraKeys:(PEPStringList * _Nullable * _Nullable)extraKeys
status:(PEPStatus * _Nullable)status
error:(NSError * _Nullable * _Nullable)error;
/** Re-evaluate rating of decrypted message */
- (BOOL)reEvaluateMessage:(PEPMessage * _Nonnull)message
xKeyList:(PEPStringList *_Nullable)xKeyList
rating:(PEPRating * _Nonnull)rating
status:(PEPStatus * _Nullable)status
error:(NSError * _Nullable * _Nullable)error;
/**
Encrypt a message, indicating the encoding format
@note The resulting message dict could be the input one.
*/
- (PEPMessage * _Nullable)encryptMessage:(PEPMessage * _Nonnull)message
extraKeys:(PEPStringList * _Nullable)extraKeys
encFormat:(PEPEncFormat)encFormat
status:(PEPStatus * _Nullable)status
error:(NSError * _Nullable * _Nullable)error;
/** Encrypt a message with default encryption format (PEP_enc_PEP) */
- (PEPMessage * _Nullable)encryptMessage:(PEPMessage * _Nonnull)message
extraKeys:(PEPStringList * _Nullable)extraKeys
status:(PEPStatus * _Nullable)status
error:(NSError * _Nullable * _Nullable)error;
/** Encrypt a message for the given own identity */
- (PEPMessage * _Nullable)encryptMessage:(PEPMessage * _Nonnull)message
forSelf:(PEPIdentity * _Nonnull)ownIdentity
extraKeys:(PEPStringList * _Nullable)extraKeys
status:(PEPStatus * _Nullable)status
error:(NSError * _Nullable * _Nullable)error;
/** Encrypt a message to the given recipient FPR, attaching the private key */
- (PEPMessage * _Nullable)encryptMessage:(PEPMessage * _Nonnull)message
toFpr:(NSString * _Nonnull)toFpr
encFormat:(PEPEncFormat)encFormat
flags:(PEPDecryptFlags)flags
status:(PEPStatus * _Nullable)status
error:(NSError * _Nullable * _Nullable)error;
/** Determine the status color of a message to be sent */
- (NSNumber * _Nullable)outgoingRatingForMessage:(PEPMessage * _Nonnull)theMessage
error:(NSError * _Nullable * _Nullable)error;
/** Determine the preview status color of a message to be sent */
- (NSNumber * _Nullable)outgoingRatingPreviewForMessage:(PEPMessage * _Nonnull)theMessage
error:(NSError * _Nullable * _Nullable)error;
/**
Determine the rating of an identity.
The rating is the rating a _message_ would have, if it is sent to this (and only this) identity.
It is *not* a rating of the identity. In fact, there is no rating for identities.
*/
- (NSNumber * _Nullable)ratingForIdentity:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error;
/** Get trustwords for a fingerprint */
- (NSArray<NSString *> * _Nullable)trustwordsForFingerprint:(NSString * _Nonnull)fingerprint
languageID:(NSString * _Nonnull)languageID
shortened:(BOOL)shortened
error:(NSError * _Nullable * _Nullable)error;
/// Marks an identity as an own identity, not changing its participation in pEp sync.
///
/// @return Returns YES on success, NO on error, setting `*error` accordingly if possible.
///
/// @note See the engine's myself function for details.
///
/// @param identity The identity to mark as own.
///
/// @param error Standard cocoa error handling.
- (BOOL)mySelf:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error;
/// Calls the engine's update_identity on the given identity.
/// You must call this method once before your process gets terminated to be able to gracefully shutdown.
/// You must not make any calls to PEPSession in between the last call to `cleanup()` and getting terminated.
///
/// @note Prior this was invoking myself if the identity was identified as being an own
/// identity, but this not the case anymore, since it cannot decide if the identity should
/// participate in pEp sync or not.
///
/// @return Returns YES on success, NO on error, setting `*error` accordingly if possible.
///
/// @param identity The identity for which to call update_identity.
///
/// @param error Standart cocoa error handling.
- (BOOL)updateIdentity:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error;
/**
Mark a key as trusted with a person.
*/
- (BOOL)trustPersonalKey:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error;
/**
if a key is not trusted by the user tell this using this message
*/
- (BOOL)keyMistrusted:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error;
/**
Use this to undo keyCompromized or trustPersonalKey
*/
- (BOOL)keyResetTrust:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error;
/**
Enables key sync.
Wraps enable_identity_for_sync.
@param identity The (own) identity to enable key sync for.
@param error The usual cocoa error handling.
@return The usual cocoa error handling.
*/
- (BOOL)enableSyncForIdentity:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error;
/**
Disables key sync.
Wraps disable_identity_for_sync.
@param identity The (own) identity to disable key sync for.
@param error The usual cocoa error handling.
@return The usual cocoa error handling.
*/
- (BOOL)disableSyncForIdentity:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error;
/**
Queries the given own identity on whether it has key sync disabled or not.
@param identity The (own) identity to query.
@param error The usual cocoa error handling.
@return An NSNumber containing a boolean denoting whether key sync is enabled or not, or
nil on error. YES means that key sync is allowed for this identity, otherwise it's NO.
*/
- (NSNumber * _Nullable)queryKeySyncEnabledForIdentity:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error;
#pragma mark -- Internal API (testing etc.)
/** For testing purpose, manual key import */
- (NSArray<PEPIdentity *> * _Nullable)importKey:(NSString * _Nonnull)keydata
error:(NSError * _Nullable * _Nullable)error;
- (BOOL)logTitle:(NSString * _Nonnull)title
entity:(NSString * _Nonnull)entity
/// Only for performance reasons: call this method only if you have to.
+ (void)cleanup;
- (void)decryptMessage:(PEPMessage *)message
flags:(PEPDecryptFlags)flags
extraKeys:(PEPStringList * _Nullable)extraKeys
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPMessage *srcMessage,
PEPMessage *dstMessage,
PEPStringList *keyList,
PEPRating rating,
PEPDecryptFlags flags))successCallback;
- (void)reEvaluateMessage:(PEPMessage *)message
xKeyList:(PEPStringList *_Nullable)xKeyList
originalRating:(PEPRating)originalRating
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPRating rating))successCallback;
/// Encrypt a message with explicit encryption format.
- (void)encryptMessage:(PEPMessage *)message
extraKeys:(PEPStringList * _Nullable)extraKeys
encFormat:(PEPEncFormat)encFormat
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPMessage *srcMessage,
PEPMessage *destMessage))successCallback;
/// Encrypt a message with the default encryption format.
- (void)encryptMessage:(PEPMessage *)message
extraKeys:(PEPStringList * _Nullable)extraKeys
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPMessage *srcMessage,
PEPMessage *destMessage))successCallback;
/// Encrypt a message to an own identity.
- (void)encryptMessage:(PEPMessage *)message
forSelf:(PEPIdentity *)ownIdentity
extraKeys:(PEPStringList * _Nullable)extraKeys
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPMessage *srcMessage,
PEPMessage *destMessage))successCallback;
/// Encrypt a message to a fingerprint.
- (void)encryptMessage:(PEPMessage *)message
toFpr:(NSString *)toFpr
encFormat:(PEPEncFormat)encFormat
flags:(PEPDecryptFlags)flags
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPMessage *srcMessage,
PEPMessage *destMessage))successCallback;
- (void)outgoingRatingForMessage:(PEPMessage *)theMessage
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPRating rating))successCallback;
- (void)ratingForIdentity:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPRating rating))successCallback;
- (void)trustwordsForFingerprint:(NSString *)fingerprint
languageID:(NSString *)languageID
shortened:(BOOL)shortened
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(NSArray<NSString *> *trustwords))successCallback;
- (void)mySelf:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPIdentity *identity))successCallback;
- (void)updateIdentity:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPIdentity *identity))successCallback;
- (void)trustPersonalKey:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
- (void)keyMistrusted:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
- (void)keyResetTrust:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
- (void)enableSyncForIdentity:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
- (void)disableSyncForIdentity:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
- (void)queryKeySyncEnabledForIdentity:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(BOOL enabled))successCallback;
- (void)importKey:(NSString *)keydata
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(NSArray<PEPIdentity *> *identities))successCallback;
- (void)logTitle:(NSString *)title
entity:(NSString *)entity
description:(NSString * _Nullable)description
comment:(NSString * _Nullable)comment
error:(NSError * _Nullable * _Nullable)error;
/**
Retrieves the log from the engine, or nil, if there is nothing yet.
*/
- (NSString * _Nullable)getLogWithError:(NSError * _Nullable * _Nullable)error;
/** Determine trustwords for two identities */
- (NSString * _Nullable)getTrustwordsIdentity1:(PEPIdentity * _Nonnull)identity1
identity2:(PEPIdentity * _Nonnull)identity2
language:(NSString * _Nullable)language
full:(BOOL)full
error:(NSError * _Nullable * _Nullable)error;
/** Determine trustwords for two fprs */
- (NSString * _Nullable)getTrustwordsFpr1:(NSString * _Nonnull)fpr1
fpr2:(NSString * _Nonnull)fpr2
language:(NSString * _Nullable)language
full:(BOOL)full
error:(NSError * _Nullable * _Nullable)error;
/**
@returns The list of supported languages for trustwords.
*/
- (NSArray<PEPLanguage *> * _Nullable)languageListWithError:(NSError * _Nullable * _Nullable)error;
/**
Can convert a string like "cannot_decrypt" into its equivalent PEPRating_cannot_decrypt.
*/
- (PEPRating)ratingFromString:(NSString * _Nonnull)string;
/**
Can convert a pEp rating like PEPRating_cannot_decrypt
into its equivalent string "cannot_decrypt" .
*/
- (NSString * _Nonnull)stringFromRating:(PEPRating)rating;
/**
Is the given identity really a pEp user?
If the engine indicates an error, or the identity is not a pEp user, returns false.
*/
- (NSNumber * _Nullable)isPEPUser:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error;
/**
When (manually) importing (secret) keys, associate them with the given own identity.
*/
- (BOOL)setOwnKey:(PEPIdentity * _Nonnull)identity fingerprint:(NSString * _Nonnull)fingerprint
error:(NSError * _Nullable * _Nullable)error;
/**
Wraps the engine's `config_passive_mode`.
@note That there's absolutely no error handling.
*/
- (void)configurePassiveModeEnabled:(BOOL)enabled;
/**
Wraps set_identity_flags.
*/
- (BOOL)setFlags:(PEPIdentityFlags)flags
forIdentity:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error;
/**
Indicate the user's choice during a handshake dialog display.
Wraps the engine's deliverHandshakeResult. Should be called in response to
[PEPNotifyHandshakeDelegate notifyHandshake:me:partner:signal
in accordance with the user's choices.
@param result The choice the user made with regards to the currently active handshake dialog.
@param identitiesSharing The identities that are involved for the user's choice.
That is, the user can chose to respond only for a subset of the
identities that were originally involved in the handshake.
@param error The default cocoa error handling.
@return `YES` when the call succedded, `NO` otherwise. In the `NO` case, see `error` for details.
*/
- (BOOL)deliverHandshakeResult:(PEPSyncHandshakeResult)result
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
- (void)getLog:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(NSString *log))successCallback;
- (void)getTrustwordsIdentity1:(PEPIdentity *)identity1
identity2:(PEPIdentity *)identity2
language:(NSString * _Nullable)language
full:(BOOL)full
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(NSString *trustwords))successCallback;
- (void)getTrustwordsFpr1:(NSString *)fpr1
fpr2:(NSString *)fpr2
language:(NSString * _Nullable)language
full:(BOOL)full
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(NSString *trustwords))successCallback;
- (void)languageList:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(NSArray<PEPLanguage *> *languages))successCallback;
- (void)isPEPUser:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(BOOL enabled))successCallback;
- (void)setOwnKey:(PEPIdentity *)identity
fingerprint:(NSString *)fingerprint
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
- (void)deliverHandshakeResult:(PEPSyncHandshakeResult)result
identitiesSharing:(NSArray<PEPIdentity *> * _Nullable)identitiesSharing
error:(NSError * _Nullable * _Nullable)error;
/**
Wraps trust_own_key.
*/
- (BOOL)trustOwnKeyIdentity:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error;
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
/**
Wraps color_from_rating.
*/
- (PEPColor)colorFromRating:(PEPRating)rating;
- (void)trustOwnKeyIdentity:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
/**
Wraps key_reset_user.
*/
- (BOOL)keyReset:(PEPIdentity * _Nonnull)identity
- (void)keyReset:(PEPIdentity *)identity
fingerprint:(NSString * _Nullable)fingerprint
error:(NSError * _Nullable * _Nullable)error;
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
- (void)leaveDeviceGroup:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
/** Wraps leave_device_group. */
- (BOOL)leaveDeviceGroup:(NSError * _Nullable * _Nullable)error;
- (void)keyResetAllOwnKeys:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
/**
Revoke and mistrust all own keys. See key_reset_all_own_keys for details.
// MARK: - Configuration
@param error The default cocoa error handling.
@return YES on success, NO if there were errors.
*/
- (BOOL)keyResetAllOwnKeysError:(NSError * _Nullable * _Nullable)error;
/// Wraps the engine's `config_passive_mode`.
/// @note That there's absolutely no error handling.
- (void)configurePassiveModeEnabled:(BOOL)enabled;
/// Add a passphrase for secret keys to the cache.