src/pEpEngine.c
changeset 14 c99db0b8fc0f
parent 10 ead888e73384
child 15 98a6c1cc9160
     1.1 --- a/src/pEpEngine.c	Thu Jul 31 10:15:09 2014 +0200
     1.2 +++ b/src/pEpEngine.c	Tue Aug 05 20:33:20 2014 +0200
     1.3 @@ -749,7 +749,7 @@
     1.4  		switch (gpgme_error) {
     1.5  		case GPG_ERR_NO_ERROR:
     1.6  			{
     1.7 -				gpgme_verify_result_t gpgme_verify_result;
     1.8 +                gpgme_verify_result_t gpgme_verify_result;
     1.9                  char *_buffer = NULL;
    1.10  				size_t reading;
    1.11                  size_t length = _session->gpgme_data_seek(plain, 0, SEEK_END);
    1.12 @@ -837,8 +837,34 @@
    1.13  			break;
    1.14  		case GPG_ERR_BAD_PASSPHRASE:
    1.15  			NOT_IMPLEMENTED;
    1.16 -		default:
    1.17 -			result = PEP_CANNOT_DECRYPT_UNKNOWN;
    1.18 +        default:
    1.19 +            {
    1.20 +                gpgme_decrypt_result_t gpgme_decrypt_result = _session->gpgme_op_decrypt_result(_session->ctx);
    1.21 +                result = PEP_CANNOT_DECRYPT_UNKNOWN;
    1.22 +
    1.23 +                if (gpgme_decrypt_result != NULL) {
    1.24 +                    *keylist = new_stringlist(gpgme_decrypt_result->unsupported_algorithm);
    1.25 +                    assert(*keylist);
    1.26 +                    if (*keylist == NULL) {
    1.27 +                        result = PEP_OUT_OF_MEMORY;
    1.28 +                        break;
    1.29 +                    }
    1.30 +                    
    1.31 +                    stringlist_t *_keylist = *keylist;
    1.32 +                    for (gpgme_recipient_t r = gpgme_decrypt_result->recipients; r != NULL; r = r->next) {
    1.33 +                        _keylist = stringlist_add(_keylist, r->keyid);
    1.34 +                        assert(_keylist);
    1.35 +                        if (_keylist == NULL) {
    1.36 +                            free_stringlist(*keylist);
    1.37 +                            *keylist = NULL;
    1.38 +                            result = PEP_OUT_OF_MEMORY;
    1.39 +                            break;
    1.40 +                        }
    1.41 +                    }
    1.42 +                    if (result == PEP_OUT_OF_MEMORY)
    1.43 +                        break;
    1.44 +                }
    1.45 +            }
    1.46  		}
    1.47  		break;
    1.48  
    1.49 @@ -1954,6 +1980,11 @@
    1.50      gpgme_error = _session->gpgme_op_keylist_next(_session->ctx, &key);
    1.51      assert(gpgme_error != GPG_ERR_INV_VALUE);
    1.52  
    1.53 +    if (key == NULL) {
    1.54 +        _session->gpgme_op_keylist_end(_session->ctx);
    1.55 +        return PEP_KEY_NOT_FOUND;
    1.56 +    }
    1.57 +
    1.58      switch (key->protocol) {
    1.59      case GPGME_PROTOCOL_OpenPGP:
    1.60      case GPGME_PROTOCOL_DEFAULT:
    1.61 @@ -2019,4 +2050,4 @@
    1.62      _session->gpgme_op_keylist_end(_session->ctx);
    1.63  
    1.64      return status;
    1.65 -}
    1.66 \ No newline at end of file
    1.67 +}