IOSAD-90 extraKeys for encrypt to self
authorDirk Zimmermann <dirk@pep-project.org>
Fri, 06 Apr 2018 09:13:32 +0200
changeset 5568f0dfa74c08b
parent 555 770d5f569ac9
child 557 7cf2f6710453
IOSAD-90 extraKeys for encrypt to self
pEpObjCAdapter/PEPInternalSession.m
pEpObjCAdapter/PEPSession.m
pEpObjCAdapter/PEPSessionProtocol.h
pEpObjCTests/PEPSessionTest.m
     1.1 --- a/pEpObjCAdapter/PEPInternalSession.m	Wed Apr 04 19:49:57 2018 +0200
     1.2 +++ b/pEpObjCAdapter/PEPInternalSession.m	Fri Apr 06 09:13:32 2018 +0200
     1.3 @@ -305,6 +305,7 @@
     1.4  
     1.5  - (PEPDict * _Nullable)encryptMessageDict:(PEPDict * _Nonnull)messageDict
     1.6                                   identity:(PEPIdentity * _Nonnull)identity
     1.7 +                                extraKeys:(PEPStringList * _Nullable)extraKeys
     1.8                                     status:(PEP_STATUS * _Nullable)status
     1.9                                      error:(NSError * _Nullable * _Nullable)error
    1.10  {
    1.11 @@ -314,15 +315,20 @@
    1.12      pEp_identity *ident = PEP_identityToStruct(identity);
    1.13      message *_dst = NULL;
    1.14  
    1.15 +    stringlist_t *keysStringList = PEP_arrayToStringlist(extraKeys);
    1.16 +
    1.17      [self lockWrite];
    1.18      PEP_STATUS theStatus = encrypt_message_for_self(_session,
    1.19                                                      ident,
    1.20                                                      _src,
    1.21 +                                                    keysStringList,
    1.22                                                      &_dst,
    1.23                                                      PEP_enc_PGP_MIME,
    1.24                                                      flags);
    1.25      [self unlockWrite];
    1.26  
    1.27 +    free_stringlist(keysStringList);
    1.28 +
    1.29      if (status) {
    1.30          *status = theStatus;
    1.31      }
    1.32 @@ -349,12 +355,14 @@
    1.33  
    1.34  - (PEPMessage * _Nullable)encryptMessage:(PEPMessage * _Nonnull)message
    1.35                                  identity:(PEPIdentity * _Nonnull)identity
    1.36 +                               extraKeys:(PEPStringList * _Nullable)extraKeys
    1.37                                    status:(PEP_STATUS * _Nullable)status
    1.38                                     error:(NSError * _Nullable * _Nullable)error
    1.39  {
    1.40      PEPDict *target = [self
    1.41                         encryptMessageDict:message.dictionary
    1.42                         identity:identity
    1.43 +                       extraKeys:extraKeys
    1.44                         status:status
    1.45                         error:error];
    1.46  
     2.1 --- a/pEpObjCAdapter/PEPSession.m	Wed Apr 04 19:49:57 2018 +0200
     2.2 +++ b/pEpObjCAdapter/PEPSession.m	Fri Apr 06 09:13:32 2018 +0200
     2.3 @@ -110,20 +110,32 @@
     2.4  
     2.5  - (PEPDict * _Nullable)encryptMessageDict:(PEPDict * _Nonnull)messageDict
     2.6                                   identity:(PEPIdentity * _Nonnull)identity
     2.7 +                                extraKeys:(PEPStringList * _Nullable)extraKeys
     2.8                                     status:(PEP_STATUS * _Nullable)status
     2.9                                      error:(NSError * _Nullable * _Nullable)error
    2.10  {
    2.11      PEPInternalSession *session = [PEPSessionProvider session];
    2.12 -    return [session encryptMessageDict:messageDict identity:identity status:status error:error];
    2.13 +    return [session
    2.14 +            encryptMessageDict:messageDict
    2.15 +            identity:identity
    2.16 +            extraKeys:extraKeys
    2.17 +            status:status
    2.18 +            error:error];
    2.19  }
    2.20  
    2.21  - (PEPMessage * _Nullable)encryptMessage:(PEPMessage * _Nonnull)message
    2.22                                  identity:(PEPIdentity * _Nonnull)identity
    2.23 +                               extraKeys:(PEPStringList * _Nullable)extraKeys
    2.24                                    status:(PEP_STATUS * _Nullable)status
    2.25                                     error:(NSError * _Nullable * _Nullable)error
    2.26  {
    2.27      PEPInternalSession *session = [PEPSessionProvider session];
    2.28 -    return [session encryptMessage:message identity:identity status:status error:error];
    2.29 +    return [session
    2.30 +            encryptMessage:message
    2.31 +            identity:identity
    2.32 +            extraKeys:extraKeys
    2.33 +            status:status
    2.34 +            error:error];
    2.35  }
    2.36  
    2.37  - (BOOL)outgoingRating:(PEP_rating * _Nonnull)rating
     3.1 --- a/pEpObjCAdapter/PEPSessionProtocol.h	Wed Apr 04 19:49:57 2018 +0200
     3.2 +++ b/pEpObjCAdapter/PEPSessionProtocol.h	Fri Apr 06 09:13:32 2018 +0200
     3.3 @@ -75,12 +75,14 @@
     3.4  /** Encrypt a message dict for the given own identity */
     3.5  - (PEPDict * _Nullable)encryptMessageDict:(PEPDict * _Nonnull)messageDict
     3.6                                   identity:(PEPIdentity * _Nonnull)identity
     3.7 +                                extraKeys:(PEPStringList * _Nullable)extraKeys
     3.8                                     status:(PEP_STATUS * _Nullable)status
     3.9                                      error:(NSError * _Nullable * _Nullable)error __deprecated;
    3.10  
    3.11  /** Encrypt a message for the given own identity */
    3.12  - (PEPMessage * _Nullable)encryptMessage:(PEPMessage * _Nonnull)message
    3.13                                  identity:(PEPIdentity * _Nonnull)identity
    3.14 +                               extraKeys:(PEPStringList * _Nullable)extraKeys
    3.15                                    status:(PEP_STATUS * _Nullable)status
    3.16                                     error:(NSError * _Nullable * _Nullable)error;
    3.17  
     4.1 --- a/pEpObjCTests/PEPSessionTest.m	Wed Apr 04 19:49:57 2018 +0200
     4.2 +++ b/pEpObjCTests/PEPSessionTest.m	Fri Apr 06 09:13:32 2018 +0200
     4.3 @@ -397,6 +397,7 @@
     4.4          PEPMessage *encMsg = [innerSession
     4.5                                encryptMessage:msg
     4.6                                identity:me
     4.7 +                              extraKeys:nil
     4.8                                status:&status error:&error];
     4.9          XCTAssertEqual(status, PEP_STATUS_OK);
    4.10          XCTAssertNotNil(encMsg);
    4.11 @@ -1263,7 +1264,12 @@
    4.12                                    longMessage:longMessage
    4.13                                       outgoing:YES];
    4.14      PEP_STATUS status = PEP_UNKNOWN_ERROR;
    4.15 -    PEPMessage *encMessage = [session encryptMessage:mail identity:me status:&status error:&error];
    4.16 +    PEPMessage *encMessage = [session
    4.17 +                              encryptMessage:mail
    4.18 +                              identity:me
    4.19 +                              extraKeys:nil
    4.20 +                              status:&status
    4.21 +                              error:&error];
    4.22      XCTAssertNil(error);
    4.23  
    4.24      return encMessage;
    4.25 @@ -1287,7 +1293,12 @@
    4.26      PEPMessage *mail = [PEPTestUtils mailFrom:me toIdent:me shortMessage:shortMessage longMessage:longMessage outgoing:YES];
    4.27  
    4.28      PEP_STATUS status;
    4.29 -    PEPMessage *encMessage = [session encryptMessage:mail identity:me status:&status error:&error];
    4.30 +    PEPMessage *encMessage = [session
    4.31 +                              encryptMessage:mail
    4.32 +                              identity:me
    4.33 +                              extraKeys:nil
    4.34 +                              status:&status
    4.35 +                              error:&error];
    4.36      XCTAssertEqual(status, 0);
    4.37      XCTAssertEqualObjects(encMessage.shortMessage, @"p≡p");
    4.38  
    4.39 @@ -1359,7 +1370,12 @@
    4.40  
    4.41      PEP_STATUS statusEnc = PEP_VERSION_MISMATCH;
    4.42      if (toSelf) {
    4.43 -        encMsg = [session encryptMessage:msg identity:identMe status:&statusEnc error:&error];
    4.44 +        encMsg = [session
    4.45 +                  encryptMessage:msg
    4.46 +                  identity:identMe
    4.47 +                  extraKeys:nil
    4.48 +                  status:&statusEnc
    4.49 +                  error:&error];
    4.50          XCTAssertEqual(statusEnc, PEP_STATUS_OK);
    4.51      } else {
    4.52          encMsg = [session encryptMessage:msg extraKeys:nil status:nil error:&error];