diff options
Diffstat (limited to 'sm')
-rw-r--r-- | sm/Makefile.am | 10 | ||||
-rw-r--r-- | sm/certchain.c | 12 | ||||
-rw-r--r-- | sm/certcheck.c | 10 | ||||
-rw-r--r-- | sm/certpath.c | 12 | ||||
-rw-r--r-- | sm/gpgsm.h | 103 | ||||
-rw-r--r-- | sm/import.c | 4 | ||||
-rw-r--r-- | sm/keydb.c | 34 | ||||
-rw-r--r-- | sm/keylist.c | 8 | ||||
-rw-r--r-- | sm/misc.c | 59 | ||||
-rwxr-xr-x | sm/mkerrors | 72 | ||||
-rw-r--r-- | sm/sign.c | 6 | ||||
-rw-r--r-- | sm/util.h | 58 | ||||
-rw-r--r-- | sm/verify.c | 24 |
13 files changed, 64 insertions, 348 deletions
diff --git a/sm/Makefile.am b/sm/Makefile.am index 67cd8c7e6..5e26382e3 100644 --- a/sm/Makefile.am +++ b/sm/Makefile.am @@ -20,14 +20,13 @@ bin_PROGRAMS = gpgsm -INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/intl +INCLUDES = -I$(top_srcdir)/common -I$(top_srcdir)/intl LDFLAGS = @LDFLAGS@ #$(LIBGCRYPT_LIBS) -BUILT_SOURCES = errors.c gpgsm_SOURCES = \ gpgsm.c gpgsm.h \ - util.h misc.c errors.c \ + misc.c \ keydb.c keydb.h \ server.c \ fingerprint.c \ @@ -41,11 +40,8 @@ gpgsm_SOURCES = \ gpgsm_LDADD = ../jnlib/libjnlib.a ../assuan/libassuan.a ../kbx/libkeybox.a \ + ../common/libcommon.a \ ../../libksba/src/.libs/libksba.a \ ../../libgcrypt/src/.libs/libgcrypt.so.1 -errors.c : gpgsm.h mkerrors - $(srcdir)/mkerrors < $(srcdir)/gpgsm.h > errors.c - - diff --git a/sm/certchain.c b/sm/certchain.c index 518acfe3a..9b98ce894 100644 --- a/sm/certchain.c +++ b/sm/certchain.c @@ -46,7 +46,7 @@ gpgsm_validate_path (KsbaCert cert) if (!kh) { log_error (_("failed to allocated keyDB handle\n")); - rc = GPGSM_General_Error; + rc = GNUPG_General_Error; goto leave; } @@ -65,7 +65,7 @@ gpgsm_validate_path (KsbaCert cert) { if (DBG_X509) log_debug ("ERROR: issuer missing\n"); - rc = GPGSM_Bad_Certificate; + rc = GNUPG_Bad_Certificate; goto leave; } @@ -74,7 +74,7 @@ gpgsm_validate_path (KsbaCert cert) if (gpgsm_check_cert_sig (subject_cert, subject_cert) ) { log_debug ("selfsigned certificate has a BAD signatures\n"); - rc = depth? GPGSM_Bad_Certificate_Path : GPGSM_Bad_Certificate; + rc = depth? GNUPG_Bad_Certificate_Path : GNUPG_Bad_Certificate; goto leave; } log_debug ("selfsigned certificate is good\n"); @@ -90,7 +90,7 @@ gpgsm_validate_path (KsbaCert cert) if (rc) { log_debug ("failed to find issuer's certificate: rc=%d\n", rc); - rc = GPGSM_Missing_Certificate; + rc = GNUPG_Missing_Certificate; goto leave; } @@ -99,7 +99,7 @@ gpgsm_validate_path (KsbaCert cert) if (rc) { log_debug ("failed to get cert: rc=%d\n", rc); - rc = GPGSM_General_Error; + rc = GNUPG_General_Error; goto leave; } @@ -109,7 +109,7 @@ gpgsm_validate_path (KsbaCert cert) if (gpgsm_check_cert_sig (issuer_cert, subject_cert) ) { log_debug ("certificate has a BAD signatures\n"); - rc = GPGSM_Bad_Certificate_Path; + rc = GNUPG_Bad_Certificate_Path; goto leave; } log_debug ("certificate is good\n"); diff --git a/sm/certcheck.c b/sm/certcheck.c index 2d5448e66..b648c8877 100644 --- a/sm/certcheck.c +++ b/sm/certcheck.c @@ -50,7 +50,7 @@ do_encode_md (GCRY_MD_HD md, int algo, unsigned int nbits, if (gcry_md_algo_info (algo, GCRYCTL_GET_ASNOID, asn, &asnlen)) { log_error ("No object identifier for algo %d\n", algo); - return GPGSM_Internal_Error; + return GNUPG_Internal_Error; } len = gcry_md_get_algo_dlen (algo); @@ -59,7 +59,7 @@ do_encode_md (GCRY_MD_HD md, int algo, unsigned int nbits, { log_error ("can't encode a %d bit MD into a %d bits frame\n", (int)(len*8), (int)nbits); - return GPGSM_Internal_Error; + return GNUPG_Internal_Error; } /* We encode the MD in this way: @@ -70,7 +70,7 @@ do_encode_md (GCRY_MD_HD md, int algo, unsigned int nbits, */ frame = xtrymalloc (nframe); if (!frame) - return GPGSM_Out_Of_Core; + return GNUPG_Out_Of_Core; n = 0; frame[n++] = 0; frame[n++] = 1; /* block type */ @@ -114,13 +114,13 @@ gpgsm_check_cert_sig (KsbaCert issuer_cert, KsbaCert cert) if (!algo) { log_error ("unknown hash algorithm `%s'\n", algoid? algoid:"?"); - return GPGSM_General_Error; + return GNUPG_General_Error; } md = gcry_md_open (algo, 0); if (!md) { log_error ("md_open failed: %s\n", gcry_strerror (-1)); - return GPGSM_General_Error; + return GNUPG_General_Error; } rc = ksba_cert_hash (cert, 1, HASH_FNC, md); diff --git a/sm/certpath.c b/sm/certpath.c index 518acfe3a..9b98ce894 100644 --- a/sm/certpath.c +++ b/sm/certpath.c @@ -46,7 +46,7 @@ gpgsm_validate_path (KsbaCert cert) if (!kh) { log_error (_("failed to allocated keyDB handle\n")); - rc = GPGSM_General_Error; + rc = GNUPG_General_Error; goto leave; } @@ -65,7 +65,7 @@ gpgsm_validate_path (KsbaCert cert) { if (DBG_X509) log_debug ("ERROR: issuer missing\n"); - rc = GPGSM_Bad_Certificate; + rc = GNUPG_Bad_Certificate; goto leave; } @@ -74,7 +74,7 @@ gpgsm_validate_path (KsbaCert cert) if (gpgsm_check_cert_sig (subject_cert, subject_cert) ) { log_debug ("selfsigned certificate has a BAD signatures\n"); - rc = depth? GPGSM_Bad_Certificate_Path : GPGSM_Bad_Certificate; + rc = depth? GNUPG_Bad_Certificate_Path : GNUPG_Bad_Certificate; goto leave; } log_debug ("selfsigned certificate is good\n"); @@ -90,7 +90,7 @@ gpgsm_validate_path (KsbaCert cert) if (rc) { log_debug ("failed to find issuer's certificate: rc=%d\n", rc); - rc = GPGSM_Missing_Certificate; + rc = GNUPG_Missing_Certificate; goto leave; } @@ -99,7 +99,7 @@ gpgsm_validate_path (KsbaCert cert) if (rc) { log_debug ("failed to get cert: rc=%d\n", rc); - rc = GPGSM_General_Error; + rc = GNUPG_General_Error; goto leave; } @@ -109,7 +109,7 @@ gpgsm_validate_path (KsbaCert cert) if (gpgsm_check_cert_sig (issuer_cert, subject_cert) ) { log_debug ("certificate has a BAD signatures\n"); - rc = GPGSM_Bad_Certificate_Path; + rc = GNUPG_Bad_Certificate_Path; goto leave; } log_debug ("certificate is good\n"); diff --git a/sm/gpgsm.h b/sm/gpgsm.h index a00e11d45..f1d4fca4d 100644 --- a/sm/gpgsm.h +++ b/sm/gpgsm.h @@ -18,103 +18,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef GPGSM_H -#define GPGSM_H +#ifndef GNUPG_H +#define GNUPG_H #include <ksba.h> -#include "util.h" - -/* Error numbers */ -enum { - GPGSM_EOF = -1, - GPGSM_No_Error = 0, - GPGSM_General_Error = 1, - GPGSM_Out_Of_Core = 2, - GPGSM_Invalid_Value = 3, - GPGSM_IO_Error = 4, - GPGSM_Resource_Limit = 5, - GPGSM_Internal_Error = 6, - GPGSM_Bad_Certificate = 7, - GPGSM_Bad_Certificate_Path = 8, - GPGSM_Missing_Certificate = 9, - GPGSM_No_Data = 10, - GPGSM_Bad_Signature = 11, - GPGSM_Not_Implemented = 12, - GPGSM_Conflict = 13, - GPGSM_Bug = 14 -}; - -/* Status codes (shared with gpg) */ -enum { - STATUS_ENTER, - STATUS_LEAVE, - STATUS_ABORT, - STATUS_GOODSIG, - STATUS_BADSIG, - STATUS_ERRSIG, - STATUS_BADARMOR, - STATUS_RSA_OR_IDEA, - STATUS_SIGEXPIRED, - STATUS_KEYREVOKED, - STATUS_TRUST_UNDEFINED, - STATUS_TRUST_NEVER, - STATUS_TRUST_MARGINAL, - STATUS_TRUST_FULLY, - STATUS_TRUST_ULTIMATE, - - STATUS_SHM_INFO, - STATUS_SHM_GET, - STATUS_SHM_GET_BOOL, - STATUS_SHM_GET_HIDDEN, - - STATUS_NEED_PASSPHRASE, - STATUS_VALIDSIG, - STATUS_SIG_ID, - STATUS_ENC_TO, - STATUS_NODATA, - STATUS_BAD_PASSPHRASE, - STATUS_NO_PUBKEY, - STATUS_NO_SECKEY, - STATUS_NEED_PASSPHRASE_SYM, - STATUS_DECRYPTION_FAILED, - STATUS_DECRYPTION_OKAY, - STATUS_MISSING_PASSPHRASE, - STATUS_GOOD_PASSPHRASE, - STATUS_GOODMDC, - STATUS_BADMDC, - STATUS_ERRMDC, - STATUS_IMPORTED, - STATUS_IMPORT_RES, - STATUS_FILE_START, - STATUS_FILE_DONE, - STATUS_FILE_ERROR, - - STATUS_BEGIN_DECRYPTION, - STATUS_END_DECRYPTION, - STATUS_BEGIN_ENCRYPTION, - STATUS_END_ENCRYPTION, - - STATUS_DELETE_PROBLEM, - STATUS_GET_BOOL, - STATUS_GET_LINE, - STATUS_GET_HIDDEN, - STATUS_GOT_IT, - STATUS_PROGRESS, - STATUS_SIG_CREATED, - STATUS_SESSION_KEY, - STATUS_NOTATION_NAME, - STATUS_NOTATION_DATA, - STATUS_POLICY_URL, - STATUS_BEGIN_STREAM, - STATUS_END_STREAM, - STATUS_KEY_CREATED, - STATUS_USERID_HIN, - STATUS_UNEXPECTED, - STATUS_INV_RECP, - STATUS_NO_RECP, - STATUS_ALREADY_SIGNED, -}; - +#include "../common/util.h" +#include "../common/errors.h" #define MAX_DIGEST_LEN 24 @@ -224,7 +133,7 @@ int gpgsm_sign (CTRL ctrl, int data_fd, int detached, FILE *out_fp); /*-- errors.c (built) --*/ -const char *gpgsm_strerror (int err); +const char *gnupg_strerror (int err); -#endif /*GPGSM_H*/ +#endif /*GNUPG_H*/ diff --git a/sm/import.c b/sm/import.c index ba21312de..fc628a6f1 100644 --- a/sm/import.c +++ b/sm/import.c @@ -251,12 +251,12 @@ store_cert (KsbaCert cert) } rc = keydb_locate_writable (kh, 0); if (rc) - log_error (_("error finding writable keyDB: %s\n"), gpgsm_strerror (rc)); + log_error (_("error finding writable keyDB: %s\n"), gnupg_strerror (rc)); rc = keydb_insert_cert (kh, cert); if (rc) { - log_error (_("error storing certificate: %s\n"), gpgsm_strerror (rc)); + log_error (_("error storing certificate: %s\n"), gnupg_strerror (rc)); } keydb_release (kh); } diff --git a/sm/keydb.c b/sm/keydb.c index 6ca7a3393..b6501fe5f 100644 --- a/sm/keydb.c +++ b/sm/keydb.c @@ -97,7 +97,7 @@ keydb_add_resource (const char *url, int force, int secret) #if !defined(HAVE_DRIVE_LETTERS) && !defined(__riscos__) else if (strchr (resname, ':')) { log_error ("invalid key resource URL `%s'\n", url ); - rc = GPGSM_General_Error; + rc = GNUPG_General_Error; goto leave; } #endif /* !HAVE_DRIVE_LETTERS && !__riscos__ */ @@ -141,7 +141,7 @@ keydb_add_resource (const char *url, int force, int secret) switch (rt) { case KEYDB_RESOURCE_TYPE_NONE: log_error ("unknown type of key resource `%s'\n", url ); - rc = GPGSM_General_Error; + rc = GNUPG_General_Error; goto leave; case KEYDB_RESOURCE_TYPE_KEYBOX: @@ -205,7 +205,7 @@ keydb_add_resource (const char *url, int force, int secret) if (!token) ; /* already registered - ignore it */ else if (used_resources >= MAX_KEYDB_RESOURCES) - rc = GPGSM_Resource_Limit; + rc = GNUPG_Resource_Limit; else { all_resources[used_resources].type = rt; @@ -219,7 +219,7 @@ keydb_add_resource (const char *url, int force, int secret) default: log_error ("resource type of `%s' not supported\n", url); - rc = GPGSM_General_Error; + rc = GNUPG_General_Error; goto leave; } @@ -227,7 +227,7 @@ keydb_add_resource (const char *url, int force, int secret) leave: if (rc) - log_error ("keyblock resource `%s': %s\n", filename, gpgsm_strerror(rc)); + log_error ("keyblock resource `%s': %s\n", filename, gnupg_strerror(rc)); else if (secret) any_secret = 1; else @@ -520,7 +520,7 @@ keydb_get_cert (KEYDB_HANDLE hd, KsbaCert *r_cert) int rc = 0; if (!hd) - return GPGSM_Invalid_Value; + return GNUPG_Invalid_Value; if ( hd->found < 0 || hd->found >= hd->used) return -1; /* nothing found */ @@ -528,7 +528,7 @@ keydb_get_cert (KEYDB_HANDLE hd, KsbaCert *r_cert) switch (hd->active[hd->found].type) { case KEYDB_RESOURCE_TYPE_NONE: - rc = GPGSM_General_Error; /* oops */ + rc = GNUPG_General_Error; /* oops */ break; case KEYDB_RESOURCE_TYPE_KEYBOX: rc = keybox_get_cert (hd->active[hd->found].u.kr, r_cert); @@ -549,7 +549,7 @@ keydb_insert_cert (KEYDB_HANDLE hd, KsbaCert cert) char digest[20]; if (!hd) - return GPGSM_Invalid_Value; + return GNUPG_Invalid_Value; if (opt.dry_run) return 0; @@ -559,7 +559,7 @@ keydb_insert_cert (KEYDB_HANDLE hd, KsbaCert cert) else if ( hd->current >= 0 && hd->current < hd->used) idx = hd->current; else - return GPGSM_General_Error; + return GNUPG_General_Error; rc = lock_all (hd); if (rc) @@ -570,7 +570,7 @@ keydb_insert_cert (KEYDB_HANDLE hd, KsbaCert cert) switch (hd->active[idx].type) { case KEYDB_RESOURCE_TYPE_NONE: - rc = GPGSM_General_Error; + rc = GNUPG_General_Error; break; case KEYDB_RESOURCE_TYPE_KEYBOX: rc = keybox_insert_cert (hd->active[idx].u.kr, cert, digest); @@ -591,7 +591,7 @@ keydb_update_cert (KEYDB_HANDLE hd, KsbaCert cert) char digest[20]; if (!hd) - return GPGSM_Invalid_Value; + return GNUPG_Invalid_Value; if ( hd->found < 0 || hd->found >= hd->used) return -1; /* nothing found */ @@ -608,7 +608,7 @@ keydb_update_cert (KEYDB_HANDLE hd, KsbaCert cert) switch (hd->active[hd->found].type) { case KEYDB_RESOURCE_TYPE_NONE: - rc = GPGSM_General_Error; /* oops */ + rc = GNUPG_General_Error; /* oops */ break; case KEYDB_RESOURCE_TYPE_KEYBOX: rc = keybox_update_cert (hd->active[hd->found].u.kr, cert, digest); @@ -629,7 +629,7 @@ keydb_delete (KEYDB_HANDLE hd) int rc = -1; if (!hd) - return GPGSM_Invalid_Value; + return GNUPG_Invalid_Value; if ( hd->found < 0 || hd->found >= hd->used) return -1; /* nothing found */ @@ -644,7 +644,7 @@ keydb_delete (KEYDB_HANDLE hd) switch (hd->active[hd->found].type) { case KEYDB_RESOURCE_TYPE_NONE: - rc = GPGSM_General_Error; + rc = GNUPG_General_Error; break; case KEYDB_RESOURCE_TYPE_KEYBOX: rc = keybox_delete (hd->active[hd->found].u.kr); @@ -668,7 +668,7 @@ keydb_locate_writable (KEYDB_HANDLE hd, const char *reserved) int rc; if (!hd) - return GPGSM_Invalid_Value; + return GNUPG_Invalid_Value; rc = keydb_search_reset (hd); /* this does reset hd->current */ if (rc) @@ -728,7 +728,7 @@ keydb_search_reset (KEYDB_HANDLE hd) int i, rc = 0; if (!hd) - return GPGSM_Invalid_Value; + return GNUPG_Invalid_Value; hd->current = 0; hd->found = -1; @@ -758,7 +758,7 @@ keydb_search (KEYDB_HANDLE hd, KEYDB_SEARCH_DESC *desc, size_t ndesc) int rc = -1; if (!hd) - return GPGSM_Invalid_Value; + return GNUPG_Invalid_Value; while (rc == -1 && hd->current >= 0 && hd->current < hd->used) { diff --git a/sm/keylist.c b/sm/keylist.c index f1aaf9e52..f47a0b79e 100644 --- a/sm/keylist.c +++ b/sm/keylist.c @@ -131,13 +131,13 @@ gpgsm_list_keys (CTRL ctrl, STRLIST names, FILE *fp) hd = keydb_new (0); if (!hd) - rc = GPGSM_General_Error; + rc = GNUPG_General_Error; else rc = keydb_search_first (hd); if (rc) { if (rc != -1) - log_error ("keydb_search_first failed: %s\n", gpgsm_strerror (rc) ); + log_error ("keydb_search_first failed: %s\n", gnupg_strerror (rc) ); goto leave; } @@ -147,7 +147,7 @@ gpgsm_list_keys (CTRL ctrl, STRLIST names, FILE *fp) rc = keydb_get_cert (hd, &cert); if (rc) { - log_error ("keydb_get_cert failed: %s\n", gpgsm_strerror (rc)); + log_error ("keydb_get_cert failed: %s\n", gnupg_strerror (rc)); goto leave; } @@ -175,7 +175,7 @@ gpgsm_list_keys (CTRL ctrl, STRLIST names, FILE *fp) } while (!(rc = keydb_search_next (hd))); if (rc && rc != -1) - log_error ("keydb_search_next failed: %s\n", gpgsm_strerror (rc)); + log_error ("keydb_search_next failed: %s\n", gnupg_strerror (rc)); leave: ksba_cert_release (cert); @@ -28,64 +28,5 @@ #include <ksba.h> -#include "util.h" #include "gpgsm.h" - -/* Note: we might want to wrap this in a macro to get our hands on - the line and file where the error occired */ -int -map_ksba_err (int err) -{ - switch (err) - { - case -1: - case 0: - break; - - default: - err = GPGSM_General_Error; - break; - } - return err; -} - - -int -map_gcry_err (int err) -{ - switch (err) - { - case -1: - case 0: - break; - - default: - err = GPGSM_General_Error; - break; - } - return err; -} - -int -map_kbx_err (int err) -{ - switch (err) - { - case -1: - case 0: - break; - - default: - err = GPGSM_General_Error; - break; - } - return err; -} - - - - - - - diff --git a/sm/mkerrors b/sm/mkerrors deleted file mode 100755 index 46c28e8c9..000000000 --- a/sm/mkerrors +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/sh -# mkerrors - Extract error strings from gpgsm.h -# and create C source for gpgsm_strerror -# Copyright (C) 2001 Free Software Foundation, Inc. -# -# This file is part of GnuPG. -# -# GnuPG is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# GnuPG is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - -cat <<EOF -/* Generated automatically by mkerrors */ -/* Do not edit! */ - -#include <config.h> -#include <stdio.h> -#include "gpgsm.h" - -/** - * gpgsm_strerror: - * @err: Error code - * - * This function returns a textual representaion of the given - * errorcode. If this is an unknown value, a string with the value - * is returned (Beware: it is hold in a static buffer). - * - * Return value: String with the error description. - **/ -const char * -gpgsm_strerror (int err) -{ - const char *s; - static char buf[25]; - - switch (err) - { -EOF - -awk ' -/GPGSM_No_Error/ { okay=1 } -!okay {next} -/}/ { exit 0 } -/GPGSM_[A-Za-z_]*/ { print_code($1) } - - -function print_code( s ) -{ -printf " case %s: s=\"", s ; -gsub(/_/, " ", s ); -printf "%s\"; break;\n", tolower(substr(s,7)); -} -' - -cat <<EOF - default: sprintf (buf, "ec=%d", err ); s=buf; break; - } - - return s; -} - -EOF
\ No newline at end of file @@ -136,7 +136,7 @@ gpgsm_sign (CTRL ctrl, int data_fd, int detached, FILE *out_fp) if (!kh) { log_error (_("failed to allocated keyDB handle\n")); - rc = GPGSM_General_Error; + rc = GNUPG_General_Error; goto leave; } @@ -238,7 +238,7 @@ gpgsm_sign (CTRL ctrl, int data_fd, int detached, FILE *out_fp) if (!algo) { log_error ("unknown hash algorithm `%s'\n", algoid? algoid:"?"); - rc = GPGSM_Bug; + rc = GNUPG_Bug; goto leave; } gcry_md_enable (data_md, algo); @@ -261,7 +261,7 @@ gpgsm_sign (CTRL ctrl, int data_fd, int detached, FILE *out_fp) if ( !digest || !digest_len) { log_error ("problem getting the hash of the data\n"); - rc = GPGSM_Bug; + rc = GNUPG_Bug; goto leave; } err = ksba_cms_set_message_digest (cms, signer, digest, digest_len); diff --git a/sm/util.h b/sm/util.h deleted file mode 100644 index ffd4a4030..000000000 --- a/sm/util.h +++ /dev/null @@ -1,58 +0,0 @@ -/* util.h - Utility functions for GpgSM - * Copyright (C) 2001 Free Software Foundation, Inc. - * - * This file is part of GnuPG. - * - * GnuPG is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * GnuPG is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - -#ifndef UTIL_H -#define UTIL_H - -#include <gcrypt.h> /* we need this for the memory function protos */ - -/* to pass the fucntion to libksba we need to cast it */ -#define HASH_FNC ((void (*)(void *, const void*,size_t))gcry_md_write) - - -#include "../jnlib/logging.h" -#include "../jnlib/argparse.h" -#include "../jnlib/stringhelp.h" -#include "../jnlib/mischelp.h" -#include "../jnlib/strlist.h" -#include "../jnlib/dotlock.h" - -#define xtrymalloc(a) gcry_malloc ((a)) -#define xtrycalloc(a,b) gcry_calloc ((a),(b)) -#define xtryrealloc(a,b) gcry_realloc ((a),(b)) -#define xtrystrdup(a) gcry_strdup ((a)) -#define xfree(a) gcry_free ((a)) - -#define xmalloc(a) gcry_xmalloc ((a)) -#define xcalloc(a,b) gcry_xcalloc ((a),(b)) -#define xrealloc(a,b) gcry_xrealloc ((a),(b)) -#define xstrdup(a) gcry_xstrdup ((a)) - - -#define seterr(a) (GPGSM_ ## a) - -/*-- misc.c --*/ -int map_ksba_err (int err); -int map_gcry_err (int err); -int map_kbx_err (int err); - -#endif /*UTIL_H*/ - - diff --git a/sm/verify.c b/sm/verify.c index 26bb8cfcd..b44dd6add 100644 --- a/sm/verify.c +++ b/sm/verify.c @@ -109,12 +109,12 @@ store_cert (KsbaCert cert) } rc = keydb_locate_writable (kh, 0); if (rc) - log_error (_("error finding writable keyDB: %s\n"), gpgsm_strerror (rc)); + log_error (_("error finding writable keyDB: %s\n"), gnupg_strerror (rc)); rc = keydb_insert_cert (kh, cert); if (rc) { - log_error (_("error storing certificate: %s\n"), gpgsm_strerror (rc)); + log_error (_("error storing certificate: %s\n"), gnupg_strerror (rc)); } keydb_release (kh); } @@ -190,7 +190,7 @@ gpgsm_verify (CTRL ctrl, int in_fd, int data_fd) if (!kh) { log_error (_("failed to allocated keyDB handle\n")); - rc = GPGSM_General_Error; + rc = GNUPG_General_Error; goto leave; } @@ -264,7 +264,7 @@ gpgsm_verify (CTRL ctrl, int in_fd, int data_fd) if (stopreason == KSBA_SR_BEGIN_DATA) { log_error ("error: only detached signatures are supportted\n"); - rc = GPGSM_Not_Implemented; + rc = GNUPG_Not_Implemented; goto leave; } @@ -285,7 +285,7 @@ gpgsm_verify (CTRL ctrl, int in_fd, int data_fd) if (data_fd == -1) { log_error ("detached signature but no data given\n"); - rc = GPGSM_Bad_Signature; + rc = GNUPG_Bad_Signature; goto leave; } hash_data (data_fd, data_md); @@ -297,7 +297,7 @@ gpgsm_verify (CTRL ctrl, int in_fd, int data_fd) if (data_fd != -1 && !is_detached) { log_error ("data given for a non-detached signature"); - rc = GPGSM_Conflict; + rc = GNUPG_Conflict; goto leave; } @@ -357,14 +357,14 @@ gpgsm_verify (CTRL ctrl, int in_fd, int data_fd) if (rc) { log_debug ("failed to find the certificate: %s\n", - gpgsm_strerror(rc)); + gnupg_strerror(rc)); goto next_signer; } rc = keydb_get_cert (kh, &cert); if (rc) { - log_debug ("failed to get cert: %s\n", gpgsm_strerror (rc)); + log_debug ("failed to get cert: %s\n", gnupg_strerror (rc)); goto next_signer; } @@ -411,7 +411,7 @@ gpgsm_verify (CTRL ctrl, int in_fd, int data_fd) if (rc) { - log_error ("invalid signature: %s\n", gpgsm_strerror (rc)); + log_error ("invalid signature: %s\n", gnupg_strerror (rc)); gpgsm_status (ctrl, STATUS_BADSIG, NULL); goto next_signer; } @@ -433,9 +433,9 @@ gpgsm_verify (CTRL ctrl, int in_fd, int data_fd) rc = gpgsm_validate_path (cert); if (rc) { - log_error ("invalid certification path: %s\n", gpgsm_strerror (rc)); - if (rc == GPGSM_Bad_Certificate_Path - || rc == GPGSM_Bad_Certificate) + log_error ("invalid certification path: %s\n", gnupg_strerror (rc)); + if (rc == GNUPG_Bad_Certificate_Path + || rc == GNUPG_Bad_Certificate) gpgsm_status (ctrl, STATUS_TRUST_NEVER, NULL); else gpgsm_status (ctrl, STATUS_TRUST_UNDEFINED, NULL); |