Browse Source

Myself records replaced revoked key when generating a new key to replace revoked key

doc_update_sequoia
Edouard Tisserant 6 years ago
parent
commit
1b14e9b72d
1 changed files with 29 additions and 19 deletions
  1. +29
    -19
      src/keymanagement.c

+ 29
- 19
src/keymanagement.c View File

@ -367,12 +367,26 @@ DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
free_stringlist(keylist);
}
}
// TODO : Check key for revoked state
if (EMPTYSTR(identity->fpr) /* or revoked */)
bool revoked = false;
char *r_fpr = NULL;
if (!EMPTYSTR(identity->fpr))
{
stringlist_t *keylist = NULL;
status = key_revoked(session, identity->fpr, &revoked);
assert(status == PEP_STATUS_OK);
if (status != PEP_STATUS_OK) {
return status;
}
}
if (EMPTYSTR(identity->fpr) || revoked)
{
if(revoked)
{
r_fpr = strdup(identity->fpr);
if(!r_fpr)
return PEP_OUT_OF_MEMORY;
}
DEBUG_LOG("generating key pair", "debug", identity->address);
status = generate_keypair(session, identity);
@ -381,24 +395,20 @@ DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
char buf[11];
snprintf(buf, 11, "%d", status);
DEBUG_LOG("generating key pair failed", "debug", buf);
if(revoked && r_fpr)
free(r_fpr);
return status;
}
status = find_keys(session, identity->address, &keylist);
assert(status != PEP_OUT_OF_MEMORY);
if (status == PEP_OUT_OF_MEMORY)
return PEP_OUT_OF_MEMORY;
assert(keylist && keylist->value);
if (keylist == NULL) {
return PEP_UNKNOWN_ERROR;
}else if (keylist->value == NULL) {
free_stringlist(keylist);
return PEP_UNKNOWN_ERROR;
if(revoked)
{
status = set_revoked(session, r_fpr,
identity->fpr, time(NULL));
free(r_fpr);
if (status != PEP_STATUS_OK) {
return status;
}
}
// TODO if revoked re-created , store in revoke_keys
}
else
{


Loading…
Cancel
Save