IOSAD-72 clean up encrypt/decrypt API, argument names
authorDirk Zimmermann <dirk@pep-project.org>
Mon, 12 Mar 2018 12:08:39 +0100
changeset 5233d167bef8afa
parent 522 534d277b410d
child 524 60dbfc88af73
IOSAD-72 clean up encrypt/decrypt API, argument names
pEpObjCAdapter/PEPInternalSession.m
pEpObjCAdapter/PEPSession.m
pEpObjCAdapter/PEPSessionProtocol.h
pEpObjCTests/PEPSessionTest.m
     1.1 --- a/pEpObjCAdapter/PEPInternalSession.m	Mon Mar 12 12:08:38 2018 +0100
     1.2 +++ b/pEpObjCAdapter/PEPInternalSession.m	Mon Mar 12 12:08:39 2018 +0100
     1.3 @@ -98,7 +98,7 @@
     1.4  
     1.5  - (PEPDict * _Nullable)decryptMessageDict:(nonnull PEPDict *)messageDict
     1.6                                     rating:(PEP_rating * _Nullable)rating
     1.7 -                                     keys:(PEPStringList * _Nullable * _Nullable)keys
     1.8 +                                extraKeys:(PEPStringList * _Nullable * _Nullable)extraKeys
     1.9                                      error:(NSError * _Nullable * _Nullable)error
    1.10  {
    1.11      if (rating) {
    1.12 @@ -136,8 +136,8 @@
    1.13      free_message(_dst);
    1.14      free_stringlist(_keys);
    1.15  
    1.16 -    if (keys) {
    1.17 -        *keys = keys_;
    1.18 +    if (extraKeys) {
    1.19 +        *extraKeys = keys_;
    1.20      }
    1.21  
    1.22      if (rating) {
    1.23 @@ -147,14 +147,14 @@
    1.24      return dst_;
    1.25  }
    1.26  
    1.27 -- (PEPMessage * _Nullable)decryptMessage:(nonnull PEPMessage *)src
    1.28 +- (PEPMessage * _Nullable)decryptMessage:(nonnull PEPMessage *)message
    1.29                                    rating:(PEP_rating * _Nullable)rating
    1.30 -                                    keys:(PEPStringList * _Nullable * _Nullable)keys
    1.31 +                               extraKeys:(PEPStringList * _Nullable * _Nullable)extraKeys
    1.32                                     error:(NSError * _Nullable * _Nullable)error
    1.33  {
    1.34 -    PEPDict *destDict = [self decryptMessageDict:(PEPDict *)src
    1.35 +    PEPDict *destDict = [self decryptMessageDict:(PEPDict *)message
    1.36                                            rating:rating
    1.37 -                                            keys:keys
    1.38 +                                       extraKeys:extraKeys
    1.39                                             error:error];
    1.40  
    1.41      if (!destDict) {
     2.1 --- a/pEpObjCAdapter/PEPSession.m	Mon Mar 12 12:08:38 2018 +0100
     2.2 +++ b/pEpObjCAdapter/PEPSession.m	Mon Mar 12 12:08:39 2018 +0100
     2.3 @@ -21,22 +21,22 @@
     2.4      [PEPSessionProvider cleanup];
     2.5  }
     2.6  
     2.7 -- (PEPDict * _Nullable)decryptMessageDict:(nonnull PEPDict *)src
     2.8 +- (PEPDict * _Nullable)decryptMessageDict:(nonnull PEPDict *)messageDict
     2.9                                     rating:(PEP_rating * _Nullable)rating
    2.10 -                                     keys:(PEPStringList * _Nullable * _Nullable)keys
    2.11 +                                extraKeys:(PEPStringList * _Nullable * _Nullable)extraKeys
    2.12                                      error:(NSError * _Nullable * _Nullable)error
    2.13  {
    2.14      PEPInternalSession *session = [PEPSessionProvider session];
    2.15 -    return [session decryptMessageDict:src rating:rating keys:keys error:error];
    2.16 +    return [session decryptMessageDict:messageDict rating:rating extraKeys:extraKeys error:error];
    2.17  }
    2.18  
    2.19 -- (PEPMessage * _Nullable)decryptMessage:(nonnull PEPMessage *)src
    2.20 +- (PEPMessage * _Nullable)decryptMessage:(nonnull PEPMessage *)message
    2.21                                    rating:(PEP_rating * _Nullable)rating
    2.22 -                                    keys:(PEPStringList * _Nullable * _Nullable)keys
    2.23 +                               extraKeys:(PEPStringList * _Nullable * _Nullable)extraKeys
    2.24                                     error:(NSError * _Nullable * _Nullable)error
    2.25  {
    2.26      PEPInternalSession *session = [PEPSessionProvider session];
    2.27 -    return [session decryptMessage:src rating:rating keys:keys error:error];
    2.28 +    return [session decryptMessage:message rating:rating extraKeys:extraKeys error:error];
    2.29  }
    2.30  
    2.31  - (BOOL)reEvaluateMessageDict:(nonnull PEPDict *)messageDict
    2.32 @@ -55,46 +55,50 @@
    2.33      return [session reEvaluateMessage:message rating:rating error:error];
    2.34  }
    2.35  
    2.36 -- (PEPDict * _Nullable)encryptMessageDict:(nonnull PEPDict *)src
    2.37 +- (PEPDict * _Nullable)encryptMessageDict:(nonnull PEPDict *)messageDict
    2.38                                      extraKeys:(nullable PEPStringList *)extraKeys
    2.39                                  encFormat:(PEP_enc_format)encFormat
    2.40                                      error:(NSError * _Nullable * _Nullable)error
    2.41  {
    2.42      PEPInternalSession *session = [PEPSessionProvider session];
    2.43 -    return [session encryptMessageDict:src extraKeys:extraKeys encFormat:encFormat error:error];
    2.44 +    return [session
    2.45 +            encryptMessageDict:messageDict
    2.46 +            extraKeys:extraKeys
    2.47 +            encFormat:encFormat
    2.48 +            error:error];
    2.49  }
    2.50  
    2.51 -- (PEPMessage * _Nullable)encryptMessage:(nonnull PEPMessage *)src
    2.52 -                                   extraKeys:(nullable PEPStringList *)extraKeys
    2.53 +- (PEPMessage * _Nullable)encryptMessage:(nonnull PEPMessage *)message
    2.54 +                               extraKeys:(nullable PEPStringList *)extraKeys
    2.55                                 encFormat:(PEP_enc_format)encFormat
    2.56                                     error:(NSError * _Nullable * _Nullable)error
    2.57  {
    2.58      PEPInternalSession *session = [PEPSessionProvider session];
    2.59 -    return [session encryptMessage:src extraKeys:extraKeys encFormat:encFormat error:error];
    2.60 +    return [session encryptMessage:message extraKeys:extraKeys encFormat:encFormat error:error];
    2.61  }
    2.62  
    2.63 -- (PEPMessage * _Nullable)encryptMessage:(nonnull PEPMessage *)src
    2.64 -                                   extraKeys:(nullable PEPStringList *)extraKeys
    2.65 +- (PEPMessage * _Nullable)encryptMessage:(nonnull PEPMessage *)message
    2.66 +                               extraKeys:(nullable PEPStringList *)extraKeys
    2.67                                     error:(NSError * _Nullable * _Nullable)error
    2.68  {
    2.69      PEPInternalSession *session = [PEPSessionProvider session];
    2.70 -    return [session encryptMessage:src extraKeys:extraKeys error:error];
    2.71 +    return [session encryptMessage:message extraKeys:extraKeys error:error];
    2.72  }
    2.73  
    2.74 -- (PEP_STATUS)encryptMessageDict:(nonnull PEPDict *)src
    2.75 +- (PEP_STATUS)encryptMessageDict:(nonnull PEPDict *)messageDict
    2.76                          identity:(nonnull PEPIdentity *)identity
    2.77                              dest:(PEPDict * _Nullable * _Nullable)dst
    2.78  {
    2.79      PEPInternalSession *session = [PEPSessionProvider session];
    2.80 -    return [session encryptMessageDict:src identity:identity dest:dst];
    2.81 +    return [session encryptMessageDict:messageDict identity:identity dest:dst];
    2.82  }
    2.83  
    2.84 -- (PEP_STATUS)encryptMessage:(nonnull PEPMessage *)src
    2.85 +- (PEP_STATUS)encryptMessage:(nonnull PEPMessage *)message
    2.86                      identity:(nonnull PEPIdentity *)identity
    2.87                          dest:(PEPMessage * _Nullable * _Nullable)dst
    2.88  {
    2.89      PEPInternalSession *session = [PEPSessionProvider session];
    2.90 -    return [session encryptMessage:src identity:identity dest:dst];
    2.91 +    return [session encryptMessage:message identity:identity dest:dst];
    2.92  }
    2.93  
    2.94  - (PEP_rating)outgoingColorForMessage:(nonnull PEPMessage *)message
     3.1 --- a/pEpObjCAdapter/PEPSessionProtocol.h	Mon Mar 12 12:08:38 2018 +0100
     3.2 +++ b/pEpObjCAdapter/PEPSessionProtocol.h	Mon Mar 12 12:08:39 2018 +0100
     3.3 @@ -21,15 +21,15 @@
     3.4  @protocol PEPSessionProtocol <NSObject>
     3.5  
     3.6  /** Decrypt a message */
     3.7 -- (PEPDict * _Nullable)decryptMessageDict:(nonnull PEPDict *)src
     3.8 +- (PEPDict * _Nullable)decryptMessageDict:(nonnull PEPDict *)messageDict
     3.9                                     rating:(PEP_rating * _Nullable)rating
    3.10 -                                     keys:(PEPStringList * _Nullable * _Nullable)keys
    3.11 +                                extraKeys:(PEPStringList * _Nullable * _Nullable)extraKeys
    3.12                                      error:(NSError * _Nullable * _Nullable)error __deprecated;
    3.13  
    3.14  /** Decrypt a message */
    3.15 -- (PEPMessage * _Nullable)decryptMessage:(nonnull PEPMessage *)src
    3.16 +- (PEPMessage * _Nullable)decryptMessage:(nonnull PEPMessage *)message
    3.17                                    rating:(PEP_rating * _Nullable)rating
    3.18 -                                    keys:(PEPStringList * _Nullable * _Nullable)keys
    3.19 +                               extraKeys:(PEPStringList * _Nullable * _Nullable)extraKeys
    3.20                                     error:(NSError * _Nullable * _Nullable)error;
    3.21  
    3.22  /** Re-evaluate rating of decrypted message */
    3.23 @@ -46,7 +46,7 @@
    3.24   Encrypt a message dictionary, indicating the encoding format.
    3.25   @note The resulting message dict could be the input one.
    3.26   */
    3.27 -- (PEPDict * _Nullable)encryptMessageDict:(nonnull PEPDict *)src
    3.28 +- (PEPDict * _Nullable)encryptMessageDict:(nonnull PEPDict *)messageDict
    3.29                                  extraKeys:(nullable PEPStringList *)extraKeys
    3.30                                  encFormat:(PEP_enc_format)encFormat
    3.31                                      error:(NSError * _Nullable * _Nullable)error __deprecated;
    3.32 @@ -55,23 +55,23 @@
    3.33   Encrypt a message, indicating the encoding format
    3.34   @note The resulting message dict could be the input one.
    3.35   */
    3.36 -- (PEPMessage * _Nullable)encryptMessage:(nonnull PEPMessage *)src
    3.37 +- (PEPMessage * _Nullable)encryptMessage:(nonnull PEPMessage *)message
    3.38                                 extraKeys:(nullable PEPStringList *)extraKeys
    3.39                                 encFormat:(PEP_enc_format)encFormat
    3.40                                     error:(NSError * _Nullable * _Nullable)error;
    3.41  
    3.42  /** Encrypt a message with default encryption format (PEP_enc_PEP) */
    3.43 -- (PEPMessage * _Nullable)encryptMessage:(nonnull PEPMessage *)src
    3.44 +- (PEPMessage * _Nullable)encryptMessage:(nonnull PEPMessage *)message
    3.45                                 extraKeys:(nullable PEPStringList *)extraKeys
    3.46                                     error:(NSError * _Nullable * _Nullable)error;
    3.47  
    3.48  /** Encrypt a message for the given own identity */
    3.49 -- (PEP_STATUS)encryptMessageDict:(nonnull PEPDict *)src
    3.50 +- (PEP_STATUS)encryptMessageDict:(nonnull PEPDict *)mesageDict
    3.51                          identity:(nonnull PEPIdentity *)identity
    3.52                              dest:(PEPDict * _Nullable * _Nullable)dst __deprecated;
    3.53  
    3.54  /** Encrypt a message for the given own identity */
    3.55 -- (PEP_STATUS)encryptMessage:(nonnull PEPMessage *)src
    3.56 +- (PEP_STATUS)encryptMessage:(nonnull PEPMessage *)message
    3.57                      identity:(nonnull PEPIdentity *)identity
    3.58                          dest:(PEPMessage * _Nullable * _Nullable)dst;
    3.59  
     4.1 --- a/pEpObjCTests/PEPSessionTest.m	Mon Mar 12 12:08:38 2018 +0100
     4.2 +++ b/pEpObjCTests/PEPSessionTest.m	Mon Mar 12 12:08:39 2018 +0100
     4.3 @@ -688,7 +688,7 @@
     4.4      PEPMessage *decmsg = [session
     4.5                            decryptMessage:encMsg
     4.6                            rating:&clr
     4.7 -                          keys:&keys
     4.8 +                          extraKeys:&keys
     4.9                            error:&error];
    4.10      XCTAssertNotNil(decmsg);
    4.11      XCTAssertNil(error);
    4.12 @@ -732,7 +732,7 @@
    4.13      PEPMessage *pepDecryptedMail = [session
    4.14                                      decryptMessage:msg
    4.15                                      rating:nil
    4.16 -                                    keys:&keys
    4.17 +                                    extraKeys:&keys
    4.18                                      error:&error];
    4.19      XCTAssertNotNil(pepDecryptedMail);
    4.20      XCTAssertNil(error);
    4.21 @@ -900,7 +900,7 @@
    4.22      PEPMessage *decMsg = [session
    4.23                            decryptMessage:encMsg
    4.24                            rating:&pEpRating
    4.25 -                          keys:&keys
    4.26 +                          extraKeys:&keys
    4.27                            error:&error];
    4.28      XCTAssertNotNil(decMsg);
    4.29      XCTAssertNil(error);
    4.30 @@ -1124,7 +1124,7 @@
    4.31      PEPMessage *unencDict = [session
    4.32                               decryptMessage:encMessage
    4.33                               rating:&rating
    4.34 -                             keys:keys
    4.35 +                             extraKeys:keys
    4.36                               error:&error];
    4.37      XCTAssertNotNil(unencDict);
    4.38      XCTAssertNil(error);
    4.39 @@ -1198,7 +1198,7 @@
    4.40      PEPMessage *decMsg = [session
    4.41                            decryptMessage:encMsg
    4.42                            rating:&pEpRating
    4.43 -                          keys:&keys
    4.44 +                          extraKeys:&keys
    4.45                            error:&error];
    4.46      XCTAssertNil(error);
    4.47      XCTAssertNotNil(decMsg);