Sync : asynchronously inject KeyGen and CannotDecrypt to fsm keysync
authorEdouard Tisserant <edouard@pep-project.org>
Mon, 26 Sep 2016 16:55:23 +0200
branchkeysync
changeset 119553f8859f476b
parent 1173 5a8002f941e0
child 1198 47ff9a548e96
child 1203 c463238a1942
Sync : asynchronously inject KeyGen and CannotDecrypt to fsm
src/keymanagement.c
src/message_api.c
src/sync_fsm.h
src/sync_impl.h
     1.1 --- a/src/keymanagement.c	Sat Sep 24 09:46:53 2016 +0200
     1.2 +++ b/src/keymanagement.c	Mon Sep 26 16:55:23 2016 +0200
     1.3 @@ -9,6 +9,8 @@
     1.4  #include "pEp_internal.h"
     1.5  #include "keymanagement.h"
     1.6  
     1.7 +#include "sync_fsm.h"
     1.8 +
     1.9  #ifndef EMPTYSTR
    1.10  #define EMPTYSTR(STR) ((STR) == NULL || (STR)[0] == '\0')
    1.11  #endif
    1.12 @@ -513,8 +515,7 @@
    1.13      if(new_key_generated)
    1.14      {
    1.15          // if a state machine for keysync is in place, inject notify
    1.16 -        if (session->sync_state != DeviceState_state_NONE)
    1.17 -            status = fsm_DeviceState_inject(session, KeyGen, NULL, NULL);
    1.18 +        status = inject_DeviceState_event(session, KeyGen, NULL, NULL);
    1.19          if (status != PEP_STATUS_OK)
    1.20              return status;
    1.21      }
     2.1 --- a/src/message_api.c	Sat Sep 24 09:46:53 2016 +0200
     2.2 +++ b/src/message_api.c	Mon Sep 26 16:55:23 2016 +0200
     2.3 @@ -1434,8 +1434,10 @@
     2.4      }
     2.5      status = cryptotech[crypto].decrypt_and_verify(session, ctext,
     2.6                                                     csize, &ptext, &psize, &_keylist);
     2.7 -    if (status > PEP_CANNOT_DECRYPT_UNKNOWN)
     2.8 +    if (status > PEP_CANNOT_DECRYPT_UNKNOWN){
     2.9 +        status = inject_DeviceState_event(session, CannotDecrypt, NULL, NULL);
    2.10          goto pep_error;
    2.11 +    }
    2.12  
    2.13      decrypt_status = status;
    2.14  
     3.1 --- a/src/sync_fsm.h	Sat Sep 24 09:46:53 2016 +0200
     3.2 +++ b/src/sync_fsm.h	Mon Sep 26 16:55:23 2016 +0200
     3.3 @@ -86,6 +86,14 @@
     3.4          stringlist_t *keylist
     3.5      );
     3.6  
     3.7 +// event injector
     3.8 +
     3.9 +PEP_STATUS inject_DeviceState_event(
    3.10 +    PEP_SESSION session, 
    3.11 +    DeviceState_event event,
    3.12 +    Identity partner,
    3.13 +    void *extra);
    3.14 +
    3.15  // state machine
    3.16  
    3.17  DeviceState_state fsm_DeviceState(
     4.1 --- a/src/sync_impl.h	Sat Sep 24 09:46:53 2016 +0200
     4.2 +++ b/src/sync_impl.h	Mon Sep 26 16:55:23 2016 +0200
     4.3 @@ -13,6 +13,12 @@
     4.4          sync_msg_t *sync_msg
     4.5      );
     4.6  
     4.7 +PEP_STATUS inject_DeviceState_event(
     4.8 +    PEP_SESSION session, 
     4.9 +    DeviceState_event event,
    4.10 +    Identity partner,
    4.11 +    void *extra);
    4.12 +
    4.13  PEP_STATUS receive_DeviceState_msg(
    4.14      PEP_SESSION session, 
    4.15      message *src,