pgp_netpgp.c : export private keys
authorEdouard Tisserant <edouard@pep-project.org>
Thu, 11 May 2017 17:39:31 +0200
changeset 177643db1100ebd2
parent 1775 ae8a180c113f
child 1777 a537bef47d07
pgp_netpgp.c : export private keys
src/pgp_netpgp.c
     1.1 --- a/src/pgp_netpgp.c	Thu May 11 00:18:57 2017 +0200
     1.2 +++ b/src/pgp_netpgp.c	Thu May 11 17:39:31 2017 +0200
     1.3 @@ -1058,18 +1058,18 @@
     1.4      PEP_STATUS result;
     1.5      char *buffer;
     1.6      size_t buflen;
     1.7 +    const pgp_keyring_t *srcring;
     1.8  
     1.9      assert(session);
    1.10      assert(fprstr);
    1.11      assert(key_data);
    1.12      assert(size);
    1.13  
    1.14 -    // TODO : support export secret key
    1.15 -    // crashing stub until export secret supported
    1.16 -    assert(!secret);
    1.17      if (secret)
    1.18 -        return PEP_ILLEGAL_VALUE;
    1.19 -
    1.20 +        srcring = netpgp.secring;
    1.21 +    else
    1.22 +        srcring = netpgp.pubring;
    1.23 +    
    1.24      if (!session || !fprstr || !key_data || !size)
    1.25          return PEP_ILLEGAL_VALUE;
    1.26  
    1.27 @@ -1080,7 +1080,7 @@
    1.28      if (str_to_fpr(fprstr, fpr, &fprlen)) {
    1.29          unsigned from = 0;
    1.30  
    1.31 -        if ((key = (pgp_key_t *)pgp_getkeybyfpr(netpgp.io, netpgp.pubring,
    1.32 +        if ((key = (pgp_key_t *)pgp_getkeybyfpr(netpgp.io, srcring,
    1.33                                                  fpr, fprlen, &from,
    1.34                                                  NULL,0,0)) == NULL) {
    1.35              result = PEP_KEY_NOT_FOUND;