merge default IOSAD-131
authorDirk Zimmermann <dz@pep.security>
Mon, 02 Sep 2019 11:51:07 +0200
branchIOSAD-131
changeset 1177f0e1d9295cee
parent 1170 9f01730dd62c
parent 1168 91dae11f1818
child 1178 b48176815596
merge default
pEpObjCAdapter.xcodeproj/project.pbxproj
pEpObjCAdapter.xcodeproj/xcshareddata/xcschemes/PEPObjCAdapterFramework.xcscheme
pEpObjCAdapter/PEPInternalSession.m
     1.1 --- a/pEpObjCAdapter.xcodeproj/project.pbxproj	Thu Aug 15 14:27:21 2019 +0200
     1.2 +++ b/pEpObjCAdapter.xcodeproj/project.pbxproj	Mon Sep 02 11:51:07 2019 +0200
     1.3 @@ -61,6 +61,8 @@
     1.4  		437BEA9122328E570051E3A1 /* pEpTrustWords.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 64AE6B211BE15E3A000867E4 /* pEpTrustWords.bundle */; };
     1.5  		4396CEB82187196600FDD398 /* PEPSessionTestNotifyHandshakeDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4396CEB62187190F00FDD398 /* PEPSessionTestNotifyHandshakeDelegate.m */; };
     1.6  		4396CECB2187220200FDD398 /* PEPSessionTestSendMessageDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4396CEC8218721F900FDD398 /* PEPSessionTestSendMessageDelegate.m */; };
     1.7 +		43AD0E3022E99ECE00D46F56 /* PEPInternalConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 43AD0E2E22E99ECE00D46F56 /* PEPInternalConstants.h */; };
     1.8 +		43AD0E3122E99ECE00D46F56 /* PEPInternalConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 43AD0E2F22E99ECE00D46F56 /* PEPInternalConstants.m */; };
     1.9  		43BCEFF7222FBA2400148303 /* NSDictionary+CommType.h in Headers */ = {isa = PBXBuildFile; fileRef = 43D27DE41F5DA78700795687 /* NSDictionary+CommType.h */; settings = {ATTRIBUTES = (Public, ); }; };
    1.10  		43E02A201C71F65B008F05E9 /* A3FC7F0A_sec.asc in Resources */ = {isa = PBXBuildFile; fileRef = 43E02A1C1C71F65B008F05E9 /* A3FC7F0A_sec.asc */; };
    1.11  		43E02A211C71F65B008F05E9 /* A3FC7F0A.asc in Resources */ = {isa = PBXBuildFile; fileRef = 43E02A1D1C71F65B008F05E9 /* A3FC7F0A.asc */; };
    1.12 @@ -194,6 +196,8 @@
    1.13  		4396CEC9218721F900FDD398 /* PEPSessionTestSendMessageDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PEPSessionTestSendMessageDelegate.h; sourceTree = "<group>"; };
    1.14  		439D91A3208479EE003F6AC2 /* PEPAttachment.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPAttachment.h; sourceTree = "<group>"; };
    1.15  		439D91A4208479EE003F6AC2 /* PEPAttachment.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPAttachment.m; sourceTree = "<group>"; };
    1.16 +		43AD0E2E22E99ECE00D46F56 /* PEPInternalConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPInternalConstants.h; sourceTree = "<group>"; };
    1.17 +		43AD0E2F22E99ECE00D46F56 /* PEPInternalConstants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPInternalConstants.m; sourceTree = "<group>"; };
    1.18  		43D27DE41F5DA78700795687 /* NSDictionary+CommType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+CommType.h"; sourceTree = "<group>"; };
    1.19  		43D27DE51F5DA7B700795687 /* NSDictionary+CommType.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+CommType.m"; sourceTree = "<group>"; };
    1.20  		43DED784203C25E200D45CD6 /* NSError+PEP.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSError+PEP.h"; sourceTree = "<group>"; };
    1.21 @@ -350,6 +354,8 @@
    1.22  				43F73BE92166248E00AB4524 /* PEPSync.m */,
    1.23  				430CD9BF2292B1EA00AAC37F /* PEPSync_Internal.h */,
    1.24  				433CFC8622F30ECC00A4136D /* PEPIdentity+Internal.h */,
    1.25 +				43AD0E2E22E99ECE00D46F56 /* PEPInternalConstants.h */,
    1.26 +				43AD0E2F22E99ECE00D46F56 /* PEPInternalConstants.m */,
    1.27  			);
    1.28  			path = pEpObjCAdapter;
    1.29  			sourceTree = "<group>";
    1.30 @@ -425,6 +431,7 @@
    1.31  				435C0C9922292C080025C6B5 /* PEPMessage.h in Headers */,
    1.32  				435C0CA222292E7C0025C6B5 /* PEPTypes.h in Headers */,
    1.33  				435F5164222045FB006EB11F /* PEPIdentity.h in Headers */,
    1.34 +				43AD0E3022E99ECE00D46F56 /* PEPInternalConstants.h in Headers */,
    1.35  				430CD9B62292ADAC00AAC37F /* PEPSendMessageDelegate.h in Headers */,
    1.36  				43E3985F221D7E56008E7983 /* PEPObjCAdapterFramework.h in Headers */,
    1.37  				435C0C8C22291FFB0025C6B5 /* PEPSession.h in Headers */,
    1.38 @@ -631,6 +638,7 @@
    1.39  				435F517A222046C2006EB11F /* NSObject+Extension.m in Sources */,
    1.40  				435F517D222046C2006EB11F /* PEPSync.m in Sources */,
    1.41  				435F516D222046C2006EB11F /* PEPQueue.m in Sources */,
    1.42 +				43AD0E3122E99ECE00D46F56 /* PEPInternalConstants.m in Sources */,
    1.43  			);
    1.44  			runOnlyForDeploymentPostprocessing = 0;
    1.45  		};
     2.1 --- a/pEpObjCAdapter.xcodeproj/xcshareddata/xcschemes/PEPObjCAdapterFramework.xcscheme	Thu Aug 15 14:27:21 2019 +0200
     2.2 +++ b/pEpObjCAdapter.xcodeproj/xcshareddata/xcschemes/PEPObjCAdapterFramework.xcscheme	Mon Sep 02 11:51:07 2019 +0200
     2.3 @@ -20,20 +20,6 @@
     2.4                 ReferencedContainer = "container:pEpObjCAdapter.xcodeproj">
     2.5              </BuildableReference>
     2.6           </BuildActionEntry>
     2.7 -         <BuildActionEntry
     2.8 -            buildForTesting = "YES"
     2.9 -            buildForRunning = "YES"
    2.10 -            buildForProfiling = "YES"
    2.11 -            buildForArchiving = "YES"
    2.12 -            buildForAnalyzing = "YES">
    2.13 -            <BuildableReference
    2.14 -               BuildableIdentifier = "primary"
    2.15 -               BlueprintIdentifier = "64415E161BE94FCB00F6CBB2"
    2.16 -               BuildableName = "pEpObjCAdapterTests.xctest"
    2.17 -               BlueprintName = "pEpObjCAdapterTests"
    2.18 -               ReferencedContainer = "container:pEpObjCAdapter.xcodeproj">
    2.19 -            </BuildableReference>
    2.20 -         </BuildActionEntry>
    2.21        </BuildActionEntries>
    2.22     </BuildAction>
    2.23     <TestAction
    2.24 @@ -42,26 +28,7 @@
    2.25        selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
    2.26        shouldUseLaunchSchemeArgsEnv = "YES">
    2.27        <Testables>
    2.28 -         <TestableReference
    2.29 -            skipped = "NO">
    2.30 -            <BuildableReference
    2.31 -               BuildableIdentifier = "primary"
    2.32 -               BlueprintIdentifier = "64415E161BE94FCB00F6CBB2"
    2.33 -               BuildableName = "pEpObjCAdapterTests.xctest"
    2.34 -               BlueprintName = "pEpObjCAdapterTests"
    2.35 -               ReferencedContainer = "container:pEpObjCAdapter.xcodeproj">
    2.36 -            </BuildableReference>
    2.37 -         </TestableReference>
    2.38        </Testables>
    2.39 -      <MacroExpansion>
    2.40 -         <BuildableReference
    2.41 -            BuildableIdentifier = "primary"
    2.42 -            BlueprintIdentifier = "43E3985A221D7E56008E7983"
    2.43 -            BuildableName = "PEPObjCAdapterFramework.framework"
    2.44 -            BlueprintName = "PEPObjCAdapterFramework"
    2.45 -            ReferencedContainer = "container:pEpObjCAdapter.xcodeproj">
    2.46 -         </BuildableReference>
    2.47 -      </MacroExpansion>
    2.48        <AdditionalOptions>
    2.49        </AdditionalOptions>
    2.50     </TestAction>
    2.51 @@ -111,3 +78,36 @@
    2.52        revealArchiveInOrganizer = "YES">
    2.53     </ArchiveAction>
    2.54  </Scheme>
    2.55 +            BlueprintIdentifier = "43E3985A221D7E56008E7983"
    2.56 +            BuildableName = "PEPObjCAdapterFramework.framework"
    2.57 +            BlueprintName = "PEPObjCAdapterFramework"
    2.58 +            ReferencedContainer = "container:pEpObjCAdapter.xcodeproj">
    2.59 +         </BuildableReference>
    2.60 +      </MacroExpansion>
    2.61 +      <AdditionalOptions>
    2.62 +      </AdditionalOptions>
    2.63 +   </LaunchAction>
    2.64 +   <ProfileAction
    2.65 +      buildConfiguration = "Release"
    2.66 +      shouldUseLaunchSchemeArgsEnv = "YES"
    2.67 +      savedToolIdentifier = ""
    2.68 +      useCustomWorkingDirectory = "NO"
    2.69 +      debugDocumentVersioning = "YES">
    2.70 +      <MacroExpansion>
    2.71 +         <BuildableReference
    2.72 +            BuildableIdentifier = "primary"
    2.73 +            BlueprintIdentifier = "43E3985A221D7E56008E7983"
    2.74 +            BuildableName = "PEPObjCAdapterFramework.framework"
    2.75 +            BlueprintName = "PEPObjCAdapterFramework"
    2.76 +            ReferencedContainer = "container:pEpObjCAdapter.xcodeproj">
    2.77 +         </BuildableReference>
    2.78 +      </MacroExpansion>
    2.79 +   </ProfileAction>
    2.80 +   <AnalyzeAction
    2.81 +      buildConfiguration = "Debug">
    2.82 +   </AnalyzeAction>
    2.83 +   <ArchiveAction
    2.84 +      buildConfiguration = "Release"
    2.85 +      revealArchiveInOrganizer = "YES">
    2.86 +   </ArchiveAction>
    2.87 +</Scheme>
     3.1 --- a/pEpObjCAdapter/NSError+PEP.m	Thu Aug 15 14:27:21 2019 +0200
     3.2 +++ b/pEpObjCAdapter/NSError+PEP.m	Mon Sep 02 11:51:07 2019 +0200
     3.3 @@ -152,6 +152,7 @@
     3.4          case PEP_CANNOT_CONFIG: return @"PEP_CANNOT_CONFIG";
     3.5          case PEP_SYNC_CANNOT_START: return @"PEP_SYNC_CANNOT_START";
     3.6          case PEP_SOME_KEYS_IMPORTED: return @"PEP_SOME_KEYS_IMPORTED";
     3.7 +        case PEP_CANNOT_SET_PEP_VERSION: return @"PEP_CANNOT_SET_PEP_VERSION";
     3.8      }
     3.9  }
    3.10  
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/pEpObjCAdapter/PEPInternalConstants.h	Mon Sep 02 11:51:07 2019 +0200
     4.3 @@ -0,0 +1,20 @@
     4.4 +//
     4.5 +//  PEPInternalConstants.h
     4.6 +//  PEPObjCAdapterFramework
     4.7 +//
     4.8 +//  Created by Dirk Zimmermann on 25.07.19.
     4.9 +//  Copyright © 2019 p≡p. All rights reserved.
    4.10 +//
    4.11 +
    4.12 +#import <Foundation/Foundation.h>
    4.13 +
    4.14 +NS_ASSUME_NONNULL_BEGIN
    4.15 +
    4.16 +@interface PEPInternalConstants : NSObject
    4.17 +
    4.18 +/** Constant for the string undefined */
    4.19 +extern NSString *const _Nonnull kUndefined;
    4.20 +
    4.21 +@end
    4.22 +
    4.23 +NS_ASSUME_NONNULL_END
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/pEpObjCAdapter/PEPInternalConstants.m	Mon Sep 02 11:51:07 2019 +0200
     5.3 @@ -0,0 +1,15 @@
     5.4 +//
     5.5 +//  PEPInternalConstants.m
     5.6 +//  PEPObjCAdapterFramework
     5.7 +//
     5.8 +//  Created by Dirk Zimmermann on 25.07.19.
     5.9 +//  Copyright © 2019 p≡p. All rights reserved.
    5.10 +//
    5.11 +
    5.12 +#import "PEPInternalConstants.h"
    5.13 +
    5.14 +@implementation PEPInternalConstants
    5.15 +
    5.16 +NSString *const kUndefined = @"undefined";
    5.17 +
    5.18 +@end
     6.1 --- a/pEpObjCAdapter/PEPInternalSession.h	Thu Aug 15 14:27:21 2019 +0200
     6.2 +++ b/pEpObjCAdapter/PEPInternalSession.h	Mon Sep 02 11:51:07 2019 +0200
     6.3 @@ -27,6 +27,8 @@
     6.4  
     6.5  @property (nonatomic) PEP_SESSION _Nullable session;
     6.6  
     6.7 +- (_Nullable instancetype)init;
     6.8 +
     6.9  /**
    6.10   Configures the session's unecryptedSubjectEnabled value.
    6.11  
     7.1 --- a/pEpObjCAdapter/PEPInternalSession.m	Thu Aug 15 14:27:21 2019 +0200
     7.2 +++ b/pEpObjCAdapter/PEPInternalSession.m	Mon Sep 02 11:51:07 2019 +0200
     7.3 @@ -26,12 +26,13 @@
     7.4  #import "NSMutableDictionary+PEP.h"
     7.5  #import "PEPSync_Internal.h"
     7.6  #import "PEPIdentity+Internal.h"
     7.7 +#import "PEPInternalConstants.h"
     7.8  
     7.9  #import "key_reset.h"
    7.10  
    7.11  @implementation PEPInternalSession
    7.12  
    7.13 -- (instancetype)init
    7.14 +- (_Nullable instancetype)init
    7.15  {
    7.16      self = [super init];
    7.17      if (self) {
    7.18 @@ -49,7 +50,9 @@
    7.19  
    7.20  - (void)dealloc
    7.21  {
    7.22 -    release(_session);
    7.23 +    if (_session != nil) {
    7.24 +        release(_session);
    7.25 +    }
    7.26  }
    7.27  
    7.28  #pragma mark - CONFIG
    7.29 @@ -829,7 +832,7 @@
    7.30        [NSNumber numberWithInteger:PEPRatingMistrust]: @"mistrust",
    7.31        [NSNumber numberWithInteger:PEPRatingB0rken]: @"b0rken",
    7.32        [NSNumber numberWithInteger:PEPRatingUnderAttack]: @"under_attack",
    7.33 -      [NSNumber numberWithInteger:PEPRatingUndefined]: @"undefined",
    7.34 +      [NSNumber numberWithInteger:PEPRatingUndefined]: kUndefined,
    7.35        };
    7.36      NSMutableDictionary *stringToRatingMutable = [NSMutableDictionary
    7.37                                                    dictionaryWithCapacity:
    7.38 @@ -858,7 +861,7 @@
    7.39      if (stringRating) {
    7.40          return stringRating;
    7.41      } else {
    7.42 -        return @"undefined";
    7.43 +        return kUndefined;
    7.44      }
    7.45  }
    7.46  
     8.1 --- a/pEpObjCAdapter/PEPSession.m	Thu Aug 15 14:27:21 2019 +0200
     8.2 +++ b/pEpObjCAdapter/PEPSession.m	Mon Sep 02 11:51:07 2019 +0200
     8.3 @@ -14,9 +14,26 @@
     8.4  
     8.5  #import "PEPMessageUtil.h"
     8.6  #import "NSNumber+PEPRating.h"
     8.7 +#import "NSError+PEP+Internal.h"
     8.8 +#import "PEPInternalConstants.h"
     8.9  
    8.10  @implementation PEPSession
    8.11  
    8.12 +/**
    8.13 + Macro for causing a return if the given session is nil, optionally setting an error.
    8.14 +
    8.15 + @param session A session object that will be checked for being nil or not.
    8.16 + @param error If non-nil, will receive PEP_UNKNOWN_ERROR when the session is nil.
    8.17 + @param what The value to return in case of an error (session is nil).
    8.18 + */
    8.19 +#define RETURN_ON_ERROR(session, error, what)\
    8.20 +  if (session == nil) { \
    8.21 +    if (error != nil) { \
    8.22 +      *error = [NSError errorWithPEPStatusInternal:PEP_UNKNOWN_ERROR]; \
    8.23 +      return what; \
    8.24 +    } \
    8.25 +  }
    8.26 +
    8.27  #pragma mark - Public API
    8.28  
    8.29  + (void)cleanup
    8.30 @@ -32,6 +49,7 @@
    8.31                                      error:(NSError * _Nullable * _Nullable)error
    8.32  {
    8.33      PEPInternalSession *session = [PEPSessionProvider session];
    8.34 +    RETURN_ON_ERROR(session, error, nil);
    8.35      return [session
    8.36              decryptMessageDict:messageDict
    8.37              flags:flags
    8.38 @@ -49,6 +67,7 @@
    8.39                                     error:(NSError * _Nullable * _Nullable)error
    8.40  {
    8.41      PEPInternalSession *session = [PEPSessionProvider session];
    8.42 +    RETURN_ON_ERROR(session, error, nil);
    8.43      return [session
    8.44              decryptMessage:message
    8.45              flags:flags
    8.46 @@ -65,6 +84,7 @@
    8.47                          error:(NSError * _Nullable * _Nullable)error
    8.48  {
    8.49      PEPInternalSession *session = [PEPSessionProvider session];
    8.50 +    RETURN_ON_ERROR(session, error, NO);
    8.51      return [session reEvaluateMessageDict:messageDict
    8.52                                   xKeyList:xKeyList
    8.53                                     rating:rating
    8.54 @@ -79,6 +99,7 @@
    8.55                      error:(NSError * _Nullable * _Nullable)error
    8.56  {
    8.57      PEPInternalSession *session = [PEPSessionProvider session];
    8.58 +    RETURN_ON_ERROR(session, error, NO);
    8.59      return [session reEvaluateMessage:message
    8.60                               xKeyList:xKeyList
    8.61                                 rating:rating
    8.62 @@ -93,6 +114,7 @@
    8.63                                      error:(NSError * _Nullable * _Nullable)error
    8.64  {
    8.65      PEPInternalSession *session = [PEPSessionProvider session];
    8.66 +    RETURN_ON_ERROR(session, error, nil);
    8.67      return [session
    8.68              encryptMessageDict:messageDict
    8.69              extraKeys:extraKeys
    8.70 @@ -108,6 +130,7 @@
    8.71                                     error:(NSError * _Nullable * _Nullable)error
    8.72  {
    8.73      PEPInternalSession *session = [PEPSessionProvider session];
    8.74 +    RETURN_ON_ERROR(session, error, nil);
    8.75      return [session
    8.76              encryptMessage:message
    8.77              extraKeys:extraKeys
    8.78 @@ -122,6 +145,7 @@
    8.79                                     error:(NSError * _Nullable * _Nullable)error
    8.80  {
    8.81      PEPInternalSession *session = [PEPSessionProvider session];
    8.82 +    RETURN_ON_ERROR(session, error, nil);
    8.83      return [session encryptMessage:message extraKeys:extraKeys status:status error:error];
    8.84  }
    8.85  
    8.86 @@ -132,6 +156,7 @@
    8.87                                      error:(NSError * _Nullable * _Nullable)error
    8.88  {
    8.89      PEPInternalSession *session = [PEPSessionProvider session];
    8.90 +    RETURN_ON_ERROR(session, error, nil);
    8.91      return [session
    8.92              encryptMessageDict:messageDict
    8.93              forSelf:ownIdentity
    8.94 @@ -147,6 +172,7 @@
    8.95                                     error:(NSError * _Nullable * _Nullable)error
    8.96  {
    8.97      PEPInternalSession *session = [PEPSessionProvider session];
    8.98 +    RETURN_ON_ERROR(session, error, nil);
    8.99      return [session
   8.100              encryptMessage:message
   8.101              forSelf:ownIdentity
   8.102 @@ -163,6 +189,7 @@
   8.103                                      error:(NSError * _Nullable * _Nullable)error __deprecated
   8.104  {
   8.105      PEPInternalSession *session = [PEPSessionProvider session];
   8.106 +    RETURN_ON_ERROR(session, error, nil);
   8.107      return [session
   8.108              encryptMessageDict:messageDict
   8.109              toFpr:toFpr
   8.110 @@ -180,6 +207,7 @@
   8.111                                     error:(NSError * _Nullable * _Nullable)error
   8.112  {
   8.113      PEPInternalSession *session = [PEPSessionProvider session];
   8.114 +    RETURN_ON_ERROR(session, error, nil);
   8.115      return [session
   8.116              encryptMessage:message
   8.117              toFpr:toFpr
   8.118 @@ -193,6 +221,7 @@
   8.119                                             error:(NSError * _Nullable * _Nullable)error
   8.120  {
   8.121      PEPInternalSession *session = [PEPSessionProvider session];
   8.122 +    RETURN_ON_ERROR(session, error, nil);
   8.123      return [session outgoingRatingForMessage:theMessage error:error];
   8.124  }
   8.125  
   8.126 @@ -200,6 +229,7 @@
   8.127                                                    error:(NSError * _Nullable * _Nullable)error
   8.128  {
   8.129      PEPInternalSession *session = [PEPSessionProvider session];
   8.130 +    RETURN_ON_ERROR(session, error, nil);
   8.131      return [session outgoingRatingPreviewForMessage:theMessage error:error];
   8.132  }
   8.133  
   8.134 @@ -207,6 +237,7 @@
   8.135                                      error:(NSError * _Nullable * _Nullable)error
   8.136  {
   8.137      PEPInternalSession *session = [PEPSessionProvider session];
   8.138 +    RETURN_ON_ERROR(session, error, nil);
   8.139      return [session ratingForIdentity:identity error:error];
   8.140  }
   8.141  
   8.142 @@ -216,6 +247,7 @@
   8.143                                            error:(NSError * _Nullable * _Nullable)error
   8.144  {
   8.145      PEPInternalSession *session = [PEPSessionProvider session];
   8.146 +    RETURN_ON_ERROR(session, error, nil);
   8.147      return [session
   8.148              trustwordsForFingerprint:fingerprint
   8.149              languageID:languageID
   8.150 @@ -226,6 +258,7 @@
   8.151  - (BOOL)mySelf:(PEPIdentity * _Nonnull)identity error:(NSError * _Nullable * _Nullable)error
   8.152  {
   8.153      PEPInternalSession *session = [PEPSessionProvider session];
   8.154 +    RETURN_ON_ERROR(session, error, NO);
   8.155      return [session mySelf:identity error:error];
   8.156  }
   8.157  
   8.158 @@ -233,6 +266,7 @@
   8.159                   error:(NSError * _Nullable * _Nullable)error
   8.160  {
   8.161      PEPInternalSession *session = [PEPSessionProvider session];
   8.162 +    RETURN_ON_ERROR(session, error, NO);
   8.163      return [session updateIdentity:identity error:error];
   8.164  }
   8.165  
   8.166 @@ -240,6 +274,7 @@
   8.167                     error:(NSError * _Nullable * _Nullable)error
   8.168  {
   8.169      PEPInternalSession *session = [PEPSessionProvider session];
   8.170 +    RETURN_ON_ERROR(session, error, NO);
   8.171      return [session trustPersonalKey:identity error:error];
   8.172  }
   8.173  
   8.174 @@ -247,6 +282,7 @@
   8.175                  error:(NSError * _Nullable * _Nullable)error
   8.176  {
   8.177      PEPInternalSession *session = [PEPSessionProvider session];
   8.178 +    RETURN_ON_ERROR(session, error, NO);
   8.179      return [session keyMistrusted:identity error:error];
   8.180  }
   8.181  
   8.182 @@ -254,6 +290,7 @@
   8.183                  error:(NSError * _Nullable * _Nullable)error
   8.184  {
   8.185      PEPInternalSession *session = [PEPSessionProvider session];
   8.186 +    RETURN_ON_ERROR(session, error, NO);
   8.187      return [session keyResetTrust:identity error:error];
   8.188  }
   8.189  
   8.190 @@ -263,6 +300,7 @@
   8.191                             error:(NSError * _Nullable * _Nullable)error
   8.192  {
   8.193      PEPInternalSession *session = [PEPSessionProvider session];
   8.194 +    RETURN_ON_ERROR(session, error, nil);
   8.195      return [session importKey:keydata error:error];
   8.196  }
   8.197  
   8.198 @@ -273,6 +311,7 @@
   8.199             error:(NSError * _Nullable * _Nullable)error
   8.200  {
   8.201      PEPInternalSession *session = [PEPSessionProvider session];
   8.202 +    RETURN_ON_ERROR(session, error, NO);
   8.203      return [session
   8.204              logTitle:title
   8.205              entity:entity
   8.206 @@ -284,6 +323,7 @@
   8.207  - (NSString * _Nullable)getLogWithError:(NSError * _Nullable * _Nullable)error
   8.208  {
   8.209      PEPInternalSession *session = [PEPSessionProvider session];
   8.210 +    RETURN_ON_ERROR(session, error, nil);
   8.211      return [session getLogWithError:error];
   8.212  }
   8.213  
   8.214 @@ -294,6 +334,7 @@
   8.215                                           error:(NSError * _Nullable * _Nullable)error
   8.216  {
   8.217      PEPInternalSession *session = [PEPSessionProvider session];
   8.218 +    RETURN_ON_ERROR(session, error, nil);
   8.219      return [session getTrustwordsIdentity1:identity1
   8.220                                   identity2:identity2
   8.221                                    language:language
   8.222 @@ -308,24 +349,32 @@
   8.223                                      error:(NSError * _Nullable * _Nullable)error
   8.224  {
   8.225      PEPInternalSession *session = [PEPSessionProvider session];
   8.226 +    RETURN_ON_ERROR(session, error, nil);
   8.227      return [session getTrustwordsFpr1:fpr1 fpr2:fpr2 language:language full:full error:error];
   8.228  }
   8.229  
   8.230  - (NSArray<PEPLanguage *> * _Nullable)languageListWithError:(NSError * _Nullable * _Nullable)error
   8.231  {
   8.232      PEPInternalSession *session = [PEPSessionProvider session];
   8.233 +    RETURN_ON_ERROR(session, error, nil);
   8.234      return [session languageListWithError:error];
   8.235  }
   8.236  
   8.237  - (PEPRating)ratingFromString:(NSString * _Nonnull)string
   8.238  {
   8.239      PEPInternalSession *session = [PEPSessionProvider session];
   8.240 +    if (session == nil) {
   8.241 +        return PEPRatingUndefined;
   8.242 +    }
   8.243      return [session ratingFromString:string];
   8.244  }
   8.245  
   8.246  - (NSString * _Nonnull)stringFromRating:(PEPRating)rating
   8.247  {
   8.248      PEPInternalSession *session = [PEPSessionProvider session];
   8.249 +    if (session == nil) {
   8.250 +        return kUndefined;
   8.251 +    }
   8.252      return [session stringFromRating:rating];
   8.253  }
   8.254  
   8.255 @@ -333,6 +382,7 @@
   8.256                              error:(NSError * _Nullable * _Nullable)error
   8.257  {
   8.258      PEPInternalSession *session = [PEPSessionProvider session];
   8.259 +    RETURN_ON_ERROR(session, error, nil);
   8.260      return [session isPEPUser:identity error:error];
   8.261  }
   8.262  
   8.263 @@ -340,6 +390,7 @@
   8.264              error:(NSError * _Nullable * _Nullable)error
   8.265  {
   8.266      PEPInternalSession *session = [PEPSessionProvider session];
   8.267 +    RETURN_ON_ERROR(session, error, NO);
   8.268      return [session setOwnKey:identity fingerprint:fingerprint error:error];
   8.269  }
   8.270  
   8.271 @@ -354,6 +405,7 @@
   8.272             error:(NSError * _Nullable * _Nullable)error
   8.273  {
   8.274      PEPInternalSession *session = [PEPSessionProvider session];
   8.275 +    RETURN_ON_ERROR(session, error, NO);
   8.276      return [session setFlags:flags forIdentity:identity error:error];
   8.277  }
   8.278  
   8.279 @@ -361,6 +413,7 @@
   8.280                        error:(NSError * _Nullable * _Nullable)error
   8.281  {
   8.282      PEPInternalSession *session = [PEPSessionProvider session];
   8.283 +    RETURN_ON_ERROR(session, error, NO);
   8.284      return [session trustOwnKeyIdentity:identity error:error];
   8.285  }
   8.286  
   8.287 @@ -369,12 +422,16 @@
   8.288                           error:(NSError * _Nullable * _Nullable)error;
   8.289  {
   8.290      PEPInternalSession *session = [PEPSessionProvider session];
   8.291 +    RETURN_ON_ERROR(session, error, NO);
   8.292      return [session deliverHandshakeResult:result identitiesSharing:identitiesSharing error:error];
   8.293  }
   8.294  
   8.295  - (PEPColor)colorFromRating:(PEPRating)rating
   8.296  {
   8.297      PEPInternalSession *session = [PEPSessionProvider session];
   8.298 +    if (session == nil) {
   8.299 +        return PEPColorNoColor;
   8.300 +    }
   8.301      return [session colorFromRating:rating];
   8.302  }
   8.303  
   8.304 @@ -383,12 +440,14 @@
   8.305             error:(NSError * _Nullable * _Nullable)error
   8.306  {
   8.307      PEPInternalSession *session = [PEPSessionProvider session];
   8.308 +    RETURN_ON_ERROR(session, error, NO);
   8.309      return [session keyReset:identity fingerprint:fingerprint error:error];
   8.310  }
   8.311  
   8.312  - (BOOL)leaveDeviceGroupError:(NSError * _Nullable * _Nullable)error
   8.313  {
   8.314      PEPInternalSession *session = [PEPSessionProvider session];
   8.315 +    RETURN_ON_ERROR(session, error, NO);
   8.316      return [session leaveDeviceGroupError:error];
   8.317  }
   8.318  
     9.1 --- a/pEpObjCAdapter/PEPSync.m	Thu Aug 15 14:27:21 2019 +0200
     9.2 +++ b/pEpObjCAdapter/PEPSync.m	Mon Sep 02 11:51:07 2019 +0200
     9.3 @@ -22,7 +22,9 @@
     9.4  #import "PEPSessionProvider.h"
     9.5  #import "PEPInternalSession.h"
     9.6  
     9.7 -// MARK: - Declare internals
     9.8 +// MARK: - Internals
     9.9 +
    9.10 +os_log_t s_logger;
    9.11  
    9.12  typedef PEP_STATUS (* t_messageToSendCallback)(struct _message *msg);
    9.13  typedef int (* t_injectSyncCallback)(SYNC_EVENT ev, void *management);
    9.14 @@ -34,7 +36,6 @@
    9.15  @property (nonatomic, nonnull) PEPQueue *queue;
    9.16  @property (nonatomic, nullable) NSThread *syncThread;
    9.17  @property (nonatomic, nullable) NSConditionLock *conditionLockForJoiningSyncThread;
    9.18 -@property (nonnull, readonly) os_log_t logger;
    9.19  
    9.20  /**
    9.21   @Return: The callback for message sending that should be used on every session init.
    9.22 @@ -132,6 +133,7 @@
    9.23      if (status != PEP_STATUS_OK) {
    9.24          if (error) {
    9.25              *error = [NSError errorWithPEPStatusInternal:status];
    9.26 +            os_log(s_logger, "error creating session: %{public}@", *error);
    9.27          }
    9.28          return nil;
    9.29      }
    9.30 @@ -145,7 +147,6 @@
    9.31                                               _Nullable)notifyHandshakeDelegate
    9.32  {
    9.33      if (self = [super init]) {
    9.34 -        _logger = os_log_create("security.pEp.adapter", "PEPSync");
    9.35          _sendMessageDelegate = sendMessageDelegate;
    9.36          _notifyHandshakeDelegate = notifyHandshakeDelegate;
    9.37          _queue = [PEPQueue new];
    9.38 @@ -179,6 +180,11 @@
    9.39  
    9.40  // MARK: - Private
    9.41  
    9.42 ++ (void)initialize
    9.43 +{
    9.44 +    s_logger = os_log_create("security.pEp.adapter", "PEPSync");
    9.45 +}
    9.46 +
    9.47  + (PEPSync * _Nullable)instance
    9.48  {
    9.49      return s_pEpSync;
    9.50 @@ -193,7 +199,7 @@
    9.51  {
    9.52      [self.conditionLockForJoiningSyncThread lock];
    9.53  
    9.54 -    os_log(self.logger, "trying to start the sync loop");
    9.55 +    os_log(s_logger, "trying to start the sync loop");
    9.56  
    9.57      PEPInternalSession *session = [PEPSessionProvider session];
    9.58  
    9.59 @@ -203,19 +209,19 @@
    9.60          if (status == PEP_STATUS_OK) {
    9.61              status = do_sync_protocol(session.session, nil);
    9.62              if (status != PEP_STATUS_OK) {
    9.63 -                os_log_error(self.logger, "do_sync_protocol returned PEP_STATUS %d", status);
    9.64 -                os_log(self.logger, "sync loop is NOT running");
    9.65 +                os_log_error(s_logger, "do_sync_protocol returned PEP_STATUS %d", status);
    9.66 +                os_log(s_logger, "sync loop is NOT running");
    9.67              }
    9.68              unregister_sync_callbacks(session.session);
    9.69          } else {
    9.70 -            os_log_error(self.logger, "register_sync_callbacks returned PEP_STATUS %d", status);
    9.71 -            os_log(self.logger, "sync loop is NOT running");
    9.72 +            os_log_error(s_logger, "register_sync_callbacks returned PEP_STATUS %d", status);
    9.73 +            os_log(s_logger, "sync loop is NOT running");
    9.74          }
    9.75      } else {
    9.76 -        os_log_error(self.logger, "could not create session for starting the sync loop");
    9.77 +        os_log_error(s_logger, "could not create session for starting the sync loop");
    9.78      }
    9.79  
    9.80 -    os_log(self.logger, "sync loop finished");
    9.81 +    os_log(s_logger, "sync loop finished");
    9.82  
    9.83      session = nil;
    9.84  
    10.1 --- a/pEpObjCAdapterFramework/PEPEngineTypes.h	Thu Aug 15 14:27:21 2019 +0200
    10.2 +++ b/pEpObjCAdapterFramework/PEPEngineTypes.h	Mon Sep 02 11:51:07 2019 +0200
    10.3 @@ -83,6 +83,7 @@
    10.4      PEPStatusCannotSetTrust                            = 0x0384, // PEP_CANNOT_SET_TRUST
    10.5      PEPStatusKeyBlacklisted                             = 0x0385, // PEP_KEY_BLACKLISTED
    10.6      PEPStatusCannotFindPerson                          = 0x0386, // PEP_CANNOT_FIND_PERSON
    10.7 +    PEPStatusCannotSetPEPVersion = 0X0387, // PEP_CANNOT_SET_PEP_VERSION
    10.8  
    10.9      PEPStatusCannotFindAlias                           = 0x0391, // PEP_CANNOT_FIND_ALIAS
   10.10      PEPStatusCannotSetAlias                            = 0x0392, // PEP_CANNOT_SET_ALIAS
   10.11 @@ -172,6 +173,9 @@
   10.12      // handshake dialog must be closed
   10.13      PEPSyncHandshakeSignalOvertaken = 9, // SYNC_NOTIFY_OVERTAKEN = 9,
   10.14  
   10.15 +    /** currently exchanging private keys */
   10.16 +    PEPSyncHandshakeSignalFormingGroup = 10, // SYNC_NOTIFY_FORMING_GROUP = 10
   10.17 +
   10.18      // notificaton of actual group status
   10.19      PEPSyncHandshakeSignalSole = 254, // SYNC_NOTIFY_SOLE = 254,
   10.20      PEPSyncHandshakeSignalInGroup = 255 // SYNC_NOTIFY_IN_GROUP = 255
    11.1 --- a/pEpObjCAdapterFramework/PEPSessionProtocol.h	Thu Aug 15 14:27:21 2019 +0200
    11.2 +++ b/pEpObjCAdapterFramework/PEPSessionProtocol.h	Mon Sep 02 11:51:07 2019 +0200
    11.3 @@ -242,6 +242,7 @@
    11.4  
    11.5  /**
    11.6   Wraps the engine's `config_passive_mode`.
    11.7 + @note That there's absolutely no error handling.
    11.8   */
    11.9  - (void)configurePassiveModeEnabled:(BOOL)enabled;
   11.10