merge "default" into "ENGINE-198" and open that branch again because there are still bogus assertions we cannot explain, yet ENGINE-198
authorRoker <roker@pep-project.org>
Tue, 02 May 2017 08:41:57 +0200
branchENGINE-198
changeset 1740961f325d7a85
parent 1719 b1e855594c13
parent 1739 73374beaca6f
child 1741 5bd49bd73192
merge "default" into "ENGINE-198" and open that branch again because there are still bogus assertions we cannot explain, yet
     1.1 --- a/build-mac/pEpEngine.xcodeproj/project.pbxproj	Wed Apr 19 10:54:38 2017 +0200
     1.2 +++ b/build-mac/pEpEngine.xcodeproj/project.pbxproj	Tue May 02 08:41:57 2017 +0200
     1.3 @@ -292,7 +292,7 @@
     1.4  		646C414C1D510D8800C63EFF /* baseprotocol.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = baseprotocol.c; path = ../src/baseprotocol.c; sourceTree = "<group>"; };
     1.5  		646C414D1D510D8800C63EFF /* baseprotocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = baseprotocol.h; path = ../src/baseprotocol.h; sourceTree = "<group>"; };
     1.6  		64796A3F1B455AA5004B1C24 /* libpEpEngine.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libpEpEngine.a; sourceTree = BUILT_PRODUCTS_DIR; };
     1.7 -		64951A1B1BE0FCD800B10E71 /* system.db */ = {isa = PBXFileReference; lastKnownFileType = file; name = system.db; path = ../db/system.db; sourceTree = "<group>"; };
     1.8 +		64951A1B1BE0FCD800B10E71 /* system.db */ = {isa = PBXFileReference; lastKnownFileType = text; name = system.db; path = ../db/system.db; sourceTree = "<group>"; };
     1.9  		649DE08A1B45C19100912F72 /* libcurl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libcurl.a; sourceTree = "<group>"; };
    1.10  		64A8264C1B455D0800EECAF0 /* bloblist.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = bloblist.c; path = ../src/bloblist.c; sourceTree = "<group>"; };
    1.11  		64A8264D1B455D0800EECAF0 /* bloblist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = bloblist.h; path = ../src/bloblist.h; sourceTree = "<group>"; };
    1.12 @@ -947,7 +947,7 @@
    1.13  					"$(SRCROOT)",
    1.14  					"$(SRCROOT)/../../netpgp-et/include/",
    1.15  					"$(SRCROOT)/../../netpgp-et/src/",
    1.16 -					"$(SRCROOT)/../../netpgp-et/netpgp-xcode/openssl/include/",
    1.17 +					"$(SRCROOT)/../../OpenSSL-for-iPhone/include",
    1.18  					"$(SRCROOT)/../asn.1/",
    1.19  				);
    1.20  				IPHONEOS_DEPLOYMENT_TARGET = 9.0;
    1.21 @@ -994,7 +994,7 @@
    1.22  					"$(SRCROOT)",
    1.23  					"$(SRCROOT)/../../netpgp-et/include/",
    1.24  					"$(SRCROOT)/../../netpgp-et/src/",
    1.25 -					"$(SRCROOT)/../../netpgp-et/netpgp-xcode/openssl/include/",
    1.26 +					"$(SRCROOT)/../../OpenSSL-for-iPhone/include",
    1.27  					"$(SRCROOT)/../asn.1/",
    1.28  				);
    1.29  				IPHONEOS_DEPLOYMENT_TARGET = 9.0;
     2.1 --- a/src/keymanagement.c	Wed Apr 19 10:54:38 2017 +0200
     2.2 +++ b/src/keymanagement.c	Tue May 02 08:41:57 2017 +0200
     2.3 @@ -179,10 +179,11 @@
     2.4                         downgrade eventually trusted comm_type */
     2.5                      temp_id->comm_type = _comm_type_key;
     2.6                  } else {
     2.7 -                    /* otherwise take stored comm_type as-is */
     2.8 +                    /* otherwise take stored comm_type as-is except if 
     2.9 +                       is unknown or is expired (but key not expired anymore) */
    2.10                      temp_id->comm_type = stored_identity->comm_type;
    2.11 -                    if (temp_id->comm_type == PEP_ct_unknown) {
    2.12 -                        /* except if unknown */
    2.13 +                    if (temp_id->comm_type == PEP_ct_unknown ||
    2.14 +                        temp_id->comm_type == PEP_ct_key_expired) {
    2.15                          temp_id->comm_type = _comm_type_key;
    2.16                      }
    2.17                  }
     3.1 --- a/src/sync.h	Wed Apr 19 10:54:38 2017 +0200
     3.2 +++ b/src/sync.h	Tue May 02 08:41:57 2017 +0200
     3.3 @@ -309,11 +309,12 @@
     3.4  //  parameters:
     3.5  //      management (in)     application defined
     3.6  //      timeout (in,out)    do not wait longer than timeout for message
     3.7 +//                          timeout == NULL or *timeout == 0 is blocking
     3.8  //
     3.9  //  return value:
    3.10 -//      next message or :
    3.11 -//      NULL and timeout == 0 for termination
    3.12 -//      NULL and timeout != 0 for timeout occurence
    3.13 +//      next message, then timeout[out] == remaining time
    3.14 +//      NULL and timeout[out] != 0 for timeout occurence
    3.15 +//      NULL and timeout[out] == 0 for termination
    3.16  
    3.17  typedef void *(*retrieve_next_sync_msg_t)(void *management, time_t *timeout);
    3.18  
     4.1 --- a/src/sync_actions.c	Wed Apr 19 10:54:38 2017 +0200
     4.2 +++ b/src/sync_actions.c	Tue May 02 08:41:57 2017 +0200
     4.3 @@ -105,6 +105,23 @@
     4.4      return 1;
     4.5  }
     4.6  
     4.7 +int sameKeyAndAddress(PEP_SESSION session, Identity a, Identity b)
     4.8 +{
     4.9 +    assert(session);
    4.10 +    assert(a);
    4.11 +    assert(b);
    4.12 +
    4.13 +    if (!(session && a && b))
    4.14 +        return invalid_condition; // error
    4.15 +
    4.16 +    if (a->fpr == NULL || b->fpr == NULL ||
    4.17 +        (!_same_fpr(a->fpr, strlen(a->fpr), b->fpr, strlen(b->fpr))) ||
    4.18 +        a->address == NULL || b->address == NULL ||
    4.19 +        strcmp(a->address, b->address) != 0)
    4.20 +            return 0;
    4.21 +    return 1;
    4.22 +}
    4.23 +
    4.24  // actions
    4.25  
    4.26  PEP_STATUS _notifyHandshake(
     5.1 --- a/sync/devicegroup.fsm	Wed Apr 19 10:54:38 2017 +0200
     5.2 +++ b/sync/devicegroup.fsm	Tue May 02 08:41:57 2017 +0200
     5.3 @@ -21,6 +21,7 @@
     5.4          condition deviceGrouped();
     5.5          condition keyElectionWon(Identity partner);
     5.6          condition sameIdentities(Identity a, Identity b);
     5.7 +        condition sameKeyAndAddress(Identity a, Identity b);
     5.8  
     5.9          state InitState {
    5.10              on Init {
    5.11 @@ -31,10 +32,14 @@
    5.12          }
    5.13  
    5.14          state Sole end=1 {
    5.15 -            on KeyGen
    5.16 +            on KeyGen {
    5.17                  do sendBeacon;
    5.18 -            on CannotDecrypt
    5.19 +                go SoleWaiting;
    5.20 +            }
    5.21 +            on CannotDecrypt {
    5.22                  do sendBeacon;
    5.23 +                go SoleWaiting;
    5.24 +            }
    5.25              on Beacon(Identity partner){
    5.26                  do sendHandshakeRequest(partner);
    5.27                  go SoleBeaconed(partner);
    5.28 @@ -45,6 +50,26 @@
    5.29              }
    5.30          }
    5.31  
    5.32 +        // copy of sole state with a timeout to enable fast polling for a second
    5.33 +        // TODO use more YSLT power here (substates ?) 
    5.34 +        state SoleWaiting timeout=60 {
    5.35 +            on KeyGen {
    5.36 +                do sendBeacon;
    5.37 +            }
    5.38 +            on CannotDecrypt {
    5.39 +                do sendBeacon;
    5.40 +            }
    5.41 +            on Beacon(Identity partner){
    5.42 +                do sendHandshakeRequest(partner);
    5.43 +                go SoleBeaconed(partner);
    5.44 +            }
    5.45 +            on HandshakeRequest(Identity partner) {
    5.46 +                do sendHandshakeRequest(partner);
    5.47 +                go HandshakingSole(partner);
    5.48 +            }
    5.49 +            on Timeout go Sole;
    5.50 +        }
    5.51 +
    5.52          state SoleBeaconed timeout=600 (Identity expected) {
    5.53              on KeyGen{
    5.54                  do sendBeacon;
    5.55 @@ -71,10 +96,10 @@
    5.56  
    5.57          state HandshakingSole timeout=600 (Identity expected) {
    5.58              on Init{
    5.59 -                if keyElectionWon(partner) {
    5.60 -                    do notifyInitFormGroup(partner);
    5.61 +                if keyElectionWon(expected) {
    5.62 +                    do notifyInitFormGroup(expected);
    5.63                  } else {
    5.64 -                    do notifyInitAddOurDevice(partner);
    5.65 +                    do notifyInitAddOurDevice(expected);
    5.66                  }
    5.67              }
    5.68              on HandshakeRejected(Identity partner) {
    5.69 @@ -97,10 +122,11 @@
    5.70              }
    5.71              on Cancel go Sole;
    5.72              on GroupKeys(Identity partner, GroupKeys groupkeys) {
    5.73 -                if keyElectionWon(partner) {
    5.74 -                    // not suppose to receive groupkeys - ignore
    5.75 +                if keyElectionWon(expected) {
    5.76 +                    // not supposed to receive groupkeys - ignore
    5.77                  } else {
    5.78 -                    if sameIdentities(partner, expected) {
    5.79 +                    // UUID changes in between, so we can only check for same address and fpr
    5.80 +                    if sameKeyAndAddress(partner, expected) {
    5.81                          go WaitForAcceptSole(partner, groupkeys);
    5.82                      }
    5.83                  }
    5.84 @@ -114,7 +140,8 @@
    5.85      
    5.86          state WaitForGroupKeysSole timeout=600 (Identity expected) {
    5.87              on GroupKeys(Identity partner, GroupKeys groupkeys) {
    5.88 -                if sameIdentities(partner, expected) {
    5.89 +                // UUID changes in between, so we can only check for same address and fpr
    5.90 +                if sameKeyAndAddress(partner, expected) {
    5.91                      do storeGroupKeys(partner, groupkeys);
    5.92                      do sendGroupUpdate;
    5.93                      do renewUUID;
    5.94 @@ -134,7 +161,8 @@
    5.95                  go Sole;
    5.96              }
    5.97              on HandshakeAccepted(Identity partner) {
    5.98 -                if sameIdentities(partner, expected) {
    5.99 +                // UUID changes in between, so we can only check for same address and fpr
   5.100 +                if sameKeyAndAddress(partner, expected) {
   5.101                      do acceptHandshake(partner); 
   5.102                      do storeGroupKeys(partner, groupkeys);
   5.103                      do sendGroupUpdate;
   5.104 @@ -157,6 +185,7 @@
   5.105              on CannotDecrypt {
   5.106                  do sendUpdateRequest;
   5.107                  do sendBeacon;
   5.108 +                go GroupWaiting;
   5.109              }
   5.110              on UpdateRequest
   5.111                  do sendGroupUpdate;
   5.112 @@ -172,6 +201,29 @@
   5.113                  do storeGroupUpdate(partner, keys);
   5.114          }
   5.115  
   5.116 +        // copy of grouped state, with a timeout to enable fast poling for a minut
   5.117 +        state GroupWaiting timeout=60 {
   5.118 +            on KeyGen
   5.119 +                do sendGroupUpdate;
   5.120 +            on CannotDecrypt {
   5.121 +                do sendUpdateRequest;
   5.122 +                do sendBeacon;
   5.123 +            }
   5.124 +            on UpdateRequest
   5.125 +                do sendGroupUpdate;
   5.126 +            on Beacon(Identity partner){
   5.127 +                do sendHandshakeRequest(partner);
   5.128 +                go GroupedBeaconed(partner);
   5.129 +            }
   5.130 +            on HandshakeRequest(Identity partner) {
   5.131 +                do sendHandshakeRequest(partner);
   5.132 +                go HandshakingGrouped(partner);
   5.133 +            }
   5.134 +            on GroupUpdate(Identity partner, IdentityList keys)
   5.135 +                do storeGroupUpdate(partner, keys);
   5.136 +            on Timeout go Grouped;
   5.137 +        }
   5.138 +
   5.139          state GroupedBeaconed timeout=600 (Identity expected){
   5.140              on KeyGen
   5.141                  do sendGroupUpdate;
   5.142 @@ -201,7 +253,7 @@
   5.143          state HandshakingGrouped timeout=600 (Identity expected) {
   5.144              // HandshakeRequest from same group are filtered in receive_sync_msg
   5.145              on Init{
   5.146 -                if keyElectionWon(partner) {
   5.147 +                if keyElectionWon(expected) {
   5.148                      do notifyInitAddOtherDevice(partner);
   5.149                  } else {
   5.150                      do notifyInitMoveOurDevice(partner);
   5.151 @@ -224,8 +276,13 @@
   5.152              }
   5.153              on Cancel go Grouped;
   5.154              on GroupKeys(Identity partner, GroupKeys groupkeys) {
   5.155 -                if sameIdentities(partner, expected) {
   5.156 -                    go WaitForAcceptGrouped(partner, groupkeys);
   5.157 +                if keyElectionWon(expected) {
   5.158 +                    // not supposed to receive groupkeys - ignore
   5.159 +                } else {
   5.160 +                    // UUID changes in between, so we can only check for same address and fpr
   5.161 +                    if sameKeyAndAddress(partner, expected) {
   5.162 +                        go WaitForAcceptGrouped(partner, groupkeys);
   5.163 +                    }
   5.164                  }
   5.165              }
   5.166              on GroupUpdate(Identity partner, IdentityList keys) {
     6.1 --- a/sync/gen_statemachine.ysl2	Wed Apr 19 10:54:38 2017 +0200
     6.2 +++ b/sync/gen_statemachine.ysl2	Tue May 02 08:41:57 2017 +0200
     6.3 @@ -231,7 +231,6 @@
     6.4          ||
     6.5  
     6.6          ||
     6.7 -            *timeout = «@timeout»;
     6.8              switch (event) {
     6.9          ||
    6.10  
    6.11 @@ -239,6 +238,7 @@
    6.12          ||
    6.13                  case Init: 
    6.14                      DEBUG_LOG("FSM event", "«../@filename»_fsm.c, state=«@name»", "event=Init") 
    6.15 +                    *timeout = «@timeout»;
    6.16                      break;
    6.17          ||
    6.18  
    6.19 @@ -300,13 +300,16 @@
    6.20          case «@name»:
    6.21          {
    6.22              DEBUG_LOG("FSM event", "«../../@filename»_fsm.c, state=«../@name»", "event=«@name»")
    6.23 +        `` if "@name='Init'" |> *timeout = «../@timeout»;
    6.24          ||
    6.25 +
    6.26          if "count(parm) > 1" {
    6.27              // TODO get ride of void *extra, pass per-event struct incl all params.
    6.28              const "extrapEpType" call "pEp_type" with "type","name(parm[2]/*[1])"; 
    6.29              const "extraArgName","name(parm[2]/*[2])"; 
    6.30              |> «$extrapEpType» «$extraArgName» = («$extrapEpType»)extra;
    6.31          }
    6.32 +
    6.33          ||
    6.34          `` apply "action|transition|condition";
    6.35          `` if "name(*[position()=last()]) != 'transition'" |> break;
     7.1 --- a/sync/generated/sync_fsm.c	Wed Apr 19 10:54:38 2017 +0200
     7.2 +++ b/sync/generated/sync_fsm.c	Tue May 02 08:41:57 2017 +0200
     7.3 @@ -56,11 +56,11 @@
     7.4          case InitState:
     7.5          {
     7.6              DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=InitState")
     7.7 -            *timeout = 0;
     7.8              switch (event) {
     7.9                  case Init:
    7.10                  {
    7.11                      DEBUG_LOG("FSM event", "sync_fsm.c, state=InitState", "event=Init")
    7.12 +                    *timeout = 0;
    7.13                      {
    7.14                          int cond_result = deviceGrouped(session);
    7.15                          #ifndef NDEBUG
    7.16 @@ -86,10 +86,10 @@
    7.17          case Sole:
    7.18          {
    7.19              DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=Sole")
    7.20 -            *timeout = 0;
    7.21              switch (event) {
    7.22                  case Init: 
    7.23                      DEBUG_LOG("FSM event", "sync_fsm.c, state=Sole", "event=Init") 
    7.24 +                    *timeout = 0;
    7.25                      break;
    7.26                  case KeyGen:
    7.27                  {
    7.28 @@ -100,7 +100,8 @@
    7.29                          return (int) invalid_out_of_memory;
    7.30                      if (status != PEP_STATUS_OK)
    7.31                          return (int) invalid_action;
    7.32 -                    break;
    7.33 +                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=Sole, event=KeyGen", "target=SoleWaiting")
    7.34 +                    return SoleWaiting;
    7.35                  }
    7.36                  case CannotDecrypt:
    7.37                  {
    7.38 @@ -111,7 +112,8 @@
    7.39                          return (int) invalid_out_of_memory;
    7.40                      if (status != PEP_STATUS_OK)
    7.41                          return (int) invalid_action;
    7.42 -                    break;
    7.43 +                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=Sole, event=CannotDecrypt", "target=SoleWaiting")
    7.44 +                    return SoleWaiting;
    7.45                  }
    7.46                  case Beacon:
    7.47                  {
    7.48 @@ -152,16 +154,91 @@
    7.49              }
    7.50              break;
    7.51          }
    7.52 +        case SoleWaiting:
    7.53 +        {
    7.54 +            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=SoleWaiting")
    7.55 +            switch (event) {
    7.56 +                case Init: 
    7.57 +                    DEBUG_LOG("FSM event", "sync_fsm.c, state=SoleWaiting", "event=Init") 
    7.58 +                    *timeout = 60;
    7.59 +                    break;
    7.60 +                case KeyGen:
    7.61 +                {
    7.62 +                    DEBUG_LOG("FSM event", "sync_fsm.c, state=SoleWaiting", "event=KeyGen")
    7.63 +                    DEBUG_LOG("FSM action", "sync_fsm.c, state=SoleWaiting, event=KeyGen", "action=sendBeacon")
    7.64 +                    status = sendBeacon(session, state, NULL, NULL);
    7.65 +                    if (status == PEP_OUT_OF_MEMORY)
    7.66 +                        return (int) invalid_out_of_memory;
    7.67 +                    if (status != PEP_STATUS_OK)
    7.68 +                        return (int) invalid_action;
    7.69 +                    break;
    7.70 +                }
    7.71 +                case CannotDecrypt:
    7.72 +                {
    7.73 +                    DEBUG_LOG("FSM event", "sync_fsm.c, state=SoleWaiting", "event=CannotDecrypt")
    7.74 +                    DEBUG_LOG("FSM action", "sync_fsm.c, state=SoleWaiting, event=CannotDecrypt", "action=sendBeacon")
    7.75 +                    status = sendBeacon(session, state, NULL, NULL);
    7.76 +                    if (status == PEP_OUT_OF_MEMORY)
    7.77 +                        return (int) invalid_out_of_memory;
    7.78 +                    if (status != PEP_STATUS_OK)
    7.79 +                        return (int) invalid_action;
    7.80 +                    break;
    7.81 +                }
    7.82 +                case Beacon:
    7.83 +                {
    7.84 +                    DEBUG_LOG("FSM event", "sync_fsm.c, state=SoleWaiting", "event=Beacon")
    7.85 +                    DEBUG_LOG("FSM action", "sync_fsm.c, state=SoleWaiting, event=Beacon", "action=sendHandshakeRequest")
    7.86 +                    status = sendHandshakeRequest(session, state, partner, NULL);
    7.87 +                    if (status == PEP_OUT_OF_MEMORY)
    7.88 +                        return (int) invalid_out_of_memory;
    7.89 +                    if (status != PEP_STATUS_OK)
    7.90 +                        return (int) invalid_action;
    7.91 +                    session->sync_state_payload = malloc(sizeof(SoleBeaconed_state_payload_t));
    7.92 +                    assert(session->sync_state_payload);
    7.93 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
    7.94 +                    ((SoleBeaconed_state_payload_t*)session->sync_state_payload)->expected =
    7.95 +                        identity_dup(partner);
    7.96 +                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=SoleWaiting, event=Beacon", "target=SoleBeaconed")
    7.97 +                    return SoleBeaconed;
    7.98 +                }
    7.99 +                case HandshakeRequest:
   7.100 +                {
   7.101 +                    DEBUG_LOG("FSM event", "sync_fsm.c, state=SoleWaiting", "event=HandshakeRequest")
   7.102 +                    DEBUG_LOG("FSM action", "sync_fsm.c, state=SoleWaiting, event=HandshakeRequest", "action=sendHandshakeRequest")
   7.103 +                    status = sendHandshakeRequest(session, state, partner, NULL);
   7.104 +                    if (status == PEP_OUT_OF_MEMORY)
   7.105 +                        return (int) invalid_out_of_memory;
   7.106 +                    if (status != PEP_STATUS_OK)
   7.107 +                        return (int) invalid_action;
   7.108 +                    session->sync_state_payload = malloc(sizeof(HandshakingSole_state_payload_t));
   7.109 +                    assert(session->sync_state_payload);
   7.110 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
   7.111 +                    ((HandshakingSole_state_payload_t*)session->sync_state_payload)->expected =
   7.112 +                        identity_dup(partner);
   7.113 +                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=SoleWaiting, event=HandshakeRequest", "target=HandshakingSole")
   7.114 +                    return HandshakingSole;
   7.115 +                }
   7.116 +                case Timeout:
   7.117 +                {
   7.118 +                    DEBUG_LOG("FSM event", "sync_fsm.c, state=SoleWaiting", "event=Timeout")
   7.119 +                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=SoleWaiting, event=Timeout", "target=Sole")
   7.120 +                    return Sole;
   7.121 +                }
   7.122 +                default:
   7.123 +                    return (DeviceState_state) invalid_event;
   7.124 +            }
   7.125 +            break;
   7.126 +        }
   7.127          case SoleBeaconed:
   7.128          {
   7.129              DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=SoleBeaconed")
   7.130              assert(session->sync_state_payload);
   7.131              if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   7.132              Identity expected = ((SoleBeaconed_state_payload_t*)session->sync_state_payload)->expected;
   7.133 -            *timeout = 600;
   7.134              switch (event) {
   7.135                  case Init: 
   7.136                      DEBUG_LOG("FSM event", "sync_fsm.c, state=SoleBeaconed", "event=Init") 
   7.137 +                    *timeout = 600;
   7.138                      break;
   7.139                  case KeyGen:
   7.140                  {
   7.141 @@ -277,13 +354,13 @@
   7.142              assert(session->sync_state_payload);
   7.143              if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   7.144              Identity expected = ((HandshakingSole_state_payload_t*)session->sync_state_payload)->expected;
   7.145 -            *timeout = 600;
   7.146              switch (event) {
   7.147                  case Init:
   7.148                  {
   7.149                      DEBUG_LOG("FSM event", "sync_fsm.c, state=HandshakingSole", "event=Init")
   7.150 +                    *timeout = 600;
   7.151                      {
   7.152 -                        int cond_result = keyElectionWon(session, partner);
   7.153 +                        int cond_result = keyElectionWon(session, expected);
   7.154                          #ifndef NDEBUG
   7.155                          char resstr[11] = {0,};
   7.156                          snprintf(resstr,10,"result=%d",cond_result);
   7.157 @@ -293,7 +370,7 @@
   7.158                              return cond_result;
   7.159                          if (cond_result) {
   7.160                          DEBUG_LOG("FSM action", "sync_fsm.c, state=HandshakingSole, event=Init", "action=notifyInitFormGroup")
   7.161 -                        status = notifyInitFormGroup(session, state, partner, NULL);
   7.162 +                        status = notifyInitFormGroup(session, state, expected, NULL);
   7.163                          if (status == PEP_OUT_OF_MEMORY)
   7.164                              return (int) invalid_out_of_memory;
   7.165                          if (status != PEP_STATUS_OK)
   7.166 @@ -301,7 +378,7 @@
   7.167                          }
   7.168                          else {
   7.169                          DEBUG_LOG("FSM action", "sync_fsm.c, state=HandshakingSole, event=Init", "action=notifyInitAddOurDevice")
   7.170 -                        status = notifyInitAddOurDevice(session, state, partner, NULL);
   7.171 +                        status = notifyInitAddOurDevice(session, state, expected, NULL);
   7.172                          if (status == PEP_OUT_OF_MEMORY)
   7.173                              return (int) invalid_out_of_memory;
   7.174                          if (status != PEP_STATUS_OK)
   7.175 @@ -427,7 +504,7 @@
   7.176                      DEBUG_LOG("FSM event", "sync_fsm.c, state=HandshakingSole", "event=GroupKeys")
   7.177                      group_keys_extra_t* groupkeys = (group_keys_extra_t*)extra;
   7.178                      {
   7.179 -                        int cond_result = keyElectionWon(session, partner);
   7.180 +                        int cond_result = keyElectionWon(session, expected);
   7.181                          #ifndef NDEBUG
   7.182                          char resstr[11] = {0,};
   7.183                          snprintf(resstr,10,"result=%d",cond_result);
   7.184 @@ -439,12 +516,12 @@
   7.185                          }
   7.186                          else {
   7.187                          {
   7.188 -                            int cond_result = sameIdentities(session, partner, expected);
   7.189 +                            int cond_result = sameKeyAndAddress(session, partner, expected);
   7.190                              #ifndef NDEBUG
   7.191                              char resstr[11] = {0,};
   7.192                              snprintf(resstr,10,"result=%d",cond_result);
   7.193                              #endif
   7.194 -                            DEBUG_LOG("FSM condition", "sync_fsm.c, state=HandshakingSole, event=GroupKeys, condition=sameIdentities", resstr)
   7.195 +                            DEBUG_LOG("FSM condition", "sync_fsm.c, state=HandshakingSole, event=GroupKeys, condition=sameKeyAndAddress", resstr)
   7.196                              if (cond_result < 0)
   7.197                                  return cond_result;
   7.198                              if (cond_result) {
   7.199 @@ -502,22 +579,22 @@
   7.200              assert(session->sync_state_payload);
   7.201              if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   7.202              Identity expected = ((WaitForGroupKeysSole_state_payload_t*)session->sync_state_payload)->expected;
   7.203 -            *timeout = 600;
   7.204              switch (event) {
   7.205                  case Init: 
   7.206                      DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForGroupKeysSole", "event=Init") 
   7.207 +                    *timeout = 600;
   7.208                      break;
   7.209                  case GroupKeys:
   7.210                  {
   7.211                      DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForGroupKeysSole", "event=GroupKeys")
   7.212                      group_keys_extra_t* groupkeys = (group_keys_extra_t*)extra;
   7.213                      {
   7.214 -                        int cond_result = sameIdentities(session, partner, expected);
   7.215 +                        int cond_result = sameKeyAndAddress(session, partner, expected);
   7.216                          #ifndef NDEBUG
   7.217                          char resstr[11] = {0,};
   7.218                          snprintf(resstr,10,"result=%d",cond_result);
   7.219                          #endif
   7.220 -                        DEBUG_LOG("FSM condition", "sync_fsm.c, state=WaitForGroupKeysSole, event=GroupKeys, condition=sameIdentities", resstr)
   7.221 +                        DEBUG_LOG("FSM condition", "sync_fsm.c, state=WaitForGroupKeysSole, event=GroupKeys, condition=sameKeyAndAddress", resstr)
   7.222                          if (cond_result < 0)
   7.223                              return cond_result;
   7.224                          if (cond_result) {
   7.225 @@ -585,10 +662,10 @@
   7.226              if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   7.227              Identity expected = ((WaitForAcceptSole_state_payload_t*)session->sync_state_payload)->expected;
   7.228              group_keys_extra_t* groupkeys = ((WaitForAcceptSole_state_payload_t*)session->sync_state_payload)->groupkeys;
   7.229 -            *timeout = 600;
   7.230              switch (event) {
   7.231                  case Init: 
   7.232                      DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForAcceptSole", "event=Init") 
   7.233 +                    *timeout = 600;
   7.234                      break;
   7.235                  case HandshakeRejected:
   7.236                  {
   7.237 @@ -612,12 +689,12 @@
   7.238                  {
   7.239                      DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForAcceptSole", "event=HandshakeAccepted")
   7.240                      {
   7.241 -                        int cond_result = sameIdentities(session, partner, expected);
   7.242 +                        int cond_result = sameKeyAndAddress(session, partner, expected);
   7.243                          #ifndef NDEBUG
   7.244                          char resstr[11] = {0,};
   7.245                          snprintf(resstr,10,"result=%d",cond_result);
   7.246                          #endif
   7.247 -                        DEBUG_LOG("FSM condition", "sync_fsm.c, state=WaitForAcceptSole, event=HandshakeAccepted, condition=sameIdentities", resstr)
   7.248 +                        DEBUG_LOG("FSM condition", "sync_fsm.c, state=WaitForAcceptSole, event=HandshakeAccepted, condition=sameKeyAndAddress", resstr)
   7.249                          if (cond_result < 0)
   7.250                              return cond_result;
   7.251                          if (cond_result) {
   7.252 @@ -708,10 +785,10 @@
   7.253          case Grouped:
   7.254          {
   7.255              DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=Grouped")
   7.256 -            *timeout = 0;
   7.257              switch (event) {
   7.258                  case Init: 
   7.259                      DEBUG_LOG("FSM event", "sync_fsm.c, state=Grouped", "event=Init") 
   7.260 +                    *timeout = 0;
   7.261                      break;
   7.262                  case KeyGen:
   7.263                  {
   7.264 @@ -739,7 +816,8 @@
   7.265                          return (int) invalid_out_of_memory;
   7.266                      if (status != PEP_STATUS_OK)
   7.267                          return (int) invalid_action;
   7.268 -                    break;
   7.269 +                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=Grouped, event=CannotDecrypt", "target=GroupWaiting")
   7.270 +                    return GroupWaiting;
   7.271                  }
   7.272                  case UpdateRequest:
   7.273                  {
   7.274 @@ -803,16 +881,120 @@
   7.275              }
   7.276              break;
   7.277          }
   7.278 +        case GroupWaiting:
   7.279 +        {
   7.280 +            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=GroupWaiting")
   7.281 +            switch (event) {
   7.282 +                case Init: 
   7.283 +                    DEBUG_LOG("FSM event", "sync_fsm.c, state=GroupWaiting", "event=Init") 
   7.284 +                    *timeout = 60;
   7.285 +                    break;
   7.286 +                case KeyGen:
   7.287 +                {
   7.288 +                    DEBUG_LOG("FSM event", "sync_fsm.c, state=GroupWaiting", "event=KeyGen")
   7.289 +                    DEBUG_LOG("FSM action", "sync_fsm.c, state=GroupWaiting, event=KeyGen", "action=sendGroupUpdate")
   7.290 +                    status = sendGroupUpdate(session, state, NULL, NULL);
   7.291 +                    if (status == PEP_OUT_OF_MEMORY)
   7.292 +                        return (int) invalid_out_of_memory;
   7.293 +                    if (status != PEP_STATUS_OK)
   7.294 +                        return (int) invalid_action;
   7.295 +                    break;
   7.296 +                }
   7.297 +                case CannotDecrypt:
   7.298 +                {
   7.299 +                    DEBUG_LOG("FSM event", "sync_fsm.c, state=GroupWaiting", "event=CannotDecrypt")
   7.300 +                    DEBUG_LOG("FSM action", "sync_fsm.c, state=GroupWaiting, event=CannotDecrypt", "action=sendUpdateRequest")
   7.301 +                    status = sendUpdateRequest(session, state, NULL, NULL);
   7.302 +                    if (status == PEP_OUT_OF_MEMORY)
   7.303 +                        return (int) invalid_out_of_memory;
   7.304 +                    if (status != PEP_STATUS_OK)
   7.305 +                        return (int) invalid_action;
   7.306 +                    DEBUG_LOG("FSM action", "sync_fsm.c, state=GroupWaiting, event=CannotDecrypt", "action=sendBeacon")
   7.307 +                    status = sendBeacon(session, state, NULL, NULL);
   7.308 +                    if (status == PEP_OUT_OF_MEMORY)
   7.309 +                        return (int) invalid_out_of_memory;
   7.310 +                    if (status != PEP_STATUS_OK)
   7.311 +                        return (int) invalid_action;
   7.312 +                    break;
   7.313 +                }
   7.314 +                case UpdateRequest:
   7.315 +                {
   7.316 +                    DEBUG_LOG("FSM event", "sync_fsm.c, state=GroupWaiting", "event=UpdateRequest")
   7.317 +                    DEBUG_LOG("FSM action", "sync_fsm.c, state=GroupWaiting, event=UpdateRequest", "action=sendGroupUpdate")
   7.318 +                    status = sendGroupUpdate(session, state, NULL, NULL);
   7.319 +                    if (status == PEP_OUT_OF_MEMORY)
   7.320 +                        return (int) invalid_out_of_memory;
   7.321 +                    if (status != PEP_STATUS_OK)
   7.322 +                        return (int) invalid_action;
   7.323 +                    break;
   7.324 +                }
   7.325 +                case Beacon:
   7.326 +                {
   7.327 +                    DEBUG_LOG("FSM event", "sync_fsm.c, state=GroupWaiting", "event=Beacon")
   7.328 +                    DEBUG_LOG("FSM action", "sync_fsm.c, state=GroupWaiting, event=Beacon", "action=sendHandshakeRequest")
   7.329 +                    status = sendHandshakeRequest(session, state, partner, NULL);
   7.330 +                    if (status == PEP_OUT_OF_MEMORY)
   7.331 +                        return (int) invalid_out_of_memory;
   7.332 +                    if (status != PEP_STATUS_OK)
   7.333 +                        return (int) invalid_action;
   7.334 +                    session->sync_state_payload = malloc(sizeof(GroupedBeaconed_state_payload_t));
   7.335 +                    assert(session->sync_state_payload);
   7.336 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
   7.337 +                    ((GroupedBeaconed_state_payload_t*)session->sync_state_payload)->expected =
   7.338 +                        identity_dup(partner);
   7.339 +                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=GroupWaiting, event=Beacon", "target=GroupedBeaconed")
   7.340 +                    return GroupedBeaconed;
   7.341 +                }
   7.342 +                case HandshakeRequest:
   7.343 +                {
   7.344 +                    DEBUG_LOG("FSM event", "sync_fsm.c, state=GroupWaiting", "event=HandshakeRequest")
   7.345 +                    DEBUG_LOG("FSM action", "sync_fsm.c, state=GroupWaiting, event=HandshakeRequest", "action=sendHandshakeRequest")
   7.346 +                    status = sendHandshakeRequest(session, state, partner, NULL);
   7.347 +                    if (status == PEP_OUT_OF_MEMORY)
   7.348 +                        return (int) invalid_out_of_memory;
   7.349 +                    if (status != PEP_STATUS_OK)
   7.350 +                        return (int) invalid_action;
   7.351 +                    session->sync_state_payload = malloc(sizeof(HandshakingGrouped_state_payload_t));
   7.352 +                    assert(session->sync_state_payload);
   7.353 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
   7.354 +                    ((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected =
   7.355 +                        identity_dup(partner);
   7.356 +                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=GroupWaiting, event=HandshakeRequest", "target=HandshakingGrouped")
   7.357 +                    return HandshakingGrouped;
   7.358 +                }
   7.359 +                case GroupUpdate:
   7.360 +                {
   7.361 +                    DEBUG_LOG("FSM event", "sync_fsm.c, state=GroupWaiting", "event=GroupUpdate")
   7.362 +                    identity_list* keys = (identity_list*)extra;
   7.363 +                    DEBUG_LOG("FSM action", "sync_fsm.c, state=GroupWaiting, event=GroupUpdate", "action=storeGroupUpdate")
   7.364 +                    status = storeGroupUpdate(session, state, partner, keys);
   7.365 +                    if (status == PEP_OUT_OF_MEMORY)
   7.366 +                        return (int) invalid_out_of_memory;
   7.367 +                    if (status != PEP_STATUS_OK)
   7.368 +                        return (int) invalid_action;
   7.369 +                    break;
   7.370 +                }
   7.371 +                case Timeout:
   7.372 +                {
   7.373 +                    DEBUG_LOG("FSM event", "sync_fsm.c, state=GroupWaiting", "event=Timeout")
   7.374 +                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=GroupWaiting, event=Timeout", "target=Grouped")
   7.375 +                    return Grouped;
   7.376 +                }
   7.377 +                default:
   7.378 +                    return (DeviceState_state) invalid_event;
   7.379 +            }
   7.380 +            break;
   7.381 +        }
   7.382          case GroupedBeaconed:
   7.383          {
   7.384              DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=GroupedBeaconed")
   7.385              assert(session->sync_state_payload);
   7.386              if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   7.387              Identity expected = ((GroupedBeaconed_state_payload_t*)session->sync_state_payload)->expected;
   7.388 -            *timeout = 600;
   7.389              switch (event) {
   7.390                  case Init: 
   7.391                      DEBUG_LOG("FSM event", "sync_fsm.c, state=GroupedBeaconed", "event=Init") 
   7.392 +                    *timeout = 600;
   7.393                      break;
   7.394                  case KeyGen:
   7.395                  {
   7.396 @@ -945,13 +1127,13 @@
   7.397              assert(session->sync_state_payload);
   7.398              if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   7.399              Identity expected = ((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected;
   7.400 -            *timeout = 600;
   7.401              switch (event) {
   7.402                  case Init:
   7.403                  {
   7.404                      DEBUG_LOG("FSM event", "sync_fsm.c, state=HandshakingGrouped", "event=Init")
   7.405 +                    *timeout = 600;
   7.406                      {
   7.407 -                        int cond_result = keyElectionWon(session, partner);
   7.408 +                        int cond_result = keyElectionWon(session, expected);
   7.409                          #ifndef NDEBUG
   7.410                          char resstr[11] = {0,};
   7.411                          snprintf(resstr,10,"result=%d",cond_result);
   7.412 @@ -1076,29 +1258,43 @@
   7.413                      DEBUG_LOG("FSM event", "sync_fsm.c, state=HandshakingGrouped", "event=GroupKeys")
   7.414                      group_keys_extra_t* groupkeys = (group_keys_extra_t*)extra;
   7.415                      {
   7.416 -                        int cond_result = sameIdentities(session, partner, expected);
   7.417 +                        int cond_result = keyElectionWon(session, expected);
   7.418                          #ifndef NDEBUG
   7.419                          char resstr[11] = {0,};
   7.420                          snprintf(resstr,10,"result=%d",cond_result);
   7.421                          #endif
   7.422 -                        DEBUG_LOG("FSM condition", "sync_fsm.c, state=HandshakingGrouped, event=GroupKeys, condition=sameIdentities", resstr)
   7.423 +                        DEBUG_LOG("FSM condition", "sync_fsm.c, state=HandshakingGrouped, event=GroupKeys, condition=keyElectionWon", resstr)
   7.424                          if (cond_result < 0)
   7.425                              return cond_result;
   7.426                          if (cond_result) {
   7.427 -                        assert(session->sync_state_payload);
   7.428 -                        if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   7.429 -                        free_identity(((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected);
   7.430 -                        free(session->sync_state_payload);
   7.431 -                        session->sync_state_payload = NULL;
   7.432 -                        session->sync_state_payload = malloc(sizeof(WaitForAcceptGrouped_state_payload_t));
   7.433 -                        assert(session->sync_state_payload);
   7.434 -                        if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
   7.435 -                        ((WaitForAcceptGrouped_state_payload_t*)session->sync_state_payload)->expected =
   7.436 -                            identity_dup(partner);
   7.437 -                        ((WaitForAcceptGrouped_state_payload_t*)session->sync_state_payload)->groupkeys =
   7.438 -                            group_keys_extra_dup(groupkeys);
   7.439 -                        DEBUG_LOG("FSM transition", "sync_fsm.c, state=HandshakingGrouped, event=GroupKeys", "target=WaitForAcceptGrouped")
   7.440 -                        return WaitForAcceptGrouped;
   7.441 +                        }
   7.442 +                        else {
   7.443 +                        {
   7.444 +                            int cond_result = sameKeyAndAddress(session, partner, expected);
   7.445 +                            #ifndef NDEBUG
   7.446 +                            char resstr[11] = {0,};
   7.447 +                            snprintf(resstr,10,"result=%d",cond_result);
   7.448 +                            #endif
   7.449 +                            DEBUG_LOG("FSM condition", "sync_fsm.c, state=HandshakingGrouped, event=GroupKeys, condition=sameKeyAndAddress", resstr)
   7.450 +                            if (cond_result < 0)
   7.451 +                                return cond_result;
   7.452 +                            if (cond_result) {
   7.453 +                            assert(session->sync_state_payload);
   7.454 +                            if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   7.455 +                            free_identity(((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected);
   7.456 +                            free(session->sync_state_payload);
   7.457 +                            session->sync_state_payload = NULL;
   7.458 +                            session->sync_state_payload = malloc(sizeof(WaitForAcceptGrouped_state_payload_t));
   7.459 +                            assert(session->sync_state_payload);
   7.460 +                            if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
   7.461 +                            ((WaitForAcceptGrouped_state_payload_t*)session->sync_state_payload)->expected =
   7.462 +                                identity_dup(partner);
   7.463 +                            ((WaitForAcceptGrouped_state_payload_t*)session->sync_state_payload)->groupkeys =
   7.464 +                                group_keys_extra_dup(groupkeys);
   7.465 +                            DEBUG_LOG("FSM transition", "sync_fsm.c, state=HandshakingGrouped, event=GroupKeys", "target=WaitForAcceptGrouped")
   7.466 +                            return WaitForAcceptGrouped;
   7.467 +                            }
   7.468 +                        }
   7.469                          }
   7.470                      }
   7.471                      break;
   7.472 @@ -1155,10 +1351,10 @@
   7.473              assert(session->sync_state_payload);
   7.474              if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   7.475              Identity expected = ((WaitForGroupKeysGrouped_state_payload_t*)session->sync_state_payload)->expected;
   7.476 -            *timeout = 600;
   7.477              switch (event) {
   7.478                  case Init: 
   7.479                      DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForGroupKeysGrouped", "event=Init") 
   7.480 +                    *timeout = 600;
   7.481                      break;
   7.482                  case GroupKeys:
   7.483                  {
   7.484 @@ -1262,10 +1458,10 @@
   7.485              if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   7.486              Identity expected = ((WaitForAcceptGrouped_state_payload_t*)session->sync_state_payload)->expected;
   7.487              group_keys_extra_t* groupkeys = ((WaitForAcceptGrouped_state_payload_t*)session->sync_state_payload)->groupkeys;
   7.488 -            *timeout = 600;
   7.489              switch (event) {
   7.490                  case Init: 
   7.491                      DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForAcceptGrouped", "event=Init") 
   7.492 +                    *timeout = 600;
   7.493                      break;
   7.494                  case HandshakeRejected:
   7.495                  {
     8.1 --- a/sync/generated/sync_fsm.h	Wed Apr 19 10:54:38 2017 +0200
     8.2 +++ b/sync/generated/sync_fsm.h	Tue May 02 08:41:57 2017 +0200
     8.3 @@ -32,6 +32,7 @@
     8.4  int deviceGrouped(PEP_SESSION session);
     8.5  int keyElectionWon(PEP_SESSION session, Identity partner);
     8.6  int sameIdentities(PEP_SESSION session, Identity a, Identity b);
     8.7 +int sameKeyAndAddress(PEP_SESSION session, Identity a, Identity b);
     8.8  
     8.9  // states
    8.10  
    8.11 @@ -46,11 +47,13 @@
    8.12      DeviceState_state_NONE = 0,
    8.13      InitState, 
    8.14      Sole, 
    8.15 +    SoleWaiting, 
    8.16      SoleBeaconed, 
    8.17      HandshakingSole, 
    8.18      WaitForGroupKeysSole, 
    8.19      WaitForAcceptSole, 
    8.20      Grouped, 
    8.21 +    GroupWaiting, 
    8.22      GroupedBeaconed, 
    8.23      HandshakingGrouped, 
    8.24      WaitForGroupKeysGrouped, 
     9.1 --- a/sync/skeletons/sync_actions.c	Wed Apr 19 10:54:38 2017 +0200
     9.2 +++ b/sync/skeletons/sync_actions.c	Tue May 02 08:41:57 2017 +0200
     9.3 @@ -28,8 +28,8 @@
     9.4      PEP_STATUS status = PEP_STATUS_OK;
     9.5  
     9.6      assert(session);
     9.7 -    assert(partner);
     9.8 -    if (!(session && partner))
     9.9 +    assert(!partner);
    9.10 +    if (!(session && !partner))
    9.11          return PEP_ILLEGAL_VALUE;
    9.12  
    9.13      // working code
    9.14 @@ -65,8 +65,8 @@
    9.15      PEP_STATUS status = PEP_STATUS_OK;
    9.16  
    9.17      assert(session);
    9.18 -    assert(partner);
    9.19 -    if (!(session && partner))
    9.20 +    assert(!partner);
    9.21 +    if (!(session && !partner))
    9.22          return PEP_ILLEGAL_VALUE;
    9.23  
    9.24      // working code
    10.1 --- a/test/pEpEngineTest.cc	Wed Apr 19 10:54:38 2017 +0200
    10.2 +++ b/test/pEpEngineTest.cc	Tue May 02 08:41:57 2017 +0200
    10.3 @@ -304,7 +304,7 @@
    10.4  
    10.5      PEP_comm_type tcomm_type;
    10.6      PEP_STATUS tstatus = get_key_rating(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", &tcomm_type);
    10.7 -    cout << "get_key_rating() exits with " << tstatus << endl;
    10.8 +    cout << "get_key_rating() exits with " << status(tstatus) << endl;
    10.9      assert(tstatus == PEP_STATUS_OK);
   10.10      assert(tcomm_type == PEP_ct_OpenPGP_unconfirmed);
   10.11