pgp_netpgp : pgp_renew_key takes frp not keyid
authorEdouard Tisserant
Fri, 18 Mar 2016 16:14:30 +0100
changeset 51172a289e60d50
parent 510 fa26f8ffe06b
child 512 58dc270bf31e
pgp_netpgp : pgp_renew_key takes frp not keyid
src/pgp_netpgp.c
     1.1 --- a/src/pgp_netpgp.c	Thu Mar 17 00:02:25 2016 +0100
     1.2 +++ b/src/pgp_netpgp.c	Fri Mar 18 16:14:30 2016 +0100
     1.3 @@ -1454,13 +1454,14 @@
     1.4  
     1.5  PEP_STATUS pgp_renew_key(
     1.6          PEP_SESSION session,
     1.7 -        const char *keyidstr,
     1.8 +        const char *fprstr,
     1.9          const timestamp *ts
    1.10      )
    1.11  {
    1.12      pgp_key_t *pkey;
    1.13      pgp_key_t *skey;
    1.14 -    uint8_t keyid[PGP_KEY_ID_SIZE];
    1.15 +    uint8_t fpr[PGP_FINGERPRINT_SIZE];
    1.16 +    size_t length;
    1.17      unsigned from = 0;
    1.18      time_t duration;
    1.19      const uint8_t *primid;
    1.20 @@ -1468,9 +1469,9 @@
    1.21      PEP_STATUS status = PEP_STATUS_OK;
    1.22  
    1.23      assert(session);
    1.24 -    assert(keyidstr);
    1.25 +    assert(fprstr);
    1.26  
    1.27 -    if (!session || !keyidstr )
    1.28 +    if (!session || !fprstr )
    1.29          return PEP_UNKNOWN_ERROR;
    1.30  
    1.31      if(ts)
    1.32 @@ -1492,15 +1493,17 @@
    1.33          return PEP_UNKNOWN_ERROR;
    1.34      }
    1.35  
    1.36 -    if(!str_to_id(keyid, keyidstr))
    1.37 -    {
    1.38 +    
    1.39 +    if (!str_to_fpr(fprstr, fpr, &length)) {
    1.40          status = PEP_ILLEGAL_VALUE;
    1.41          goto unlock_netpgp;
    1.42      }
    1.43 -
    1.44 -    pkey = (pgp_key_t*)pgp_getkeybyid(netpgp.io, netpgp.pubring, 
    1.45 -             keyid, &from, NULL, NULL, 
    1.46 -             1, 0); /* reject revoked, accept expired */
    1.47 +    
    1.48 +    pkey = pgp_getkeybyfpr(
    1.49 +                          netpgp.io,
    1.50 +                          netpgp.pubring,
    1.51 +                          fpr, length, &from, NULL,
    1.52 +                          1, 0); /* reject revoked, accept expired */
    1.53  
    1.54      if(pkey == NULL)
    1.55      {
    1.56 @@ -1509,9 +1512,11 @@
    1.57      }
    1.58  
    1.59      from = 0;
    1.60 -    skey = (pgp_key_t*)pgp_getkeybyid(netpgp.io, netpgp.secring, 
    1.61 -             keyid, &from, NULL, NULL, 
    1.62 -             1, 0); /* reject revoked, accept expired */
    1.63 +    skey = pgp_getkeybyfpr(
    1.64 +                           netpgp.io,
    1.65 +                           netpgp.pubring,
    1.66 +                           fpr, length, &from, NULL,
    1.67 +                           1, 0); /* reject revoked, accept expired */
    1.68  
    1.69      if(skey == NULL)
    1.70      {