Added keysync acceptHandshake action, fixed typo in fsm definitions keysync
authorEdouard Tisserant <edouard@pep-project.org>
Wed, 14 Sep 2016 01:54:05 +0200
branchkeysync
changeset 11619a1f9ec6561a
parent 1160 a176739cd3c3
child 1162 f8db5c47b7f3
Added keysync acceptHandshake action, fixed typo in fsm definitions
src/sync_actions.c
src/sync_fsm.h
src/sync_send_actions.c
sync/devicegroup.fsm
     1.1 --- a/src/sync_actions.c	Tue Sep 13 16:35:17 2016 +0200
     1.2 +++ b/src/sync_actions.c	Wed Sep 14 01:54:05 2016 +0200
     1.3 @@ -145,7 +145,7 @@
     1.4  }
     1.5  
     1.6  
     1.7 -// reject() - stores rejection of partner
     1.8 +// acceptHandshake() - stores acception of partner
     1.9  //
    1.10  //  params:
    1.11  //      session (in)        session handle
    1.12 @@ -155,7 +155,39 @@
    1.13  //  returns:
    1.14  //      PEP_STATUS_OK or any other value on error
    1.15  
    1.16 -PEP_STATUS reject(
    1.17 +PEP_STATUS acceptHandshake(
    1.18 +        PEP_SESSION session,
    1.19 +        DeviceState_state state,
    1.20 +        Identity partner,
    1.21 +        void *extra
    1.22 +    )
    1.23 +{
    1.24 +    PEP_STATUS status = PEP_STATUS_OK;
    1.25 +
    1.26 +    assert(session);
    1.27 +    assert(partner);
    1.28 +    assert(extra == NULL);
    1.29 +    if (!(session && partner))
    1.30 +        return PEP_ILLEGAL_VALUE;
    1.31 +
    1.32 +    status = trust_personal_key(session, partner);
    1.33 +
    1.34 +    free_identity(partner);
    1.35 +    return status;
    1.36 +}
    1.37 +
    1.38 +
    1.39 +// rejectHandshake() - stores rejection of partner
    1.40 +//
    1.41 +//  params:
    1.42 +//      session (in)        session handle
    1.43 +//      state (in)          state the state machine is in
    1.44 +//      partner (in)        partner to communicate with
    1.45 +//
    1.46 +//  returns:
    1.47 +//      PEP_STATUS_OK or any other value on error
    1.48 +
    1.49 +PEP_STATUS rejectHandshake(
    1.50          PEP_SESSION session,
    1.51          DeviceState_state state,
    1.52          Identity partner,
     2.1 --- a/src/sync_fsm.h	Tue Sep 13 16:35:17 2016 +0200
     2.2 +++ b/src/sync_fsm.h	Wed Sep 14 01:54:05 2016 +0200
     2.3 @@ -64,8 +64,7 @@
     2.4      HandshakeRejected, 
     2.5      HandshakeAccepted, 
     2.6      Cancel, 
     2.7 -    Reject, 
     2.8 -    Hand
     2.9 +    Reject
    2.10  } DeviceState_event;
    2.11  
    2.12  // actions
    2.13 @@ -73,9 +72,10 @@
    2.14  PEP_STATUS sendBeacon(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    2.15  PEP_STATUS sendHandshakeRequest(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    2.16  PEP_STATUS showHandshake(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    2.17 -PEP_STATUS reject(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    2.18 +PEP_STATUS rejectHandshake(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    2.19 +PEP_STATUS acceptHandshake(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    2.20 +PEP_STATUS sendGroupKeys(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    2.21  PEP_STATUS storeGroupKeys(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    2.22 -PEP_STATUS sendGroupKeys(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    2.23  
    2.24  // message receiver
    2.25  
     3.1 --- a/src/sync_send_actions.c	Tue Sep 13 16:35:17 2016 +0200
     3.2 +++ b/src/sync_send_actions.c	Wed Sep 14 01:54:05 2016 +0200
     3.3 @@ -109,7 +109,7 @@
     3.4  //  params:
     3.5  //      session (in)        session handle
     3.6  //      state (in)          state the state machine is in
     3.7 -//      partner (in)        (must be NULL)
     3.8 +//      partner (in)        partner to communicate with
     3.9  //
    3.10  //  returns:
    3.11  //      PEP_STATUS_OK or any other value on error
     4.1 --- a/sync/devicegroup.fsm	Tue Sep 13 16:35:17 2016 +0200
     4.2 +++ b/sync/devicegroup.fsm	Wed Sep 14 01:54:05 2016 +0200
     4.3 @@ -42,14 +42,14 @@
     4.4              on Init
     4.5                  do showHandshake(partner);
     4.6              on HandshakeRejected(Identity partner) {
     4.7 -                do reject(partner);             // stores rejection of partner
     4.8 +                do rejectHandshake(partner);             // stores rejection of partner
     4.9                  go Sole;
    4.10              }
    4.11              on HandshakeAccepted(Identity partner) {
    4.12 +                do acceptHandshake(partner); 
    4.13                  if keyElectionWon(partner) {    // an already existing group
    4.14                                                  // always wins
    4.15 -                    ownGroupKeys;
    4.16 -                    sendGroupKeys(partner);
    4.17 +                    do sendGroupKeys(partner);
    4.18                      go Grouped;
    4.19                  }
    4.20                  go WaitForGroupKeys(Identity partner);
    4.21 @@ -63,7 +63,7 @@
    4.22              }
    4.23              on Cancel go Sole;
    4.24              on Reject(Identity partner) {
    4.25 -                do reject(partner);
    4.26 +                do rejectHandshake(partner);
    4.27                  go Sole;
    4.28              }
    4.29          }
    4.30 @@ -76,12 +76,13 @@
    4.31                  do showHandshake(partner);
    4.32              }
    4.33              on HandshakeRejected(Identity partner)
    4.34 -                do reject(partner);
    4.35 -            on Hand
    4.36 -                hakeAccepted(Identity partner)
    4.37 +                do rejectHandshake(partner);
    4.38 +            on HandshakeAccepted(Identity partner){
    4.39 +                do acceptHandshake(partner); 
    4.40                  do sendGroupKeys(partner);
    4.41 +            }
    4.42              on Reject(Identity partner)
    4.43 -                do reject partner;
    4.44 +                do rejectHandshake partner;
    4.45          }
    4.46  
    4.47          tag Init 1;