diff --git a/NEWS b/NEWS index 78c1be50..8a7299b4 100644 --- a/NEWS +++ b/NEWS @@ -3,9 +3,14 @@ Noteworthy changes in version 0.4.1 (unreleased) * GPGME_ATTR_IS_SECRET is not anymore representable as a string. + * gpgme_op_verify and gpgme_op_decrypt_verify don't return a status + summary anymore. Use gpgme_get_sig_status to retrieve the individual stati. + * Interface changes relative to the 0.4.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -gpgme_key_get_string_attr CHANGED: Don't handle GPGME_ATR_IS_SECRET. +gpgme_key_get_string_attr CHANGED: Don't handle GPGME_ATTR_IS_SECRET. +gpgme_op_verify CHANGED: Drop R_STAT argument. +gpgme_op_decrypt_verify CHANGED: Drop R_STAT argument. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 0.4.0 (2002-12-23) diff --git a/doc/ChangeLog b/doc/ChangeLog index 39a54aaf..8a652714 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,9 @@ +2002-12-24 Marcus Brinkmann + + * gpgme.texi (Verify): Drop R_STAT argument in gpgme_op_verify. + * gpgme.texi (Decrypt and Verify): Likewise for + gpgme_op_decrypt_verify. + 2002-12-23 Marcus Brinkmann * gpgme.texi (Information About Keys): Document that diff --git a/doc/gpgme.texi b/doc/gpgme.texi index a74ec240..d3c02be8 100644 --- a/doc/gpgme.texi +++ b/doc/gpgme.texi @@ -2466,7 +2466,7 @@ have a different status. You can get each key's status with @end deftp -@deftypefun GpgmeError gpgme_op_verify (@w{GpgmeCtx @var{ctx}}, @w{GpgmeData @var{sig}}, @w{GpgmeData @var{signed_text}}, @w{GpgmeData @var{plain}}, @w{GpgmeSigStat *@var{r_stat}}) +@deftypefun GpgmeError gpgme_op_verify (@w{GpgmeCtx @var{ctx}}, @w{GpgmeData @var{sig}}, @w{GpgmeData @var{signed_text}}, @w{GpgmeData @var{plain}}) The function @code{gpgme_op_verify} verifies that the signature in the data object @var{sig} is a valid signature. If @var{sig} is a detached signature, then the signed text should be provided in @@ -2476,7 +2476,6 @@ Otherwise, if @var{sig} is a normal (or cleartext) signature, writable data object that will contain the plaintext after successful verification. -The combined status of all signatures is returned in @var{r_stat}. The results of the individual signature verifications can be retrieved with @code{gpgme_get_sig_status} and @code{gpgme_get_sig_key}. @@ -2658,11 +2657,11 @@ The function returns a string if the notation data is available or @cindex signature check @cindex cryptographic operation, decryption and verification -@deftypefun GpgmeError gpgme_op_decrypt_verify (@w{GpgmeCtx @var{ctx}}, @w{GpgmeData @var{cipher}}, @w{GpgmeData @var{plain}}, @w{GpgmeSigStat *@var{r_stat}}) +@deftypefun GpgmeError gpgme_op_decrypt_verify (@w{GpgmeCtx @var{ctx}}, @w{GpgmeData @var{cipher}}, @w{GpgmeData @var{plain}}) The function @code{gpgme_op_decrypt_verify} decrypts the ciphertext in the data object @var{cipher} and stores it into the data object @var{plain}. If @var{cipher} contains signatures, they will be -verified and their combined status will be returned in @var{r_stat}. +verified. After the operation completed, @code{gpgme_op_get_sig_status} and @code{gpgme_op_get_sig_key} can be used to retrieve more information diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index 448252a6..ca4f2ada 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,3 +1,13 @@ +2002-12-24 Marcus Brinkmann + + * gpgme.h (gpgme_op_verify, gpgme_op_decrypt_verify): Drop R_STAT + argument. + * decrypt-verify.c (gpgme_op_decrypt_verify): Drop R_STAT + argument. + * verify.c (gpgme_op_verify): Drop R_STAT argument. + (_gpgme_intersect_stati): Function removed. + * ops.h (_gpgme_intersect_stati): Remove prototype. + 2002-12-24 Marcus Brinkmann * libgpgme.vers: New file. diff --git a/gpgme/decrypt-verify.c b/gpgme/decrypt-verify.c index b78df703..f49bb726 100644 --- a/gpgme/decrypt-verify.c +++ b/gpgme/decrypt-verify.c @@ -1,25 +1,26 @@ /* decrypt-verify.c - decrypt and verify functions - * 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 - */ + 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 +#endif #include #include #include @@ -59,23 +60,16 @@ gpgme_op_decrypt_verify_start (GpgmeCtx ctx, GpgmeData ciph, GpgmeData plain) * Return value: 0 on success or an errorcode. **/ GpgmeError -gpgme_op_decrypt_verify (GpgmeCtx ctx, - GpgmeData in, GpgmeData out, - GpgmeSigStat *r_stat) +gpgme_op_decrypt_verify (GpgmeCtx ctx, GpgmeData in, GpgmeData out) { GpgmeError err; gpgme_data_release (ctx->notation); ctx->notation = NULL; - *r_stat = GPGME_SIG_STAT_NONE; err = _gpgme_decrypt_start (ctx, 1, in, out, decrypt_verify_status_handler); if (!err) - { - err = _gpgme_wait_one (ctx); - if (!err) - *r_stat = _gpgme_intersect_stati (ctx->result.verify); - } + err = _gpgme_wait_one (ctx); return err; } diff --git a/gpgme/gpgme.h b/gpgme/gpgme.h index 4332c862..f38f2919 100644 --- a/gpgme/gpgme.h +++ b/gpgme/gpgme.h @@ -707,8 +707,7 @@ GpgmeError gpgme_op_decrypt (GpgmeCtx ctx, GpgmeError gpgme_op_decrypt_verify_start (GpgmeCtx ctx, GpgmeData cipher, GpgmeData plain); GpgmeError gpgme_op_decrypt_verify (GpgmeCtx ctx, - GpgmeData cipher, GpgmeData plain, - GpgmeSigStat *r_status); + GpgmeData cipher, GpgmeData plain); /* Sign the plaintext PLAIN and store the signature in SIG. Only detached signatures are supported for now. */ @@ -723,8 +722,7 @@ GpgmeError gpgme_op_sign (GpgmeCtx ctx, GpgmeError gpgme_op_verify_start (GpgmeCtx ctx, GpgmeData sig, GpgmeData signed_text, GpgmeData plaintext); GpgmeError gpgme_op_verify (GpgmeCtx ctx, GpgmeData sig, - GpgmeData signed_text, GpgmeData plaintext, - GpgmeSigStat *r_status); + GpgmeData signed_text, GpgmeData plaintext); /* Import the key in KEYDATA into the keyring. */ GpgmeError gpgme_op_import_start (GpgmeCtx ctx, GpgmeData keydata); diff --git a/gpgme/ops.h b/gpgme/ops.h index 4398de52..022eef52 100644 --- a/gpgme/ops.h +++ b/gpgme/ops.h @@ -84,7 +84,6 @@ GpgmeError _gpgme_op_reset (GpgmeCtx ctx, int synchronous); /*-- verify.c --*/ void _gpgme_release_verify_result (VerifyResult result); -GpgmeSigStat _gpgme_intersect_stati (VerifyResult result); void _gpgme_verify_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args); diff --git a/gpgme/verify.c b/gpgme/verify.c index bc2a787b..b3d7314f 100644 --- a/gpgme/verify.c +++ b/gpgme/verify.c @@ -406,26 +406,11 @@ gpgme_op_verify_start (GpgmeCtx ctx, GpgmeData sig, GpgmeData signed_text, } -/* Figure out a common status value for all signatures. */ -GpgmeSigStat -_gpgme_intersect_stati (VerifyResult result) -{ - GpgmeSigStat status = result->status; - - for (result = result->next; result; result = result->next) - { - if (status != result->status) - return GPGME_SIG_STAT_DIFF; - } - return status; -} - /** * gpgme_op_verify: * @c: the context * @sig: the signature data * @text: the signed text - * @r_stat: returns the status of the signature * * Perform a signature check on the signature given in @sig. If @text * is a new and uninitialized data object, it is assumed that @sig @@ -435,6 +420,34 @@ _gpgme_intersect_stati (VerifyResult result) * If @text is initialized, it is assumed that @sig is a detached * signature for the material given in @text. * + * Return value: 0 on success or an errorcode if something not related to + * the signature itself did go wrong. + **/ +GpgmeError +gpgme_op_verify (GpgmeCtx ctx, GpgmeData sig, GpgmeData signed_text, + GpgmeData plaintext) +{ + GpgmeError err; + + gpgme_data_release (ctx->notation); + ctx->notation = NULL; + + err = _gpgme_op_verify_start (ctx, 1, sig, signed_text, plaintext); + if (!err) + err = _gpgme_wait_one (ctx); + return err; +} + + +/** + * gpgme_get_sig_status: + * @c: Context + * @idx: Index of the signature starting at 0 + * @r_stat: Returns the status + * @r_created: Returns the creation timestamp + * + * Return information about an already verified signatures. + * * The result of this operation is returned in @r_stat which can take these * values: * GPGME_SIG_STAT_NONE: No status - should not happen @@ -449,41 +462,6 @@ _gpgme_intersect_stati (VerifyResult result) * GPGME_SIG_STAT_GOOD_EXP: The signature is good but has expired. * GPGME_SIG_STAT_GOOD_KEYEXP: The signature is good but the key has expired. * - * Return value: 0 on success or an errorcode if something not related to - * the signature itself did go wrong. - **/ -GpgmeError -gpgme_op_verify (GpgmeCtx ctx, GpgmeData sig, GpgmeData signed_text, - GpgmeData plaintext, GpgmeSigStat *r_stat) -{ - GpgmeError err; - - if (!r_stat) - return mk_error (Invalid_Value); - - gpgme_data_release (ctx->notation); - ctx->notation = NULL; - - *r_stat = GPGME_SIG_STAT_NONE; - err = _gpgme_op_verify_start (ctx, 1, sig, signed_text, plaintext); - if (!err) - { - err = _gpgme_wait_one (ctx); - if (!err && ctx->result.verify) - *r_stat = _gpgme_intersect_stati (ctx->result.verify); - } - return err; -} - - -/** - * gpgme_get_sig_status: - * @c: Context - * @idx: Index of the signature starting at 0 - * @r_stat: Returns the status - * @r_created: Returns the creation timestamp - * - * Return information about an already verified signatures. * * Return value: The fingerprint or NULL in case of an problem or * when there are no more signatures. diff --git a/tests/ChangeLog b/tests/ChangeLog index 955b9e5a..1ca88b52 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,10 @@ +2002-12-24 Marcus Brinkmann + + * gpgsm/t-verify.c (main): Adjust caller of gpgme_op_verify. + * gpg/t-verify.c (main): Likewise. + * gpg/t-decrypt-verify.c (main): Likewise for + gpgme_op_decrypt_verify. + 2002-12-23 Marcus Brinkmann * gpgsm/Makefile.am (./gpgsm.conf): Add a faked system time to diff --git a/tests/gpg/t-decrypt-verify.c b/tests/gpg/t-decrypt-verify.c index 276f7e6d..1a129a79 100644 --- a/tests/gpg/t-decrypt-verify.c +++ b/tests/gpg/t-decrypt-verify.c @@ -1,23 +1,22 @@ /* t-decrypt-verify.c - regression test - * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001 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 - */ + 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. */ #include #include @@ -102,7 +101,7 @@ main (int argc, char **argv) GpgmeData in, out, pwdata = NULL; struct passphrase_cb_info_s info; const char *cipher_2_asc = mk_fname ("cipher-2.asc"); - GpgmeSigStat stat; + GpgmeSigStat status; char *p; do @@ -124,15 +123,20 @@ main (int argc, char **argv) err = gpgme_data_new (&out); fail_if_err (err); - err = gpgme_op_decrypt_verify (ctx, in, out, &stat); + err = gpgme_op_decrypt_verify (ctx, in, out); fail_if_err (err); fflush (NULL); fputs ("Begin Result:\n", stdout); print_data (out); fputs ("End Result.\n", stdout); - - if (stat != GPGME_SIG_STAT_GOOD) + + if (!gpgme_get_sig_status (ctx, 0, &status, NULL)) + { + fprintf (stderr, "Signature check failed unexpectedly.\n"); + exit (1); + } + if (status != GPGME_SIG_STAT_GOOD) { fprintf (stderr, "Signature check failed unexpectedly.\n"); exit (1); diff --git a/tests/gpg/t-verify.c b/tests/gpg/t-verify.c index f12b6068..1dcca5db 100644 --- a/tests/gpg/t-verify.c +++ b/tests/gpg/t-verify.c @@ -1,23 +1,22 @@ /* t-verify.c - regression test - * 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 - */ + 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. */ #include #include @@ -188,8 +187,13 @@ main (int argc, char **argv ) fail_if_err (err); puts ("checking a valid message:\n"); - err = gpgme_op_verify (ctx, sig, text, NULL, &status); + err = gpgme_op_verify (ctx, sig, text, NULL); fail_if_err (err); + if (!gpgme_get_sig_status (ctx, 0, &status, NULL)) + { + fprintf (stderr, "%s:%d: No signature\n", __FILE__, __LINE__); + exit (1); + } print_sig_stat (ctx, status); if (status != GPGME_SIG_STAT_GOOD) { @@ -206,9 +210,13 @@ main (int argc, char **argv ) test_text1f, strlen (test_text1f), 0); fail_if_err (err); gpgme_data_rewind (sig); - err = gpgme_op_verify (ctx, sig, text, NULL, &status); + err = gpgme_op_verify (ctx, sig, text, NULL); fail_if_err (err); - + if (!gpgme_get_sig_status (ctx, 0, &status, NULL)) + { + fprintf (stderr, "%s:%d: No signature\n", __FILE__, __LINE__); + exit (1); + } print_sig_stat (ctx, status); if (status != GPGME_SIG_STAT_BAD) { @@ -225,8 +233,13 @@ main (int argc, char **argv ) fail_if_err (err); err = gpgme_data_new (&text); fail_if_err (err); - err = gpgme_op_verify (ctx, sig, NULL, text, &status); + err = gpgme_op_verify (ctx, sig, NULL, text); fail_if_err (err); + if (!gpgme_get_sig_status (ctx, 0, &status, NULL)) + { + fprintf (stderr, "%s:%d: No signature\n", __FILE__, __LINE__); + exit (1); + } nota = gpgme_data_release_and_get_mem (text, &len); for (j = 0; j < len; j++) diff --git a/tests/gpgsm/t-verify.c b/tests/gpgsm/t-verify.c index 715b3473..0a48b3cb 100644 --- a/tests/gpgsm/t-verify.c +++ b/tests/gpgsm/t-verify.c @@ -1,23 +1,22 @@ /* t-verify.c - regression test - * 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 - */ + 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. */ #include #include @@ -186,12 +185,14 @@ main (int argc, char **argv ) fail_if_err (err); puts ("checking a valid message:\n"); - err = gpgme_op_verify (ctx, sig, text, NULL, &status); - print_sig_stat (ctx, status); - print_sig_stat (ctx, status); - print_sig_stat (ctx, status); - print_sig_stat (ctx, status); + err = gpgme_op_verify (ctx, sig, text, NULL); fail_if_err (err); + if (!gpgme_get_sig_status (ctx, 0, &status, NULL)) + { + fprintf (stderr, "%s:%d: No signature\n", __FILE__, __LINE__); + exit (1); + } + print_sig_stat (ctx, status); if ( (nota=gpgme_get_notation (ctx)) ) printf ("---Begin Notation---\n%s---End Notation---\n", nota); @@ -202,10 +203,15 @@ main (int argc, char **argv ) test_text1f, strlen (test_text1f), 0); fail_if_err (err); gpgme_data_rewind ( sig ); - err = gpgme_op_verify (ctx, sig, text, NULL, &status); - - print_sig_stat (ctx, status); + err = gpgme_op_verify (ctx, sig, text, NULL); fail_if_err (err); + if (!gpgme_get_sig_status (ctx, 0, &status, NULL)) + { + fprintf (stderr, "%s:%d: No signature\n", __FILE__, __LINE__); + exit (1); + } + print_sig_stat (ctx, status); + if ((nota=gpgme_get_notation (ctx))) printf ("---Begin Notation---\n%s---End Notation---\n", nota);