even Sith lords get hungry sync
authorVolker Birk <vb@pep.foundation>
Tue, 20 Nov 2018 12:32:09 +0100
branchsync
changeset 3129ad8aa4d09cf0
parent 3127 d97ed5c1c16e
child 3130 7416d52013ff
even Sith lords get hungry
src/baseprotocol.c
src/baseprotocol.h
sync/gen_statemachine.ysl2
     1.1 --- a/src/baseprotocol.c	Thu Nov 08 13:20:38 2018 +0100
     1.2 +++ b/src/baseprotocol.c	Tue Nov 20 12:32:09 2018 +0100
     1.3 @@ -7,7 +7,8 @@
     1.4  PEP_STATUS base_decorate_message(
     1.5          message *msg,
     1.6          char *payload,
     1.7 -        size_t size
     1.8 +        size_t size,
     1.9 +        char *fpr
    1.10      )
    1.11  {
    1.12      assert(msg);
    1.13 @@ -22,6 +23,10 @@
    1.14      if (bl == NULL)
    1.15          goto enomem;
    1.16  
    1.17 +    if (fpr) {
    1.18 +        // add signature
    1.19 +    }
    1.20 +
    1.21      msg->attachments = bl;
    1.22      return PEP_STATUS_OK;
    1.23  
    1.24 @@ -34,6 +39,7 @@
    1.25          const pEp_identity *partner,
    1.26          char *payload,
    1.27          size_t size,
    1.28 +        char *fpr,
    1.29          message **result
    1.30      )
    1.31  {
    1.32 @@ -75,7 +81,7 @@
    1.33      if (!msg->longmsg)
    1.34          goto enomem;
    1.35  
    1.36 -    status = base_decorate_message(msg, payload, size);
    1.37 +    status = base_decorate_message(msg, payload, size, fpr);
    1.38      if (status == PEP_STATUS_OK)
    1.39          *result = msg;
    1.40      return status;
     2.1 --- a/src/baseprotocol.h	Thu Nov 08 13:20:38 2018 +0100
     2.2 +++ b/src/baseprotocol.h	Tue Nov 20 12:32:09 2018 +0100
     2.3 @@ -16,6 +16,7 @@
     2.4  //      msg (inout)     message to decorate
     2.5  //      payload (in)    payload to send
     2.6  //      size (in)       size of payload
     2.7 +//      fpr (in)        optional key to sign or NULL
     2.8  //
     2.9  //  returns:
    2.10  //      PEP_STATUS_OK and result on success or an error on failure
    2.11 @@ -27,7 +28,8 @@
    2.12  PEP_STATUS base_decorate_message(
    2.13          message *msg,
    2.14          char *payload,
    2.15 -        size_t size
    2.16 +        size_t size,
    2.17 +        char *fpr
    2.18      );
    2.19  
    2.20  
    2.21 @@ -38,6 +40,7 @@
    2.22  //      partner (in)    identity to use for the receiver
    2.23  //      payload (in)    payload to send
    2.24  //      size (in)       size of payload
    2.25 +//      fpr (in)        optional key to sign or NULL
    2.26  //      result (out)    message with payload
    2.27  //
    2.28  //  returns:
    2.29 @@ -52,6 +55,7 @@
    2.30          const pEp_identity *partner,
    2.31          char *payload,
    2.32          size_t size,
    2.33 +        char *fpr,
    2.34          message **result
    2.35      );
    2.36  
     3.1 --- a/sync/gen_statemachine.ysl2	Thu Nov 08 13:20:38 2018 +0100
     3.2 +++ b/sync/gen_statemachine.ysl2	Tue Nov 20 12:32:09 2018 +0100
     3.3 @@ -451,25 +451,38 @@
     3.4                          goto the_end;
     3.5                      }
     3.6                      memcpy(_data, data, size);
     3.7 -                    status = base_prepare_message(
     3.8 -                            li->ident,
     3.9 -                            li->ident,
    3.10 -                            _data,
    3.11 -                            size,
    3.12 -                            &_m
    3.13 -                        );
    3.14 -                    if (status) {
    3.15 -                        free(_data);
    3.16 -                        goto the_end;
    3.17 -                    }
    3.18  
    3.19                      switch (message_type) {
    3.20                      `` for "fsm/message[@security='unencrypted']" |>>> case «../@name»__payload_PR_«yml:mixedCase(@name)»:
    3.21 +                            status = base_prepare_message(
    3.22 +                                    li->ident,
    3.23 +                                    li->ident,
    3.24 +                                    _data,
    3.25 +                                    size,
    3.26 +                                    li->ident->fpr,
    3.27 +                                    &_m
    3.28 +                                );
    3.29 +                            if (status) {
    3.30 +                                free(_data);
    3.31 +                                goto the_end;
    3.32 +                            }
    3.33                              attach_own_key(session, _m);
    3.34                              m = _m;
    3.35                              break;
    3.36  
    3.37                          default:
    3.38 +                            status = base_prepare_message(
    3.39 +                                    li->ident,
    3.40 +                                    li->ident,
    3.41 +                                    _data,
    3.42 +                                    size,
    3.43 +                                    NULL,
    3.44 +                                    &_m
    3.45 +                                );
    3.46 +                            if (status) {
    3.47 +                                free(_data);
    3.48 +                                goto the_end;
    3.49 +                            }
    3.50                              status = encrypt_message(session, _m, NULL, &m, PEP_enc_PEP, 0);
    3.51                              if (status) {
    3.52                                  status = PEP_«yml:ucase(@name)»_CANNOT_ENCRYPT;