mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-10 13:04:23 +01:00
Update error handling to match gpg-error in CVS.
This commit is contained in:
parent
39e6e163d4
commit
a58ce94d8e
@ -48,11 +48,11 @@ ask_for_card (CTRL ctrl, const unsigned char *shadow_info, char **r_kid)
|
||||
*r_kid = NULL;
|
||||
s = shadow_info;
|
||||
if (*s != '(')
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
s++;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
want_sn = xtrymalloc (n*2+1);
|
||||
if (!want_sn)
|
||||
return out_of_core ();
|
||||
@ -68,7 +68,7 @@ ask_for_card (CTRL ctrl, const unsigned char *shadow_info, char **r_kid)
|
||||
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
want_kid = xtrymalloc (n+1);
|
||||
if (!want_kid)
|
||||
{
|
||||
@ -261,11 +261,11 @@ divert_pkdecrypt (CTRL ctrl,
|
||||
|
||||
s = cipher;
|
||||
if (*s != '(')
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
s++;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
if (!smatch (&s, n, "enc-val"))
|
||||
return gpg_error (GPG_ERR_UNKNOWN_SEXP);
|
||||
if (*s != '(')
|
||||
@ -273,7 +273,7 @@ divert_pkdecrypt (CTRL ctrl,
|
||||
s++;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
if (!smatch (&s, n, "rsa"))
|
||||
return gpg_error (GPG_ERR_UNSUPPORTED_ALGORITHM);
|
||||
if (*s != '(')
|
||||
@ -281,7 +281,7 @@ divert_pkdecrypt (CTRL ctrl,
|
||||
s++;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
if (!smatch (&s, n, "a"))
|
||||
return gpg_error (GPG_ERR_UNKNOWN_SEXP);
|
||||
n = snext (&s);
|
||||
|
@ -101,7 +101,7 @@ agent_genkey (CTRL ctrl, const char *keyparam, size_t keyparamlen,
|
||||
if (rc)
|
||||
{
|
||||
log_error ("failed to convert keyparam: %s\n", gcry_strerror (rc));
|
||||
return gpg_error (GPG_ERR_INVALID_DATA);
|
||||
return gpg_error (GPG_ERR_INV_DATA);
|
||||
}
|
||||
|
||||
/* Get the passphrase now, cause key generation may take a while. */
|
||||
@ -147,7 +147,7 @@ agent_genkey (CTRL ctrl, const char *keyparam, size_t keyparamlen,
|
||||
log_error ("key generation failed: invalid return value\n");
|
||||
gcry_sexp_release (s_key);
|
||||
xfree (pi);
|
||||
return gpg_error (GPG_ERR_INVALID_DATA);
|
||||
return gpg_error (GPG_ERR_INV_DATA);
|
||||
}
|
||||
s_public = gcry_sexp_find_token (s_key, "public-key", 0);
|
||||
if (!s_public)
|
||||
@ -156,7 +156,7 @@ agent_genkey (CTRL ctrl, const char *keyparam, size_t keyparamlen,
|
||||
gcry_sexp_release (s_private);
|
||||
gcry_sexp_release (s_key);
|
||||
xfree (pi);
|
||||
return gpg_error (GPG_ERR_INVALID_DATA);
|
||||
return gpg_error (GPG_ERR_INV_DATA);
|
||||
}
|
||||
gcry_sexp_release (s_key); s_key = NULL;
|
||||
|
||||
|
@ -110,7 +110,7 @@ kpinfo_cb (void *opaque, const char *line)
|
||||
}
|
||||
else if ((p - item->hexgrip) != 40 || !spacep (p))
|
||||
{ /* not a 20 byte hex keygrip or not followed by a space */
|
||||
parm->error = gpg_error (GPG_ERR_INVALID_RESPONSE);
|
||||
parm->error = gpg_error (GPG_ERR_INV_RESPONSE);
|
||||
xfree (item);
|
||||
return;
|
||||
}
|
||||
@ -122,7 +122,7 @@ kpinfo_cb (void *opaque, const char *line)
|
||||
p++;
|
||||
if (p == item->id)
|
||||
{ /* invalid ID string */
|
||||
parm->error = gpg_error (GPG_ERR_INVALID_RESPONSE);
|
||||
parm->error = gpg_error (GPG_ERR_INV_RESPONSE);
|
||||
xfree (item);
|
||||
return;
|
||||
}
|
||||
@ -154,7 +154,7 @@ certinfo_cb (void *opaque, const char *line)
|
||||
;
|
||||
if (p == pend || !*p)
|
||||
{
|
||||
parm->error = gpg_error (GPG_ERR_INVALID_RESPONSE);
|
||||
parm->error = gpg_error (GPG_ERR_INV_RESPONSE);
|
||||
return;
|
||||
}
|
||||
*pend = 0; /* ignore trailing stuff */
|
||||
|
@ -77,7 +77,7 @@ agent_pkdecrypt (CTRL ctrl, const char *ciphertext, size_t ciphertextlen,
|
||||
|
||||
if (!gcry_sexp_canon_len (ciphertext, ciphertextlen, NULL, NULL))
|
||||
{
|
||||
rc = gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
rc = gpg_error (GPG_ERR_INV_SEXP);
|
||||
goto leave;
|
||||
}
|
||||
|
||||
|
@ -68,11 +68,11 @@ calculate_mic (const unsigned char *plainkey, unsigned char *sha1hash)
|
||||
|
||||
s = plainkey;
|
||||
if (*s != '(')
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
s++;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
if (!smatch (&s, n, "private-key"))
|
||||
return gpg_error (GPG_ERR_UNKNOWN_SEXP);
|
||||
if (*s != '(')
|
||||
@ -81,7 +81,7 @@ calculate_mic (const unsigned char *plainkey, unsigned char *sha1hash)
|
||||
s++;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
s += n; /* skip over the algorithm name */
|
||||
|
||||
while (*s == '(')
|
||||
@ -89,18 +89,18 @@ calculate_mic (const unsigned char *plainkey, unsigned char *sha1hash)
|
||||
s++;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
s += n;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
s += n;
|
||||
if ( *s != ')' )
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
s++;
|
||||
}
|
||||
if (*s != ')')
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
s++;
|
||||
hash_end = s;
|
||||
|
||||
@ -278,12 +278,12 @@ agent_protect (const unsigned char *plainkey, const char *passphrase,
|
||||
|
||||
s = plainkey;
|
||||
if (*s != '(')
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
depth++;
|
||||
s++;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
if (!smatch (&s, n, "private-key"))
|
||||
return gpg_error (GPG_ERR_UNKNOWN_SEXP);
|
||||
if (*s != '(')
|
||||
@ -293,7 +293,7 @@ agent_protect (const unsigned char *plainkey, const char *passphrase,
|
||||
s++;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
|
||||
for (infidx=0; protect_info[infidx].algo
|
||||
&& !smatch (&s, n, protect_info[infidx].algo); infidx++)
|
||||
@ -307,28 +307,28 @@ agent_protect (const unsigned char *plainkey, const char *passphrase,
|
||||
if (i == protect_info[infidx].prot_from)
|
||||
prot_begin = s;
|
||||
if (*s != '(')
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
depth++;
|
||||
s++;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
if (n != 1 || c != *s)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
s += n;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
s +=n; /* skip value */
|
||||
if (*s != ')')
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
depth--;
|
||||
if (i == protect_info[infidx].prot_to)
|
||||
prot_end = s;
|
||||
s++;
|
||||
}
|
||||
if (*s != ')' || !prot_begin || !prot_end )
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
depth--;
|
||||
hash_end = s;
|
||||
s++;
|
||||
@ -566,7 +566,7 @@ merge_lists (const unsigned char *protectedkey,
|
||||
|
||||
invalid_sexp:
|
||||
xfree (newlist);
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
}
|
||||
|
||||
|
||||
@ -591,11 +591,11 @@ agent_unprotect (const unsigned char *protectedkey, const char *passphrase,
|
||||
|
||||
s = protectedkey;
|
||||
if (*s != '(')
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
s++;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
if (!smatch (&s, n, "protected-private-key"))
|
||||
return gpg_error (GPG_ERR_UNKNOWN_SEXP);
|
||||
if (*s != '(')
|
||||
@ -603,7 +603,7 @@ agent_unprotect (const unsigned char *protectedkey, const char *passphrase,
|
||||
s++;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
|
||||
for (infidx=0; protect_info[infidx].algo
|
||||
&& !smatch (&s, n, protect_info[infidx].algo); infidx++)
|
||||
@ -620,12 +620,12 @@ agent_unprotect (const unsigned char *protectedkey, const char *passphrase,
|
||||
for (;;)
|
||||
{
|
||||
if (*s != '(')
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
prot_begin = s;
|
||||
s++;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
if (smatch (&s, n, "protected"))
|
||||
break;
|
||||
s += n;
|
||||
@ -637,15 +637,15 @@ agent_unprotect (const unsigned char *protectedkey, const char *passphrase,
|
||||
/* found */
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
if (!smatch (&s, n, "openpgp-s2k3-sha1-" PROT_CIPHER_STRING "-cbc"))
|
||||
return gpg_error (GPG_ERR_UNSUPPORTED_PROTECTION);
|
||||
if (*s != '(' || s[1] != '(')
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
s += 2;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
if (!smatch (&s, n, "sha1"))
|
||||
return gpg_error (GPG_ERR_UNSUPPORTED_PROTECTION);
|
||||
n = snext (&s);
|
||||
@ -660,7 +660,7 @@ agent_unprotect (const unsigned char *protectedkey, const char *passphrase,
|
||||
here. We might want to check that we only have digits - but this
|
||||
is nothing we should worry about */
|
||||
if (s[n] != ')' )
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
s2kcount = strtoul (s, NULL, 10);
|
||||
if (!s2kcount)
|
||||
return gpg_error (GPG_ERR_CORRUPTED_PROTECTION);
|
||||
@ -673,11 +673,11 @@ agent_unprotect (const unsigned char *protectedkey, const char *passphrase,
|
||||
iv = s;
|
||||
s += n;
|
||||
if (*s != ')' )
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
s++;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
|
||||
rc = do_decryption (s, n,
|
||||
passphrase, s2ksalt, s2kcount,
|
||||
@ -836,15 +836,15 @@ agent_shadow_key (const unsigned char *pubkey,
|
||||
size_t shadow_info_len = gcry_sexp_canon_len (shadow_info, 0, NULL,NULL);
|
||||
|
||||
if (!pubkey_len || !shadow_info_len)
|
||||
return gpg_error (GPG_ERR_INVALID_VALUE);
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
s = pubkey;
|
||||
if (*s != '(')
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
depth++;
|
||||
s++;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
if (!smatch (&s, n, "public-key"))
|
||||
return gpg_error (GPG_ERR_UNKNOWN_SEXP);
|
||||
if (*s != '(')
|
||||
@ -853,25 +853,25 @@ agent_shadow_key (const unsigned char *pubkey,
|
||||
s++;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
s += n; /* skip over the algorithm name */
|
||||
|
||||
while (*s != ')')
|
||||
{
|
||||
if (*s != '(')
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
depth++;
|
||||
s++;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
s += n;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
s +=n; /* skip value */
|
||||
if (*s != ')')
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
depth--;
|
||||
s++;
|
||||
}
|
||||
@ -912,12 +912,12 @@ agent_get_shadow_info (const unsigned char *shadowkey,
|
||||
|
||||
s = shadowkey;
|
||||
if (*s != '(')
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
depth++;
|
||||
s++;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
if (!smatch (&s, n, "shadowed-private-key"))
|
||||
return gpg_error (GPG_ERR_UNKNOWN_SEXP);
|
||||
if (*s != '(')
|
||||
@ -926,7 +926,7 @@ agent_get_shadow_info (const unsigned char *shadowkey,
|
||||
s++;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
s += n; /* skip over the algorithm name */
|
||||
|
||||
for (;;)
|
||||
@ -934,32 +934,32 @@ agent_get_shadow_info (const unsigned char *shadowkey,
|
||||
if (*s == ')')
|
||||
return gpg_error (GPG_ERR_UNKNOWN_SEXP);
|
||||
if (*s != '(')
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
depth++;
|
||||
s++;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
if (smatch (&s, n, "shadowed"))
|
||||
break;
|
||||
s += n;
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
s +=n; /* skip value */
|
||||
if (*s != ')')
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
depth--;
|
||||
s++;
|
||||
}
|
||||
/* found the shadowed list, s points to the protocol */
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
if (smatch (&s, n, "t1-v1"))
|
||||
{
|
||||
if (*s != '(')
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
*shadow_info = s;
|
||||
}
|
||||
else
|
||||
|
@ -68,10 +68,10 @@ sskip (unsigned char const **buf, int *depth)
|
||||
else
|
||||
{
|
||||
if (!d)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
n = snext (&s);
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
s += n;
|
||||
}
|
||||
}
|
||||
|
@ -23,11 +23,7 @@
|
||||
|
||||
#include "util.h"
|
||||
|
||||
#ifdef GPG_ERR_SOURCE_DEFAULT
|
||||
# define GPG_ERR_INVALID_VALUE GPG_ERR_INV_VALUE
|
||||
# define GPG_ERR_INVALID_DATA GPG_ERR_INV_DATA
|
||||
# define GPG_ERR_INVALID_SEXP GPG_ERR_INV_SEXP
|
||||
#else /*GPG_ERR_SOURCE_DEFAUL*/
|
||||
#ifndef GPG_ERR_SOURCE_DEFAULT
|
||||
/* Error numbers. Note, that they are onkly used for old code not yet
|
||||
converted to libgpg-error. */
|
||||
enum {
|
||||
|
@ -128,13 +128,13 @@ dinsig_enum_keypairs (CARD card, int idx,
|
||||
log_error ("failed to parse the certificate at idx %d: %s\n",
|
||||
idx, ksba_strerror (krc));
|
||||
ksba_cert_release (cert);
|
||||
return gpg_error (GPG_ERR_CARD_ERROR);
|
||||
return gpg_error (GPG_ERR_CARD);
|
||||
}
|
||||
if (card_help_get_keygrip (cert, keygrip))
|
||||
{
|
||||
log_error ("failed to calculate the keygrip at index %d\n", idx);
|
||||
ksba_cert_release (cert);
|
||||
return gpg_error (GPG_ERR_CARD_ERROR);
|
||||
return gpg_error (GPG_ERR_CARD);
|
||||
}
|
||||
ksba_cert_release (cert);
|
||||
|
||||
@ -171,7 +171,7 @@ dinsig_read_cert (CARD card, const char *certidstr,
|
||||
else if (!strcmp (certidstr, "DINSIG-DF01.C200"))
|
||||
sc_format_path ("3F00DF01C200", &path);
|
||||
else
|
||||
return gpg_error (GPG_ERR_INVALID_ID);
|
||||
return gpg_error (GPG_ERR_INV_ID);
|
||||
|
||||
rc = sc_select_file (card->scard, &path, &file);
|
||||
if (rc)
|
||||
@ -184,13 +184,13 @@ dinsig_read_cert (CARD card, const char *certidstr,
|
||||
{
|
||||
log_error ("wrong type or structure of certificate EF\n");
|
||||
sc_file_free (file);
|
||||
return gpg_error (GPG_ERR_CARD_ERROR);
|
||||
return gpg_error (GPG_ERR_CARD);
|
||||
}
|
||||
if (file->size < 20) /* check against a somewhat arbitrary length */
|
||||
{
|
||||
log_error ("certificate EF too short\n");
|
||||
sc_file_free (file);
|
||||
return gpg_error (GPG_ERR_CARD_ERROR);
|
||||
return gpg_error (GPG_ERR_CARD);
|
||||
}
|
||||
buf = xtrymalloc (file->size);
|
||||
if (!buf)
|
||||
@ -206,7 +206,7 @@ dinsig_read_cert (CARD card, const char *certidstr,
|
||||
log_error ("short read on certificate EF\n");
|
||||
sc_file_free (file);
|
||||
xfree (buf);
|
||||
return gpg_error (GPG_ERR_CARD_ERROR);
|
||||
return gpg_error (GPG_ERR_CARD);
|
||||
}
|
||||
sc_file_free (file);
|
||||
if (rc < 0)
|
||||
|
@ -70,7 +70,7 @@ init_private_data (CARD card)
|
||||
{
|
||||
log_error ("private keys enumeration failed: %s\n", sc_strerror (rc));
|
||||
xfree (priv);
|
||||
return gpg_error (GPG_ERR_CARD_ERROR);
|
||||
return gpg_error (GPG_ERR_CARD);
|
||||
}
|
||||
priv->n_prkey_rsa_objs = rc;
|
||||
|
||||
@ -82,7 +82,7 @@ init_private_data (CARD card)
|
||||
{
|
||||
log_error ("private keys enumeration failed: %s\n", sc_strerror (rc));
|
||||
xfree (priv);
|
||||
return gpg_error (GPG_ERR_CARD_ERROR);
|
||||
return gpg_error (GPG_ERR_CARD);
|
||||
}
|
||||
priv->n_cert_objs = rc;
|
||||
|
||||
@ -145,7 +145,7 @@ p15_enum_keypairs (CARD card, int idx,
|
||||
{
|
||||
log_info ("failed to read certificate for private key %d: %s\n",
|
||||
idx, sc_strerror (rc));
|
||||
return gpg_error (GPG_ERR_CARD_ERROR);
|
||||
return gpg_error (GPG_ERR_CARD);
|
||||
}
|
||||
|
||||
cert = ksba_cert_new ();
|
||||
@ -162,13 +162,13 @@ p15_enum_keypairs (CARD card, int idx,
|
||||
log_error ("failed to parse the certificate for private key %d: %s\n",
|
||||
idx, ksba_strerror (krc));
|
||||
ksba_cert_release (cert);
|
||||
return gpg_error (GPG_ERR_CARD_ERROR);
|
||||
return gpg_error (GPG_ERR_CARD);
|
||||
}
|
||||
if (card_help_get_keygrip (cert, keygrip))
|
||||
{
|
||||
log_error ("failed to calculate the keygrip of private key %d\n", idx);
|
||||
ksba_cert_release (cert);
|
||||
return gpg_error (GPG_ERR_CARD_ERROR);
|
||||
return gpg_error (GPG_ERR_CARD);
|
||||
}
|
||||
ksba_cert_release (cert);
|
||||
|
||||
@ -252,14 +252,14 @@ idstr_to_id (const char *idstr, struct sc_pkcs15_id *id)
|
||||
|
||||
/* For now we only support the standard DF */
|
||||
if (strncmp (idstr, "P15-5015.", 9) )
|
||||
return gpg_error (GPG_ERR_INVALID_ID);
|
||||
return gpg_error (GPG_ERR_INV_ID);
|
||||
for (s=idstr+9, n=0; hexdigitp (s); s++, n++)
|
||||
;
|
||||
if (*s || (n&1))
|
||||
return gpg_error (GPG_ERR_INVALID_ID); /*invalid or odd number of digits*/
|
||||
return gpg_error (GPG_ERR_INV_ID); /*invalid or odd number of digits*/
|
||||
n /= 2;
|
||||
if (!n || n > SC_PKCS15_MAX_ID_SIZE)
|
||||
return gpg_error (GPG_ERR_INVALID_ID); /* empty or too large */
|
||||
return gpg_error (GPG_ERR_INV_ID); /* empty or too large */
|
||||
for (s=idstr+9, n=0; *s; s += 2, n++)
|
||||
id->value[n] = xtoi_2 (s);
|
||||
id->len = n;
|
||||
@ -279,7 +279,7 @@ p15_read_cert (CARD card, const char *certidstr,
|
||||
int rc;
|
||||
|
||||
if (!card || !certidstr || !cert || !ncert)
|
||||
return gpg_error (GPG_ERR_INVALID_VALUE);
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
if (!card->p15card)
|
||||
return gpg_error (GPG_ERR_NO_PKCS15_APP);
|
||||
|
||||
@ -300,7 +300,7 @@ p15_read_cert (CARD card, const char *certidstr,
|
||||
{
|
||||
log_info ("failed to read certificate '%s': %s\n",
|
||||
certidstr, sc_strerror (rc));
|
||||
return gpg_error (GPG_ERR_CARD_ERROR);
|
||||
return gpg_error (GPG_ERR_CARD);
|
||||
}
|
||||
|
||||
*cert = xtrymalloc (certder->data_len);
|
||||
@ -411,7 +411,7 @@ p15_sign (CARD card, const char *keyidstr, int hashalgo,
|
||||
if (rc < 0)
|
||||
{
|
||||
log_error ("failed to create signature: %s\n", sc_strerror (rc));
|
||||
rc = gpg_error (GPG_ERR_CARD_ERROR);
|
||||
rc = gpg_error (GPG_ERR_CARD);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -473,7 +473,7 @@ p15_decipher (CARD card, const char *keyidstr,
|
||||
if (rc < 0)
|
||||
{
|
||||
log_error ("failed to decipher the data: %s\n", sc_strerror (rc));
|
||||
rc = gpg_error (GPG_ERR_CARD_ERROR);
|
||||
rc = gpg_error (GPG_ERR_CARD);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
31
scd/card.c
31
scd/card.c
@ -48,9 +48,9 @@ map_sc_err (int rc)
|
||||
case SC_ERROR_OUT_OF_MEMORY: e = GPG_ERR_ENOMEM; break;
|
||||
case SC_ERROR_CARD_NOT_PRESENT: e = GPG_ERR_CARD_NOT_PRESENT; break;
|
||||
case SC_ERROR_CARD_REMOVED: e = GPG_ERR_CARD_REMOVED; break;
|
||||
case SC_ERROR_INVALID_CARD: e = GPG_ERR_INVALID_CARD; break;
|
||||
case SC_ERROR_INVALID_CARD: e = GPG_ERR_INV_CARD; break;
|
||||
#endif
|
||||
default: e = GPG_ERR_CARD_ERROR; break;
|
||||
default: e = GPG_ERR_CARD; break;
|
||||
}
|
||||
return gpg_make_error (GPG_ERR_SOURCE_UNKNOWN, e);
|
||||
}
|
||||
@ -114,7 +114,7 @@ card_open (CARD *rcard)
|
||||
if (card->reader >= card->ctx->reader_count)
|
||||
{
|
||||
log_error ("no card reader available\n");
|
||||
rc = gpg_error (GPG_ERR_CARD_ERROR);
|
||||
rc = gpg_error (GPG_ERR_CARD);
|
||||
goto leave;
|
||||
}
|
||||
card->ctx->error_file = log_get_stream ();
|
||||
@ -242,7 +242,7 @@ find_iccsn (const unsigned char *buffer, size_t length, char **serial)
|
||||
|
||||
s = find_simple_tlv (buffer, length, 0x5A, &n);
|
||||
if (!s)
|
||||
return gpg_error (GPG_ERR_CARD_ERROR);
|
||||
return gpg_error (GPG_ERR_CARD);
|
||||
length -= s - buffer;
|
||||
if (n > length)
|
||||
{
|
||||
@ -257,12 +257,11 @@ find_iccsn (const unsigned char *buffer, size_t length, char **serial)
|
||||
n--;
|
||||
}
|
||||
else
|
||||
return gpg_error (GPG_ERR_CARD_ERROR); /* Bad encoding; does
|
||||
not fit into
|
||||
buffer. */
|
||||
return gpg_error (GPG_ERR_CARD); /* Bad encoding; does
|
||||
not fit into buffer. */
|
||||
}
|
||||
if (!n)
|
||||
return gpg_error (GPG_ERR_CARD_ERROR); /* Well, that is too short. */
|
||||
return gpg_error (GPG_ERR_CARD); /* Well, that is too short. */
|
||||
|
||||
*serial = p = xtrymalloc (2*n+1);
|
||||
if (!*serial)
|
||||
@ -332,21 +331,21 @@ card_get_serial_and_stamp (CARD card, char **serial, time_t *stamp)
|
||||
if (rc)
|
||||
{
|
||||
log_error ("sc_select_file failed: %s\n", sc_strerror (rc));
|
||||
return gpg_error (GPG_ERR_CARD_ERROR);
|
||||
return gpg_error (GPG_ERR_CARD);
|
||||
}
|
||||
if (file->type != SC_FILE_TYPE_WORKING_EF
|
||||
|| file->ef_structure != SC_FILE_EF_TRANSPARENT)
|
||||
{
|
||||
log_error ("wrong type or structure of GDO file\n");
|
||||
sc_file_free (file);
|
||||
return gpg_error (GPG_ERR_CARD_ERROR);
|
||||
return gpg_error (GPG_ERR_CARD);
|
||||
}
|
||||
|
||||
if (!file->size || file->size >= DIM(buf) )
|
||||
{ /* FIXME: Use a real parser */
|
||||
log_error ("unsupported size of GDO file (%d)\n", file->size);
|
||||
sc_file_free (file);
|
||||
return gpg_error (GPG_ERR_CARD_ERROR);
|
||||
return gpg_error (GPG_ERR_CARD);
|
||||
}
|
||||
buflen = file->size;
|
||||
|
||||
@ -355,16 +354,16 @@ card_get_serial_and_stamp (CARD card, char **serial, time_t *stamp)
|
||||
if (rc < 0)
|
||||
{
|
||||
log_error ("error reading GDO file: %s\n", sc_strerror (rc));
|
||||
return gpg_error (GPG_ERR_CARD_ERROR);
|
||||
return gpg_error (GPG_ERR_CARD);
|
||||
}
|
||||
if (rc != buflen)
|
||||
{
|
||||
log_error ("short read on GDO file\n");
|
||||
return gpg_error (GPG_ERR_CARD_ERROR);
|
||||
return gpg_error (GPG_ERR_CARD);
|
||||
}
|
||||
|
||||
rc = find_iccsn (buf, buflen, serial);
|
||||
if (gpg_err_code (rc) == GPG_ERR_CARD_ERROR)
|
||||
if (gpg_err_code (rc) == GPG_ERR_CARD)
|
||||
log_error ("invalid structure of GDO file\n");
|
||||
if (!rc && card->p15card && !strcmp (*serial, "D27600000000000000000000"))
|
||||
{ /* This is a German card with a silly serial number. Try to get
|
||||
@ -436,7 +435,7 @@ card_enum_keypairs (CARD card, int idx,
|
||||
if (!card || !keygrip)
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
if (idx < 0)
|
||||
return gpg_error (GPG_ERR_INVALID_INDEX);
|
||||
return gpg_error (GPG_ERR_INV_INDEX);
|
||||
if (!card->fnc.initialized)
|
||||
return gpg_error (GPG_ERR_CARD_NOT_INITIALIZED);
|
||||
if (!card->fnc.enum_keypairs)
|
||||
@ -468,7 +467,7 @@ card_enum_certs (CARD card, int idx, char **certid, int *certtype)
|
||||
if (!card)
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
if (idx < 0)
|
||||
return gpg_error (GPG_ERR_INVALID_INDEX);
|
||||
return gpg_error (GPG_ERR_INV_INDEX);
|
||||
if (!card->fnc.initialized)
|
||||
return gpg_error (GPG_ERR_CARD_NOT_INITIALIZED);
|
||||
if (!card->fnc.enum_certs)
|
||||
|
@ -452,7 +452,7 @@ pin_cb (void *opaque, const char *info, char **retstr)
|
||||
{
|
||||
/* We require that the returned value is an UTF-8 string */
|
||||
xfree (value);
|
||||
return gpg_error (GPG_ERR_INVALID_RESPONSE);
|
||||
return gpg_error (GPG_ERR_INV_RESPONSE);
|
||||
}
|
||||
*retstr = value;
|
||||
return 0;
|
||||
|
@ -607,7 +607,7 @@ gpgsm_finish_writer (Base64Context ctx)
|
||||
struct writer_cb_parm_s *parm;
|
||||
|
||||
if (!ctx)
|
||||
return gpg_error (GPG_ERR_INVALID_VALUE);
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
parm = &ctx->u.wparm;
|
||||
if (parm->did_finish)
|
||||
return 0; /* already done */
|
||||
|
@ -415,7 +415,7 @@ gpgsm_agent_pksign (const char *keygrip,
|
||||
if (!gcry_sexp_canon_len (*r_buf, *r_buflen, NULL, NULL))
|
||||
{
|
||||
xfree (*r_buf); *r_buf = NULL;
|
||||
return gpg_error (GPG_ERR_INVALID_VALUE);
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
}
|
||||
|
||||
return *r_buf? 0 : OUT_OF_CORE (errno);
|
||||
@ -455,12 +455,12 @@ gpgsm_agent_pkdecrypt (const char *keygrip,
|
||||
size_t ciphertextlen;
|
||||
|
||||
if (!keygrip || strlen(keygrip) != 40 || !ciphertext || !r_buf || !r_buflen)
|
||||
return gpg_error (GPG_ERR_INVALID_VALUE);
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
*r_buf = NULL;
|
||||
|
||||
ciphertextlen = gcry_sexp_canon_len (ciphertext, 0, NULL, NULL);
|
||||
if (!ciphertextlen)
|
||||
return gpg_error (GPG_ERR_INVALID_VALUE);
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
rc = start_agent ();
|
||||
if (rc)
|
||||
@ -499,11 +499,11 @@ gpgsm_agent_pkdecrypt (const char *keygrip,
|
||||
len--; /* remove the terminating 0 */
|
||||
n = strtoul (buf, &endp, 10);
|
||||
if (!n || *endp != ':')
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
endp++;
|
||||
if (endp-buf+n > len)
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP); /* oops len does not
|
||||
match internal len*/
|
||||
return gpg_error (GPG_ERR_INV_SEXP); /* oops len does not
|
||||
match internal len*/
|
||||
memmove (buf, endp, n);
|
||||
*r_buflen = n;
|
||||
*r_buf = buf;
|
||||
@ -552,7 +552,7 @@ gpgsm_agent_genkey (KsbaConstSexp keyparms, KsbaSexp *r_pubkey)
|
||||
gk_parm.sexp = keyparms;
|
||||
gk_parm.sexplen = gcry_sexp_canon_len (keyparms, 0, NULL, NULL);
|
||||
if (!gk_parm.sexplen)
|
||||
return gpg_error (GPG_ERR_INVALID_VALUE);
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
rc = assuan_transact (agent_ctx, "GENKEY",
|
||||
membuf_data_cb, &data,
|
||||
inq_genkey_parms, &gk_parm, NULL, NULL);
|
||||
@ -567,7 +567,7 @@ gpgsm_agent_genkey (KsbaConstSexp keyparms, KsbaSexp *r_pubkey)
|
||||
if (!gcry_sexp_canon_len (buf, len, NULL, NULL))
|
||||
{
|
||||
xfree (buf);
|
||||
return gpg_error (GPG_ERR_INVALID_SEXP);
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
}
|
||||
*r_pubkey = buf;
|
||||
return 0;
|
||||
@ -651,7 +651,7 @@ gpgsm_agent_havekey (const char *hexkeygrip)
|
||||
return rc;
|
||||
|
||||
if (!hexkeygrip || strlen (hexkeygrip) != 40)
|
||||
return gpg_error (GPG_ERR_INVALID_VALUE);
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
snprintf (line, DIM(line)-1, "HAVEKEY %s", hexkeygrip);
|
||||
line[DIM(line)-1] = 0;
|
||||
@ -768,7 +768,7 @@ gpgsm_agent_passwd (const char *hexkeygrip)
|
||||
return rc;
|
||||
|
||||
if (!hexkeygrip || strlen (hexkeygrip) != 40)
|
||||
return gpg_error (GPG_ERR_INVALID_VALUE);
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
snprintf (line, DIM(line)-1, "PASSWD %s", hexkeygrip);
|
||||
line[DIM(line)-1] = 0;
|
||||
|
@ -186,7 +186,7 @@ check_cert_policy (KsbaCert cert)
|
||||
{
|
||||
fclose (fp);
|
||||
xfree (policies);
|
||||
return gpg_error (GPG_ERR_CONFIGURATION_ERROR);
|
||||
return gpg_error (GPG_ERR_CONFIGURATION);
|
||||
}
|
||||
*p = 0; /* strip the rest of the line */
|
||||
/* See whether we find ALLOWED (which is an OID) in POLICIES */
|
||||
|
@ -450,7 +450,7 @@ gpgsm_decrypt (CTRL ctrl, int in_fd, FILE *out_fp)
|
||||
if (!npadding || npadding > dfparm.blklen)
|
||||
{
|
||||
log_error ("invalid padding with value %d\n", npadding);
|
||||
rc = gpg_error (GPG_ERR_INVALID_DATA);
|
||||
rc = gpg_error (GPG_ERR_INV_DATA);
|
||||
goto leave;
|
||||
}
|
||||
rc = ksba_writer_write (writer,
|
||||
@ -466,7 +466,7 @@ gpgsm_decrypt (CTRL ctrl, int in_fd, FILE *out_fp)
|
||||
if (dfparm.lastblock[i] != npadding)
|
||||
{
|
||||
log_error ("inconsistent padding\n");
|
||||
rc = gpg_error (GPG_ERR_INVALID_DATA);
|
||||
rc = gpg_error (GPG_ERR_INV_DATA);
|
||||
goto leave;
|
||||
}
|
||||
}
|
||||
|
18
sm/keydb.c
18
sm/keydb.c
@ -562,7 +562,7 @@ keydb_get_cert (KEYDB_HANDLE hd, KsbaCert *r_cert)
|
||||
int rc = 0;
|
||||
|
||||
if (!hd)
|
||||
return gpg_error (GPG_ERR_INVALID_VALUE);
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if ( hd->found < 0 || hd->found >= hd->used)
|
||||
return -1; /* nothing found */
|
||||
@ -591,7 +591,7 @@ keydb_insert_cert (KEYDB_HANDLE hd, KsbaCert cert)
|
||||
char digest[20];
|
||||
|
||||
if (!hd)
|
||||
return gpg_error (GPG_ERR_INVALID_VALUE);
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (opt.dry_run)
|
||||
return 0;
|
||||
@ -633,7 +633,7 @@ keydb_update_cert (KEYDB_HANDLE hd, KsbaCert cert)
|
||||
char digest[20];
|
||||
|
||||
if (!hd)
|
||||
return gpg_error (GPG_ERR_INVALID_VALUE);
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if ( hd->found < 0 || hd->found >= hd->used)
|
||||
return -1; /* nothing found */
|
||||
@ -671,7 +671,7 @@ keydb_delete (KEYDB_HANDLE hd)
|
||||
int rc = -1;
|
||||
|
||||
if (!hd)
|
||||
return gpg_error (GPG_ERR_INVALID_VALUE);
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if ( hd->found < 0 || hd->found >= hd->used)
|
||||
return -1; /* nothing found */
|
||||
@ -710,7 +710,7 @@ keydb_locate_writable (KEYDB_HANDLE hd, const char *reserved)
|
||||
int rc;
|
||||
|
||||
if (!hd)
|
||||
return gpg_error (GPG_ERR_INVALID_VALUE);
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
rc = keydb_search_reset (hd); /* this does reset hd->current */
|
||||
if (rc)
|
||||
@ -770,7 +770,7 @@ keydb_search_reset (KEYDB_HANDLE hd)
|
||||
int i, rc = 0;
|
||||
|
||||
if (!hd)
|
||||
return gpg_error (GPG_ERR_INVALID_VALUE);
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
hd->current = 0;
|
||||
hd->found = -1;
|
||||
@ -800,7 +800,7 @@ keydb_search (KEYDB_HANDLE hd, KEYDB_SEARCH_DESC *desc, size_t ndesc)
|
||||
int rc = -1;
|
||||
|
||||
if (!hd)
|
||||
return gpg_error (GPG_ERR_INVALID_VALUE);
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
while (rc == -1 && hd->current >= 0 && hd->current < hd->used)
|
||||
{
|
||||
@ -891,12 +891,12 @@ keydb_search_issuer_sn (KEYDB_HANDLE hd,
|
||||
desc.mode = KEYDB_SEARCH_MODE_ISSUER_SN;
|
||||
s = serial;
|
||||
if (*s !='(')
|
||||
return gpg_error (GPG_ERR_INVALID_VALUE);
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
s++;
|
||||
for (desc.snlen = 0; digitp (s); s++)
|
||||
desc.snlen = 10*desc.snlen + atoi_1 (s);
|
||||
if (*s !=':')
|
||||
return gpg_error (GPG_ERR_INVALID_VALUE);
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
desc.sn = s+1;
|
||||
desc.u.name = issuer;
|
||||
rc = keydb_search (hd, &desc, 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user