KeySync: accept handshake requests addressed to group, continued AllGroupDevicesShowHandshake
authorEdouard Tisserant <edouard@pep-project.org>
Wed, 01 Mar 2017 15:59:00 +0100
branchAllGroupDevicesShowHandshake
changeset 160816c78f261d78
parent 1607 f22aa0501060
child 1622 4460e54ed8ba
KeySync: accept handshake requests addressed to group, continued
src/sync_impl.c
     1.1 --- a/src/sync_impl.c	Wed Mar 01 15:45:56 2017 +0100
     1.2 +++ b/src/sync_impl.c	Wed Mar 01 15:59:00 2017 +0100
     1.3 @@ -88,19 +88,21 @@
     1.4                  break;
     1.5  
     1.6              case DeviceGroup_Protocol__payload_PR_handshakeRequest:
     1.7 -                // re-check uuid in case sync_uuid changed while in the queue
     1.8 -
     1.9 -// TODO check matching group-ID as well
    1.10 -
    1.11 -                if (!_is_own_uuid(session, 
    1.12 -                        msg->payload.choice.handshakeRequest.partner_id)){
    1.13 +            {
    1.14 +                // re-check uuid in case sync_uuid or group changed while in the queue
    1.15 +                bool is_for_me = _is_own_uuid(session, 
    1.16 +                    msg->payload.choice.handshakeRequest.partner_id);
    1.17 +                bool is_for_group = !is_for_me && _is_own_group_uuid(session, 
    1.18 +                    msg->payload.choice.handshakeRequest.partner_id);
    1.19 +                if (!(is_for_me || is_for_group)){
    1.20                      status = PEP_SYNC_ILLEGAL_MESSAGE;
    1.21                      goto error;
    1.22                  }
    1.23  
    1.24                  if(msgIsFromGroup) {
    1.25 -                    if(_is_own_group_uuid(session, 
    1.26 -                           msg->payload.choice.handshakeRequest.group_id)) {
    1.27 +                    bool is_from_group = _is_own_group_uuid(session, 
    1.28 +                        msg->payload.choice.handshakeRequest.group_id);
    1.29 +                    if(is_from_group) {
    1.30                          status = PEP_SYNC_ILLEGAL_MESSAGE;
    1.31                          goto error;
    1.32                      }
    1.33 @@ -113,6 +115,7 @@
    1.34                  event = HandshakeRequest;
    1.35                  break;
    1.36  
    1.37 +            }
    1.38              case DeviceGroup_Protocol__payload_PR_updateRequest:
    1.39                  event = UpdateRequest;
    1.40                  break;
    1.41 @@ -458,13 +461,15 @@
    1.42                                  msg->payload.choice.handshakeRequest.partner_id);
    1.43                              bool is_for_group = !is_for_me && _is_own_group_uuid(session, 
    1.44                                  msg->payload.choice.handshakeRequest.partner_id);
    1.45 +                            // Reject handshake requests not addressed to us
    1.46                              if (rating < PEP_rating_reliable ||
    1.47                                  !(is_for_me || is_for_group)){
    1.48                                  discard = true;
    1.49                                  goto free_all;
    1.50                              }
    1.51 +
    1.52 +                            // do not consume handshake request for group
    1.53                              if(is_for_group){ 
    1.54 -                                // if handshake request is for group then dont consume
    1.55                                  force_keep_msg = true;
    1.56                              }
    1.57                              break;