diff options
-rw-r--r-- | lib/gnutls_errors.c | 2 | ||||
-rw-r--r-- | lib/includes/gnutls/gnutls.h.in | 1 | ||||
-rw-r--r-- | lib/openpgp/pgp.c | 5 | ||||
-rw-r--r-- | lib/openpgp/privkey.c | 5 |
4 files changed, 11 insertions, 2 deletions
diff --git a/lib/gnutls_errors.c b/lib/gnutls_errors.c index d9548e3884..fada304654 100644 --- a/lib/gnutls_errors.c +++ b/lib/gnutls_errors.c @@ -216,6 +216,8 @@ static const gnutls_error_entry error_algorithms[] = { GNUTLS_E_INCOMPATIBLE_LIBTASN1_LIBRARY, 1), ERROR_ENTRY (N_("The OpenPGP User ID is revoked."), GNUTLS_E_OPENPGP_UID_REVOKED, 1), + ERROR_ENTRY (N_("The OpenPGP key has not a preferred key set."), + GNUTLS_E_OPENPGP_PREFERRED_KEY_ERROR, 1), ERROR_ENTRY (N_("Error loading the keyring."), GNUTLS_E_OPENPGP_KEYRING_ERROR, 1), ERROR_ENTRY (N_("The initialization of crypto backend has failed."), diff --git a/lib/includes/gnutls/gnutls.h.in b/lib/includes/gnutls/gnutls.h.in index 5933f4d4c7..13b3e4fc8a 100644 --- a/lib/includes/gnutls/gnutls.h.in +++ b/lib/includes/gnutls/gnutls.h.in @@ -1714,6 +1714,7 @@ extern "C" #define GNUTLS_E_CHANNEL_BINDING_NOT_AVAILABLE -213 #define GNUTLS_E_BAD_COOKIE -214 +#define GNUTLS_E_OPENPGP_PREFERRED_KEY_ERROR -215 /* PKCS11 related */ #define GNUTLS_E_PKCS11_ERROR -300 diff --git a/lib/openpgp/pgp.c b/lib/openpgp/pgp.c index ffee4c9db7..75be8ad14e 100644 --- a/lib/openpgp/pgp.c +++ b/lib/openpgp/pgp.c @@ -1559,7 +1559,10 @@ int gnutls_openpgp_crt_get_preferred_key_id (gnutls_openpgp_crt_t key, gnutls_openpgp_keyid_t keyid) { - if (!key || !keyid || !key->preferred_set) + if (!key->preferred_set) + return gnutls_assert_val(GNUTLS_E_OPENPGP_PREFERRED_KEY_ERROR); + + if (!key || !keyid) { gnutls_assert (); return GNUTLS_E_INVALID_REQUEST; diff --git a/lib/openpgp/privkey.c b/lib/openpgp/privkey.c index 07bb9880c5..0ed4f0d7cf 100644 --- a/lib/openpgp/privkey.c +++ b/lib/openpgp/privkey.c @@ -1176,7 +1176,10 @@ int gnutls_openpgp_privkey_get_preferred_key_id (gnutls_openpgp_privkey_t key, gnutls_openpgp_keyid_t keyid) { - if (!key || !keyid || !key->preferred_set) + if (!key->preferred_set) + return gnutls_assert_val(GNUTLS_E_OPENPGP_PREFERRED_KEY_ERROR); + + if (!key || !keyid) { gnutls_assert (); return GNUTLS_E_INVALID_REQUEST; |