Browse Source

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()

doc_update_sequoia
Edouard Tisserant 6 years ago
parent
commit
f82c4f2c7b
4 changed files with 25 additions and 27 deletions
  1. +18
    -19
      src/keymanagement.c
  2. +3
    -5
      src/keymanagement.h
  3. +2
    -2
      src/message_api.c
  4. +2
    -1
      src/pgp_gpg.c

+ 18
- 19
src/keymanagement.c View File

@ -73,8 +73,10 @@ PEP_STATUS elect_pubkey(
return PEP_STATUS_OK;
}
PEP_STATUS _update_identity(
PEP_SESSION session, pEp_identity * identity, bool with_myself
PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen);
DYNAMIC_API PEP_STATUS update_identity(
PEP_SESSION session, pEp_identity * identity
)
{
pEp_identity *stored_identity;
@ -89,13 +91,8 @@ PEP_STATUS _update_identity(
return PEP_ILLEGAL_VALUE;
if (identity->me || (identity->user_id && strcmp(identity->user_id, PEP_OWN_USERID) == 0)) {
if (with_myself) {
identity->me = true;
return myself(session, identity);
}
else {
return PEP_ILLEGAL_VALUE;
}
identity->me = true;
return _myself(session, identity, false);
}
int _no_user_id = EMPTYSTR(identity->user_id);
@ -107,7 +104,7 @@ PEP_STATUS _update_identity(
&stored_identity);
if (status == PEP_STATUS_OK) {
free_identity(stored_identity);
return myself(session, identity);
return _myself(session, identity, false);
}
free(identity->user_id);
@ -308,13 +305,6 @@ exit_free :
return status;
}
DYNAMIC_API PEP_STATUS update_identity(
PEP_SESSION session, pEp_identity * identity
)
{
return _update_identity(session, identity, true);
}
PEP_STATUS elect_ownkey(
PEP_SESSION session, pEp_identity * identity
)
@ -410,7 +400,7 @@ PEP_STATUS _has_usable_priv_key(PEP_SESSION session, char* fpr,
return status;
}
DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen)
{
pEp_identity *stored_identity;
PEP_STATUS status;
@ -554,6 +544,10 @@ DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
if (EMPTYSTR(identity->fpr) || revoked)
{
if(!do_keygen){
return PEP_GET_KEY_FAILED;
}
if(revoked)
{
r_fpr = identity->fpr;
@ -625,6 +619,11 @@ DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
}
DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
{
return _myself(session, identity, true);
}
DYNAMIC_API PEP_STATUS register_examine_function(
PEP_SESSION session,
examine_identity_t examine_identity,
@ -991,4 +990,4 @@ PEP_STATUS contains_priv_key(PEP_SESSION session, const char *fpr,
return PEP_ILLEGAL_VALUE;
return session->cryptotech[PEP_crypt_OpenPGP].contains_priv_key(session, fpr, has_private);
}
}

+ 3
- 5
src/keymanagement.h View File

@ -6,10 +6,6 @@
extern "C" {
#endif
PEP_STATUS _update_identity(
PEP_SESSION session, pEp_identity * identity, bool with_myself
);
// update_identity() - update identity information
//
// parameters:
@ -26,7 +22,7 @@ PEP_STATUS _update_identity(
// writing
// this function NEVER reads the incoming fpr, only writes to it.
DYNAMIC_API PEP_STATUS update_identity(
PEP_STATUS update_identity(
PEP_SESSION session, pEp_identity * identity
);
@ -51,6 +47,8 @@ DYNAMIC_API PEP_STATUS update_identity(
DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity);
PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen);
// retrieve_next_identity() - callback being called by do_keymanagement()
//


+ 2
- 2
src/message_api.c View File

@ -1791,7 +1791,7 @@ static void _max_comm_type_from_identity_list(
{
if (il->ident)
{
PEP_STATUS status = _update_identity(session, il->ident, true);
PEP_STATUS status = update_identity(session, il->ident);
if (status == PEP_STATUS_OK)
{
*max_comm_type = _get_comm_type(session, *max_comm_type,
@ -1858,7 +1858,7 @@ DYNAMIC_API PEP_STATUS identity_rating(
return PEP_ILLEGAL_VALUE;
if (ident->me)
status = myself(session, ident);
status = _myself(session, ident, false);
else
status = update_identity(session, ident);


+ 2
- 1
src/pgp_gpg.c View File

@ -2158,4 +2158,5 @@ PEP_STATUS pgp_contains_priv_key(PEP_SESSION session, const char *fpr,
break;
}
return status;
}
}

Loading…
Cancel
Save