aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcus Brinkmann <[email protected]>2003-04-28 21:28:22 +0000
committerMarcus Brinkmann <[email protected]>2003-04-28 21:28:22 +0000
commit16c4687a9c9c104ef8bc6e1e5bd7cb449dd1f4b7 (patch)
treeffc17f7dd78ec04514d2df367f51a00a266957ca
parentdoc/ (diff)
downloadgpgme-16c4687a9c9c104ef8bc6e1e5bd7cb449dd1f4b7.tar.gz
gpgme-16c4687a9c9c104ef8bc6e1e5bd7cb449dd1f4b7.zip
2003-04-28 Marcus Brinkmann <[email protected]>
* gpgsm/t-decrypt.c (main): Rewritten.
Diffstat (limited to '')
-rw-r--r--tests/ChangeLog2
-rw-r--r--tests/gpgsm/t-decrypt.c101
-rw-r--r--tests/gpgsm/t-import.c2
3 files changed, 53 insertions, 52 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 4c24f9c4..11cd38cf 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,5 +1,7 @@
2003-04-28 Marcus Brinkmann <[email protected]>
+ * gpgsm/t-decrypt.c (main): Rewritten.
+
* gpg/t-decrypt.c: Rewritten.
* gpg/t-signers.c: Rewritten.
diff --git a/tests/gpgsm/t-decrypt.c b/tests/gpgsm/t-decrypt.c
index 7b8e186b..499d82e3 100644
--- a/tests/gpgsm/t-decrypt.c
+++ b/tests/gpgsm/t-decrypt.c
@@ -1,32 +1,31 @@
-/* t-encrypt.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
- */
+/* t-encrypt.c - Regression test.
+ Copyright (C) 2000 Werner Koch (dd9jn)
+ Copyright (C) 2001, 2003 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 <stdio.h>
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
-#include <assert.h>
#include <errno.h>
#include <gpgme.h>
+
static const char test_text1[] = "Hallo Leute!\n";
static const char test_cip1[] =
"-----BEGIN CMS OBJECT-----\n"
@@ -51,13 +50,14 @@ static const char test_cip1[] =
static void
print_data (GpgmeData dh)
{
- char buf[100];
+#define BUF_SIZE 512
+ char buf[BUF_SIZE + 1];
int ret;
ret = gpgme_data_seek (dh, 0, SEEK_SET);
if (ret)
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);
if (ret < 0)
fail_if_err (GPGME_File_Error);
@@ -65,39 +65,38 @@ print_data (GpgmeData dh)
int
-main (int argc, char **argv )
+main (int argc, char *argv[])
{
- GpgmeCtx ctx;
- GpgmeError err;
- GpgmeData in, out, pwdata = NULL;
+ GpgmeCtx ctx;
+ GpgmeError err;
+ GpgmeData in, out;
+ GpgmeDecryptResult result;
- do {
- err = gpgme_new (&ctx);
- fail_if_err (err);
- gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
+ err = gpgme_new (&ctx);
+ fail_if_err (err);
+ gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
- err = gpgme_data_new_from_mem ( &in,
- test_cip1, strlen (test_cip1), 0 );
- fail_if_err (err);
+ err = gpgme_data_new_from_mem (&in, test_cip1, strlen (test_cip1), 0);
+ fail_if_err (err);
- err = gpgme_data_new ( &out );
- fail_if_err (err);
+ err = gpgme_data_new (&out);
+ fail_if_err (err);
- err = gpgme_op_decrypt (ctx, in, out );
- fail_if_err (err);
-
- fflush (NULL);
- fputs ("Begin Result:\n", stdout );
- print_data (out);
- fputs ("End Result.\n", stdout );
-
- gpgme_data_release (in);
- gpgme_data_release (out);
- gpgme_data_release (pwdata);
- gpgme_release (ctx);
- } while ( argc > 1 && !strcmp( argv[1], "--loop" ) );
+ err = gpgme_op_decrypt (ctx, in, out);
+ fail_if_err (err);
+ result = gpgme_op_decrypt_result (ctx);
+ if (result->unsupported_algorithm)
+ {
+ fprintf (stderr, "%s:%i: unsupported algorithm: %s\n",
+ __FILE__, __LINE__, result->unsupported_algorithm);
+ exit (1);
+ }
+ print_data (out);
- return 0;
+ gpgme_data_release (in);
+ gpgme_data_release (out);
+ gpgme_release (ctx);
+ return 0;
}
diff --git a/tests/gpgsm/t-import.c b/tests/gpgsm/t-import.c
index 332b0407..219ce95b 100644
--- a/tests/gpgsm/t-import.c
+++ b/tests/gpgsm/t-import.c
@@ -1,4 +1,4 @@
-/* t-import.c - regression test
+/* t-import.c - Regression test.
Copyright (C) 2000 Werner Koch (dd9jn)
Copyright (C) 2001, 2003 g10 Code GmbH