summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2011-03-16 19:41:52 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2011-03-16 20:53:31 +0100
commit58b87f252c11b1f1e01a88fa13e8ff6f4a3042a6 (patch)
tree47a9b53d9d4736fede16d580c0b157e95546e661
parent418625f3abd4193cc89699c5b58d82045cc6c086 (diff)
downloadgnutls-58b87f252c11b1f1e01a88fa13e8ff6f4a3042a6.tar.gz
introduced GNUTLS_E_OPENPGP_PREFERRED_KEY_ERROR
-rw-r--r--lib/gnutls_errors.c2
-rw-r--r--lib/includes/gnutls/gnutls.h.in1
-rw-r--r--lib/openpgp/pgp.c5
-rw-r--r--lib/openpgp/privkey.c5
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;