2003-04-28 Marcus Brinkmann <marcus@g10code.de>
* gpgsm/t-decrypt.c (main): Rewritten.
This commit is contained in:
parent
174e293252
commit
16c4687a9c
@ -1,5 +1,7 @@
|
|||||||
2003-04-28 Marcus Brinkmann <marcus@g10code.de>
|
2003-04-28 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* gpgsm/t-decrypt.c (main): Rewritten.
|
||||||
|
|
||||||
* gpg/t-decrypt.c: Rewritten.
|
* gpg/t-decrypt.c: Rewritten.
|
||||||
|
|
||||||
* gpg/t-signers.c: Rewritten.
|
* gpg/t-signers.c: Rewritten.
|
||||||
|
@ -1,32 +1,31 @@
|
|||||||
/* t-encrypt.c - regression test
|
/* t-encrypt.c - Regression test.
|
||||||
* Copyright (C) 2000 Werner Koch (dd9jn)
|
Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
* Copyright (C) 2001 g10 Code GmbH
|
Copyright (C) 2001, 2003 g10 Code GmbH
|
||||||
*
|
|
||||||
* This file is part of GPGME.
|
This file is part of GPGME.
|
||||||
*
|
|
||||||
* GPGME is free software; you can redistribute it and/or modify
|
GPGME is free software; you can redistribute it and/or modify it
|
||||||
* it under the terms of the GNU General Public License as published by
|
under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
(at your option) any later version.
|
||||||
*
|
|
||||||
* GPGME is distributed in the hope that it will be useful,
|
GPGME is distributed in the hope that it will be useful, but
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* GNU General Public License for more details.
|
General Public License for more details.
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
along with GPGME; if not, write to the Free Software Foundation,
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <gpgme.h>
|
#include <gpgme.h>
|
||||||
|
|
||||||
|
|
||||||
static const char test_text1[] = "Hallo Leute!\n";
|
static const char test_text1[] = "Hallo Leute!\n";
|
||||||
static const char test_cip1[] =
|
static const char test_cip1[] =
|
||||||
"-----BEGIN CMS OBJECT-----\n"
|
"-----BEGIN CMS OBJECT-----\n"
|
||||||
@ -51,13 +50,14 @@ static const char test_cip1[] =
|
|||||||
static void
|
static void
|
||||||
print_data (GpgmeData dh)
|
print_data (GpgmeData dh)
|
||||||
{
|
{
|
||||||
char buf[100];
|
#define BUF_SIZE 512
|
||||||
|
char buf[BUF_SIZE + 1];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||||
if (ret)
|
if (ret)
|
||||||
fail_if_err (GPGME_File_Error);
|
fail_if_err (GPGME_File_Error);
|
||||||
while ((ret = gpgme_data_read (dh, buf, 100)) > 0)
|
while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0)
|
||||||
fwrite (buf, ret, 1, stdout);
|
fwrite (buf, ret, 1, stdout);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
fail_if_err (GPGME_File_Error);
|
fail_if_err (GPGME_File_Error);
|
||||||
@ -65,39 +65,38 @@ print_data (GpgmeData dh)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv )
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
GpgmeCtx ctx;
|
GpgmeCtx ctx;
|
||||||
GpgmeError err;
|
GpgmeError err;
|
||||||
GpgmeData in, out, pwdata = NULL;
|
GpgmeData in, out;
|
||||||
|
GpgmeDecryptResult result;
|
||||||
|
|
||||||
do {
|
err = gpgme_new (&ctx);
|
||||||
err = gpgme_new (&ctx);
|
fail_if_err (err);
|
||||||
fail_if_err (err);
|
gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
|
||||||
gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
|
|
||||||
|
|
||||||
err = gpgme_data_new_from_mem ( &in,
|
err = gpgme_data_new_from_mem (&in, test_cip1, strlen (test_cip1), 0);
|
||||||
test_cip1, strlen (test_cip1), 0 );
|
fail_if_err (err);
|
||||||
fail_if_err (err);
|
|
||||||
|
|
||||||
err = gpgme_data_new ( &out );
|
err = gpgme_data_new (&out);
|
||||||
fail_if_err (err);
|
fail_if_err (err);
|
||||||
|
|
||||||
err = gpgme_op_decrypt (ctx, in, out );
|
err = gpgme_op_decrypt (ctx, in, out);
|
||||||
fail_if_err (err);
|
fail_if_err (err);
|
||||||
|
result = gpgme_op_decrypt_result (ctx);
|
||||||
fflush (NULL);
|
if (result->unsupported_algorithm)
|
||||||
fputs ("Begin Result:\n", stdout );
|
{
|
||||||
print_data (out);
|
fprintf (stderr, "%s:%i: unsupported algorithm: %s\n",
|
||||||
fputs ("End Result.\n", stdout );
|
__FILE__, __LINE__, result->unsupported_algorithm);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
print_data (out);
|
||||||
|
|
||||||
gpgme_data_release (in);
|
gpgme_data_release (in);
|
||||||
gpgme_data_release (out);
|
gpgme_data_release (out);
|
||||||
gpgme_data_release (pwdata);
|
gpgme_release (ctx);
|
||||||
gpgme_release (ctx);
|
return 0;
|
||||||
} while ( argc > 1 && !strcmp( argv[1], "--loop" ) );
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* t-import.c - regression test
|
/* t-import.c - Regression test.
|
||||||
Copyright (C) 2000 Werner Koch (dd9jn)
|
Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
Copyright (C) 2001, 2003 g10 Code GmbH
|
Copyright (C) 2001, 2003 g10 Code GmbH
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user