|
Packit Service |
672cf4 |
/* t-verify.c - Regression test.
|
|
Packit Service |
0ef63b |
* Copyright (C) 2000 Werner Koch (dd9jn)
|
|
Packit Service |
0ef63b |
* Copyright (C) 2001, 2002, 2003, 2004 g10 Code GmbH
|
|
Packit Service |
0ef63b |
*
|
|
Packit Service |
0ef63b |
* This file is part of GPGME.
|
|
Packit Service |
0ef63b |
*
|
|
Packit Service |
0ef63b |
* GPGME is free software; you can redistribute it and/or modify it
|
|
Packit Service |
0ef63b |
* under the terms of the GNU Lesser General Public License as
|
|
Packit Service |
0ef63b |
* published by the Free Software Foundation; either version 2.1 of
|
|
Packit Service |
0ef63b |
* the License, or (at your option) any later version.
|
|
Packit Service |
0ef63b |
*
|
|
Packit Service |
0ef63b |
* GPGME is distributed in the hope that it will be useful, but
|
|
Packit Service |
0ef63b |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
0ef63b |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
0ef63b |
* Lesser General Public License for more details.
|
|
Packit Service |
0ef63b |
*
|
|
Packit Service |
0ef63b |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
0ef63b |
* License along with this program; if not, see <https://gnu.org/licenses/>.
|
|
Packit Service |
0ef63b |
* SPDX-License-Identifier: LGPL-2.1-or-later
|
|
Packit Service |
0ef63b |
*/
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
/* We need to include config.h so that we know whether we are building
|
|
Packit Service |
672cf4 |
with large file system (LFS) support. */
|
|
Packit Service |
672cf4 |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
672cf4 |
#include <config.h>
|
|
Packit Service |
672cf4 |
#endif
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
#include <stdlib.h>
|
|
Packit Service |
672cf4 |
#include <stdio.h>
|
|
Packit Service |
672cf4 |
#include <string.h>
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
#include <gpgme.h>
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
0ef63b |
#define PGM "t-verify"
|
|
Packit Service |
672cf4 |
#include "t-support.h"
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
0ef63b |
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
static const char test_text1[] = "Just GNU it!\n";
|
|
Packit Service |
672cf4 |
static const char test_text1f[]= "Just GNU it?\n";
|
|
Packit Service |
672cf4 |
static const char test_sig1[] =
|
|
Packit Service |
672cf4 |
"-----BEGIN PGP SIGNATURE-----\n"
|
|
Packit Service |
672cf4 |
"\n"
|
|
Packit Service |
672cf4 |
"iN0EABECAJ0FAjoS+i9FFIAAAAAAAwA5YmFyw7bDpMO8w58gZGFzIHdhcmVuIFVt\n"
|
|
Packit Service |
672cf4 |
"bGF1dGUgdW5kIGpldHp0IGVpbiBwcm96ZW50JS1aZWljaGVuNRSAAAAAAAgAJGZv\n"
|
|
Packit Service |
672cf4 |
"b2Jhci4xdGhpcyBpcyBhIG5vdGF0aW9uIGRhdGEgd2l0aCAyIGxpbmVzGhpodHRw\n"
|
|
Packit Service |
672cf4 |
"Oi8vd3d3Lmd1Lm9yZy9wb2xpY3kvAAoJEC1yfMdoaXc0JBIAoIiLlUsvpMDOyGEc\n"
|
|
Packit Service |
6c01f9 |
"dADGKXF/Hcb+AKCJWPphZCphduxSvrzH0hgzHdeQaA==\n"
|
|
Packit Service |
6c01f9 |
"=nts1\n"
|
|
Packit Service |
0ef63b |
"-----END PGP SIGNATURE-----\n";
|
|
Packit Service |
0ef63b |
|
|
Packit Service |
0ef63b |
/* The same as test_sig1 but with a second signature for which we do
|
|
Packit Service |
0ef63b |
* not have the public key (deleted after signature creation). */
|
|
Packit Service |
0ef63b |
static const char test_sig1_plus_unknown_key[] =
|
|
Packit Service |
0ef63b |
"-----BEGIN PGP SIGNATURE-----\n"
|
|
Packit Service |
0ef63b |
"\n"
|
|
Packit Service |
0ef63b |
"iN0EABECAJ0FAjoS+i9FFIAAAAAAAwA5YmFyw7bDpMO8w58gZGFzIHdhcmVuIFVt\n"
|
|
Packit Service |
0ef63b |
"bGF1dGUgdW5kIGpldHp0IGVpbiBwcm96ZW50JS1aZWljaGVuNRSAAAAAAAgAJGZv\n"
|
|
Packit Service |
0ef63b |
"b2Jhci4xdGhpcyBpcyBhIG5vdGF0aW9uIGRhdGEgd2l0aCAyIGxpbmVzGhpodHRw\n"
|
|
Packit Service |
0ef63b |
"Oi8vd3d3Lmd1Lm9yZy9wb2xpY3kvAAoJEC1yfMdoaXc0JBIAoIiLlUsvpMDOyGEc\n"
|
|
Packit Service |
0ef63b |
"dADGKXF/Hcb+AKCJWPphZCphduxSvrzH0hgzHdeQaIh1BAAWCAAdFiEENuwqcMZC\n"
|
|
Packit Service |
0ef63b |
"brD85btN+RyY8EnUIEwFAlrPR4cACgkQ+RyY8EnUIEyiuAEAm41LJTGUFDzhavRm\n"
|
|
Packit Service |
0ef63b |
"jNwqUZxGGOySduW+u/X1lEfV+MYA/2lJOo75rHtD1EG+tkFVWt4Ukj0rjhR132vZ\n"
|
|
Packit Service |
0ef63b |
"IOtrYAcG\n"
|
|
Packit Service |
0ef63b |
"=yYwZ\n"
|
|
Packit Service |
0ef63b |
"-----END PGP SIGNATURE-----\n";
|
|
Packit Service |
0ef63b |
|
|
Packit Service |
672cf4 |
static const char test_sig2[] =
|
|
Packit Service |
672cf4 |
"-----BEGIN PGP MESSAGE-----\n"
|
|
Packit Service |
672cf4 |
"\n"
|
|
Packit Service |
672cf4 |
"owGbwMvMwCSoW1RzPCOz3IRxjXQSR0lqcYleSUWJTZOvjVdpcYmCu1+oQmaJIleH\n"
|
|
Packit Service |
672cf4 |
"GwuDIBMDGysTSIqBi1MApi+nlGGuwDeHao53HBr+FoVGP3xX+kvuu9fCMJvl6IOf\n"
|
|
Packit Service |
672cf4 |
"y1kvP4y+8D5a11ang0udywsA\n"
|
|
Packit Service |
672cf4 |
"=Crq6\n"
|
|
Packit Service |
672cf4 |
"-----END PGP MESSAGE-----\n";
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
/* A message with a prepended but unsigned plaintext packet. */
|
|
Packit Service |
672cf4 |
static const char double_plaintext_sig[] =
|
|
Packit Service |
672cf4 |
"-----BEGIN PGP MESSAGE-----\n"
|
|
Packit Service |
672cf4 |
"\n"
|
|
Packit Service |
672cf4 |
"rDRiCmZvb2Jhci50eHRF4pxNVGhpcyBpcyBteSBzbmVha3kgcGxhaW50ZXh0IG1l\n"
|
|
Packit Service |
672cf4 |
"c3NhZ2UKowGbwMvMwCSoW1RzPCOz3IRxTWISa6JebnG666MFD1wzSzJSixQ81XMV\n"
|
|
Packit Service |
672cf4 |
"UlITUxTyixRyKxXKE0uSMxQyEosVikvyCwpSU/S4FNCArq6Ce1F+aXJGvoJvYlGF\n"
|
|
Packit Service |
672cf4 |
"erFCTmJxiUJ5flFKMVeHGwuDIBMDGysTyA4GLk4BmO036xgWzMgzt9V85jCtfDFn\n"
|
|
Packit Service |
672cf4 |
"UqVooWlGXHwNw/xg/fVzt9VNbtjtJ/fhUqYo0/LyCGEA\n"
|
|
Packit Service |
672cf4 |
"=6+AK\n"
|
|
Packit Service |
672cf4 |
"-----END PGP MESSAGE-----\n";
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
0ef63b |
/* NO_OF_SIGS is the expected number of signatures. SKIP_SKIPS is
|
|
Packit Service |
0ef63b |
* which of these signatures to check (0 based). */
|
|
Packit Service |
672cf4 |
static void
|
|
Packit Service |
0ef63b |
check_result (gpgme_verify_result_t result, int no_of_sigs, int skip_sigs,
|
|
Packit Service |
0ef63b |
unsigned int summary, const char *fpr,
|
|
Packit Service |
672cf4 |
gpgme_error_t status, int notation)
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
672cf4 |
gpgme_signature_t sig;
|
|
Packit Service |
0ef63b |
int n;
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
sig = result->signatures;
|
|
Packit Service |
0ef63b |
for (n=0; sig; sig = sig->next)
|
|
Packit Service |
0ef63b |
n++;
|
|
Packit Service |
0ef63b |
if (n != no_of_sigs)
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
0ef63b |
fprintf (stderr, "%s:%i: Unexpected number of signatures"
|
|
Packit Service |
0ef63b |
" (got %d expected %d)\n", PGM, __LINE__, n, no_of_sigs);
|
|
Packit Service |
672cf4 |
exit (1);
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
0ef63b |
if (skip_sigs >= n)
|
|
Packit Service |
0ef63b |
{
|
|
Packit Service |
0ef63b |
fprintf (stderr, "%s:%i: oops SKIPP_SIGS to high\n", PGM, __LINE__);
|
|
Packit Service |
0ef63b |
exit (1);
|
|
Packit Service |
0ef63b |
}
|
|
Packit Service |
0ef63b |
|
|
Packit Service |
0ef63b |
for (n=0, sig = result->signatures; n < skip_sigs; sig = sig->next, n++)
|
|
Packit Service |
0ef63b |
;
|
|
Packit Service |
0ef63b |
|
|
Packit Service |
672cf4 |
if (sig->summary != summary)
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
0ef63b |
fprintf (stderr, "%s:%i:sig-%d: Unexpected signature summary: "
|
|
Packit Service |
672cf4 |
"want=0x%x have=0x%x\n",
|
|
Packit Service |
0ef63b |
PGM, __LINE__, skip_sigs, summary, sig->summary);
|
|
Packit Service |
672cf4 |
exit (1);
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
if (strcmp (sig->fpr, fpr))
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
0ef63b |
if (strlen (sig->fpr) == 16 && strlen (fpr) == 40
|
|
Packit Service |
0ef63b |
&& !strncmp (sig->fpr, fpr + 24, 16))
|
|
Packit Service |
0ef63b |
; /* okay because gnupg < 2.2.6 only shows the keyid. */
|
|
Packit Service |
0ef63b |
else
|
|
Packit Service |
0ef63b |
{
|
|
Packit Service |
0ef63b |
fprintf (stderr, "%s:%i:sig-%d: Unexpected fingerprint: %s\n",
|
|
Packit Service |
0ef63b |
PGM, __LINE__, skip_sigs, sig->fpr);
|
|
Packit Service |
0ef63b |
exit (1);
|
|
Packit Service |
0ef63b |
}
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
if (gpgme_err_code (sig->status) != status)
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
0ef63b |
fprintf (stderr, "%s:%i:sig-%d: Unexpected signature status: %s\n",
|
|
Packit Service |
0ef63b |
PGM, __LINE__, skip_sigs, gpgme_strerror (sig->status));
|
|
Packit Service |
672cf4 |
exit (1);
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
if (notation)
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
672cf4 |
static struct {
|
|
Packit Service |
672cf4 |
const char *name;
|
|
Packit Service |
672cf4 |
const char *value;
|
|
Packit Service |
672cf4 |
int seen;
|
|
Packit Service |
672cf4 |
} expected_notations[] = {
|
|
Packit Service |
672cf4 |
{ "bar",
|
|
Packit Service |
672cf4 |
"\xc3\xb6\xc3\xa4\xc3\xbc\xc3\x9f"
|
|
Packit Service |
672cf4 |
" das waren Umlaute und jetzt ein prozent%-Zeichen" },
|
|
Packit Service |
672cf4 |
{ "foobar.1",
|
|
Packit Service |
672cf4 |
"this is a notation data with 2 lines" },
|
|
Packit Service |
672cf4 |
{ NULL,
|
|
Packit Service |
672cf4 |
"http://www.gu.org/policy/" }
|
|
Packit Service |
672cf4 |
};
|
|
Packit Service |
672cf4 |
int i;
|
|
Packit Service |
672cf4 |
gpgme_sig_notation_t r;
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
for (i=0; i < DIM(expected_notations); i++ )
|
|
Packit Service |
672cf4 |
expected_notations[i].seen = 0;
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
for (r = sig->notations; r; r = r->next)
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
672cf4 |
int any = 0;
|
|
Packit Service |
672cf4 |
for (i=0; i < DIM(expected_notations); i++)
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
672cf4 |
if ( ((r->name && expected_notations[i].name
|
|
Packit Service |
672cf4 |
&& !strcmp (r->name, expected_notations[i].name)
|
|
Packit Service |
672cf4 |
&& r->name_len
|
|
Packit Service |
672cf4 |
== strlen (expected_notations[i].name))
|
|
Packit Service |
672cf4 |
|| (!r->name && !expected_notations[i].name
|
|
Packit Service |
672cf4 |
&& r->name_len == 0))
|
|
Packit Service |
672cf4 |
&& r->value
|
|
Packit Service |
672cf4 |
&& !strcmp (r->value, expected_notations[i].value)
|
|
Packit Service |
672cf4 |
&& r->value_len == strlen (expected_notations[i].value))
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
672cf4 |
expected_notations[i].seen++;
|
|
Packit Service |
672cf4 |
any++;
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
if (!any)
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
0ef63b |
fprintf (stderr, "%s:%i:sig-%d: Unexpected notation data\n",
|
|
Packit Service |
0ef63b |
PGM, __LINE__, skip_sigs);
|
|
Packit Service |
672cf4 |
exit (1);
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
for (i=0; i < DIM(expected_notations); i++ )
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
672cf4 |
if (expected_notations[i].seen != 1)
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
0ef63b |
fprintf (stderr, "%s:%i:sig-%d: "
|
|
Packit Service |
0ef63b |
"Missing or duplicate notation data\n",
|
|
Packit Service |
0ef63b |
PGM, __LINE__, skip_sigs);
|
|
Packit Service |
672cf4 |
exit (1);
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
if (sig->wrong_key_usage)
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
0ef63b |
fprintf (stderr, "%s:%i:sig-%d: Unexpectedly wrong key usage\n",
|
|
Packit Service |
0ef63b |
PGM, __LINE__, skip_sigs);
|
|
Packit Service |
672cf4 |
exit (1);
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
if (sig->validity != GPGME_VALIDITY_UNKNOWN)
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
0ef63b |
fprintf (stderr, "%s:%i:sig-%d: Unexpected validity: %i\n",
|
|
Packit Service |
0ef63b |
PGM, __LINE__, skip_sigs, sig->validity);
|
|
Packit Service |
672cf4 |
exit (1);
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
if (gpgme_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR)
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
0ef63b |
fprintf (stderr, "%s:%i:sig-%d: Unexpected validity reason: %s\n",
|
|
Packit Service |
0ef63b |
PGM, __LINE__, skip_sigs,
|
|
Packit Service |
0ef63b |
gpgme_strerror (sig->validity_reason));
|
|
Packit Service |
672cf4 |
exit (1);
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
int
|
|
Packit Service |
672cf4 |
main (int argc, char *argv[])
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
672cf4 |
gpgme_ctx_t ctx;
|
|
Packit Service |
672cf4 |
gpgme_error_t err;
|
|
Packit Service |
672cf4 |
gpgme_data_t sig, text;
|
|
Packit Service |
672cf4 |
gpgme_verify_result_t result;
|
|
Packit Service |
672cf4 |
const char *s;
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
(void)argc;
|
|
Packit Service |
672cf4 |
(void)argv;
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
init_gpgme (GPGME_PROTOCOL_OpenPGP);
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
err = gpgme_new (&ctx;;
|
|
Packit Service |
672cf4 |
fail_if_err (err);
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
/* Checking a valid message. */
|
|
Packit Service |
672cf4 |
err = gpgme_data_new_from_mem (&text, test_text1, strlen (test_text1), 0);
|
|
Packit Service |
672cf4 |
fail_if_err (err);
|
|
Packit Service |
672cf4 |
err = gpgme_data_new_from_mem (&sig, test_sig1, strlen (test_sig1), 0);
|
|
Packit Service |
672cf4 |
fail_if_err (err);
|
|
Packit Service |
672cf4 |
err = gpgme_op_verify (ctx, sig, text, NULL);
|
|
Packit Service |
672cf4 |
fail_if_err (err);
|
|
Packit Service |
672cf4 |
result = gpgme_op_verify_result (ctx);
|
|
Packit Service |
0ef63b |
check_result (result, 1, 0, 0, "A0FF4590BB6122EDEF6E3C542D727CC768697734",
|
|
Packit Service |
672cf4 |
GPG_ERR_NO_ERROR, 1);
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
/* Checking a manipulated message. */
|
|
Packit Service |
672cf4 |
gpgme_data_release (text);
|
|
Packit Service |
672cf4 |
err = gpgme_data_new_from_mem (&text, test_text1f, strlen (test_text1f), 0);
|
|
Packit Service |
672cf4 |
fail_if_err (err);
|
|
Packit Service |
672cf4 |
gpgme_data_seek (sig, 0, SEEK_SET);
|
|
Packit Service |
672cf4 |
err = gpgme_op_verify (ctx, sig, text, NULL);
|
|
Packit Service |
672cf4 |
fail_if_err (err);
|
|
Packit Service |
672cf4 |
result = gpgme_op_verify_result (ctx);
|
|
Packit Service |
0ef63b |
check_result (result, 1, 0, GPGME_SIGSUM_RED, "2D727CC768697734",
|
|
Packit Service |
672cf4 |
GPG_ERR_BAD_SIGNATURE, 0);
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
0ef63b |
/* Checking a valid message. Bu that one has a second signature
|
|
Packit Service |
0ef63b |
* made by an unknown key. */
|
|
Packit Service |
0ef63b |
gpgme_data_release (text);
|
|
Packit Service |
0ef63b |
gpgme_data_release (sig);
|
|
Packit Service |
0ef63b |
err = gpgme_data_new_from_mem (&text, test_text1, strlen (test_text1), 0);
|
|
Packit Service |
0ef63b |
fail_if_err (err);
|
|
Packit Service |
0ef63b |
err = gpgme_data_new_from_mem (&sig, test_sig1_plus_unknown_key,
|
|
Packit Service |
0ef63b |
strlen (test_sig1_plus_unknown_key), 0);
|
|
Packit Service |
0ef63b |
fail_if_err (err);
|
|
Packit Service |
0ef63b |
err = gpgme_op_verify (ctx, sig, text, NULL);
|
|
Packit Service |
0ef63b |
fail_if_err (err);
|
|
Packit Service |
0ef63b |
result = gpgme_op_verify_result (ctx);
|
|
Packit Service |
0ef63b |
check_result (result, 2, 0, 0,
|
|
Packit Service |
0ef63b |
"A0FF4590BB6122EDEF6E3C542D727CC768697734",
|
|
Packit Service |
0ef63b |
GPG_ERR_NO_ERROR, 1);
|
|
Packit Service |
0ef63b |
check_result (result, 2, 1, GPGME_SIGSUM_KEY_MISSING,
|
|
Packit Service |
0ef63b |
"36EC2A70C6426EB0FCE5BB4DF91C98F049D4204C",
|
|
Packit Service |
0ef63b |
GPG_ERR_NO_PUBKEY, 0);
|
|
Packit Service |
0ef63b |
|
|
Packit Service |
0ef63b |
|
|
Packit Service |
672cf4 |
/* Checking a normal signature. */
|
|
Packit Service |
672cf4 |
gpgme_data_release (sig);
|
|
Packit Service |
672cf4 |
gpgme_data_release (text);
|
|
Packit Service |
672cf4 |
err = gpgme_data_new_from_mem (&sig, test_sig2, strlen (test_sig2), 0);
|
|
Packit Service |
672cf4 |
fail_if_err (err);
|
|
Packit Service |
672cf4 |
err = gpgme_data_new (&text);
|
|
Packit Service |
672cf4 |
fail_if_err (err);
|
|
Packit Service |
672cf4 |
err = gpgme_op_verify (ctx, sig, NULL, text);
|
|
Packit Service |
672cf4 |
fail_if_err (err);
|
|
Packit Service |
672cf4 |
result = gpgme_op_verify_result (ctx);
|
|
Packit Service |
0ef63b |
check_result (result, 1, 0, 0, "A0FF4590BB6122EDEF6E3C542D727CC768697734",
|
|
Packit Service |
672cf4 |
GPG_ERR_NO_ERROR, 0);
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
/* Checking an invalid message. */
|
|
Packit Service |
672cf4 |
gpgme_data_release (sig);
|
|
Packit Service |
672cf4 |
gpgme_data_release (text);
|
|
Packit Service |
672cf4 |
err = gpgme_data_new_from_mem (&sig, double_plaintext_sig,
|
|
Packit Service |
672cf4 |
strlen (double_plaintext_sig), 0);
|
|
Packit Service |
672cf4 |
fail_if_err (err);
|
|
Packit Service |
672cf4 |
err = gpgme_data_new (&text);
|
|
Packit Service |
672cf4 |
fail_if_err (err);
|
|
Packit Service |
672cf4 |
err = gpgme_op_verify (ctx, sig, NULL, text);
|
|
Packit Service |
672cf4 |
if (gpgme_err_code (err) != GPG_ERR_BAD_DATA)
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
672cf4 |
fprintf (stderr, "%s:%i: Double plaintext message not detected\n",
|
|
Packit Service |
0ef63b |
PGM, __LINE__);
|
|
Packit Service |
672cf4 |
exit (1);
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
/* Checking that set/get_sernder works. */
|
|
Packit Service |
672cf4 |
err = gpgme_set_sender (ctx, "foo@example.org");
|
|
Packit Service |
672cf4 |
fail_if_err (err);
|
|
Packit Service |
672cf4 |
s = gpgme_get_sender (ctx);
|
|
Packit Service |
672cf4 |
if (!s || strcmp (s, "foo@example.org"))
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
672cf4 |
fprintf (stderr, "%s:%i: gpgme_{set,get}_sender mismatch\n",
|
|
Packit Service |
0ef63b |
PGM, __LINE__);
|
|
Packit Service |
672cf4 |
exit (1);
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
err = gpgme_set_sender (ctx, "<bar@example.org>");
|
|
Packit Service |
672cf4 |
fail_if_err (err);
|
|
Packit Service |
672cf4 |
s = gpgme_get_sender (ctx);
|
|
Packit Service |
672cf4 |
if (!s || strcmp (s, "bar@example.org"))
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
672cf4 |
fprintf (stderr, "%s:%i: gpgme_{set,get}_sender mismatch\n",
|
|
Packit Service |
0ef63b |
PGM, __LINE__);
|
|
Packit Service |
672cf4 |
exit (1);
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
err = gpgme_set_sender (ctx, "Foo bar (comment) <foo@example.org>");
|
|
Packit Service |
672cf4 |
fail_if_err (err);
|
|
Packit Service |
672cf4 |
s = gpgme_get_sender (ctx);
|
|
Packit Service |
672cf4 |
if (!s || strcmp (s, "foo@example.org"))
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
672cf4 |
fprintf (stderr, "%s:%i: gpgme_{set,get}_sender mismatch\n",
|
|
Packit Service |
0ef63b |
PGM, __LINE__);
|
|
Packit Service |
672cf4 |
exit (1);
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
err = gpgme_set_sender (ctx, "foo");
|
|
Packit Service |
672cf4 |
if (gpgme_err_code (err) != GPG_ERR_INV_VALUE)
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
672cf4 |
fprintf (stderr, "%s:%i: gpgme_set_sender didn't detect bogus address\n",
|
|
Packit Service |
0ef63b |
PGM, __LINE__);
|
|
Packit Service |
672cf4 |
exit (1);
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
/* (the former address should still be there.) */
|
|
Packit Service |
672cf4 |
s = gpgme_get_sender (ctx);
|
|
Packit Service |
672cf4 |
if (!s || strcmp (s, "foo@example.org"))
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
672cf4 |
fprintf (stderr, "%s:%i: gpgme_{set,get}_sender mismatch\n",
|
|
Packit Service |
0ef63b |
PGM, __LINE__);
|
|
Packit Service |
672cf4 |
exit (1);
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
gpgme_data_release (sig);
|
|
Packit Service |
672cf4 |
gpgme_data_release (text);
|
|
Packit Service |
672cf4 |
gpgme_release (ctx);
|
|
Packit Service |
672cf4 |
return 0;
|
|
Packit Service |
672cf4 |
}
|