diff options
| -rw-r--r-- | NEWS | 1 | ||||
| -rw-r--r-- | doc/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/gpgme.texi | 9 | ||||
| -rw-r--r-- | gpgme/ChangeLog | 11 | ||||
| -rw-r--r-- | gpgme/genkey.c | 73 | ||||
| -rw-r--r-- | gpgme/gpgme.h | 76 | ||||
| -rw-r--r-- | gpgmeplug/ChangeLog | 5 | ||||
| -rw-r--r-- | gpgmeplug/gpgmeplug.c | 2 | ||||
| -rw-r--r-- | tests/ChangeLog | 5 | ||||
| -rw-r--r-- | tests/gpg/t-genkey.c | 2 | 
10 files changed, 126 insertions, 63 deletions
@@ -22,6 +22,7 @@ gpgme_op_verify			CHANGED: Take different data objects for  				signed text and plain text.  gpgme_op_verify_start		CHANGED: See gpgme_op_verify.  gpgme_check_engine		REMOVED: Deprecated since 0.3.0. +gpgme_op_genkey			CHANGED: New parameter FPR.  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  Noteworthy changes in version 0.3.11 (2002-09-20) diff --git a/doc/ChangeLog b/doc/ChangeLog index 38640cf8..64261dec 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2002-11-19  Marcus Brinkmann  <[email protected]> + +	* gpgme.texi (Generating Keys): Document new argument to +	gpgme_op_genkey. +  2002-11-05  Marcus Brinkmann  <[email protected]>  	* gpgme.texi (Verify): Fix prototype of gpgme_get_sig_key. diff --git a/doc/gpgme.texi b/doc/gpgme.texi index 2663f075..7c114b47 100644 --- a/doc/gpgme.texi +++ b/doc/gpgme.texi @@ -1803,7 +1803,7 @@ The function @code{gpgme_key_release} is an alias for  @cindex key, creation  @cindex key ring, add -@deftypefun GpgmeError gpgme_op_genkey (@w{GpgmeCtx @var{ctx}}, @w{const char *@var{parms}}, @w{GpgmeData @var{pubkey}}, @w{GpgmeData @var{seckey}}) +@deftypefun GpgmeError gpgme_op_genkey (@w{GpgmeCtx @var{ctx}}, @w{const char *@var{parms}}, @w{GpgmeData @var{pubkey}}, @w{GpgmeData @var{seckey}}, @w{char **@var{fpr}})  The function @code{gpgme_op_genkey} generates a new key pair in the  context @var{ctx} and puts it into the standard key ring if both  @var{pubkey} and @var{seckey} are @code{NULL}.  In this case the @@ -1856,6 +1856,13 @@ for now is ``internal''.  The content of the @code{GnupgKeyParms}  container is passed verbatim to GnuPG.  Control statements are not  allowed. +If @var{fpr} is not a null pointer, the function succeeds, and the +crypto engine supports it, *@var{fpr} will contain a string with the +fingerprint of the key, allocated with @code{malloc}.  If both a +primary and a sub key was generated, the fingerprint of the primary +key will be returned.  If the crypto engine does not provide the +fingerprint, *@var{fpr} will be a null pointer. +  The function returns @code{GPGME_No_Error} if the operation could be  started successfully, @code{GPGME_Invalid_Value} if @var{parms} is not  a valid XML string, @code{GPGME_Not_Supported} if @var{pubkey} or diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index f420a738..a2c9175a 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,5 +1,16 @@  2002-11-19  Marcus Brinkmann  <[email protected]> +	* genkey.c: Only include <config.h> if [HAVE_CONFIG_H]. +	(struct genkey_result_s): Add new member FPR. +	(_gpgme_release_genkey_result): Free RESULT->fpr if set. +	(genkey_status_handler): Extract the fingerprint from the status +	line. +	(gpgme_op_genkey): Add new argument FPR and return the fingerprint +	in it. +	* gpgme.h: Adjust prototype of gpgme_op_genkey. + +2002-11-19  Marcus Brinkmann  <[email protected]> +  	* rungpg.c (gpg_keylist): Add --with-fingerprint to gpg invocation  	twice, to get fingerprints on subkeys.  Suggested by Timo Schulz diff --git a/gpgme/genkey.c b/gpgme/genkey.c index ab36cdc2..b4e67084 100644 --- a/gpgme/genkey.c +++ b/gpgme/genkey.c @@ -1,25 +1,26 @@ -/* genkey.c -  key generation - *	Copyright (C) 2000 Werner Koch (dd9jn) - *      Copyright (C) 2001, 2002 g10 Code GmbH - * - * This file is part of GPGME. - * - * GPGME 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. - * - * GPGME 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 - */ - +/* genkey.c - Key generation. +   Copyright (C) 2000 Werner Koch (dd9jn) +   Copyright (C) 2001, 2002 g10 Code GmbH + +   This file is part of GPGME. +  +   GPGME 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. +  +   GPGME 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 GPGME; if not, write to the Free Software Foundation, +   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ + +#if HAVE_CONFIG_H  #include <config.h> +#endif  #include <stdio.h>  #include <stdlib.h>  #include <string.h> @@ -34,6 +35,7 @@ struct genkey_result_s  {    int created_primary : 1;    int created_sub : 1; +  char *fpr;  }; @@ -42,9 +44,12 @@ _gpgme_release_genkey_result (GenKeyResult result)  {    if (!result)      return; +  if (result->fpr) +    free (result->fpr);    free (result);  } +  static void  genkey_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args)  { @@ -63,6 +68,14 @@ genkey_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args)  	    ctx->result.genkey->created_primary = 1;  	  if (*args == 'B' || *args == 'S')  	    ctx->result.genkey->created_sub = 1; +	  if (args[1] == ' ') +	    { +	      if (ctx->result.genkey->fpr) +		free (ctx->result.genkey->fpr); +	      ctx->result.genkey->fpr = strdup (&args[2]); +	      if (!ctx->result.genkey->fpr) +		ctx->error = mk_error (Out_Of_Core); +	    }  	}        break; @@ -78,6 +91,7 @@ genkey_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args)      }  } +  static GpgmeError  _gpgme_op_genkey_start (GpgmeCtx ctx, int synchronous, const char *parms,  			GpgmeData pubkey, GpgmeData seckey) @@ -183,7 +197,8 @@ gpgme_op_genkey_start (GpgmeCtx ctx, const char *parms,   * @parms: XML string with the key parameters   * @pubkey: Returns the public key   * @seckey: Returns the secret key - *  + * @fpr: Returns the fingerprint of the key. + *   * Generate a new key and store the key in the default keyrings if both   * @pubkey and @seckey are NULL.  If @pubkey and @seckey are given, the newly   * created key will be returned in these data objects. @@ -193,10 +208,22 @@ gpgme_op_genkey_start (GpgmeCtx ctx, const char *parms,   **/  GpgmeError  gpgme_op_genkey (GpgmeCtx ctx, const char *parms, -                 GpgmeData pubkey, GpgmeData seckey) +                 GpgmeData pubkey, GpgmeData seckey, +		 char **fpr)  {    GpgmeError err = _gpgme_op_genkey_start (ctx, 1, parms, pubkey, seckey);    if (!err)      err = _gpgme_wait_one (ctx); +  if (!err && fpr) +    { +      if (ctx->result.genkey->fpr) +	{ +	  *fpr = strdup (ctx->result.genkey->fpr); +	  if (!*fpr) +	    return mk_error (Out_Of_Core); +	} +      else +	*fpr = NULL; +    }    return err;  } diff --git a/gpgme/gpgme.h b/gpgme/gpgme.h index 74fa2594..90eef034 100644 --- a/gpgme/gpgme.h +++ b/gpgme/gpgme.h @@ -1,23 +1,22 @@ -/* gpgme.h -  GnuPG Made Easy - *	Copyright (C) 2000 Werner Koch (dd9jn) - *      Copyright (C) 2001, 2002 g10 Code GmbH - * - * This file is part of GPGME. - * - * GPGME 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. - * - * GPGME 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 - */ +/* gpgme.h - Public interface to GnuPG Made Easy. +   Copyright (C) 2000 Werner Koch (dd9jn) +   Copyright (C) 2001, 2002 g10 Code GmbH + +   This file is part of GPGME. +  +   GPGME 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. +  +   GPGME 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 GPGME; if not, write to the Free Software Foundation, +   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */  #ifndef GPGME_H  #define GPGME_H @@ -115,10 +114,10 @@ GpgmeDataType;  /* The possible encoding mode of GpgmeData objects.  */  typedef enum    { -    GPGME_DATA_ENCODING_NONE   = 0, /* i.e. not specified */ +    GPGME_DATA_ENCODING_NONE   = 0,	/* I.e. not specified.  */      GPGME_DATA_ENCODING_BINARY = 1, -    GPGME_DATA_ENCODING_BASE64 = 2,  -    GPGME_DATA_ENCODING_ARMOR  = 3 /* Either PEM or OpenPGP Armor */ +    GPGME_DATA_ENCODING_BASE64 = 2, +    GPGME_DATA_ENCODING_ARMOR  = 3	/* Either PEM or OpenPGP Armor.  */    }  GpgmeDataEncoding; @@ -137,20 +136,20 @@ typedef enum    }  GpgmeSigStat; -/* Flags used with the GPGME_ATTR_SIG_SUMMARY. */ +/* Flags used with the GPGME_ATTR_SIG_SUMMARY.  */  enum     { -    GPGME_SIGSUM_VALID       = 0x0001,  /* The signature is fully valid */ -    GPGME_SIGSUM_GREEN       = 0x0002,  /* The signature is good. */ -    GPGME_SIGSUM_RED         = 0x0004,  /* The signature is bad. */ -    GPGME_SIGSUM_KEY_REVOKED = 0x0010,  /* One key has been revoked. */ -    GPGME_SIGSUM_KEY_EXPIRED = 0x0020,  /* One key has expired. */ -    GPGME_SIGSUM_SIG_EXPIRED = 0x0040,  /* The signature has expired. */ -    GPGME_SIGSUM_KEY_MISSING = 0x0080,  /* Can't verify: key missing. */ -    GPGME_SIGSUM_CRL_MISSING = 0x0100,  /* CRL not available. */ -    GPGME_SIGSUM_CRL_TOO_OLD = 0x0200,  /* Available CRL is too old. */ -    GPGME_SIGSUM_BAD_POLICY  = 0x0400,  /* A policy was not met. */ -    GPGME_SIGSUM_SYS_ERROR   = 0x0800   /* A system error occured. */ +    GPGME_SIGSUM_VALID       = 0x0001,  /* The signature is fully valid.  */ +    GPGME_SIGSUM_GREEN       = 0x0002,  /* The signature is good.  */ +    GPGME_SIGSUM_RED         = 0x0004,  /* The signature is bad.  */ +    GPGME_SIGSUM_KEY_REVOKED = 0x0010,  /* One key has been revoked.  */ +    GPGME_SIGSUM_KEY_EXPIRED = 0x0020,  /* One key has expired.  */ +    GPGME_SIGSUM_SIG_EXPIRED = 0x0040,  /* The signature has expired.  */ +    GPGME_SIGSUM_KEY_MISSING = 0x0080,  /* Can't verify: key missing.  */ +    GPGME_SIGSUM_CRL_MISSING = 0x0100,  /* CRL not available.  */ +    GPGME_SIGSUM_CRL_TOO_OLD = 0x0200,  /* Available CRL is too old.  */ +    GPGME_SIGSUM_BAD_POLICY  = 0x0400,  /* A policy was not met.  */ +    GPGME_SIGSUM_SYS_ERROR   = 0x0800   /* A system error occured.  */    }; @@ -716,11 +715,14 @@ GpgmeError gpgme_op_export (GpgmeCtx ctx, GpgmeRecipients recp,  /* Generate a new keypair and add it to the keyring.  PUBKEY and     SECKEY should be null for now.  PARMS specifies what keys should be -   generated.  */ +   generated.  On success, if *FPR is non-null, it contains a +   malloc()'ed string with the fingerprint of the generated key on +   success.  */  GpgmeError gpgme_op_genkey_start (GpgmeCtx ctx, const char *parms,  				  GpgmeData pubkey, GpgmeData seckey);  GpgmeError gpgme_op_genkey (GpgmeCtx ctx, const char *parms, -			    GpgmeData pubkey, GpgmeData seckey); +			    GpgmeData pubkey, GpgmeData seckey, +			    char **fpr);  /* Delete KEY from the keyring.  If ALLOW_SECRET is non-zero, secret     keys are also deleted.  */ diff --git a/gpgmeplug/ChangeLog b/gpgmeplug/ChangeLog index d9c6d9d4..f098ba16 100644 --- a/gpgmeplug/ChangeLog +++ b/gpgmeplug/ChangeLog @@ -1,3 +1,8 @@ +2002-11-19  Marcus Brinkmann  <[email protected]> + +	* gpgmeplug.c (requestDecentralCertificate): Add new argument to +	gpgme_op_genkey invocation. +  2002-10-12  Marcus Brinkmann  <[email protected]>  	* gpgmeplug.c (checkMessageSignature): Update call to diff --git a/gpgmeplug/gpgmeplug.c b/gpgmeplug/gpgmeplug.c index 8391593c..8a916109 100644 --- a/gpgmeplug/gpgmeplug.c +++ b/gpgmeplug/gpgmeplug.c @@ -1802,7 +1802,7 @@ bool requestDecentralCertificate( const char* certparms,      gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);      /* Don't ASCII-armor, the MUA will use base64 encoding */      /*    gpgme_set_armor (ctx, 1); */ -    err = gpgme_op_genkey (ctx, certparms, pub, NULL ); +    err = gpgme_op_genkey (ctx, certparms, pub, NULL, NULL);      fprintf( stderr,  "3: gpgme returned %d\n", err );      if( err != GPGME_No_Error ) {          gpgme_data_release( pub ); diff --git a/tests/ChangeLog b/tests/ChangeLog index 3ef332ad..9efd160d 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +2002-11-19  Marcus Brinkmann  <[email protected]> + +	* gpg/t-genkey.c (main): Add missing argument to gpgme_op_genkey +	invocation. +  2002-10-09  Marcus Brinkmann  <[email protected]>  	* gpg/t-decrypt.c (print_data): Update to new gpgme_data_read diff --git a/tests/gpg/t-genkey.c b/tests/gpg/t-genkey.c index 09206fb4..4bb59b2d 100644 --- a/tests/gpg/t-genkey.c +++ b/tests/gpg/t-genkey.c @@ -70,7 +70,7 @@ main (int argc, char **argv )      if (!parms)          exit (8);      sprintf (parms, format, ++count ); -    err = gpgme_op_genkey (ctx, parms, NULL, NULL ); +    err = gpgme_op_genkey (ctx, parms, NULL, NULL, NULL);      fail_if_err (err);      free (parms);  | 
