netgpg sig fix ENGINE-74
authorKrista Grothoff <krista@pep-project.org>
Thu, 24 Nov 2016 09:53:59 +0100
branchENGINE-74
changeset 1436bab49ad81840
parent 1433 04b5bdcb5dcd
parent 1435 838db6c0b04f
child 1441 f16b13f6e658
netgpg sig fix
     1.1 --- a/src/pgp_netpgp.c	Wed Nov 23 21:10:56 2016 +0100
     1.2 +++ b/src/pgp_netpgp.c	Thu Nov 24 09:53:59 2016 +0100
     1.3 @@ -67,7 +67,7 @@
     1.4  
     1.5  unlock_netpgp:
     1.6      pthread_mutex_unlock(&netpgp_mutex);
     1.7 -    
     1.8 +
     1.9      return status;
    1.10  }
    1.11  
    1.12 @@ -107,7 +107,7 @@
    1.13  }
    1.14  
    1.15  static void release_curl(
    1.16 -    pthread_mutex_t *curl_mutex, 
    1.17 +    pthread_mutex_t *curl_mutex,
    1.18      bool out_last)
    1.19  {
    1.20      if(pthread_mutex_lock(curl_mutex)){
    1.21 @@ -216,17 +216,17 @@
    1.22  {
    1.23      unsigned i;
    1.24      int	n;
    1.25 -    
    1.26 +
    1.27      /* 4 hexes per short + null */
    1.28      *str = malloc((length / 2) * 4 + 1);
    1.29 -    
    1.30 +
    1.31      if(*str == NULL)
    1.32          return 0;
    1.33 -    
    1.34 +
    1.35      for (n = 0, i = 0 ; i < length; i += 2) {
    1.36          n += snprintf(&((*str)[n]), 5, "%02x%02x", fpr[i], fpr[i+1]);
    1.37      }
    1.38 -    
    1.39 +
    1.40      return 1;
    1.41  }
    1.42  
    1.43 @@ -236,9 +236,9 @@
    1.44  str_to_fpr (const char *str, uint8_t *fpr, size_t *length)
    1.45  {
    1.46      unsigned i,j;
    1.47 -    
    1.48 +
    1.49      *length = 0;
    1.50 -    
    1.51 +
    1.52      while(*str && *length < PGP_FINGERPRINT_SIZE){
    1.53          while (*str == ' ') str++;
    1.54          for (j = 0; j < 2; j++) {
    1.55 @@ -263,7 +263,7 @@
    1.56      return 1;
    1.57  }
    1.58  
    1.59 -// Iterate through netpgp' reported valid signatures 
    1.60 +// Iterate through netpgp' reported valid signatures
    1.61  // fill a list of valid figerprints
    1.62  // returns PEP_STATUS_OK if all sig reported valid
    1.63  // error status otherwise.
    1.64 @@ -302,10 +302,10 @@
    1.65              const pgp_key_t	 *signer;
    1.66              char *fprstr = NULL;
    1.67              const uint8_t *keyid = vresult->valid_sigs[n].signer_id;
    1.68 -            
    1.69 +
    1.70              signer = pgp_getkeybyid(netpgp->io, netpgp->pubring,
    1.71                                      keyid, &from, NULL, NULL,
    1.72 -                                    0, 0); /* check neither revocation nor expiry 
    1.73 +                                    0, 0); /* check neither revocation nor expiry
    1.74                                                as is should be checked already */
    1.75              if(signer)
    1.76                  fpr_to_str(&fprstr,
    1.77 @@ -313,14 +313,14 @@
    1.78                             signer->pubkeyfpr.length);
    1.79              else
    1.80                  return PEP_VERIFY_NO_KEY;
    1.81 -            
    1.82 +
    1.83              if (fprstr == NULL)
    1.84                  return PEP_OUT_OF_MEMORY;
    1.85 -            
    1.86 +
    1.87              k = stringlist_add(k, fprstr);
    1.88 -            
    1.89 +
    1.90              free(fprstr);
    1.91 -            
    1.92 +
    1.93              if(!k){
    1.94                  free_stringlist(*_keylist);
    1.95                  return PEP_OUT_OF_MEMORY;
    1.96 @@ -330,14 +330,14 @@
    1.97      }
    1.98      if (vresult->validc + vresult->invalidc + vresult->unknownc == 0) {
    1.99          // No signatures found - is this memory signed?
   1.100 -        return PEP_VERIFY_NO_KEY; 
   1.101 -    } 
   1.102 -    
   1.103 +        return PEP_VERIFY_NO_KEY;
   1.104 +    }
   1.105 +
   1.106      if (vresult->invalidc) {
   1.107          // some invalid signatures
   1.108          return PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH;
   1.109      }
   1.110 -    
   1.111 +
   1.112      // only unknown sigs
   1.113      return PEP_DECRYPTED;
   1.114  }
   1.115 @@ -346,6 +346,7 @@
   1.116  #define ARMOR_HEAD    "^-----BEGIN PGP MESSAGE-----"_ENDL
   1.117  PEP_STATUS pgp_decrypt_and_verify(
   1.118      PEP_SESSION session, const char *ctext, size_t csize,
   1.119 +    const char *dsigtext, size_t dsigsize,
   1.120      char **ptext, size_t *psize, stringlist_t **keylist
   1.121      )
   1.122  {
   1.123 @@ -364,7 +365,7 @@
   1.124      assert(psize);
   1.125      assert(keylist);
   1.126  
   1.127 -    if(!session || !ctext || !csize || !ptext || !psize || !keylist) 
   1.128 +    if(!session || !ctext || !csize || !ptext || !psize || !keylist)
   1.129          return PEP_ILLEGAL_VALUE;
   1.130  
   1.131      if(pthread_mutex_lock(&netpgp_mutex)){
   1.132 @@ -464,7 +465,7 @@
   1.133      assert(sig_size);
   1.134      assert(keylist);
   1.135  
   1.136 -    if(!session || !text || !size || !signature || !sig_size || !keylist) 
   1.137 +    if(!session || !text || !size || !signature || !sig_size || !keylist)
   1.138          return PEP_ILLEGAL_VALUE;
   1.139  
   1.140      if(pthread_mutex_lock(&netpgp_mutex)){
   1.141 @@ -557,7 +558,7 @@
   1.142      assert(ctext);
   1.143      assert(csize);
   1.144  
   1.145 -    if(!session || !ptext || !psize || !ctext || !csize || !keylist) 
   1.146 +    if(!session || !ptext || !psize || !ctext || !csize || !keylist)
   1.147          return PEP_ILLEGAL_VALUE;
   1.148  
   1.149      if(pthread_mutex_lock(&netpgp_mutex)){
   1.150 @@ -573,7 +574,7 @@
   1.151      }
   1.152      for (_keylist = keylist; _keylist != NULL; _keylist = _keylist->next) {
   1.153          assert(_keylist->value);
   1.154 -        
   1.155 +
   1.156          const pgp_key_t *key;
   1.157          uint8_t fpr[PGP_FINGERPRINT_SIZE];
   1.158          size_t fprlen;
   1.159 @@ -634,7 +635,7 @@
   1.160      signedmem = pgp_sign_buf(netpgp.io, ptext, psize, seckey,
   1.161                  time(NULL), /* birthtime */
   1.162                  0 /* duration */,
   1.163 -                hashalg, 
   1.164 +                hashalg,
   1.165                  0 /* armored */,
   1.166                  0 /* cleartext */);
   1.167  
   1.168 @@ -647,7 +648,7 @@
   1.169  
   1.170      cmem = pgp_encrypt_buf(netpgp.io, pgp_mem_data(signedmem),
   1.171              pgp_mem_len(signedmem), rcpts, 1 /* armored */,
   1.172 -            netpgp_getvar(&netpgp, "cipher"), 
   1.173 +            netpgp_getvar(&netpgp, "cipher"),
   1.174              1 /* takes raw OpenPGP message */);
   1.175  
   1.176      if (cmem == NULL) {
   1.177 @@ -704,7 +705,7 @@
   1.178      assert(identity->fpr == NULL);
   1.179      assert(identity->username);
   1.180  
   1.181 -    if(!session || !identity || 
   1.182 +    if(!session || !identity ||
   1.183         !identity->address || identity->fpr || !identity->username)
   1.184          return PEP_ILLEGAL_VALUE;
   1.185  
   1.186 @@ -717,7 +718,7 @@
   1.187          result =  PEP_BUFFER_TOO_SMALL;
   1.188          goto unlock_netpgp;
   1.189      }
   1.190 -    
   1.191 +
   1.192      hashalg = netpgp_getvar(&netpgp, "hash");
   1.193      cipher = netpgp_getvar(&netpgp, "cipher");
   1.194  
   1.195 @@ -742,7 +743,7 @@
   1.196      }
   1.197  
   1.198      // "Expire-Date: 1y\n";
   1.199 -    if (!pgp_add_selfsigned_userid(&newseckey, newpubkey, 
   1.200 +    if (!pgp_add_selfsigned_userid(&newseckey, newpubkey,
   1.201                                    (uint8_t *)newid, 365*24*3600))
   1.202      {
   1.203          result = PEP_CANNOT_CREATE_KEY;
   1.204 @@ -759,9 +760,9 @@
   1.205      if (!pgp_keyring_add(netpgp.secring, &newseckey)){
   1.206          result = PEP_OUT_OF_MEMORY;
   1.207          goto delete_pubkey;
   1.208 -    } 
   1.209 +    }
   1.210  
   1.211 -    // save rings 
   1.212 +    // save rings
   1.213      if (netpgp_save_pubring(&netpgp) && netpgp_save_secring(&netpgp))
   1.214      {
   1.215          char *fprstr = NULL;
   1.216 @@ -772,7 +773,7 @@
   1.217          if (fprstr == NULL) {
   1.218              result = PEP_OUT_OF_MEMORY;
   1.219              goto pop_secring;
   1.220 -        } 
   1.221 +        }
   1.222  
   1.223          /* keys saved, pass fingerprint back */
   1.224          identity->fpr = fprstr;
   1.225 @@ -791,7 +792,7 @@
   1.226      ((pgp_keyring_t *)netpgp.secring)->keyc--;
   1.227  delete_pubkey:
   1.228      pgp_deletekeybyfpr(netpgp.io,
   1.229 -                    (pgp_keyring_t *)netpgp.pubring, 
   1.230 +                    (pgp_keyring_t *)netpgp.pubring,
   1.231                      newseckey.pubkeyfpr.fingerprint,
   1.232                      newseckey.pubkeyfpr.length);
   1.233  free_seckey:
   1.234 @@ -818,13 +819,13 @@
   1.235      if(pthread_mutex_lock(&netpgp_mutex)){
   1.236          return PEP_UNKNOWN_ERROR;
   1.237      }
   1.238 -    
   1.239 +
   1.240      if (str_to_fpr(fprstr, fpr, &length)) {
   1.241          unsigned insec = pgp_deletekeybyfpr(netpgp.io,
   1.242 -                                (pgp_keyring_t *)netpgp.secring, 
   1.243 +                                (pgp_keyring_t *)netpgp.secring,
   1.244                                  (const uint8_t *)fpr, length);
   1.245          unsigned inpub = pgp_deletekeybyfpr(netpgp.io,
   1.246 -                                (pgp_keyring_t *)netpgp.pubring, 
   1.247 +                                (pgp_keyring_t *)netpgp.pubring,
   1.248                                  (const uint8_t *)fpr, length);
   1.249          if(!insec && !inpub){
   1.250              result = PEP_KEY_NOT_FOUND;
   1.251 @@ -837,8 +838,8 @@
   1.252          goto unlock_netpgp;
   1.253      }
   1.254  
   1.255 -    // save rings 
   1.256 -    if (netpgp_save_pubring(&netpgp) && 
   1.257 +    // save rings
   1.258 +    if (netpgp_save_pubring(&netpgp) &&
   1.259          netpgp_save_secring(&netpgp))
   1.260      {
   1.261          result = PEP_STATUS_OK;
   1.262 @@ -855,7 +856,7 @@
   1.263  #define ARMOR_KEY_HEAD    "^-----BEGIN PGP (PUBLIC|PRIVATE) KEY BLOCK-----"_ENDL
   1.264  PEP_STATUS pgp_import_keydata(
   1.265          PEP_SESSION session,
   1.266 -        const char *key_data, 
   1.267 +        const char *key_data,
   1.268          size_t size
   1.269      )
   1.270  {
   1.271 @@ -866,7 +867,7 @@
   1.272      assert(session);
   1.273      assert(key_data);
   1.274  
   1.275 -    if(!session || !key_data) 
   1.276 +    if(!session || !key_data)
   1.277          return PEP_ILLEGAL_VALUE;
   1.278  
   1.279      if(pthread_mutex_lock(&netpgp_mutex)){
   1.280 @@ -880,16 +881,16 @@
   1.281      }
   1.282      pgp_memory_add(mem, (const uint8_t*)key_data, size);
   1.283  
   1.284 -    if (pgp_keyring_read_from_mem(netpgp.io, netpgp.pubring, netpgp.secring, 
   1.285 +    if (pgp_keyring_read_from_mem(netpgp.io, netpgp.pubring, netpgp.secring,
   1.286                                    _armoured(key_data, size, ARMOR_KEY_HEAD),
   1.287                                    mem) == 0){
   1.288          result = PEP_ILLEGAL_VALUE;
   1.289 -    }    
   1.290 +    }
   1.291  
   1.292      pgp_memory_free(mem);
   1.293  
   1.294 -    // save rings 
   1.295 -    if (netpgp_save_pubring(&netpgp) && 
   1.296 +    // save rings
   1.297 +    if (netpgp_save_pubring(&netpgp) &&
   1.298          netpgp_save_secring(&netpgp))
   1.299      {
   1.300          result = PEP_STATUS_OK;
   1.301 @@ -982,9 +983,9 @@
   1.302          result = PEP_OUT_OF_MEMORY;
   1.303          goto unlock_netpgp;
   1.304      }
   1.305 -    
   1.306 +
   1.307      result = _export_keydata(key, &buffer, &buflen);
   1.308 -    
   1.309 +
   1.310      if(result == PEP_STATUS_OK)
   1.311      {
   1.312          *key_data = buffer;
   1.313 @@ -1002,23 +1003,23 @@
   1.314    char *memory;
   1.315    size_t size;
   1.316  };
   1.317 - 
   1.318 +
   1.319  static size_t
   1.320  HKPAnswerWriter(void *contents, size_t size, size_t nmemb, void *userp)
   1.321  {
   1.322    size_t realsize = size * nmemb;
   1.323    struct HKP_answer *mem = (struct HKP_answer *)userp;
   1.324 - 
   1.325 +
   1.326    mem->memory = realloc(mem->memory, mem->size + realsize + 1);
   1.327    if(mem->memory == NULL) {
   1.328      mem->size = 0;
   1.329      return 0;
   1.330    }
   1.331 - 
   1.332 +
   1.333    memcpy(&(mem->memory[mem->size]), contents, realsize);
   1.334    mem->size += realsize;
   1.335    mem->memory[mem->size] = 0;
   1.336 - 
   1.337 +
   1.338    return realsize;
   1.339  }
   1.340  
   1.341 @@ -1035,7 +1036,7 @@
   1.342      char *request = NULL;
   1.343      struct HKP_answer answer;
   1.344      CURLcode curlres;
   1.345 -       
   1.346 +
   1.347      PEP_STATUS result;
   1.348  
   1.349      CURL *curl;
   1.350 @@ -1088,8 +1089,8 @@
   1.351          goto free_request;
   1.352      }
   1.353  
   1.354 -    result = pgp_import_keydata(session, 
   1.355 -                                answer.memory, 
   1.356 +    result = pgp_import_keydata(session,
   1.357 +                                answer.memory,
   1.358                                  answer.size);
   1.359  
   1.360  free_answer:
   1.361 @@ -1125,7 +1126,7 @@
   1.362          // Only one fingerprint can match
   1.363          if ((key = (pgp_key_t *)pgp_getkeybyfpr(
   1.364                          netpgp.io,
   1.365 -                        (pgp_keyring_t *)netpgp.pubring, 
   1.366 +                        (pgp_keyring_t *)netpgp.pubring,
   1.367                          (const uint8_t *)fpr, length,
   1.368                          &from,
   1.369                          NULL, 0, 0)) == NULL) {
   1.370 @@ -1141,7 +1142,7 @@
   1.371          result = PEP_KEY_NOT_FOUND;
   1.372          while((key = (pgp_key_t *)pgp_getnextkeybyname(
   1.373                          netpgp.io,
   1.374 -                        (pgp_keyring_t *)netpgp.pubring, 
   1.375 +                        (pgp_keyring_t *)netpgp.pubring,
   1.376  			            (const char *)pattern,
   1.377                          &from)) != NULL) {
   1.378  
   1.379 @@ -1167,7 +1168,7 @@
   1.380  
   1.381      if (newfprstr == NULL) {
   1.382          return PEP_OUT_OF_MEMORY;
   1.383 -    } else { 
   1.384 +    } else {
   1.385  
   1.386          stringlist_add(*keylist, newfprstr);
   1.387          free(newfprstr);
   1.388 @@ -1183,14 +1184,14 @@
   1.389      if (pgp_is_key_secret(key)) {
   1.390          stringlist_t **keylist = arg;
   1.391          char *newfprstr = NULL;
   1.392 -        
   1.393 +
   1.394          fpr_to_str(&newfprstr,
   1.395                  key->pubkeyfpr.fingerprint,
   1.396                  key->pubkeyfpr.length);
   1.397 -        
   1.398 +
   1.399          if (newfprstr == NULL) {
   1.400              return PEP_OUT_OF_MEMORY;
   1.401 -        } else { 
   1.402 +        } else {
   1.403              stringlist_add(*keylist, newfprstr);
   1.404              free(newfprstr);
   1.405              if (*keylist == NULL) {
   1.406 @@ -1206,23 +1207,23 @@
   1.407      stringpair_t* pair = NULL;
   1.408      char* id_fpr = NULL;
   1.409      char* primary_userid = (char*)pgp_key_get_primary_userid(key);
   1.410 -    
   1.411 +
   1.412  // Unused:
   1.413  //    bool key_revoked = false;
   1.414 -                
   1.415 +
   1.416  //    PEP_STATUS key_status = pgp_key_revoked(session, id_fpr, &key_revoked);
   1.417 -                
   1.418 +
   1.419  //    if (key_revoked || key_status == PEP_GET_KEY_FAILED)
   1.420  //        return PEP_STATUS_OK; // we just move on
   1.421 -        
   1.422 +
   1.423      fpr_to_str(&id_fpr, key->pubkeyfpr.fingerprint,
   1.424                  key->pubkeyfpr.length);
   1.425  
   1.426      pair = new_stringpair(id_fpr, primary_userid);
   1.427 -    
   1.428 +
   1.429      if (pair == NULL)
   1.430          return PEP_OUT_OF_MEMORY;
   1.431 -    
   1.432 +
   1.433      *keyinfo_list = stringpair_list_add(*keyinfo_list, pair);
   1.434      free(id_fpr);
   1.435      if (*keyinfo_list == NULL)
   1.436 @@ -1289,7 +1290,7 @@
   1.437      encoded_keys = (stringlist_t*)arg;
   1.438  
   1.439      result = _export_keydata(key, &buffer, &buflen);
   1.440 -    
   1.441 +
   1.442      if(result == PEP_STATUS_OK){
   1.443          char *encoded_key = curl_escape(buffer, (int)buflen);
   1.444          if(!encoded_key){
   1.445 @@ -1303,7 +1304,7 @@
   1.446              result = PEP_OUT_OF_MEMORY;
   1.447              goto free_encoded_key;
   1.448          }
   1.449 -        
   1.450 +
   1.451          memcpy(request, HKP_REQ_PREFIX, HKP_REQ_PREFIX_LEN);
   1.452          memcpy(request + HKP_REQ_PREFIX_LEN, encoded_key, encoded_key_len);
   1.453          request[HKP_REQ_PREFIX_LEN + encoded_key_len] = '\0';
   1.454 @@ -1318,7 +1319,7 @@
   1.455  free_encoded_key:
   1.456          curl_free(encoded_key);
   1.457  
   1.458 -free_buffer:        
   1.459 +free_buffer:
   1.460          free(buffer);
   1.461      }
   1.462  
   1.463 @@ -1433,7 +1434,7 @@
   1.464          status = PEP_ILLEGAL_VALUE;
   1.465          goto unlock_netpgp;
   1.466      }
   1.467 -        
   1.468 +
   1.469      key = pgp_getkeybyfpr(
   1.470             netpgp.io,
   1.471             netpgp.pubring,
   1.472 @@ -1515,12 +1516,12 @@
   1.473          return PEP_UNKNOWN_ERROR;
   1.474      }
   1.475  
   1.476 -    
   1.477 +
   1.478      if (!str_to_fpr(fprstr, fpr, &length)) {
   1.479          status = PEP_ILLEGAL_VALUE;
   1.480          goto unlock_netpgp;
   1.481      }
   1.482 -    
   1.483 +
   1.484      pkey = pgp_getkeybyfpr(
   1.485                            netpgp.io,
   1.486                            netpgp.pubring,
   1.487 @@ -1567,7 +1568,7 @@
   1.488      }else{
   1.489          status = PEP_UNKNOWN_ERROR;
   1.490      }
   1.491 -    
   1.492 +
   1.493  unlock_netpgp:
   1.494      pthread_mutex_unlock(&netpgp_mutex);
   1.495  
   1.496 @@ -1601,26 +1602,26 @@
   1.497          status = PEP_ILLEGAL_VALUE;
   1.498          goto unlock_netpgp;
   1.499      }
   1.500 -    
   1.501 +
   1.502      pgp_key_t *pkey = pgp_getkeybyfpr(
   1.503                             netpgp.io,
   1.504                             netpgp.pubring,
   1.505                             fpr, length, &from, NULL,
   1.506                             1, 0); /* reject revoked, accept expired */
   1.507 -    
   1.508 +
   1.509      if(pkey == NULL)
   1.510      {
   1.511          status = PEP_KEY_NOT_FOUND;
   1.512          goto unlock_netpgp;
   1.513      }
   1.514 -    
   1.515 +
   1.516      from = 0;
   1.517      pgp_key_t *skey = pgp_getkeybyfpr(
   1.518                             netpgp.io,
   1.519                             netpgp.secring,
   1.520                             fpr, length, &from, NULL,
   1.521                             1, 0); /* reject revoked, accept expired */
   1.522 -    
   1.523 +
   1.524      if(skey == NULL)
   1.525      {
   1.526          status = PEP_KEY_NOT_FOUND;
   1.527 @@ -1654,7 +1655,7 @@
   1.528      if (!session || !fprstr || !expired)
   1.529          return PEP_UNKNOWN_ERROR;
   1.530  
   1.531 -    // TODO : take "when" in account 
   1.532 +    // TODO : take "when" in account
   1.533  
   1.534      *expired = false;
   1.535  
   1.536 @@ -1678,22 +1679,22 @@
   1.537  {
   1.538      PEP_STATUS status = PEP_STATUS_OK;
   1.539      PEP_comm_type comm_type;
   1.540 -    
   1.541 +
   1.542      assert(session);
   1.543      assert(fprstr);
   1.544      assert(revoked);
   1.545 -    
   1.546 +
   1.547      *revoked = false;
   1.548 -    
   1.549 +
   1.550      status = pgp_get_key_rating(session, fprstr, &comm_type);
   1.551 -    
   1.552 +
   1.553      if (status != PEP_STATUS_OK)
   1.554          return status;
   1.555 -    
   1.556 +
   1.557      if (comm_type == PEP_ct_key_revoked){
   1.558          *revoked = true;
   1.559      }
   1.560 -    
   1.561 +
   1.562      return PEP_STATUS_OK;
   1.563  }
   1.564  
   1.565 @@ -1727,7 +1728,7 @@
   1.566          status = PEP_ILLEGAL_VALUE;
   1.567          goto unlock_netpgp;
   1.568      }
   1.569 -        
   1.570 +
   1.571      key = pgp_getkeybyfpr(
   1.572             netpgp.io,
   1.573             netpgp.pubring,
   1.574 @@ -1742,7 +1743,7 @@
   1.575          status = PEP_KEY_NOT_FOUND;
   1.576          goto unlock_netpgp;
   1.577      }
   1.578 -    
   1.579 +
   1.580  
   1.581  
   1.582  unlock_netpgp:
   1.583 @@ -1755,28 +1756,28 @@
   1.584  PEP_STATUS pgp_list_keyinfo(
   1.585          PEP_SESSION session, const char* pattern, stringpair_list_t** keyinfo_list)
   1.586  {
   1.587 -    
   1.588 +
   1.589      if (!session || !keyinfo_list)
   1.590          return PEP_UNKNOWN_ERROR;
   1.591 -    
   1.592 +
   1.593      if (pthread_mutex_lock(&netpgp_mutex))
   1.594      {
   1.595          return PEP_UNKNOWN_ERROR;
   1.596      }
   1.597 -    
   1.598 +
   1.599  // Unused:
   1.600  //    pgp_key_t *key;
   1.601  
   1.602      PEP_STATUS result;
   1.603 -    
   1.604 +
   1.605      result = find_keys_do(pattern, &add_keyinfo_to_stringpair_list, (void*)keyinfo_list);
   1.606 -    
   1.607 +
   1.608      if (!keyinfo_list)
   1.609          result = PEP_KEY_NOT_FOUND;
   1.610 -    
   1.611 +
   1.612  unlock_netpgp:
   1.613      pthread_mutex_unlock(&netpgp_mutex);
   1.614 -    
   1.615 +
   1.616      return result;
   1.617  }
   1.618  
   1.619 @@ -1785,23 +1786,23 @@
   1.620      PEP_SESSION session, const char *pattern, stringlist_t **keylist)
   1.621  {
   1.622      stringlist_t *_keylist, *_k;
   1.623 -    
   1.624 +
   1.625      PEP_STATUS result;
   1.626 -    
   1.627 +
   1.628      assert(session);
   1.629      assert(pattern);
   1.630      assert(keylist);
   1.631 -    
   1.632 +
   1.633      if (!session || !pattern || !keylist )
   1.634      {
   1.635          return PEP_ILLEGAL_VALUE;
   1.636      }
   1.637 -    
   1.638 +
   1.639      if (pthread_mutex_lock(&netpgp_mutex))
   1.640      {
   1.641          return PEP_UNKNOWN_ERROR;
   1.642      }
   1.643 -    
   1.644 +
   1.645      *keylist = NULL;
   1.646      _keylist = new_stringlist(NULL);
   1.647      if (_keylist == NULL) {
   1.648 @@ -1809,26 +1810,26 @@
   1.649          goto unlock_netpgp;
   1.650      }
   1.651      _k = _keylist;
   1.652 -    
   1.653 +
   1.654      result = find_keys_do(pattern, &add_secret_key_fpr_to_stringlist, &_k);
   1.655 -    
   1.656 +
   1.657      if (result == PEP_STATUS_OK) {
   1.658          *keylist = _keylist;
   1.659          // Transfer ownership, no free
   1.660          goto unlock_netpgp;
   1.661      }
   1.662 -    
   1.663 +
   1.664  free_keylist:
   1.665      free_stringlist(_keylist);
   1.666 -    
   1.667 +
   1.668  unlock_netpgp:
   1.669      pthread_mutex_unlock(&netpgp_mutex);
   1.670 -    
   1.671 -    return result;    
   1.672 +
   1.673 +    return result;
   1.674  }
   1.675  
   1.676  PEP_STATUS pgp_contains_priv_key(
   1.677 -    PEP_SESSION session, 
   1.678 +    PEP_SESSION session,
   1.679      const char *fpr,
   1.680      bool *has_private) {
   1.681      stringlist_t* keylist = NULL;
     2.1 --- a/src/pgp_netpgp.h	Wed Nov 23 21:10:56 2016 +0100
     2.2 +++ b/src/pgp_netpgp.h	Thu Nov 24 09:53:59 2016 +0100
     2.3 @@ -7,6 +7,7 @@
     2.4  
     2.5  PEP_STATUS pgp_decrypt_and_verify(
     2.6          PEP_SESSION session, const char *ctext, size_t csize,
     2.7 +        const char *dsigtext, size_t dsigsize,
     2.8          char **ptext, size_t *psize, stringlist_t **keylist
     2.9      );
    2.10  
    2.11 @@ -82,11 +83,10 @@
    2.12      );
    2.13  
    2.14  PEP_STATUS pgp_contains_priv_key(
    2.15 -    PEP_SESSION session, 
    2.16 +    PEP_SESSION session,
    2.17      const char *fpr,
    2.18      bool *has_private);
    2.19  
    2.20  PEP_STATUS pgp_find_private_keys(
    2.21      PEP_SESSION session, const char *pattern, stringlist_t **keylist
    2.22  );
    2.23 -