From 58b87f252c11b1f1e01a88fa13e8ff6f4a3042a6 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Wed, 16 Mar 2011 19:41:52 +0100 Subject: introduced GNUTLS_E_OPENPGP_PREFERRED_KEY_ERROR --- lib/gnutls_errors.c | 2 ++ lib/includes/gnutls/gnutls.h.in | 1 + lib/openpgp/pgp.c | 5 ++++- 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 c7661cd4ad..1e297c02be 100644 --- a/lib/gnutls_errors.c +++ b/lib/gnutls_errors.c @@ -211,6 +211,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 9f694b61bc..faa33901c1 100644 --- a/lib/includes/gnutls/gnutls.h.in +++ b/lib/includes/gnutls/gnutls.h.in @@ -1729,6 +1729,7 @@ extern "C" #define GNUTLS_E_CRYPTODEV_DEVICE_ERROR -212 #define GNUTLS_E_CHANNEL_BINDING_NOT_AVAILABLE -213 +#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 9d25adc6ba..229b69d317 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 be563059bd..4e3d0aabdf 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; -- cgit v1.2.1