From 9e7db481a6446a64c115d8e938887a1ff0262c42 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 15 Oct 2001 12:19:14 +0000 Subject: [PATCH] New API to switch to S/MIME. There is no code yet behind it. --- THANKS | 1 + TODO | 38 ++++++++++++++++++++++++++++++++++++-- configure.in | 11 ++++------- gpgme/ChangeLog | 10 ++++++++++ gpgme/context.h | 2 ++ gpgme/data.c | 2 +- gpgme/gpgme.c | 41 +++++++++++++++++++++++++++++++++++------ gpgme/gpgme.h | 8 +++++++- tests/mkdemodirs | 2 +- 9 files changed, 97 insertions(+), 18 deletions(-) diff --git a/THANKS b/THANKS index 24bcdb45..48729fdf 100644 --- a/THANKS +++ b/THANKS @@ -4,6 +4,7 @@ Enno Cramer uebergeek@web.de Jan-Oliver Wagner jan@intevation.de Johannes Poehlmann jhp@caldera.de Jose C. García Sogo jose@jaimedelamo.eu.org +Mark Mutz mutz@kde.org Stéphane Corthésy stephane@sente.ch Timo Schulz twoaday@freakmail.de Tommy Reynolds reynolds@redhat.com diff --git a/TODO b/TODO index 0446059c..f763a025 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,5 @@ * Implement posix-sema.c -* Add gpgme_mime_xxx to make handling of MIME/PGP easier - * Allow to use GTK's main loop instead of the select stuff in wait.c @@ -10,3 +8,39 @@ * Should --delete silently delete secret keys or is there a need for another flag or a callback? +* GpgmeKey misses GPGME_ATTR_EXPIRE attribute + +* Add ATTR to return the number of subkeys or uids. + +* Return GPGME_Canceled when appropriate + +* Implement decrypt+verify + +Bugs reported by Stephane Corthesy: +> - When asking a GpgmeKey for one of its sub-userIDs (index > 0) +> GPGME_ATTR_EMAIL attribute, it returns the name + email, whereas for +> the main (index = 0) userID it returns only the email. + +> - When returning a GpgmeKey GPGME_ATTR_COMMENT attribute, characters +> like ":" are not un-escaped, they are returned as \x3a + +> - When asking a GpgmeKey its main userID (index = 0), it returns the +> last userID it was asked (can be a sub, or the main). + +> BTW, here's another bug: it it not possible to retrieve fingerprints +> for subkeys + +> In GpgmeRecipients, would it be possible to provide a function which +> would return the validity assigned to a name contained in the +> GpgmeRecipients instance? + +> - There is an inconsistent behaviour: if we pass three times an +> invalid (but non empty) passphrase, return code is GPGME_No_Data, but +> if we pass three times an empty (and invalid) passphrase, we get +> GPGME_No_Passphrase. + +> passphrase callback. If I use the same GpgmeContext as the one which +> is currently asking for a passphrase, my app crashes: the r_hd in +> the +> callback has become invalid; if I use a brand new one, the callback +> is called recursively, when I ask to enumerate keys. diff --git a/configure.in b/configure.in index 65c02a65..8e830334 100644 --- a/configure.in +++ b/configure.in @@ -24,15 +24,12 @@ AC_REVISION($Revision$)dnl AC_INIT(gpgme/gpgme.h) AM_CONFIG_HEADER(config.h) AM_MAINTAINER_MODE -############################################# # Version numbers (Remember to change them just before a release) -# 1. No interfaces changed, only implementations (good): Increment REVISION. -# 2. Interfaces added, none removed (good): Increment CURRENT, increment -# AGE, set REVISION to 0. -# 3. Interfaces removed (BAD, breaks upward compatibility): Increment -# CURRENT, set AGE and REVISION to 0. +# (Interfaces removed: CURRENT++, AGE=0, REVISION=0) +# (Interfaces added: CURRENT++, AGE++, REVISION=0) +# (No interfaces changed: REVISION++) AM_INIT_AUTOMAKE(gpgme,0.2.3a) -# +# XXXX new functions LIBGPGME_LT_CURRENT=4 LIBGPGME_LT_AGE=4 LIBGPGME_LT_REVISION=0 diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index fceee93a..34ef166d 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,3 +1,13 @@ +2001-10-15 Werner Koch + + * gpgme.h (GpgmeProtocol): New. + * gpgme.c (gpgme_set_protocol): New. + +2001-09-26 Werner Koch + + * gpgme.c (gpgme_set_passphrase_cb): Ignore a NULL context. + (gpgme_set_progress_cb): Ditto. Suggested by Mark Mutz. + 2001-09-17 Werner Koch * keylist.c (finish_key): Shortcut for no tmp_key. Changed all diff --git a/gpgme/context.h b/gpgme/context.h index ad5886ca..ee3f224a 100644 --- a/gpgme/context.h +++ b/gpgme/context.h @@ -51,6 +51,8 @@ struct gpgme_context_s { int initialized; int pending; /* a gpg request is still pending */ + int use_cms; + /* at some points we need to allocate memory but we are not * able to handle a malloc problem at that point, so we set this * flag to indicate this condition */ diff --git a/gpgme/data.c b/gpgme/data.c index a0c37693..fc27d028 100644 --- a/gpgme/data.c +++ b/gpgme/data.c @@ -170,7 +170,7 @@ gpgme_data_new_with_read_cb ( GpgmeData *r_dh, * * Create a new data object and initialize it with the content of * the file @file. If @copy is %True the file is immediately read in - * adn closed. @copy of %False is not yet supportted. + * and closed. @copy of %False is not yet supportted. * * Return value: An error code or 0 on success. If the error code is * %GPGME_File_Error, the OS error code is held in %errno. diff --git a/gpgme/gpgme.c b/gpgme/gpgme.c index c36a9448..86c08270 100644 --- a/gpgme/gpgme.c +++ b/gpgme/gpgme.c @@ -195,6 +195,28 @@ _gpgme_set_op_info (GpgmeCtx c, GpgmeData info) c->op_info = info; } +GpgmeError +gpgme_set_protocol (GpgmeCtx c, GpgmeProtocol prot) +{ + if (!c) + return mk_error (Invalid_Value); + + switch (prot) + { + case GPGME_PROTOCOL_OPENPGP: + c->use_cms = 0; + break; + case GPGME_PROTOCOL_CMS: + c->use_cms = 1; + break; + case GPGME_PROTOCOL_AUTO: + return mk_error (Not_Implemented); + default: + return mk_error (Invalid_Value); + } + + return 0; +} /** * gpgme_set_armor: @@ -234,7 +256,8 @@ gpgme_get_armor (GpgmeCtx c) * @yes: boolean flag whether textmode should be enabled * * Enable or disable the use of the special textmode. Textmode is for example - * used for MIME (RFC2015) signatures + * used for the RFC2015 signatures; note that the updated RFC 3156 mandates + * that the MUA does some preparations so that textmode is not anymore needed. **/ void gpgme_set_textmode ( GpgmeCtx c, int yes ) @@ -309,12 +332,15 @@ gpgme_set_keylist_mode ( GpgmeCtx c, int mode ) void gpgme_set_passphrase_cb ( GpgmeCtx c, GpgmePassphraseCb cb, void *cb_value ) { - c->passphrase_cb = cb; - c->passphrase_cb_value = cb_value; + if (c) + { + c->passphrase_cb = cb; + c->passphrase_cb_value = cb_value; + } } /** - * gpgme_set_pprogress_cb: + * gpgme_set_progress_cb: * @c: the context * @cb: A callback function * @cb_value: The value passed to the callback function @@ -333,8 +359,11 @@ gpgme_set_passphrase_cb ( GpgmeCtx c, GpgmePassphraseCb cb, void *cb_value ) void gpgme_set_progress_cb ( GpgmeCtx c, GpgmeProgressCb cb, void *cb_value ) { - c->progress_cb = cb; - c->progress_cb_value = cb_value; + if (c) + { + c->progress_cb = cb; + c->progress_cb_value = cb_value; + } } diff --git a/gpgme/gpgme.h b/gpgme/gpgme.h index 4d89984a..b48ffc3d 100644 --- a/gpgme/gpgme.h +++ b/gpgme/gpgme.h @@ -44,7 +44,7 @@ extern "C" { * let autoconf (using the AM_PATH_GPGME macro) check that this * header matches the installed library. * Warning: Do not edit the next line. configure will do that for you! */ -#define GPGME_VERSION "0.2.3" +#define GPGME_VERSION "0.2.3a" @@ -153,6 +153,12 @@ typedef enum { } GpgmeValidity; +typedef enum { + GPGME_PROTOCOL_OpenPGP = 0, /* default */ + GPGME_PROTOCOL_CMS = 1, + GPGME_PROTOCOL_AUTO = 2 +} GpgmeProtocol; + typedef const char *(*GpgmePassphraseCb)(void*, const char *desc, void *r_hd); typedef void (*GpgmeProgressCb)(void *opaque, diff --git a/tests/mkdemodirs b/tests/mkdemodirs index 28b78352..7c3bd047 100755 --- a/tests/mkdemodirs +++ b/tests/mkdemodirs @@ -9,7 +9,7 @@ NAMES='Alpha Bravo Charlie Delta Echo Foxtrot Golf Hotel India if [ "$1" = "--clean" ]; then (for i in $NAMES; do - [ -d $i ] && rm -r $i + [ -d $i ] && rm -r $i || true done) || true exit 0 fi