IOSAD-72 decrypt with flags in/out
authorDirk Zimmermann <dirk@pep-project.org>
Mon, 23 Apr 2018 19:22:52 +0200
changeset 583f81193bdb664
parent 582 768d3beffeb8
child 584 7d876a17c31c
IOSAD-72 decrypt with flags in/out
pEpObjCAdapter/PEPInternalSession.m
pEpObjCAdapter/PEPSession.m
pEpObjCAdapter/PEPSessionProtocol.h
pEpObjCTests/PEPSessionTest.m
     1.1 --- a/pEpObjCAdapter/PEPInternalSession.m	Mon Apr 23 19:22:51 2018 +0200
     1.2 +++ b/pEpObjCAdapter/PEPInternalSession.m	Mon Apr 23 19:22:52 2018 +0200
     1.3 @@ -99,6 +99,7 @@
     1.4  #pragma mark - PEPSessionProtocol
     1.5  
     1.6  - (PEPDict * _Nullable)decryptMessageDict:(PEPDict * _Nonnull)messageDict
     1.7 +                                    flags:(PEP_decrypt_flags * _Nullable)flags
     1.8                                     rating:(PEP_rating * _Nullable)rating
     1.9                                  extraKeys:(PEPStringList * _Nullable * _Nullable)extraKeys
    1.10                                     status:(PEP_STATUS * _Nullable)status
    1.11 @@ -111,12 +112,21 @@
    1.12      message *_src = PEP_messageDictToStruct(messageDict);
    1.13      message *_dst = NULL;
    1.14      stringlist_t *_keys = NULL;
    1.15 -    PEP_decrypt_flags_t flags = 0;
    1.16 +    PEP_decrypt_flags theFlags = 0;
    1.17 +
    1.18 +    if (flags) {
    1.19 +        theFlags = *flags;
    1.20 +    }
    1.21  
    1.22      PEP_rating internalRating = PEP_rating_undefined;
    1.23  
    1.24      [self lockWrite];
    1.25 -    PEP_STATUS theStatus = decrypt_message(_session, _src, &_dst, &_keys, &internalRating, &flags);
    1.26 +    PEP_STATUS theStatus = decrypt_message(_session,
    1.27 +                                           _src,
    1.28 +                                           &_dst,
    1.29 +                                           &_keys,
    1.30 +                                           &internalRating,
    1.31 +                                           &theFlags);
    1.32      [self unlockWrite];
    1.33  
    1.34      if (status) {
    1.35 @@ -127,6 +137,10 @@
    1.36          return nil;
    1.37      }
    1.38  
    1.39 +    if (flags) {
    1.40 +        *flags = theFlags;
    1.41 +    }
    1.42 +
    1.43      NSDictionary *dst_;
    1.44  
    1.45      if (_dst) {
    1.46 @@ -155,16 +169,19 @@
    1.47  }
    1.48  
    1.49  - (PEPMessage * _Nullable)decryptMessage:(PEPMessage * _Nonnull)message
    1.50 +                                   flags:(PEP_decrypt_flags * _Nullable)flags
    1.51                                    rating:(PEP_rating * _Nullable)rating
    1.52                                 extraKeys:(PEPStringList * _Nullable * _Nullable)extraKeys
    1.53                                    status:(PEP_STATUS * _Nullable)status
    1.54                                     error:(NSError * _Nullable * _Nullable)error
    1.55  {
    1.56 -    PEPDict *destDict = [self decryptMessageDict:(PEPDict *)message
    1.57 -                                          rating:rating
    1.58 -                                       extraKeys:extraKeys
    1.59 -                                          status:status
    1.60 -                                           error:error];
    1.61 +    PEPDict *destDict = [self
    1.62 +                         decryptMessageDict:(PEPDict *)message
    1.63 +                         flags:flags
    1.64 +                         rating:rating
    1.65 +                         extraKeys:extraKeys
    1.66 +                         status:status
    1.67 +                         error:error];
    1.68  
    1.69      if (!destDict) {
    1.70          return nil;
     2.1 --- a/pEpObjCAdapter/PEPSession.m	Mon Apr 23 19:22:51 2018 +0200
     2.2 +++ b/pEpObjCAdapter/PEPSession.m	Mon Apr 23 19:22:52 2018 +0200
     2.3 @@ -22,6 +22,7 @@
     2.4  }
     2.5  
     2.6  - (PEPDict * _Nullable)decryptMessageDict:(PEPDict * _Nonnull)messageDict
     2.7 +                                    flags:(PEP_decrypt_flags * _Nullable)flags
     2.8                                     rating:(PEP_rating * _Nullable)rating
     2.9                                  extraKeys:(PEPStringList * _Nullable * _Nullable)extraKeys
    2.10                                     status:(PEP_STATUS * _Nullable)status
    2.11 @@ -30,6 +31,7 @@
    2.12      PEPInternalSession *session = [PEPSessionProvider session];
    2.13      return [session
    2.14              decryptMessageDict:messageDict
    2.15 +            flags:flags
    2.16              rating:rating
    2.17              extraKeys:extraKeys
    2.18              status:status
    2.19 @@ -37,6 +39,7 @@
    2.20  }
    2.21  
    2.22  - (PEPMessage * _Nullable)decryptMessage:(PEPMessage * _Nonnull)message
    2.23 +                                   flags:(PEP_decrypt_flags * _Nullable)flags
    2.24                                    rating:(PEP_rating * _Nullable)rating
    2.25                                 extraKeys:(PEPStringList * _Nullable * _Nullable)extraKeys
    2.26                                    status:(PEP_STATUS * _Nullable)status
    2.27 @@ -45,6 +48,7 @@
    2.28      PEPInternalSession *session = [PEPSessionProvider session];
    2.29      return [session
    2.30              decryptMessage:message
    2.31 +            flags:flags
    2.32              rating:rating
    2.33              extraKeys:extraKeys
    2.34              status:status
     3.1 --- a/pEpObjCAdapter/PEPSessionProtocol.h	Mon Apr 23 19:22:51 2018 +0200
     3.2 +++ b/pEpObjCAdapter/PEPSessionProtocol.h	Mon Apr 23 19:22:52 2018 +0200
     3.3 @@ -22,6 +22,7 @@
     3.4  
     3.5  /** Decrypt a message */
     3.6  - (PEPDict * _Nullable)decryptMessageDict:(PEPDict * _Nonnull)messageDict
     3.7 +                                    flags:(PEP_decrypt_flags * _Nullable)flags
     3.8                                     rating:(PEP_rating * _Nullable)rating
     3.9                                  extraKeys:(PEPStringList * _Nullable * _Nullable)extraKeys
    3.10                                     status:(PEP_STATUS * _Nullable)status
    3.11 @@ -29,6 +30,7 @@
    3.12  
    3.13  /** Decrypt a message */
    3.14  - (PEPMessage * _Nullable)decryptMessage:(PEPMessage * _Nonnull)message
    3.15 +                                   flags:(PEP_decrypt_flags * _Nullable)flags
    3.16                                    rating:(PEP_rating * _Nullable)rating
    3.17                                 extraKeys:(PEPStringList * _Nullable * _Nullable)extraKeys
    3.18                                    status:(PEP_STATUS * _Nullable)status
     4.1 --- a/pEpObjCTests/PEPSessionTest.m	Mon Apr 23 19:22:51 2018 +0200
     4.2 +++ b/pEpObjCTests/PEPSessionTest.m	Mon Apr 23 19:22:52 2018 +0200
     4.3 @@ -844,6 +844,7 @@
     4.4      PEP_rating rating = PEP_rating_b0rken;
     4.5      PEPMessage *decmsg = [session
     4.6                            decryptMessage:encMsg
     4.7 +                          flags:nil
     4.8                            rating:&rating
     4.9                            extraKeys:&keys
    4.10                            status:nil
    4.11 @@ -892,6 +893,7 @@
    4.12      // Technically, the mail is encrypted, but the signatures don't match
    4.13      PEPMessage *pepDecryptedMail = [session
    4.14                                      decryptMessage:msg
    4.15 +                                    flags:nil
    4.16                                      rating:nil
    4.17                                      extraKeys:&keys
    4.18                                      status:nil
    4.19 @@ -1075,6 +1077,7 @@
    4.20      error = nil;
    4.21      PEPMessage *decMsg = [session
    4.22                            decryptMessage:encMsg
    4.23 +                          flags:nil
    4.24                            rating:&pEpRating
    4.25                            extraKeys:&keys
    4.26                            status:nil
    4.27 @@ -1341,6 +1344,7 @@
    4.28      error = nil;
    4.29      PEPMessage *unencDict = [session
    4.30                               decryptMessage:encMessage
    4.31 +                             flags:nil
    4.32                               rating:&rating
    4.33                               extraKeys:keys
    4.34                               status:nil
    4.35 @@ -1425,6 +1429,7 @@
    4.36      error = nil;
    4.37      PEPMessage *decMsg = [session
    4.38                            decryptMessage:encMsg
    4.39 +                          flags:nil
    4.40                            rating:&pEpRating
    4.41                            extraKeys:&keys
    4.42                            status:nil