Myself records replaced revoked key when generating a new key to replace revoked key
authorEdouard Tisserant
Sun, 29 May 2016 00:11:56 +0200
changeset 695b8d403779089
parent 694 7e236f95f1e4
child 696 0b3ad1c40304
child 697 c6ee542ba702
Myself records replaced revoked key when generating a new key to replace revoked key
src/keymanagement.c
     1.1 --- a/src/keymanagement.c	Sat May 28 23:33:09 2016 +0200
     1.2 +++ b/src/keymanagement.c	Sun May 29 00:11:56 2016 +0200
     1.3 @@ -367,12 +367,26 @@
     1.4              free_stringlist(keylist);
     1.5          }
     1.6      }
     1.7 +
     1.8 +    bool revoked = false;
     1.9 +    char *r_fpr = NULL;
    1.10 +    if (!EMPTYSTR(identity->fpr))
    1.11 +    {
    1.12 +        status = key_revoked(session, identity->fpr, &revoked);
    1.13 +        assert(status == PEP_STATUS_OK);
    1.14 +        if (status != PEP_STATUS_OK) {
    1.15 +            return status;
    1.16 +        }
    1.17 +    }
    1.18      
    1.19 -    // TODO : Check key for revoked state
    1.20 -    
    1.21 -    if (EMPTYSTR(identity->fpr) /* or revoked */)
    1.22 -    {
    1.23 -        stringlist_t *keylist = NULL;
    1.24 +    if (EMPTYSTR(identity->fpr) || revoked)
    1.25 +    {        
    1.26 +        if(revoked)
    1.27 +        {
    1.28 +            r_fpr = strdup(identity->fpr);
    1.29 +            if(!r_fpr)
    1.30 +                return PEP_OUT_OF_MEMORY;
    1.31 +        }
    1.32          
    1.33          DEBUG_LOG("generating key pair", "debug", identity->address);
    1.34          status = generate_keypair(session, identity);
    1.35 @@ -381,24 +395,20 @@
    1.36              char buf[11];
    1.37              snprintf(buf, 11, "%d", status);
    1.38              DEBUG_LOG("generating key pair failed", "debug", buf);
    1.39 +            if(revoked && r_fpr)
    1.40 +                free(r_fpr);
    1.41              return status;
    1.42          }
    1.43          
    1.44 -        status = find_keys(session, identity->address, &keylist);
    1.45 -        assert(status != PEP_OUT_OF_MEMORY);
    1.46 -        if (status == PEP_OUT_OF_MEMORY)
    1.47 -            return PEP_OUT_OF_MEMORY;
    1.48 -        
    1.49 -        assert(keylist && keylist->value);
    1.50 -        if (keylist == NULL) {
    1.51 -            return PEP_UNKNOWN_ERROR;
    1.52 -        }else if (keylist->value == NULL) {
    1.53 -            free_stringlist(keylist);
    1.54 -            return PEP_UNKNOWN_ERROR;
    1.55 +        if(revoked)
    1.56 +        {
    1.57 +            status = set_revoked(session, r_fpr,
    1.58 +                                 identity->fpr, time(NULL));
    1.59 +            free(r_fpr);
    1.60 +            if (status != PEP_STATUS_OK) {
    1.61 +                return status;
    1.62 +            }
    1.63          }
    1.64 -        
    1.65 -        // TODO if revoked re-created , store in revoke_keys
    1.66 -        
    1.67      }
    1.68      else
    1.69      {