the ciphertext is not usable for all requested recipients.
Information about invalid recipients is available with gpgme_get_op_info.
+ * gpgme_op_verify now allows to pass an uninitialized data object as
+ its plaintext argument to check for normal and cleartext
+ signatures. The plaintext is then returned in the data object.
+
* New interfaces gpgme_set_include_certs and gpgme_get_include_certs
to set and get the number of certifications to include in S/MIME
signed messages.
* Interface changes relative to the 0.3.3 release:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gpgme_op_encrypt CHANGED: Can fail with GPGME_Invalid_Recipients
+gpgme_op_verify EXTENDED: Accepts uninitialized text argument
gpgme_set_include_certs NEW
gpgme_get_include_certs NEW
gpgme_op_encrypt_sign NEW
+2002-03-03 Marcus Brinkmann <marcus@g10code.de>
+
+ * gpgme.texi (Verify): Document verification of normal and
+ cleartext signatures.
+
2002-02-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Listing Keys): Document gpgme_op_keylist_ext_start.
@end deftp
@deftypefun GpgmeError gpgme_op_verify (@w{GpgmeCtx @var{ctx}}, @w{GpgmeData @var{sig}}, @w{GpgmeData @var{plain}}, @w{GpgmeSigStat *@var{r_stat}})
-The function @code{gpgme_op_verify} verifies that the detached
-signature in the data object @var{sig} is a valid signature for the
-plaintext in the data object @var{plain}.
+The function @code{gpgme_op_verify} verifies that the signature in the
+data object @var{sig} is a valid signature. If @var{plain} is
+initialized with plaintext data, it is assumed that @var{sig} is a
+detached signature, and its validity for the plaintext given in
+@var{plain} is verified. If @var{plain} is an uninitialized data
+object, it is assumed that @var{sig} is a normal (or cleartext)
+signature, and the plaintext is available in @var{plain} 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
The function returns @code{GPGME_No_Error} if the operation could be
completed successfully, @code{GPGME_Invalid_Value} if @var{ctx},
@var{sig}, @var{plain} or @var{r_stat} is not a valid pointer,
-@code{GPGME_No_Data} if @var{sig} or @var{plain} does not contain any
-data to verify, and passes through any errors that are reported by the
-crypto engine support routines.
+@code{GPGME_No_Data} if @var{sig} does not contain any data to verify,
+and passes through any errors that are reported by the crypto engine
+support routines.
@end deftypefun
@deftypefun GpgmeError gpgme_op_verify_start (@w{GpgmeCtx @var{ctx}}, @w{GpgmeData @var{sig}}, @w{GpgmeData @var{plain}})
+2002-03-03 Marcus Brinkmann <marcus@g10code.de>
+
+ * rungpg.c (_gpgme_gpg_op_verify): If TEXT is of mode
+ GPGME_DATA_MODE_IN, construct a command line that stores the
+ plaintext in TEXT.
+ * verify.c (gpgme_op_verify_start): Accept TEXT being
+ uninitialized, and in this case interpret SIG as a normal or
+ cleartext signature and TEXT as a return data object.
+ * engine-gpgsm.c (_gpgme_gpgsm_op_verify): Likewise.
+
2002-03-03 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_op_keylist_ext) [!ENABLE_GPGSM]:
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, 0);
if (err)
return err;
- gpgsm->message_data = text;
- err = gpgsm_set_fd (gpgsm->assuan_ctx, "MESSAGE", gpgsm->message_fd_server,
- 0);
+ if (_gpgme_data_get_mode (text) == GPGME_DATA_MODE_IN)
+ {
+ /* Normal or cleartext signature. */
+ gpgsm->output_data = text;
+ err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server,
+ 0);
+ }
+ else
+ {
+ /* Detached signature. */
+ gpgsm->message_data = text;
+ err = gpgsm_set_fd (gpgsm->assuan_ctx, "MESSAGE",
+ gpgsm->message_fd_server, 0);
+ }
if (err)
return err;
_gpgme_io_close (gpgsm->output_fd);
{
GpgmeError err = 0;
- if (gpg->pm.used)
+ if (_gpgme_data_get_mode (text) == GPGME_DATA_MODE_IN)
{
- err = _gpgme_gpg_add_arg (gpg, gpg->pm.used ? "--pipemode" : "--verify");
+ /* Normal or cleartext signature. */
+
+ err = _gpgme_gpg_add_arg (gpg, "--output");
if (!err)
- err = _gpgme_gpg_add_arg (gpg, "--");
+ err = _gpgme_gpg_add_arg (gpg, "-");
if (!err)
- err = _gpgme_gpg_add_pm_data (gpg, sig, 0);
+ err = _gpgme_gpg_add_data (gpg, sig, 0);
if (!err)
- err = _gpgme_gpg_add_pm_data (gpg, text, 1);
+ err = _gpgme_gpg_add_data (gpg, text, 1);
}
else
{
- err = _gpgme_gpg_add_arg (gpg, "--verify");
- if (!err)
- err = _gpgme_gpg_add_arg (gpg, "--");
- if (!err)
- err = _gpgme_gpg_add_data (gpg, sig, -1);
- if (text)
+ if (gpg->pm.used)
+ {
+ err = _gpgme_gpg_add_arg (gpg, gpg->pm.used ? "--pipemode" : "--verify");
+ if (!err)
+ err = _gpgme_gpg_add_arg (gpg, "--");
+ if (!err)
+ err = _gpgme_gpg_add_pm_data (gpg, sig, 0);
+ if (!err)
+ err = _gpgme_gpg_add_pm_data (gpg, text, 1);
+ }
+ else
{
+ err = _gpgme_gpg_add_arg (gpg, "--verify");
if (!err)
- err = _gpgme_gpg_add_arg (gpg, "-");
+ err = _gpgme_gpg_add_arg (gpg, "--");
if (!err)
- err = _gpgme_gpg_add_data (gpg, text, 0);
+ err = _gpgme_gpg_add_data (gpg, sig, -1);
+ if (text)
+ {
+ if (!err)
+ err = _gpgme_gpg_add_arg (gpg, "-");
+ if (!err)
+ err = _gpgme_gpg_add_data (gpg, text, 0);
+ }
}
}
return err;
err = mk_error (No_Data);
goto leave;
}
- if (text && gpgme_data_get_type (text) == GPGME_DATA_TYPE_NONE)
+ if (!text)
{
- err = mk_error (No_Data);
+ err = mk_error (Invalid_Value);
goto leave;
}
_gpgme_data_set_mode (sig, GPGME_DATA_MODE_OUT);
- if (text) /* Detached signature. */
+ if (gpgme_data_get_type (text) == GPGME_DATA_TYPE_NONE)
+ /* Normal or cleartext signature. */
+ _gpgme_data_set_mode (text, GPGME_DATA_MODE_IN);
+ else
+ /* Detached signature. */
_gpgme_data_set_mode (text, GPGME_DATA_MODE_OUT);
err = _gpgme_engine_op_verify (ctx->engine, sig, text);
* @text: the signed text
* @r_stat: returns the status of the signature
*
- * Perform a signature check on the signature given in @sig. Currently it is
- * assumed that this is a detached signature for the material given in @text.
+ * Perform a signature check on the signature given in @sig. If @text
+ * is a new and uninitialized data object, it is assumed that @sig
+ * contains a normal or cleartext signature, and the plaintext is
+ * returned in @text upon successful verification.
+ *
+ * If @text is initialized, it is assumed that @sig is a detached
+ * signature for the material given in @text.
+ *
* The result of this operation is returned in @r_stat which can take these
* values:
* GPGME_SIG_STAT_NONE: No status - should not happen
+2002-03-03 Marcus Brinkmann <marcus@g10code.de>
+
+ * gpg/t-verify.c (main): Add a few more sanity checks, and a check
+ for normal signatures.
+
2002-02-26 Marcus Brinkmann <marcus@g10code.de>
* gpg/t-encrypt-sign.c: New file.
"-----END PGP SIGNATURE-----\n"
#endif
;
-
+static const char test_sig2[] =
+"-----BEGIN PGP MESSAGE-----\n"
+"\n"
+"owGbwMvMwCSoW1RzPCOz3IRxjXQSR0lqcYleSUWJTZOvjVdpcYmCu1+oQmaJIleH\n"
+"GwuDIBMDGysTSIqBi1MApi+nlGGuwDeHao53HBr+FoVGP3xX+kvuu9fCMJvl6IOf\n"
+"y1kvP4y+8D5a11ang0udywsA\n"
+"=Crq6\n"
+"-----END PGP MESSAGE-----\n";
#define fail_if_err(a) do { if(a) { \
GpgmeSigStat status;
char *nota;
int n = 0;
+ int i, j;
err = gpgme_new (&ctx);
fail_if_err (err);
puts ("checking a valid message:\n");
err = gpgme_op_verify (ctx, sig, text, &status );
- print_sig_stat ( ctx, status );
- print_sig_stat ( ctx, status );
- print_sig_stat ( ctx, status );
- print_sig_stat ( ctx, status );
fail_if_err (err);
+ print_sig_stat ( ctx, status );
+ if (status != GPGME_SIG_STAT_GOOD)
+ {
+ fprintf (stderr, "%s:%d: Wrong sig stat\n", __FILE__, __LINE__);
+ exit (1);
+ }
if ( (nota=gpgme_get_notation (ctx)) )
printf ("---Begin Notation---\n%s---End Notation---\n", nota );
fail_if_err (err);
gpgme_data_rewind ( sig );
err = gpgme_op_verify (ctx, sig, text, &status );
-
- print_sig_stat ( ctx, status );
fail_if_err (err);
+
+ print_sig_stat (ctx, status);
+ if (status != GPGME_SIG_STAT_BAD)
+ {
+ fprintf (stderr, "%s:%d: Wrong sig stat\n", __FILE__, __LINE__);
+ exit (1);
+ }
if ( (nota=gpgme_get_notation (ctx)) )
printf ("---Begin Notation---\n%s---End Notation---\n", nota );
+ puts ("checking a normal signature:");
gpgme_data_release (sig);
gpgme_data_release (text);
+ err = gpgme_data_new_from_mem (&sig, test_sig2, strlen (test_sig2), 0);
+ fail_if_err (err);
+ err = gpgme_data_new (&text);
+ fail_if_err (err);
+ err = gpgme_op_verify (ctx, sig, text, &status);
+ fail_if_err (err);
+
+ nota = gpgme_data_release_and_get_mem (text, &i);
+ for (j = 0; j < i; j++)
+ putchar (nota[j]);
+ if (strncmp (nota, test_text1, strlen (test_text1)))
+ {
+ fprintf (stderr, "%s:%d: Wrong plaintext\n", __FILE__, __LINE__);
+ exit (1);
+ }
+
+ print_sig_stat (ctx, status);
+ if (status != GPGME_SIG_STAT_GOOD)
+ {
+ fprintf (stderr, "%s:%d: Wrong sig stat\n", __FILE__, __LINE__);
+ exit (1);
+ }
+
+ if ((nota = gpgme_get_notation (ctx)))
+ printf ("---Begin Notation---\n%s---End Notation---\n", nota);
+
+ gpgme_data_release (sig);
} while ( argc > 1 && !strcmp( argv[1], "--loop" ) && ++n < 20 );
gpgme_release (ctx);
return 0;
}
-
-
-