From f194ebc782424053896734699c2fc70b5ff0f14a Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 2 Oct 2003 10:27:34 +0000 Subject: [PATCH] Fixes to make inclusion of card raleted source files into 1.3 easier. --- ChangeLog | 4 ++++ configure.ac | 5 +++++ g10/ChangeLog | 6 +++++- g10/card-util.c | 6 ++++++ scd/ChangeLog | 11 +++++++++++ scd/apdu.c | 13 +++++++++++++ scd/app-common.h | 6 ++++++ scd/app-openpgp.c | 16 +++++++++++++++- scd/ccid-driver.c | 13 ++++++++++--- scd/iso7816.c | 20 ++++++++++++++++---- scd/iso7816.h | 4 ++++ 11 files changed, 95 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index ce3d76967..d2e219c90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2003-10-01 Werner Koch + + * configure.ac (AH_BOTTOM): Define GNUPG_MAJOR_VERSION. + 2003-09-23 Werner Koch Merged most of David Shaw's changes in 1.3 since 2003-06-03. diff --git a/configure.ac b/configure.ac index 23baee44a..12ff0d703 100644 --- a/configure.ac +++ b/configure.ac @@ -238,6 +238,11 @@ AH_BOTTOM([ /* Tell libgcrypt not to use its own libgpg-error implementation. */ #define USE_LIBGPG_ERROR 1 +/* This is the major version number of GnuPG so that + source included files can test for this. Note, that\ + we use 2 here even for GnuPG 1.9.x. */ +#define GNUPG_MAJOR_VERSION 2 + #include "g10defs.h" ]) diff --git a/g10/ChangeLog b/g10/ChangeLog index 0e0e715fc..563c71eee 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,7 @@ +2003-10-01 Werner Koch + + * card-util.c: Tweaked to use this source also under 1.3. + 2003-09-30 Werner Koch * keylist.c (print_card_serialno): New. @@ -407,7 +411,7 @@ * card-util.c (card_status): New. * call-agent.c (learn_status_cb): Parse more information. - * keylist.c (print_pubkey_info): Add FP arg for optinal printing + * keylist.c (print_pubkey_info): Add FP arg for optional printing to a stream. Changed all callers. 2003-07-23 Werner Koch diff --git a/g10/card-util.c b/g10/card-util.c index 1028cd373..70518e9ce 100644 --- a/g10/card-util.c +++ b/g10/card-util.c @@ -25,14 +25,20 @@ #include #include +#if GNUPG_MAJOR_VERSION != 1 #include "gpg.h" +#endif #include "util.h" #include "i18n.h" #include "ttyio.h" #include "status.h" #include "options.h" #include "main.h" +#if GNUPG_MAJOR_VERSION == 1 +#include "cardglue.h" +#else #include "call-agent.h" +#endif #define CONTROL_D ('D' - 'A' + 1) diff --git a/scd/ChangeLog b/scd/ChangeLog index 4363888c6..f090e34c0 100644 --- a/scd/ChangeLog +++ b/scd/ChangeLog @@ -1,3 +1,14 @@ +2003-10-01 Werner Koch + + * ccid-driver.c: Detect GnuPG 1.3 and include appropriate files. + * apdu.c: Ditto. + * app-openpgp.c: Ditto. + * iso7816.c: Ditto. + (generate_keypair): Renamed to .. + (do_generate_keypair): .. this. + * app-common.h [GNUPG_MAJOR_VERSION]: New. + * iso7816.h [GNUPG_MAJOR_VERSION]: Include cardglue.h + 2003-09-30 Werner Koch * command.c (cmd_getattr): New command GETATTR. diff --git a/scd/apdu.c b/scd/apdu.c index d5f64c6d8..d5b93de6e 100644 --- a/scd/apdu.c +++ b/scd/apdu.c @@ -28,7 +28,20 @@ # include #endif +#if GNUPG_MAJOR_VERSION == 1 +/* This is used with GnuPG version < 1.9. The code has been source + copied from the current GnuPG >= 1.9 and is maintained over + there. */ +#include "options.h" +#include "errors.h" +#include "memory.h" +#include "util.h" +#include "i18n.h" +#include "cardglue.h" +#else /* GNUPG_MAJOR_VERSION != 1 */ #include "scdaemon.h" +#endif /* GNUPG_MAJOR_VERSION != 1 */ + #include "apdu.h" #include "dynload.h" #include "ccid-driver.h" diff --git a/scd/app-common.h b/scd/app-common.h index e4b9d2f6c..33f23127b 100644 --- a/scd/app-common.h +++ b/scd/app-common.h @@ -70,6 +70,10 @@ struct app_ctx_s { }; +#if GNUPG_MAJOR_VERSION == 1 +int app_select_openpgp (APP app, unsigned char **sn, size_t *snlen); +int app_get_serial_and_stamp (APP app, char **serial, time_t *stamp); +#else /*-- app.c --*/ void app_set_default_reader_port (const char *portstr); APP select_application (void); @@ -124,6 +128,8 @@ int app_openpgp_storekey (APP app, int keyno, int app_openpgp_readkey (APP app, int keyno, unsigned char **m, size_t *mlen, unsigned char **e, size_t *elen); +#endif + #endif /*GNUPG_SCD_APP_COMMON_H*/ diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c index 3a312696b..e8fe19ea1 100644 --- a/scd/app-openpgp.c +++ b/scd/app-openpgp.c @@ -24,10 +24,24 @@ #include #include #include +#include +#if GNUPG_MAJOR_VERSION == 1 +/* This is used with GnuPG version < 1.9. The code has been source + copied from the current GnuPG >= 1.9 and is maintained over + there. */ +#include "options.h" +#include "errors.h" +#include "memory.h" +#include "util.h" +#include "i18n.h" +#include "cardglue.h" +#else /* GNUPG_MAJOR_VERSION != 1 */ #include "scdaemon.h" -#include "app-common.h" +#endif /* GNUPG_MAJOR_VERSION != 1 */ + #include "iso7816.h" +#include "app-common.h" diff --git a/scd/ccid-driver.c b/scd/ccid-driver.c index e0b48f880..b4fbc0b21 100644 --- a/scd/ccid-driver.c +++ b/scd/ccid-driver.c @@ -87,9 +87,16 @@ #define DRVNAME "ccid-driver: " -#ifdef GNUPG_DEFAULT_SCDAEMON /* This source is used within the - gnupg>=1.9 source tree. */ -# include "scdaemon.h" +#ifdef GNUPG_MAJOR_VERSION /* This source is used within GnuPG. */ + +# if GNUPG_MAJOR_VERSION == 1 /* GnuPG Version is < 1.9. */ +# include "options.h" +# include "util.h" +# include "memory.h" +# include "cardglue.h" +# else /* This is the modularized GnuPG 1.9 or later. */ +# include "scdaemon.h" +# endif # define DEBUGOUT(t) do { if (DBG_CARD_IO) \ log_debug (DRVNAME t); } while (0) diff --git a/scd/iso7816.c b/scd/iso7816.c index 2b06103ef..f4aa18c6f 100644 --- a/scd/iso7816.c +++ b/scd/iso7816.c @@ -24,10 +24,22 @@ #include #include +#if GNUPG_MAJOR_VERSION == 1 +/* This is used with GnuPG version < 1.9. The code has been source + copied from the current GnuPG >= 1.9 and is maintained over + there. */ +#include "options.h" +#include "errors.h" +#include "memory.h" +#include "util.h" +#include "i18n.h" +#else /* GNUPG_MAJOR_VERSION != 1 */ #include "scdaemon.h" +#endif /* GNUPG_MAJOR_VERSION != 1 */ + #include "iso7816.h" #include "apdu.h" -#include "dynload.h" + #define CMD_SELECT_FILE 0xA4 #define CMD_VERIFY 0x20 @@ -290,7 +302,7 @@ iso7816_internal_authenticate (int slot, static gpg_error_t -generate_keypair (int slot, int readonly, +do_generate_keypair (int slot, int readonly, const unsigned char *data, size_t datalen, unsigned char **result, size_t *resultlen) { @@ -321,7 +333,7 @@ iso7816_generate_keypair (int slot, const unsigned char *data, size_t datalen, unsigned char **result, size_t *resultlen) { - return generate_keypair (slot, 0, data, datalen, result, resultlen); + return do_generate_keypair (slot, 0, data, datalen, result, resultlen); } @@ -330,7 +342,7 @@ iso7816_read_public_key (int slot, const unsigned char *data, size_t datalen, unsigned char **result, size_t *resultlen) { - return generate_keypair (slot, 1, data, datalen, result, resultlen); + return do_generate_keypair (slot, 1, data, datalen, result, resultlen); } diff --git a/scd/iso7816.h b/scd/iso7816.h index d7e77a101..26b8d6aba 100644 --- a/scd/iso7816.h +++ b/scd/iso7816.h @@ -21,6 +21,10 @@ #ifndef ISO7816_H #define ISO7816_H +#if GNUPG_MAJOR_VERSION == 1 +#include "cardglue.h" +#endif + gpg_error_t iso7816_select_application (int slot, const char *aid, size_t aidlen); gpg_error_t iso7816_verify (int slot,