merging sync
authorVolker Birk <vb@pep-project.org>
Mon, 20 Jan 2020 10:52:53 +0100
branchsync
changeset 435566cb18185fce
parent 4354 33701483ccbd
parent 4353 3c59288158d7
child 4356 abf2aaa18e05
merging
     1.1 --- a/src/key_reset.c	Mon Jan 20 10:52:36 2020 +0100
     1.2 +++ b/src/key_reset.c	Mon Jan 20 10:52:53 2020 +0100
     1.3 @@ -1040,10 +1040,11 @@
     1.4              const char* own_key = curr_key->value;
     1.5              status = get_identities_by_main_key_id(session, own_key, &key_idents);
     1.6              
     1.7 -            if (status != PEP_CANNOT_FIND_IDENTITY)
     1.8 -                status = _key_reset_device_group_for_shared_key(session, key_idents, own_key, true);
     1.9 -            
    1.10 -            if (status != PEP_STATUS_OK)
    1.11 +            if (status == PEP_CANNOT_FIND_IDENTITY)
    1.12 +                continue;
    1.13 +            else if (status == PEP_STATUS_OK)    
    1.14 +                status = _key_reset_device_group_for_shared_key(session, key_idents, own_key, true);            
    1.15 +            else 
    1.16                  goto pEp_free;
    1.17              
    1.18              free_identity_list(key_idents);    
     2.1 --- a/src/message_api.c	Mon Jan 20 10:52:36 2020 +0100
     2.2 +++ b/src/message_api.c	Mon Jan 20 10:52:53 2020 +0100
     2.3 @@ -3803,7 +3803,7 @@
     2.4                              is_inner = (strcmp(wrap_info, "INNER") == 0);
     2.5                              if (!is_inner)
     2.6                                  is_key_reset = (strcmp(wrap_info, "KEY_RESET") == 0);
     2.7 -                        }
     2.8 +                        }                        
     2.9                              
    2.10                          // check for private key in decrypted message attachment while importing
    2.11                          // N.B. Apparently, we always import private keys into the keyring; however,
    2.12 @@ -3812,26 +3812,54 @@
    2.13                          
    2.14                          // If we have a message 2.0 message, we are ONLY going to be ok with keys
    2.15                          // we imported from THIS part of the message.
    2.16 -                        imported_private_key_address = false;
    2.17 -                        free(private_il); 
    2.18 -                        private_il = NULL;
    2.19 -                        
    2.20 -                        // import keys from decrypted INNER source
    2.21 -                        status = import_priv_keys_from_decrypted_msg(session, inner_message,
    2.22 -                                                                     &imported_keys,
    2.23 -                                                                     &imported_private_key_address,
    2.24 -                                                                     private_il);
    2.25 -                        if (status != PEP_STATUS_OK)
    2.26 -                            goto pEp_error;            
    2.27 -
    2.28 +                                                        
    2.29 +                        bool ignore_msg = false;
    2.30 +                            
    2.31 +                        if (is_key_reset) {
    2.32 +                            if (inner_message->_sender_fpr) {
    2.33 +                                bool sender_key_is_me = false;
    2.34 +                                status = is_own_key(session, inner_message->_sender_fpr, &sender_key_is_me);
    2.35 +                                if (status != PEP_STATUS_OK && status != PEP_KEY_NOT_FOUND)
    2.36 +                                    goto pEp_error;
    2.37 +                                
    2.38 +                                if (sender_key_is_me) {    
    2.39 +                                    bool grouped = false;
    2.40 +                                    status = deviceGrouped(session, &grouped);
    2.41 +                                    
    2.42 +                                    if (status != PEP_STATUS_OK)
    2.43 +                                        goto pEp_error;
    2.44 +                                    
    2.45 +                                    if (!grouped)
    2.46 +                                        ignore_msg = true;    
    2.47 +                                }
    2.48 +                            }
    2.49 +                            else
    2.50 +                                ignore_msg = true;
    2.51 +                        }
    2.52 +
    2.53 +                        if (!ignore_msg) {
    2.54 +                            imported_private_key_address = false;
    2.55 +                            free(private_il); 
    2.56 +                            private_il = NULL;
    2.57 +                            
    2.58 +                            // import keys from decrypted INNER source
    2.59 +                            status = import_priv_keys_from_decrypted_msg(session, inner_message,
    2.60 +                                                                         &imported_keys,
    2.61 +                                                                         &imported_private_key_address,
    2.62 +                                                                         private_il);
    2.63 +                            if (status != PEP_STATUS_OK)
    2.64 +                                goto pEp_error;            
    2.65 +                        }        
    2.66                          if (is_key_reset) {
    2.67                              if (decrypt_status == PEP_DECRYPTED || decrypt_status == PEP_DECRYPTED_AND_VERIFIED) {
    2.68 -                                status = receive_key_reset(session,
    2.69 -                                                           inner_message);
    2.70 -                                if (status != PEP_STATUS_OK) {
    2.71 -                                    free_message(inner_message);
    2.72 -                                    goto pEp_error;
    2.73 -                                }
    2.74 +                                if (!ignore_msg) {
    2.75 +                                    status = receive_key_reset(session,
    2.76 +                                                               inner_message);
    2.77 +                                    if (status != PEP_STATUS_OK) {
    2.78 +                                        free_message(inner_message);
    2.79 +                                        goto pEp_error;
    2.80 +                                    }
    2.81 +                                }    
    2.82                                  *flags |= PEP_decrypt_flag_consume;
    2.83                                  calculated_src = msg = inner_message;                                    
    2.84                              }
     3.1 --- a/src/pEpEngine.c	Mon Jan 20 10:52:36 2020 +0100
     3.2 +++ b/src/pEpEngine.c	Mon Jan 20 10:52:53 2020 +0100
     3.3 @@ -5225,9 +5225,6 @@
     3.4  
     3.5  PEP_STATUS is_own_key(PEP_SESSION session, const char* fpr, bool* own_key) {
     3.6      
     3.7 -    assert(session);
     3.8 -    assert(!EMPTYSTR(fpr));
     3.9 -
    3.10      if (!session || EMPTYSTR(fpr))
    3.11          return PEP_ILLEGAL_VALUE;
    3.12      
     4.1 --- a/test/src/KeyResetMessageTest.cc	Mon Jan 20 10:52:36 2020 +0100
     4.2 +++ b/test/src/KeyResetMessageTest.cc	Mon Jan 20 10:52:53 2020 +0100
     4.3 @@ -838,14 +838,20 @@
     4.4      alex_id->me = true;
     4.5      status = set_own_key(session, alex_id, pubkey1);
     4.6      ASSERT_EQ(status, PEP_STATUS_OK);
     4.7 +    status = set_identity_flags(session, alex_id, alex_id->flags | PEP_idf_devicegroup);
     4.8 +    ASSERT_EQ(status , PEP_STATUS_OK);
     4.9  
    4.10      alex_id2->me = true;
    4.11      status = set_own_key(session, alex_id2, pubkey1);
    4.12      ASSERT_EQ(status, PEP_STATUS_OK);
    4.13 +    status = set_identity_flags(session, alex_id2, alex_id2->flags | PEP_idf_devicegroup);
    4.14 +    ASSERT_EQ(status , PEP_STATUS_OK);
    4.15  
    4.16      alex_id3->me = true;
    4.17      status = set_own_key(session, alex_id3, pubkey1);
    4.18      ASSERT_EQ(status, PEP_STATUS_OK);
    4.19 +    status = set_identity_flags(session, alex_id3, alex_id3->flags | PEP_idf_devicegroup);
    4.20 +    ASSERT_EQ(status , PEP_STATUS_OK);
    4.21  
    4.22      status = myself(session, alex_id);
    4.23      ASSERT_EQ(status, PEP_STATUS_OK);
    4.24 @@ -1500,14 +1506,20 @@
    4.25      alex_id->me = true;
    4.26      status = set_own_key(session, alex_id, pubkey1);
    4.27      ASSERT_EQ(status, PEP_STATUS_OK);
    4.28 +    status = set_identity_flags(session, alex_id2, alex_id2->flags | PEP_idf_devicegroup);
    4.29 +    ASSERT_EQ(status , PEP_STATUS_OK);
    4.30  
    4.31      alex_id2->me = true;
    4.32      status = set_own_key(session, alex_id2, pubkey2);
    4.33      ASSERT_EQ(status, PEP_STATUS_OK);
    4.34 +    status = set_identity_flags(session, alex_id2, alex_id2->flags | PEP_idf_devicegroup);
    4.35 +    ASSERT_EQ(status , PEP_STATUS_OK);
    4.36  
    4.37      alex_id3->me = true;
    4.38      status = set_own_key(session, alex_id3, pubkey3);
    4.39      ASSERT_EQ(status, PEP_STATUS_OK);
    4.40 +    status = set_identity_flags(session, alex_id2, alex_id2->flags | PEP_idf_devicegroup);
    4.41 +    ASSERT_EQ(status , PEP_STATUS_OK);
    4.42  
    4.43      status = myself(session, alex_id);
    4.44      ASSERT_EQ(status, PEP_STATUS_OK);