'diphoton' test release. Stripped down sync FSM. Prevent handshake once in a group, then allowing only pairing two sole devices. test_diphoton
authorEdouard Tisserant <edouard@pep-project.org>
Wed, 15 Mar 2017 15:09:15 +0100
branchtest_diphoton
changeset 166999c54cb90ff3
parent 1666 01779e4c5940
child 1686 46fa9082dd6b
'diphoton' test release. Stripped down sync FSM. Prevent handshake once in a group, then allowing only pairing two sole devices.
sync/devicegroup.fsm
sync/generated/sync_fsm.c
sync/generated/sync_fsm.h
sync/generated/sync_send_actions.c
sync/skeletons/sync_actions.c
     1.1 --- a/sync/devicegroup.fsm	Mon Mar 13 22:44:12 2017 +0100
     1.2 +++ b/sync/devicegroup.fsm	Wed Mar 15 15:09:15 2017 +0100
     1.3 @@ -156,138 +156,13 @@
     1.4                  do sendGroupUpdate;
     1.5              on CannotDecrypt {
     1.6                  do sendUpdateRequest;
     1.7 -                do sendBeacon;
     1.8              }
     1.9              on UpdateRequest
    1.10                  do sendGroupUpdate;
    1.11 -            on Beacon(Identity partner){
    1.12 -                do sendHandshakeRequest(partner);
    1.13 -                go GroupedBeaconed(partner);
    1.14 -            }
    1.15 -            on HandshakeRequest(Identity partner) {
    1.16 -                do sendHandshakeRequest(partner);
    1.17 -                go HandshakingGrouped(partner);
    1.18 -            }
    1.19              on GroupUpdate(Identity partner, IdentityList keys)
    1.20                  do storeGroupUpdate(partner, keys);
    1.21          }
    1.22  
    1.23 -        state GroupedBeaconed timeout=600 (Identity expected){
    1.24 -            on KeyGen
    1.25 -                do sendGroupUpdate;
    1.26 -            on CannotDecrypt {
    1.27 -                do sendUpdateRequest;
    1.28 -                do sendBeacon;
    1.29 -            }
    1.30 -            on UpdateRequest
    1.31 -                do sendGroupUpdate;
    1.32 -            on Beacon(Identity partner){
    1.33 -                do sendHandshakeRequest(partner);
    1.34 -                go GroupedBeaconed(partner);
    1.35 -            }
    1.36 -            on HandshakeRequest(Identity partner) {
    1.37 -                if sameIdentities(partner, expected) {
    1.38 -                    // do nothing, to avoid sending handshake request twice 
    1.39 -                } else {
    1.40 -                    do sendHandshakeRequest(partner);
    1.41 -                }
    1.42 -                go HandshakingGrouped(partner);
    1.43 -            }
    1.44 -            on GroupUpdate(Identity partner, IdentityList keys)
    1.45 -                do storeGroupUpdate(partner, keys);
    1.46 -            on Timeout go Grouped;
    1.47 -        }
    1.48 -
    1.49 -        state HandshakingGrouped timeout=600 (Identity expected) {
    1.50 -            // HandshakeRequest from same group are filtered in receive_sync_msg
    1.51 -            on Init{
    1.52 -                if keyElectionWon(partner) {
    1.53 -                    do notifyInitAddOtherDevice(partner);
    1.54 -                } else {
    1.55 -                    do notifyInitMoveOurDevice(partner);
    1.56 -                }
    1.57 -            }
    1.58 -            on HandshakeRejected(Identity partner) {
    1.59 -                do rejectHandshake(partner);             // stores rejection of partner
    1.60 -                do sendGroupUpdate;
    1.61 -                go Grouped;
    1.62 -            }
    1.63 -            on HandshakeAccepted(Identity partner) {
    1.64 -                do acceptHandshake(partner); 
    1.65 -                do sendGroupUpdate;
    1.66 -                if keyElectionWon(partner) {
    1.67 -                    do sendGroupKeys(partner);
    1.68 -                    do notifyAcceptedDeviceAdded(partner);
    1.69 -                    go Grouped;
    1.70 -                }
    1.71 -                go WaitForGroupKeysGrouped(partner);
    1.72 -            }
    1.73 -            on Cancel go Grouped;
    1.74 -            on GroupKeys(Identity partner, GroupKeys groupkeys) {
    1.75 -                if sameIdentities(partner, expected) {
    1.76 -                    go WaitForAcceptGrouped(partner, groupkeys);
    1.77 -                }
    1.78 -            }
    1.79 -            on GroupUpdate(Identity partner, IdentityList keys) {
    1.80 -                do notifyOvertaken(partner);
    1.81 -                do storeGroupUpdate(partner, keys);
    1.82 -                go Grouped;
    1.83 -            }
    1.84 -            on Timeout {
    1.85 -                do notifyTimeout(expected);
    1.86 -                go Grouped;
    1.87 -            }
    1.88 -        }
    1.89 -
    1.90 -        state WaitForGroupKeysGrouped timeout=600 (Identity expected) {
    1.91 -            on GroupKeys(Identity partner, GroupKeys groupkeys) {
    1.92 -                if sameIdentities(partner, expected) {
    1.93 -                    do storeGroupKeys(partner, groupkeys);
    1.94 -                    do sendGroupUpdate;
    1.95 -                    do renewUUID;
    1.96 -                    do notifyAcceptedDeviceMoved(partner);
    1.97 -                    go Grouped;
    1.98 -                }
    1.99 -            }
   1.100 -            on GroupUpdate(Identity partner, IdentityList keys) {
   1.101 -                do notifyOvertaken(partner);
   1.102 -                do storeGroupUpdate(partner, keys);
   1.103 -                go Grouped;
   1.104 -            }
   1.105 -            on Timeout {
   1.106 -                do notifyTimeout(expected);
   1.107 -                go Grouped;
   1.108 -            }
   1.109 -        }
   1.110 -
   1.111 -        state WaitForAcceptGrouped timeout=600 (Identity expected, GroupKeys groupkeys) {
   1.112 -            on HandshakeRejected(Identity partner) {
   1.113 -                do rejectHandshake(partner);
   1.114 -                do sendGroupUpdate;
   1.115 -                go Grouped;
   1.116 -            }
   1.117 -            on HandshakeAccepted(Identity partner) {
   1.118 -                if sameIdentities(partner, expected) {
   1.119 -                    do acceptHandshake(partner); 
   1.120 -                    do storeGroupKeys(partner, groupkeys);
   1.121 -                    do sendGroupUpdate;
   1.122 -                    do renewUUID;
   1.123 -                    do notifyAcceptedDeviceMoved(partner);
   1.124 -                }
   1.125 -                go Grouped;
   1.126 -            }
   1.127 -            on Cancel go Grouped;
   1.128 -            on GroupUpdate(Identity partner, IdentityList keys) {
   1.129 -                do notifyOvertaken(partner);
   1.130 -                do storeGroupUpdate(partner, keys);
   1.131 -                go Grouped;
   1.132 -            }
   1.133 -            on Timeout {
   1.134 -                do notifyTimeout(expected);
   1.135 -                go Grouped;
   1.136 -            }
   1.137 -        }
   1.138 -
   1.139          tag Init 1;
   1.140          tag Beacon 2;
   1.141          tag HandshakeRequest 3;
     2.1 --- a/sync/generated/sync_fsm.c	Mon Mar 13 22:44:12 2017 +0100
     2.2 +++ b/sync/generated/sync_fsm.c	Wed Mar 15 15:09:15 2017 +0100
     2.3 @@ -21,23 +21,6 @@
     2.4      group_keys_extra_t* groupkeys;
     2.5  } WaitForAcceptSole_state_payload_t;
     2.6  
     2.7 -typedef struct _GroupedBeaconed_state_payload {
     2.8 -    Identity expected;
     2.9 -} GroupedBeaconed_state_payload_t;
    2.10 -
    2.11 -typedef struct _HandshakingGrouped_state_payload {
    2.12 -    Identity expected;
    2.13 -} HandshakingGrouped_state_payload_t;
    2.14 -
    2.15 -typedef struct _WaitForGroupKeysGrouped_state_payload {
    2.16 -    Identity expected;
    2.17 -} WaitForGroupKeysGrouped_state_payload_t;
    2.18 -
    2.19 -typedef struct _WaitForAcceptGrouped_state_payload {
    2.20 -    Identity expected;
    2.21 -    group_keys_extra_t* groupkeys;
    2.22 -} WaitForAcceptGrouped_state_payload_t;
    2.23 -
    2.24  
    2.25  // state machine for DeviceState
    2.26  
    2.27 @@ -733,12 +716,6 @@
    2.28                          return (int) invalid_out_of_memory;
    2.29                      if (status != PEP_STATUS_OK)
    2.30                          return (int) invalid_action;
    2.31 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=Grouped, event=CannotDecrypt", "action=sendBeacon")
    2.32 -                    status = sendBeacon(session, state, NULL, NULL);
    2.33 -                    if (status == PEP_OUT_OF_MEMORY)
    2.34 -                        return (int) invalid_out_of_memory;
    2.35 -                    if (status != PEP_STATUS_OK)
    2.36 -                        return (int) invalid_action;
    2.37                      break;
    2.38                  }
    2.39                  case UpdateRequest:
    2.40 @@ -752,40 +729,6 @@
    2.41                          return (int) invalid_action;
    2.42                      break;
    2.43                  }
    2.44 -                case Beacon:
    2.45 -                {
    2.46 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=Grouped", "event=Beacon")
    2.47 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=Grouped, event=Beacon", "action=sendHandshakeRequest")
    2.48 -                    status = sendHandshakeRequest(session, state, partner, NULL);
    2.49 -                    if (status == PEP_OUT_OF_MEMORY)
    2.50 -                        return (int) invalid_out_of_memory;
    2.51 -                    if (status != PEP_STATUS_OK)
    2.52 -                        return (int) invalid_action;
    2.53 -                    session->sync_state_payload = malloc(sizeof(GroupedBeaconed_state_payload_t));
    2.54 -                    assert(session->sync_state_payload);
    2.55 -                    if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
    2.56 -                    ((GroupedBeaconed_state_payload_t*)session->sync_state_payload)->expected =
    2.57 -                        identity_dup(partner);
    2.58 -                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=Grouped, event=Beacon", "target=GroupedBeaconed")
    2.59 -                    return GroupedBeaconed;
    2.60 -                }
    2.61 -                case HandshakeRequest:
    2.62 -                {
    2.63 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=Grouped", "event=HandshakeRequest")
    2.64 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=Grouped, event=HandshakeRequest", "action=sendHandshakeRequest")
    2.65 -                    status = sendHandshakeRequest(session, state, partner, NULL);
    2.66 -                    if (status == PEP_OUT_OF_MEMORY)
    2.67 -                        return (int) invalid_out_of_memory;
    2.68 -                    if (status != PEP_STATUS_OK)
    2.69 -                        return (int) invalid_action;
    2.70 -                    session->sync_state_payload = malloc(sizeof(HandshakingGrouped_state_payload_t));
    2.71 -                    assert(session->sync_state_payload);
    2.72 -                    if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
    2.73 -                    ((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected =
    2.74 -                        identity_dup(partner);
    2.75 -                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=Grouped, event=HandshakeRequest", "target=HandshakingGrouped")
    2.76 -                    return HandshakingGrouped;
    2.77 -                }
    2.78                  case GroupUpdate:
    2.79                  {
    2.80                      DEBUG_LOG("FSM event", "sync_fsm.c, state=Grouped", "event=GroupUpdate")
    2.81 @@ -803,608 +746,6 @@
    2.82              }
    2.83              break;
    2.84          }
    2.85 -        case GroupedBeaconed:
    2.86 -        {
    2.87 -            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=GroupedBeaconed")
    2.88 -            assert(session->sync_state_payload);
    2.89 -            if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
    2.90 -            Identity expected = ((GroupedBeaconed_state_payload_t*)session->sync_state_payload)->expected;
    2.91 -            *timeout = 600;
    2.92 -            switch (event) {
    2.93 -                case Init: 
    2.94 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=GroupedBeaconed", "event=Init") 
    2.95 -                    break;
    2.96 -                case KeyGen:
    2.97 -                {
    2.98 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=GroupedBeaconed", "event=KeyGen")
    2.99 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=GroupedBeaconed, event=KeyGen", "action=sendGroupUpdate")
   2.100 -                    status = sendGroupUpdate(session, state, NULL, NULL);
   2.101 -                    if (status == PEP_OUT_OF_MEMORY)
   2.102 -                        return (int) invalid_out_of_memory;
   2.103 -                    if (status != PEP_STATUS_OK)
   2.104 -                        return (int) invalid_action;
   2.105 -                    break;
   2.106 -                }
   2.107 -                case CannotDecrypt:
   2.108 -                {
   2.109 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=GroupedBeaconed", "event=CannotDecrypt")
   2.110 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=GroupedBeaconed, event=CannotDecrypt", "action=sendUpdateRequest")
   2.111 -                    status = sendUpdateRequest(session, state, NULL, NULL);
   2.112 -                    if (status == PEP_OUT_OF_MEMORY)
   2.113 -                        return (int) invalid_out_of_memory;
   2.114 -                    if (status != PEP_STATUS_OK)
   2.115 -                        return (int) invalid_action;
   2.116 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=GroupedBeaconed, event=CannotDecrypt", "action=sendBeacon")
   2.117 -                    status = sendBeacon(session, state, NULL, NULL);
   2.118 -                    if (status == PEP_OUT_OF_MEMORY)
   2.119 -                        return (int) invalid_out_of_memory;
   2.120 -                    if (status != PEP_STATUS_OK)
   2.121 -                        return (int) invalid_action;
   2.122 -                    break;
   2.123 -                }
   2.124 -                case UpdateRequest:
   2.125 -                {
   2.126 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=GroupedBeaconed", "event=UpdateRequest")
   2.127 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=GroupedBeaconed, event=UpdateRequest", "action=sendGroupUpdate")
   2.128 -                    status = sendGroupUpdate(session, state, NULL, NULL);
   2.129 -                    if (status == PEP_OUT_OF_MEMORY)
   2.130 -                        return (int) invalid_out_of_memory;
   2.131 -                    if (status != PEP_STATUS_OK)
   2.132 -                        return (int) invalid_action;
   2.133 -                    break;
   2.134 -                }
   2.135 -                case Beacon:
   2.136 -                {
   2.137 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=GroupedBeaconed", "event=Beacon")
   2.138 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=GroupedBeaconed, event=Beacon", "action=sendHandshakeRequest")
   2.139 -                    status = sendHandshakeRequest(session, state, partner, NULL);
   2.140 -                    if (status == PEP_OUT_OF_MEMORY)
   2.141 -                        return (int) invalid_out_of_memory;
   2.142 -                    if (status != PEP_STATUS_OK)
   2.143 -                        return (int) invalid_action;
   2.144 -                    assert(session->sync_state_payload);
   2.145 -                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   2.146 -                    free_identity(((GroupedBeaconed_state_payload_t*)session->sync_state_payload)->expected);
   2.147 -                    free(session->sync_state_payload);
   2.148 -                    session->sync_state_payload = NULL;
   2.149 -                    session->sync_state_payload = malloc(sizeof(GroupedBeaconed_state_payload_t));
   2.150 -                    assert(session->sync_state_payload);
   2.151 -                    if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
   2.152 -                    ((GroupedBeaconed_state_payload_t*)session->sync_state_payload)->expected =
   2.153 -                        identity_dup(partner);
   2.154 -                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=GroupedBeaconed, event=Beacon", "target=GroupedBeaconed")
   2.155 -                    return GroupedBeaconed;
   2.156 -                }
   2.157 -                case HandshakeRequest:
   2.158 -                {
   2.159 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=GroupedBeaconed", "event=HandshakeRequest")
   2.160 -                    {
   2.161 -                        int cond_result = sameIdentities(session, partner, expected);
   2.162 -                        #ifndef NDEBUG
   2.163 -                        char resstr[11] = {0,};
   2.164 -                        snprintf(resstr,10,"result=%d",cond_result);
   2.165 -                        #endif
   2.166 -                        DEBUG_LOG("FSM condition", "sync_fsm.c, state=GroupedBeaconed, event=HandshakeRequest, condition=sameIdentities", resstr)
   2.167 -                        if (cond_result < 0)
   2.168 -                            return cond_result;
   2.169 -                        if (cond_result) {
   2.170 -                        }
   2.171 -                        else {
   2.172 -                        DEBUG_LOG("FSM action", "sync_fsm.c, state=GroupedBeaconed, event=HandshakeRequest", "action=sendHandshakeRequest")
   2.173 -                        status = sendHandshakeRequest(session, state, partner, NULL);
   2.174 -                        if (status == PEP_OUT_OF_MEMORY)
   2.175 -                            return (int) invalid_out_of_memory;
   2.176 -                        if (status != PEP_STATUS_OK)
   2.177 -                            return (int) invalid_action;
   2.178 -                        }
   2.179 -                    }
   2.180 -                    assert(session->sync_state_payload);
   2.181 -                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   2.182 -                    free_identity(((GroupedBeaconed_state_payload_t*)session->sync_state_payload)->expected);
   2.183 -                    free(session->sync_state_payload);
   2.184 -                    session->sync_state_payload = NULL;
   2.185 -                    session->sync_state_payload = malloc(sizeof(HandshakingGrouped_state_payload_t));
   2.186 -                    assert(session->sync_state_payload);
   2.187 -                    if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
   2.188 -                    ((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected =
   2.189 -                        identity_dup(partner);
   2.190 -                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=GroupedBeaconed, event=HandshakeRequest", "target=HandshakingGrouped")
   2.191 -                    return HandshakingGrouped;
   2.192 -                }
   2.193 -                case GroupUpdate:
   2.194 -                {
   2.195 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=GroupedBeaconed", "event=GroupUpdate")
   2.196 -                    identity_list* keys = (identity_list*)extra;
   2.197 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=GroupedBeaconed, event=GroupUpdate", "action=storeGroupUpdate")
   2.198 -                    status = storeGroupUpdate(session, state, partner, keys);
   2.199 -                    if (status == PEP_OUT_OF_MEMORY)
   2.200 -                        return (int) invalid_out_of_memory;
   2.201 -                    if (status != PEP_STATUS_OK)
   2.202 -                        return (int) invalid_action;
   2.203 -                    break;
   2.204 -                }
   2.205 -                case Timeout:
   2.206 -                {
   2.207 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=GroupedBeaconed", "event=Timeout")
   2.208 -                    assert(session->sync_state_payload);
   2.209 -                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   2.210 -                    free_identity(((GroupedBeaconed_state_payload_t*)session->sync_state_payload)->expected);
   2.211 -                    free(session->sync_state_payload);
   2.212 -                    session->sync_state_payload = NULL;
   2.213 -                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=GroupedBeaconed, event=Timeout", "target=Grouped")
   2.214 -                    return Grouped;
   2.215 -                }
   2.216 -                default:
   2.217 -                    return (DeviceState_state) invalid_event;
   2.218 -            }
   2.219 -            break;
   2.220 -        }
   2.221 -        case HandshakingGrouped:
   2.222 -        {
   2.223 -            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=HandshakingGrouped")
   2.224 -            assert(session->sync_state_payload);
   2.225 -            if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   2.226 -            Identity expected = ((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected;
   2.227 -            *timeout = 600;
   2.228 -            switch (event) {
   2.229 -                case Init:
   2.230 -                {
   2.231 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=HandshakingGrouped", "event=Init")
   2.232 -                    {
   2.233 -                        int cond_result = keyElectionWon(session, partner);
   2.234 -                        #ifndef NDEBUG
   2.235 -                        char resstr[11] = {0,};
   2.236 -                        snprintf(resstr,10,"result=%d",cond_result);
   2.237 -                        #endif
   2.238 -                        DEBUG_LOG("FSM condition", "sync_fsm.c, state=HandshakingGrouped, event=Init, condition=keyElectionWon", resstr)
   2.239 -                        if (cond_result < 0)
   2.240 -                            return cond_result;
   2.241 -                        if (cond_result) {
   2.242 -                        DEBUG_LOG("FSM action", "sync_fsm.c, state=HandshakingGrouped, event=Init", "action=notifyInitAddOtherDevice")
   2.243 -                        status = notifyInitAddOtherDevice(session, state, partner, NULL);
   2.244 -                        if (status == PEP_OUT_OF_MEMORY)
   2.245 -                            return (int) invalid_out_of_memory;
   2.246 -                        if (status != PEP_STATUS_OK)
   2.247 -                            return (int) invalid_action;
   2.248 -                        }
   2.249 -                        else {
   2.250 -                        DEBUG_LOG("FSM action", "sync_fsm.c, state=HandshakingGrouped, event=Init", "action=notifyInitMoveOurDevice")
   2.251 -                        status = notifyInitMoveOurDevice(session, state, partner, NULL);
   2.252 -                        if (status == PEP_OUT_OF_MEMORY)
   2.253 -                            return (int) invalid_out_of_memory;
   2.254 -                        if (status != PEP_STATUS_OK)
   2.255 -                            return (int) invalid_action;
   2.256 -                        }
   2.257 -                    }
   2.258 -                    break;
   2.259 -                }
   2.260 -                case HandshakeRejected:
   2.261 -                {
   2.262 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=HandshakingGrouped", "event=HandshakeRejected")
   2.263 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=HandshakingGrouped, event=HandshakeRejected", "action=rejectHandshake")
   2.264 -                    status = rejectHandshake(session, state, partner, NULL);
   2.265 -                    if (status == PEP_OUT_OF_MEMORY)
   2.266 -                        return (int) invalid_out_of_memory;
   2.267 -                    if (status != PEP_STATUS_OK)
   2.268 -                        return (int) invalid_action;
   2.269 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=HandshakingGrouped, event=HandshakeRejected", "action=sendGroupUpdate")
   2.270 -                    status = sendGroupUpdate(session, state, NULL, NULL);
   2.271 -                    if (status == PEP_OUT_OF_MEMORY)
   2.272 -                        return (int) invalid_out_of_memory;
   2.273 -                    if (status != PEP_STATUS_OK)
   2.274 -                        return (int) invalid_action;
   2.275 -                    assert(session->sync_state_payload);
   2.276 -                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   2.277 -                    free_identity(((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected);
   2.278 -                    free(session->sync_state_payload);
   2.279 -                    session->sync_state_payload = NULL;
   2.280 -                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=HandshakingGrouped, event=HandshakeRejected", "target=Grouped")
   2.281 -                    return Grouped;
   2.282 -                }
   2.283 -                case HandshakeAccepted:
   2.284 -                {
   2.285 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=HandshakingGrouped", "event=HandshakeAccepted")
   2.286 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=HandshakingGrouped, event=HandshakeAccepted", "action=acceptHandshake")
   2.287 -                    status = acceptHandshake(session, state, partner, NULL);
   2.288 -                    if (status == PEP_OUT_OF_MEMORY)
   2.289 -                        return (int) invalid_out_of_memory;
   2.290 -                    if (status != PEP_STATUS_OK)
   2.291 -                        return (int) invalid_action;
   2.292 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=HandshakingGrouped, event=HandshakeAccepted", "action=sendGroupUpdate")
   2.293 -                    status = sendGroupUpdate(session, state, NULL, NULL);
   2.294 -                    if (status == PEP_OUT_OF_MEMORY)
   2.295 -                        return (int) invalid_out_of_memory;
   2.296 -                    if (status != PEP_STATUS_OK)
   2.297 -                        return (int) invalid_action;
   2.298 -                    {
   2.299 -                        int cond_result = keyElectionWon(session, partner);
   2.300 -                        #ifndef NDEBUG
   2.301 -                        char resstr[11] = {0,};
   2.302 -                        snprintf(resstr,10,"result=%d",cond_result);
   2.303 -                        #endif
   2.304 -                        DEBUG_LOG("FSM condition", "sync_fsm.c, state=HandshakingGrouped, event=HandshakeAccepted, condition=keyElectionWon", resstr)
   2.305 -                        if (cond_result < 0)
   2.306 -                            return cond_result;
   2.307 -                        if (cond_result) {
   2.308 -                        DEBUG_LOG("FSM action", "sync_fsm.c, state=HandshakingGrouped, event=HandshakeAccepted", "action=sendGroupKeys")
   2.309 -                        status = sendGroupKeys(session, state, partner, NULL);
   2.310 -                        if (status == PEP_OUT_OF_MEMORY)
   2.311 -                            return (int) invalid_out_of_memory;
   2.312 -                        if (status != PEP_STATUS_OK)
   2.313 -                            return (int) invalid_action;
   2.314 -                        DEBUG_LOG("FSM action", "sync_fsm.c, state=HandshakingGrouped, event=HandshakeAccepted", "action=notifyAcceptedDeviceAdded")
   2.315 -                        status = notifyAcceptedDeviceAdded(session, state, partner, NULL);
   2.316 -                        if (status == PEP_OUT_OF_MEMORY)
   2.317 -                            return (int) invalid_out_of_memory;
   2.318 -                        if (status != PEP_STATUS_OK)
   2.319 -                            return (int) invalid_action;
   2.320 -                        assert(session->sync_state_payload);
   2.321 -                        if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   2.322 -                        free_identity(((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected);
   2.323 -                        free(session->sync_state_payload);
   2.324 -                        session->sync_state_payload = NULL;
   2.325 -                        DEBUG_LOG("FSM transition", "sync_fsm.c, state=HandshakingGrouped, event=HandshakeAccepted", "target=Grouped")
   2.326 -                        return Grouped;
   2.327 -                        }
   2.328 -                    }
   2.329 -                    assert(session->sync_state_payload);
   2.330 -                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   2.331 -                    free_identity(((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected);
   2.332 -                    free(session->sync_state_payload);
   2.333 -                    session->sync_state_payload = NULL;
   2.334 -                    session->sync_state_payload = malloc(sizeof(WaitForGroupKeysGrouped_state_payload_t));
   2.335 -                    assert(session->sync_state_payload);
   2.336 -                    if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
   2.337 -                    ((WaitForGroupKeysGrouped_state_payload_t*)session->sync_state_payload)->expected =
   2.338 -                        identity_dup(partner);
   2.339 -                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=HandshakingGrouped, event=HandshakeAccepted", "target=WaitForGroupKeysGrouped")
   2.340 -                    return WaitForGroupKeysGrouped;
   2.341 -                }
   2.342 -                case Cancel:
   2.343 -                {
   2.344 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=HandshakingGrouped", "event=Cancel")
   2.345 -                    assert(session->sync_state_payload);
   2.346 -                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   2.347 -                    free_identity(((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected);
   2.348 -                    free(session->sync_state_payload);
   2.349 -                    session->sync_state_payload = NULL;
   2.350 -                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=HandshakingGrouped, event=Cancel", "target=Grouped")
   2.351 -                    return Grouped;
   2.352 -                }
   2.353 -                case GroupKeys:
   2.354 -                {
   2.355 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=HandshakingGrouped", "event=GroupKeys")
   2.356 -                    group_keys_extra_t* groupkeys = (group_keys_extra_t*)extra;
   2.357 -                    {
   2.358 -                        int cond_result = sameIdentities(session, partner, expected);
   2.359 -                        #ifndef NDEBUG
   2.360 -                        char resstr[11] = {0,};
   2.361 -                        snprintf(resstr,10,"result=%d",cond_result);
   2.362 -                        #endif
   2.363 -                        DEBUG_LOG("FSM condition", "sync_fsm.c, state=HandshakingGrouped, event=GroupKeys, condition=sameIdentities", resstr)
   2.364 -                        if (cond_result < 0)
   2.365 -                            return cond_result;
   2.366 -                        if (cond_result) {
   2.367 -                        assert(session->sync_state_payload);
   2.368 -                        if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   2.369 -                        free_identity(((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected);
   2.370 -                        free(session->sync_state_payload);
   2.371 -                        session->sync_state_payload = NULL;
   2.372 -                        session->sync_state_payload = malloc(sizeof(WaitForAcceptGrouped_state_payload_t));
   2.373 -                        assert(session->sync_state_payload);
   2.374 -                        if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
   2.375 -                        ((WaitForAcceptGrouped_state_payload_t*)session->sync_state_payload)->expected =
   2.376 -                            identity_dup(partner);
   2.377 -                        ((WaitForAcceptGrouped_state_payload_t*)session->sync_state_payload)->groupkeys =
   2.378 -                            group_keys_extra_dup(groupkeys);
   2.379 -                        DEBUG_LOG("FSM transition", "sync_fsm.c, state=HandshakingGrouped, event=GroupKeys", "target=WaitForAcceptGrouped")
   2.380 -                        return WaitForAcceptGrouped;
   2.381 -                        }
   2.382 -                    }
   2.383 -                    break;
   2.384 -                }
   2.385 -                case GroupUpdate:
   2.386 -                {
   2.387 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=HandshakingGrouped", "event=GroupUpdate")
   2.388 -                    identity_list* keys = (identity_list*)extra;
   2.389 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=HandshakingGrouped, event=GroupUpdate", "action=notifyOvertaken")
   2.390 -                    status = notifyOvertaken(session, state, partner, NULL);
   2.391 -                    if (status == PEP_OUT_OF_MEMORY)
   2.392 -                        return (int) invalid_out_of_memory;
   2.393 -                    if (status != PEP_STATUS_OK)
   2.394 -                        return (int) invalid_action;
   2.395 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=HandshakingGrouped, event=GroupUpdate", "action=storeGroupUpdate")
   2.396 -                    status = storeGroupUpdate(session, state, partner, keys);
   2.397 -                    if (status == PEP_OUT_OF_MEMORY)
   2.398 -                        return (int) invalid_out_of_memory;
   2.399 -                    if (status != PEP_STATUS_OK)
   2.400 -                        return (int) invalid_action;
   2.401 -                    assert(session->sync_state_payload);
   2.402 -                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   2.403 -                    free_identity(((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected);
   2.404 -                    free(session->sync_state_payload);
   2.405 -                    session->sync_state_payload = NULL;
   2.406 -                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=HandshakingGrouped, event=GroupUpdate", "target=Grouped")
   2.407 -                    return Grouped;
   2.408 -                }
   2.409 -                case Timeout:
   2.410 -                {
   2.411 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=HandshakingGrouped", "event=Timeout")
   2.412 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=HandshakingGrouped, event=Timeout", "action=notifyTimeout")
   2.413 -                    status = notifyTimeout(session, state, expected, NULL);
   2.414 -                    if (status == PEP_OUT_OF_MEMORY)
   2.415 -                        return (int) invalid_out_of_memory;
   2.416 -                    if (status != PEP_STATUS_OK)
   2.417 -                        return (int) invalid_action;
   2.418 -                    assert(session->sync_state_payload);
   2.419 -                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   2.420 -                    free_identity(((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected);
   2.421 -                    free(session->sync_state_payload);
   2.422 -                    session->sync_state_payload = NULL;
   2.423 -                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=HandshakingGrouped, event=Timeout", "target=Grouped")
   2.424 -                    return Grouped;
   2.425 -                }
   2.426 -                default:
   2.427 -                    return (DeviceState_state) invalid_event;
   2.428 -            }
   2.429 -            break;
   2.430 -        }
   2.431 -        case WaitForGroupKeysGrouped:
   2.432 -        {
   2.433 -            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=WaitForGroupKeysGrouped")
   2.434 -            assert(session->sync_state_payload);
   2.435 -            if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   2.436 -            Identity expected = ((WaitForGroupKeysGrouped_state_payload_t*)session->sync_state_payload)->expected;
   2.437 -            *timeout = 600;
   2.438 -            switch (event) {
   2.439 -                case Init: 
   2.440 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForGroupKeysGrouped", "event=Init") 
   2.441 -                    break;
   2.442 -                case GroupKeys:
   2.443 -                {
   2.444 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForGroupKeysGrouped", "event=GroupKeys")
   2.445 -                    group_keys_extra_t* groupkeys = (group_keys_extra_t*)extra;
   2.446 -                    {
   2.447 -                        int cond_result = sameIdentities(session, partner, expected);
   2.448 -                        #ifndef NDEBUG
   2.449 -                        char resstr[11] = {0,};
   2.450 -                        snprintf(resstr,10,"result=%d",cond_result);
   2.451 -                        #endif
   2.452 -                        DEBUG_LOG("FSM condition", "sync_fsm.c, state=WaitForGroupKeysGrouped, event=GroupKeys, condition=sameIdentities", resstr)
   2.453 -                        if (cond_result < 0)
   2.454 -                            return cond_result;
   2.455 -                        if (cond_result) {
   2.456 -                        DEBUG_LOG("FSM action", "sync_fsm.c, state=WaitForGroupKeysGrouped, event=GroupKeys", "action=storeGroupKeys")
   2.457 -                        status = storeGroupKeys(session, state, partner, groupkeys);
   2.458 -                        if (status == PEP_OUT_OF_MEMORY)
   2.459 -                            return (int) invalid_out_of_memory;
   2.460 -                        if (status != PEP_STATUS_OK)
   2.461 -                            return (int) invalid_action;
   2.462 -                        DEBUG_LOG("FSM action", "sync_fsm.c, state=WaitForGroupKeysGrouped, event=GroupKeys", "action=sendGroupUpdate")
   2.463 -                        status = sendGroupUpdate(session, state, NULL, NULL);
   2.464 -                        if (status == PEP_OUT_OF_MEMORY)
   2.465 -                            return (int) invalid_out_of_memory;
   2.466 -                        if (status != PEP_STATUS_OK)
   2.467 -                            return (int) invalid_action;
   2.468 -                        DEBUG_LOG("FSM action", "sync_fsm.c, state=WaitForGroupKeysGrouped, event=GroupKeys", "action=renewUUID")
   2.469 -                        status = renewUUID(session, state, NULL, NULL);
   2.470 -                        if (status == PEP_OUT_OF_MEMORY)
   2.471 -                            return (int) invalid_out_of_memory;
   2.472 -                        if (status != PEP_STATUS_OK)
   2.473 -                            return (int) invalid_action;
   2.474 -                        DEBUG_LOG("FSM action", "sync_fsm.c, state=WaitForGroupKeysGrouped, event=GroupKeys", "action=notifyAcceptedDeviceMoved")
   2.475 -                        status = notifyAcceptedDeviceMoved(session, state, partner, NULL);
   2.476 -                        if (status == PEP_OUT_OF_MEMORY)
   2.477 -                            return (int) invalid_out_of_memory;
   2.478 -                        if (status != PEP_STATUS_OK)
   2.479 -                            return (int) invalid_action;
   2.480 -                        assert(session->sync_state_payload);
   2.481 -                        if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   2.482 -                        free_identity(((WaitForGroupKeysGrouped_state_payload_t*)session->sync_state_payload)->expected);
   2.483 -                        free(session->sync_state_payload);
   2.484 -                        session->sync_state_payload = NULL;
   2.485 -                        DEBUG_LOG("FSM transition", "sync_fsm.c, state=WaitForGroupKeysGrouped, event=GroupKeys", "target=Grouped")
   2.486 -                        return Grouped;
   2.487 -                        }
   2.488 -                    }
   2.489 -                    break;
   2.490 -                }
   2.491 -                case GroupUpdate:
   2.492 -                {
   2.493 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForGroupKeysGrouped", "event=GroupUpdate")
   2.494 -                    identity_list* keys = (identity_list*)extra;
   2.495 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=WaitForGroupKeysGrouped, event=GroupUpdate", "action=notifyOvertaken")
   2.496 -                    status = notifyOvertaken(session, state, partner, NULL);
   2.497 -                    if (status == PEP_OUT_OF_MEMORY)
   2.498 -                        return (int) invalid_out_of_memory;
   2.499 -                    if (status != PEP_STATUS_OK)
   2.500 -                        return (int) invalid_action;
   2.501 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=WaitForGroupKeysGrouped, event=GroupUpdate", "action=storeGroupUpdate")
   2.502 -                    status = storeGroupUpdate(session, state, partner, keys);
   2.503 -                    if (status == PEP_OUT_OF_MEMORY)
   2.504 -                        return (int) invalid_out_of_memory;
   2.505 -                    if (status != PEP_STATUS_OK)
   2.506 -                        return (int) invalid_action;
   2.507 -                    assert(session->sync_state_payload);
   2.508 -                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   2.509 -                    free_identity(((WaitForGroupKeysGrouped_state_payload_t*)session->sync_state_payload)->expected);
   2.510 -                    free(session->sync_state_payload);
   2.511 -                    session->sync_state_payload = NULL;
   2.512 -                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=WaitForGroupKeysGrouped, event=GroupUpdate", "target=Grouped")
   2.513 -                    return Grouped;
   2.514 -                }
   2.515 -                case Timeout:
   2.516 -                {
   2.517 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForGroupKeysGrouped", "event=Timeout")
   2.518 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=WaitForGroupKeysGrouped, event=Timeout", "action=notifyTimeout")
   2.519 -                    status = notifyTimeout(session, state, expected, NULL);
   2.520 -                    if (status == PEP_OUT_OF_MEMORY)
   2.521 -                        return (int) invalid_out_of_memory;
   2.522 -                    if (status != PEP_STATUS_OK)
   2.523 -                        return (int) invalid_action;
   2.524 -                    assert(session->sync_state_payload);
   2.525 -                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   2.526 -                    free_identity(((WaitForGroupKeysGrouped_state_payload_t*)session->sync_state_payload)->expected);
   2.527 -                    free(session->sync_state_payload);
   2.528 -                    session->sync_state_payload = NULL;
   2.529 -                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=WaitForGroupKeysGrouped, event=Timeout", "target=Grouped")
   2.530 -                    return Grouped;
   2.531 -                }
   2.532 -                default:
   2.533 -                    return (DeviceState_state) invalid_event;
   2.534 -            }
   2.535 -            break;
   2.536 -        }
   2.537 -        case WaitForAcceptGrouped:
   2.538 -        {
   2.539 -            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=WaitForAcceptGrouped")
   2.540 -            assert(session->sync_state_payload);
   2.541 -            if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   2.542 -            Identity expected = ((WaitForAcceptGrouped_state_payload_t*)session->sync_state_payload)->expected;
   2.543 -            group_keys_extra_t* groupkeys = ((WaitForAcceptGrouped_state_payload_t*)session->sync_state_payload)->groupkeys;
   2.544 -            *timeout = 600;
   2.545 -            switch (event) {
   2.546 -                case Init: 
   2.547 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForAcceptGrouped", "event=Init") 
   2.548 -                    break;
   2.549 -                case HandshakeRejected:
   2.550 -                {
   2.551 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForAcceptGrouped", "event=HandshakeRejected")
   2.552 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=WaitForAcceptGrouped, event=HandshakeRejected", "action=rejectHandshake")
   2.553 -                    status = rejectHandshake(session, state, partner, NULL);
   2.554 -                    if (status == PEP_OUT_OF_MEMORY)
   2.555 -                        return (int) invalid_out_of_memory;
   2.556 -                    if (status != PEP_STATUS_OK)
   2.557 -                        return (int) invalid_action;
   2.558 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=WaitForAcceptGrouped, event=HandshakeRejected", "action=sendGroupUpdate")
   2.559 -                    status = sendGroupUpdate(session, state, NULL, NULL);
   2.560 -                    if (status == PEP_OUT_OF_MEMORY)
   2.561 -                        return (int) invalid_out_of_memory;
   2.562 -                    if (status != PEP_STATUS_OK)
   2.563 -                        return (int) invalid_action;
   2.564 -                    assert(session->sync_state_payload);
   2.565 -                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   2.566 -                    free_identity(((WaitForAcceptGrouped_state_payload_t*)session->sync_state_payload)->expected);
   2.567 -                    free_group_keys_extra(((WaitForAcceptGrouped_state_payload_t*)session->sync_state_payload)->groupkeys);
   2.568 -                    free(session->sync_state_payload);
   2.569 -                    session->sync_state_payload = NULL;
   2.570 -                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=WaitForAcceptGrouped, event=HandshakeRejected", "target=Grouped")
   2.571 -                    return Grouped;
   2.572 -                }
   2.573 -                case HandshakeAccepted:
   2.574 -                {
   2.575 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForAcceptGrouped", "event=HandshakeAccepted")
   2.576 -                    {
   2.577 -                        int cond_result = sameIdentities(session, partner, expected);
   2.578 -                        #ifndef NDEBUG
   2.579 -                        char resstr[11] = {0,};
   2.580 -                        snprintf(resstr,10,"result=%d",cond_result);
   2.581 -                        #endif
   2.582 -                        DEBUG_LOG("FSM condition", "sync_fsm.c, state=WaitForAcceptGrouped, event=HandshakeAccepted, condition=sameIdentities", resstr)
   2.583 -                        if (cond_result < 0)
   2.584 -                            return cond_result;
   2.585 -                        if (cond_result) {
   2.586 -                        DEBUG_LOG("FSM action", "sync_fsm.c, state=WaitForAcceptGrouped, event=HandshakeAccepted", "action=acceptHandshake")
   2.587 -                        status = acceptHandshake(session, state, partner, NULL);
   2.588 -                        if (status == PEP_OUT_OF_MEMORY)
   2.589 -                            return (int) invalid_out_of_memory;
   2.590 -                        if (status != PEP_STATUS_OK)
   2.591 -                            return (int) invalid_action;
   2.592 -                        DEBUG_LOG("FSM action", "sync_fsm.c, state=WaitForAcceptGrouped, event=HandshakeAccepted", "action=storeGroupKeys")
   2.593 -                        status = storeGroupKeys(session, state, partner, groupkeys);
   2.594 -                        if (status == PEP_OUT_OF_MEMORY)
   2.595 -                            return (int) invalid_out_of_memory;
   2.596 -                        if (status != PEP_STATUS_OK)
   2.597 -                            return (int) invalid_action;
   2.598 -                        DEBUG_LOG("FSM action", "sync_fsm.c, state=WaitForAcceptGrouped, event=HandshakeAccepted", "action=sendGroupUpdate")
   2.599 -                        status = sendGroupUpdate(session, state, NULL, NULL);
   2.600 -                        if (status == PEP_OUT_OF_MEMORY)
   2.601 -                            return (int) invalid_out_of_memory;
   2.602 -                        if (status != PEP_STATUS_OK)
   2.603 -                            return (int) invalid_action;
   2.604 -                        DEBUG_LOG("FSM action", "sync_fsm.c, state=WaitForAcceptGrouped, event=HandshakeAccepted", "action=renewUUID")
   2.605 -                        status = renewUUID(session, state, NULL, NULL);
   2.606 -                        if (status == PEP_OUT_OF_MEMORY)
   2.607 -                            return (int) invalid_out_of_memory;
   2.608 -                        if (status != PEP_STATUS_OK)
   2.609 -                            return (int) invalid_action;
   2.610 -                        DEBUG_LOG("FSM action", "sync_fsm.c, state=WaitForAcceptGrouped, event=HandshakeAccepted", "action=notifyAcceptedDeviceMoved")
   2.611 -                        status = notifyAcceptedDeviceMoved(session, state, partner, NULL);
   2.612 -                        if (status == PEP_OUT_OF_MEMORY)
   2.613 -                            return (int) invalid_out_of_memory;
   2.614 -                        if (status != PEP_STATUS_OK)
   2.615 -                            return (int) invalid_action;
   2.616 -                        }
   2.617 -                    }
   2.618 -                    assert(session->sync_state_payload);
   2.619 -                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   2.620 -                    free_identity(((WaitForAcceptGrouped_state_payload_t*)session->sync_state_payload)->expected);
   2.621 -                    free_group_keys_extra(((WaitForAcceptGrouped_state_payload_t*)session->sync_state_payload)->groupkeys);
   2.622 -                    free(session->sync_state_payload);
   2.623 -                    session->sync_state_payload = NULL;
   2.624 -                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=WaitForAcceptGrouped, event=HandshakeAccepted", "target=Grouped")
   2.625 -                    return Grouped;
   2.626 -                }
   2.627 -                case Cancel:
   2.628 -                {
   2.629 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForAcceptGrouped", "event=Cancel")
   2.630 -                    assert(session->sync_state_payload);
   2.631 -                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   2.632 -                    free_identity(((WaitForAcceptGrouped_state_payload_t*)session->sync_state_payload)->expected);
   2.633 -                    free_group_keys_extra(((WaitForAcceptGrouped_state_payload_t*)session->sync_state_payload)->groupkeys);
   2.634 -                    free(session->sync_state_payload);
   2.635 -                    session->sync_state_payload = NULL;
   2.636 -                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=WaitForAcceptGrouped, event=Cancel", "target=Grouped")
   2.637 -                    return Grouped;
   2.638 -                }
   2.639 -                case GroupUpdate:
   2.640 -                {
   2.641 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForAcceptGrouped", "event=GroupUpdate")
   2.642 -                    identity_list* keys = (identity_list*)extra;
   2.643 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=WaitForAcceptGrouped, event=GroupUpdate", "action=notifyOvertaken")
   2.644 -                    status = notifyOvertaken(session, state, partner, NULL);
   2.645 -                    if (status == PEP_OUT_OF_MEMORY)
   2.646 -                        return (int) invalid_out_of_memory;
   2.647 -                    if (status != PEP_STATUS_OK)
   2.648 -                        return (int) invalid_action;
   2.649 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=WaitForAcceptGrouped, event=GroupUpdate", "action=storeGroupUpdate")
   2.650 -                    status = storeGroupUpdate(session, state, partner, keys);
   2.651 -                    if (status == PEP_OUT_OF_MEMORY)
   2.652 -                        return (int) invalid_out_of_memory;
   2.653 -                    if (status != PEP_STATUS_OK)
   2.654 -                        return (int) invalid_action;
   2.655 -                    assert(session->sync_state_payload);
   2.656 -                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   2.657 -                    free_identity(((WaitForAcceptGrouped_state_payload_t*)session->sync_state_payload)->expected);
   2.658 -                    free_group_keys_extra(((WaitForAcceptGrouped_state_payload_t*)session->sync_state_payload)->groupkeys);
   2.659 -                    free(session->sync_state_payload);
   2.660 -                    session->sync_state_payload = NULL;
   2.661 -                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=WaitForAcceptGrouped, event=GroupUpdate", "target=Grouped")
   2.662 -                    return Grouped;
   2.663 -                }
   2.664 -                case Timeout:
   2.665 -                {
   2.666 -                    DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForAcceptGrouped", "event=Timeout")
   2.667 -                    DEBUG_LOG("FSM action", "sync_fsm.c, state=WaitForAcceptGrouped, event=Timeout", "action=notifyTimeout")
   2.668 -                    status = notifyTimeout(session, state, expected, NULL);
   2.669 -                    if (status == PEP_OUT_OF_MEMORY)
   2.670 -                        return (int) invalid_out_of_memory;
   2.671 -                    if (status != PEP_STATUS_OK)
   2.672 -                        return (int) invalid_action;
   2.673 -                    assert(session->sync_state_payload);
   2.674 -                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   2.675 -                    free_identity(((WaitForAcceptGrouped_state_payload_t*)session->sync_state_payload)->expected);
   2.676 -                    free_group_keys_extra(((WaitForAcceptGrouped_state_payload_t*)session->sync_state_payload)->groupkeys);
   2.677 -                    free(session->sync_state_payload);
   2.678 -                    session->sync_state_payload = NULL;
   2.679 -                    DEBUG_LOG("FSM transition", "sync_fsm.c, state=WaitForAcceptGrouped, event=Timeout", "target=Grouped")
   2.680 -                    return Grouped;
   2.681 -                }
   2.682 -                default:
   2.683 -                    return (DeviceState_state) invalid_event;
   2.684 -            }
   2.685 -            break;
   2.686 -        }
   2.687          default:
   2.688              return (DeviceState_state) invalid_state;
   2.689      }
     3.1 --- a/sync/generated/sync_fsm.h	Mon Mar 13 22:44:12 2017 +0100
     3.2 +++ b/sync/generated/sync_fsm.h	Wed Mar 15 15:09:15 2017 +0100
     3.3 @@ -50,11 +50,7 @@
     3.4      HandshakingSole, 
     3.5      WaitForGroupKeysSole, 
     3.6      WaitForAcceptSole, 
     3.7 -    Grouped, 
     3.8 -    GroupedBeaconed, 
     3.9 -    HandshakingGrouped, 
    3.10 -    WaitForGroupKeysGrouped, 
    3.11 -    WaitForAcceptGrouped
    3.12 +    Grouped
    3.13  } DeviceState_state;
    3.14  
    3.15  // events
    3.16 @@ -93,10 +89,6 @@
    3.17  PEP_STATUS notifyAcceptedDeviceAdded(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    3.18  PEP_STATUS sendUpdateRequest(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    3.19  PEP_STATUS storeGroupUpdate(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    3.20 -PEP_STATUS notifyInitAddOtherDevice(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    3.21 -PEP_STATUS notifyInitMoveOurDevice(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    3.22 -PEP_STATUS notifyOvertaken(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    3.23 -PEP_STATUS notifyAcceptedDeviceMoved(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    3.24  
    3.25  // event injector
    3.26  
     4.1 --- a/sync/generated/sync_send_actions.c	Mon Mar 13 22:44:12 2017 +0100
     4.2 +++ b/sync/generated/sync_send_actions.c	Wed Mar 15 15:09:15 2017 +0100
     4.3 @@ -415,107 +415,3 @@
     4.4      return _notifyHandshake(session, partner, SYNC_NOTIFY_ACCEPTED_DEVICE_ADDED);
     4.5  }
     4.6  
     4.7 -
     4.8 -// notifyInitAddOtherDevice() - notify InitAddOtherDevice to app
     4.9 -//
    4.10 -//  params:
    4.11 -//      session (in)        session handle
    4.12 -//      state (in)          state the state machine is in
    4.13 -//      partner (in)        partner to communicate with
    4.14 -//
    4.15 -//  returns:
    4.16 -//      PEP_STATUS_OK or any other value on error
    4.17 -
    4.18 -PEP_STATUS notifyInitAddOtherDevice(
    4.19 -        PEP_SESSION session,
    4.20 -        DeviceState_state state,
    4.21 -        Identity partner,
    4.22 -        void *extra
    4.23 -    )
    4.24 -{
    4.25 -    assert(session && state);
    4.26 -    assert(extra == NULL);
    4.27 -    if (!(session && state && extra == NULL))
    4.28 -        return PEP_ILLEGAL_VALUE;
    4.29 -
    4.30 -    return _notifyHandshake(session, partner, SYNC_NOTIFY_INIT_ADD_OTHER_DEVICE);
    4.31 -}
    4.32 -
    4.33 -
    4.34 -// notifyInitMoveOurDevice() - notify InitMoveOurDevice to app
    4.35 -//
    4.36 -//  params:
    4.37 -//      session (in)        session handle
    4.38 -//      state (in)          state the state machine is in
    4.39 -//      partner (in)        partner to communicate with
    4.40 -//
    4.41 -//  returns:
    4.42 -//      PEP_STATUS_OK or any other value on error
    4.43 -
    4.44 -PEP_STATUS notifyInitMoveOurDevice(
    4.45 -        PEP_SESSION session,
    4.46 -        DeviceState_state state,
    4.47 -        Identity partner,
    4.48 -        void *extra
    4.49 -    )
    4.50 -{
    4.51 -    assert(session && state);
    4.52 -    assert(extra == NULL);
    4.53 -    if (!(session && state && extra == NULL))
    4.54 -        return PEP_ILLEGAL_VALUE;
    4.55 -
    4.56 -    return _notifyHandshake(session, partner, SYNC_NOTIFY_INIT_MOVE_OUR_DEVICE);
    4.57 -}
    4.58 -
    4.59 -
    4.60 -// notifyOvertaken() - notify Overtaken to app
    4.61 -//
    4.62 -//  params:
    4.63 -//      session (in)        session handle
    4.64 -//      state (in)          state the state machine is in
    4.65 -//      partner (in)        partner to communicate with
    4.66 -//
    4.67 -//  returns:
    4.68 -//      PEP_STATUS_OK or any other value on error
    4.69 -
    4.70 -PEP_STATUS notifyOvertaken(
    4.71 -        PEP_SESSION session,
    4.72 -        DeviceState_state state,
    4.73 -        Identity partner,
    4.74 -        void *extra
    4.75 -    )
    4.76 -{
    4.77 -    assert(session && state);
    4.78 -    assert(extra == NULL);
    4.79 -    if (!(session && state && extra == NULL))
    4.80 -        return PEP_ILLEGAL_VALUE;
    4.81 -
    4.82 -    return _notifyHandshake(session, partner, SYNC_NOTIFY_OVERTAKEN);
    4.83 -}
    4.84 -
    4.85 -
    4.86 -// notifyAcceptedDeviceMoved() - notify AcceptedDeviceMoved to app
    4.87 -//
    4.88 -//  params:
    4.89 -//      session (in)        session handle
    4.90 -//      state (in)          state the state machine is in
    4.91 -//      partner (in)        partner to communicate with
    4.92 -//
    4.93 -//  returns:
    4.94 -//      PEP_STATUS_OK or any other value on error
    4.95 -
    4.96 -PEP_STATUS notifyAcceptedDeviceMoved(
    4.97 -        PEP_SESSION session,
    4.98 -        DeviceState_state state,
    4.99 -        Identity partner,
   4.100 -        void *extra
   4.101 -    )
   4.102 -{
   4.103 -    assert(session && state);
   4.104 -    assert(extra == NULL);
   4.105 -    if (!(session && state && extra == NULL))
   4.106 -        return PEP_ILLEGAL_VALUE;
   4.107 -
   4.108 -    return _notifyHandshake(session, partner, SYNC_NOTIFY_ACCEPTED_DEVICE_MOVED);
   4.109 -}
   4.110 -
     5.1 --- a/sync/skeletons/sync_actions.c	Mon Mar 13 22:44:12 2017 +0100
     5.2 +++ b/sync/skeletons/sync_actions.c	Wed Mar 15 15:09:15 2017 +0100
     5.3 @@ -414,151 +414,3 @@
     5.4      return status;
     5.5  }
     5.6  
     5.7 -
     5.8 -// notifyInitAddOtherDevice() - 
     5.9 -//
    5.10 -//  params:
    5.11 -//      session (in)        session handle
    5.12 -//      state (in)          state the state machine is in
    5.13 -//      partner (in)        partner to communicate with
    5.14 -//
    5.15 -//  returns:
    5.16 -//      PEP_STATUS_OK or any other value on error
    5.17 -
    5.18 -PEP_STATUS notifyInitAddOtherDevice(
    5.19 -        PEP_SESSION session,
    5.20 -        DeviceState_state state,
    5.21 -        Identity partner,
    5.22 -        void *extra
    5.23 -    )
    5.24 -{
    5.25 -    PEP_STATUS status = PEP_STATUS_OK;
    5.26 -
    5.27 -    assert(session);
    5.28 -    assert(partner);
    5.29 -    if (!(session && partner))
    5.30 -        return PEP_ILLEGAL_VALUE;
    5.31 -
    5.32 -    // working code
    5.33 -
    5.34 -    // free extra
    5.35 -    return status;
    5.36 -
    5.37 -enomem:
    5.38 -    status = PEP_OUT_OF_MEMORY;
    5.39 -error:
    5.40 -    // free extra
    5.41 -    return status;
    5.42 -}
    5.43 -
    5.44 -
    5.45 -// notifyInitMoveOurDevice() - 
    5.46 -//
    5.47 -//  params:
    5.48 -//      session (in)        session handle
    5.49 -//      state (in)          state the state machine is in
    5.50 -//      partner (in)        partner to communicate with
    5.51 -//
    5.52 -//  returns:
    5.53 -//      PEP_STATUS_OK or any other value on error
    5.54 -
    5.55 -PEP_STATUS notifyInitMoveOurDevice(
    5.56 -        PEP_SESSION session,
    5.57 -        DeviceState_state state,
    5.58 -        Identity partner,
    5.59 -        void *extra
    5.60 -    )
    5.61 -{
    5.62 -    PEP_STATUS status = PEP_STATUS_OK;
    5.63 -
    5.64 -    assert(session);
    5.65 -    assert(partner);
    5.66 -    if (!(session && partner))
    5.67 -        return PEP_ILLEGAL_VALUE;
    5.68 -
    5.69 -    // working code
    5.70 -
    5.71 -    // free extra
    5.72 -    return status;
    5.73 -
    5.74 -enomem:
    5.75 -    status = PEP_OUT_OF_MEMORY;
    5.76 -error:
    5.77 -    // free extra
    5.78 -    return status;
    5.79 -}
    5.80 -
    5.81 -
    5.82 -// notifyOvertaken() - 
    5.83 -//
    5.84 -//  params:
    5.85 -//      session (in)        session handle
    5.86 -//      state (in)          state the state machine is in
    5.87 -//      partner (in)        partner to communicate with
    5.88 -//
    5.89 -//  returns:
    5.90 -//      PEP_STATUS_OK or any other value on error
    5.91 -
    5.92 -PEP_STATUS notifyOvertaken(
    5.93 -        PEP_SESSION session,
    5.94 -        DeviceState_state state,
    5.95 -        Identity partner,
    5.96 -        void *extra
    5.97 -    )
    5.98 -{
    5.99 -    PEP_STATUS status = PEP_STATUS_OK;
   5.100 -
   5.101 -    assert(session);
   5.102 -    assert(partner);
   5.103 -    if (!(session && partner))
   5.104 -        return PEP_ILLEGAL_VALUE;
   5.105 -
   5.106 -    // working code
   5.107 -
   5.108 -    // free extra
   5.109 -    return status;
   5.110 -
   5.111 -enomem:
   5.112 -    status = PEP_OUT_OF_MEMORY;
   5.113 -error:
   5.114 -    // free extra
   5.115 -    return status;
   5.116 -}
   5.117 -
   5.118 -
   5.119 -// notifyAcceptedDeviceMoved() - 
   5.120 -//
   5.121 -//  params:
   5.122 -//      session (in)        session handle
   5.123 -//      state (in)          state the state machine is in
   5.124 -//      partner (in)        partner to communicate with
   5.125 -//
   5.126 -//  returns:
   5.127 -//      PEP_STATUS_OK or any other value on error
   5.128 -
   5.129 -PEP_STATUS notifyAcceptedDeviceMoved(
   5.130 -        PEP_SESSION session,
   5.131 -        DeviceState_state state,
   5.132 -        Identity partner,
   5.133 -        void *extra
   5.134 -    )
   5.135 -{
   5.136 -    PEP_STATUS status = PEP_STATUS_OK;
   5.137 -
   5.138 -    assert(session);
   5.139 -    assert(partner);
   5.140 -    if (!(session && partner))
   5.141 -        return PEP_ILLEGAL_VALUE;
   5.142 -
   5.143 -    // working code
   5.144 -
   5.145 -    // free extra
   5.146 -    return status;
   5.147 -
   5.148 -enomem:
   5.149 -    status = PEP_OUT_OF_MEMORY;
   5.150 -error:
   5.151 -    // free extra
   5.152 -    return status;
   5.153 -}
   5.154 -