No more _update_indentiy() and with_myself parameter. Rather, added a _myself(), with a do_keygen parameter. Now, only explicit call to myself(), key_mistrusted(), encrypt_message(), encrypt_message_to_self() may trigger keygen, not outgoing_message_rating() or update_identity()
authorEdouard Tisserant <edouard@pep-project.org>
Sat, 12 Nov 2016 00:24:14 +0100
changeset 13855f54184b1e94
parent 1383 91a71abc7446
child 1386 5547895c7a3f
No more _update_indentiy() and with_myself parameter. Rather, added a _myself(), with a do_keygen parameter. Now, only explicit call to myself(), key_mistrusted(), encrypt_message(), encrypt_message_to_self() may trigger keygen, not outgoing_message_rating() or update_identity()
src/keymanagement.c
src/keymanagement.h
src/message_api.c
src/pgp_gpg.c
     1.1 --- a/src/keymanagement.c	Fri Nov 11 19:16:47 2016 +0100
     1.2 +++ b/src/keymanagement.c	Sat Nov 12 00:24:14 2016 +0100
     1.3 @@ -73,8 +73,10 @@
     1.4      return PEP_STATUS_OK;
     1.5  }
     1.6  
     1.7 -PEP_STATUS _update_identity(
     1.8 -        PEP_SESSION session, pEp_identity * identity, bool with_myself
     1.9 +PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen);
    1.10 +
    1.11 +DYNAMIC_API PEP_STATUS update_identity(
    1.12 +        PEP_SESSION session, pEp_identity * identity
    1.13      )
    1.14  {
    1.15      pEp_identity *stored_identity;
    1.16 @@ -89,13 +91,8 @@
    1.17          return PEP_ILLEGAL_VALUE;
    1.18  
    1.19      if (identity->me || (identity->user_id && strcmp(identity->user_id, PEP_OWN_USERID) == 0)) {
    1.20 -        if (with_myself) {
    1.21 -            identity->me = true;
    1.22 -            return myself(session, identity);
    1.23 -        }
    1.24 -        else {
    1.25 -            return PEP_ILLEGAL_VALUE;
    1.26 -        }
    1.27 +        identity->me = true;
    1.28 +        return _myself(session, identity, false);
    1.29      }
    1.30  
    1.31      int _no_user_id = EMPTYSTR(identity->user_id);
    1.32 @@ -107,7 +104,7 @@
    1.33                  &stored_identity);
    1.34          if (status == PEP_STATUS_OK) {
    1.35              free_identity(stored_identity);
    1.36 -            return myself(session, identity);
    1.37 +            return _myself(session, identity, false);
    1.38          }
    1.39  
    1.40          free(identity->user_id);
    1.41 @@ -308,13 +305,6 @@
    1.42      return status;
    1.43  }
    1.44  
    1.45 -DYNAMIC_API PEP_STATUS update_identity(
    1.46 -        PEP_SESSION session, pEp_identity * identity
    1.47 -    )
    1.48 -{
    1.49 -    return _update_identity(session, identity, true);
    1.50 -}
    1.51 -
    1.52  PEP_STATUS elect_ownkey(
    1.53          PEP_SESSION session, pEp_identity * identity
    1.54      )
    1.55 @@ -410,7 +400,7 @@
    1.56      return status;
    1.57  }
    1.58  
    1.59 -DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
    1.60 +PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen)
    1.61  {
    1.62      pEp_identity *stored_identity;
    1.63      PEP_STATUS status;
    1.64 @@ -554,6 +544,10 @@
    1.65  
    1.66      if (EMPTYSTR(identity->fpr) || revoked)
    1.67      {        
    1.68 +        if(!do_keygen){
    1.69 +            return PEP_GET_KEY_FAILED;
    1.70 +        }
    1.71 +
    1.72          if(revoked)
    1.73          {
    1.74              r_fpr = identity->fpr;
    1.75 @@ -625,6 +619,11 @@
    1.76  
    1.77  }
    1.78  
    1.79 +DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
    1.80 +{
    1.81 +    return _myself(session, identity, true);
    1.82 +}
    1.83 +
    1.84  DYNAMIC_API PEP_STATUS register_examine_function(
    1.85          PEP_SESSION session, 
    1.86          examine_identity_t examine_identity,
    1.87 @@ -991,4 +990,4 @@
    1.88          return PEP_ILLEGAL_VALUE;
    1.89  
    1.90      return session->cryptotech[PEP_crypt_OpenPGP].contains_priv_key(session, fpr, has_private);
    1.91 -}
    1.92 \ No newline at end of file
    1.93 +}
     2.1 --- a/src/keymanagement.h	Fri Nov 11 19:16:47 2016 +0100
     2.2 +++ b/src/keymanagement.h	Sat Nov 12 00:24:14 2016 +0100
     2.3 @@ -6,10 +6,6 @@
     2.4  extern "C" {
     2.5  #endif
     2.6  
     2.7 -PEP_STATUS _update_identity(
     2.8 -        PEP_SESSION session, pEp_identity * identity, bool with_myself
     2.9 -    );
    2.10 -
    2.11  // update_identity() - update identity information
    2.12  //
    2.13  //  parameters:
    2.14 @@ -26,7 +22,7 @@
    2.15  //      writing
    2.16  //      this function NEVER reads the incoming fpr, only writes to it.
    2.17  
    2.18 -DYNAMIC_API PEP_STATUS update_identity(
    2.19 +PEP_STATUS update_identity(
    2.20          PEP_SESSION session, pEp_identity * identity
    2.21      );
    2.22  
    2.23 @@ -51,6 +47,8 @@
    2.24  
    2.25  DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity);
    2.26  
    2.27 +PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen);
    2.28 +
    2.29  
    2.30  // retrieve_next_identity() - callback being called by do_keymanagement()
    2.31  //
     3.1 --- a/src/message_api.c	Fri Nov 11 19:16:47 2016 +0100
     3.2 +++ b/src/message_api.c	Sat Nov 12 00:24:14 2016 +0100
     3.3 @@ -1791,7 +1791,7 @@
     3.4      {
     3.5          if (il->ident)
     3.6          {
     3.7 -            PEP_STATUS status = _update_identity(session, il->ident, true);
     3.8 +            PEP_STATUS status = update_identity(session, il->ident);
     3.9              if (status == PEP_STATUS_OK)
    3.10              {
    3.11                  *max_comm_type = _get_comm_type(session, *max_comm_type,
    3.12 @@ -1858,7 +1858,7 @@
    3.13          return PEP_ILLEGAL_VALUE;
    3.14  
    3.15      if (ident->me)
    3.16 -        status = myself(session, ident);
    3.17 +        status = _myself(session, ident, false);
    3.18      else
    3.19          status = update_identity(session, ident);
    3.20  
     4.1 --- a/src/pgp_gpg.c	Fri Nov 11 19:16:47 2016 +0100
     4.2 +++ b/src/pgp_gpg.c	Sat Nov 12 00:24:14 2016 +0100
     4.3 @@ -2158,4 +2158,5 @@
     4.4              break;
     4.5      }
     4.6      return status;
     4.7 -}
     4.8 \ No newline at end of file
     4.9 +}
    4.10 +