diff --git a/tests/ChangeLog b/tests/ChangeLog index c52c9be6..68429cbe 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,12 @@ +2001-12-14 Marcus Brinkmann + + * gpgsm/t-decrypt.c: New file. + * gpgsm/567064FE6D14A17B2D811ABB407728BC558AA455: Likewise. + * gpgsm/Makefile.am (TESTS): Add t-decrypt. + (key_id): New variable. + (all-local): New target ./private-keys-v1.d/$(key_id) added. + (./private-keys-v1.d/$(key_id)): New target. + 2001-12-14 Marcus Brinkmann * gpgsm/t-verify.c: New file. diff --git a/tests/gpgsm/567064FE6D14A17B2D811ABB407728BC558AA455 b/tests/gpgsm/567064FE6D14A17B2D811ABB407728BC558AA455 new file mode 100644 index 00000000..cf0535ff --- /dev/null +++ b/tests/gpgsm/567064FE6D14A17B2D811ABB407728BC558AA455 @@ -0,0 +1,18 @@ +(private-key + (oid.1.2.840.113549.1.1.1 + (n #00e0ce96f90b6c9e02f3922beada93fe50a875eac6bcc18bb9a9cf2e84965caa2d1ff95a7f542465c6c0c19d276e4526ce048868a7a914fd343cc3a87dd74291ffc565506d5bbb25cbac6a0e2dd1f8bcaab0d4a29c2f37c950f363484bf269f7891440464baf79827e03a36e70b814938eebdc63e964247be75dc58b014b7ea251#) + (e #010001#) + (d #046129F2489D71579BE0A75FE029BD6CDB574EBF57EA8A5B0FDA942CAB943B117D7BB95E5D28875E0F9FC5FCC06A72F6D502464DABDED78EF6B716177B83D5BDC543DC5D3FED932E59F5897E92E6F58A0F33424106A3B6FA2CBF877510E4AC21C3EE47851E97D12996222AC3566D4CCB0B83D164074ABF7DE655FC2446DA1781#) + (p #00e861b700e17e8afe6837e7512e35b6ca11d0ae47d8b85161c67baf64377213fe52d772f2035b3ca830af41d8a4120e1c1c70d12cc22f00d28d31dd48a8d424f1#) + (q #00f7a7ca5367c661f8e62df34f0d05c10c88e5492348dd7bddc942c9a8f369f935a07785d2db805215ed786e4285df1658eed3ce84f469b81b50d358407b4ad361#) + (u #304559a9ead56d2309d203811a641bb1a09626bc8eb36fffa23c968ec5bd891eebbafc73ae666e01ba7c8990bae06cc2bbe10b75e69fcacb353a6473079d8e9b#) + ) +) + + + + + + + + diff --git a/tests/gpgsm/Makefile.am b/tests/gpgsm/Makefile.am index bf234a8a..2cabb57f 100644 --- a/tests/gpgsm/Makefile.am +++ b/tests/gpgsm/Makefile.am @@ -23,7 +23,7 @@ GPGSM = @GPGSM@ TESTS_ENVIRONMENT = GNUPGHOME=. -TESTS = t-import t-keylist t-encrypt t-verify +TESTS = t-import t-keylist t-encrypt t-verify t-decrypt EXTRA_DIST = cert_dfn_pca01.der cert_dfn_pca15.der cert_g10code_test1.der @@ -33,7 +33,16 @@ LDADD = ../../gpgme/libgpgme.la noinst_PROGRAMS = $(TESTS) -all-local: ./pubcerts.kbx +key_id := 567064FE6D14A17B2D811ABB407728BC558AA455 + +all-local: ./pubcerts.kbx ./gpg-agent.conf ./private-keys-v1.d/$(key_id) ./pubcerts.kbx: $(srcdir)/cert_g10code_test1.der $(GPGSM) --homedir . --import $(srcdir)/cert_g10code_test1.der + +./gpg-agent.conf: + echo batch > ./gpg-agent.conf + +./private-keys-v1.d/$(key_id): $(srcdir)/$(key_id) + mkdir ./private-keys-v1.d + cp $(srcdir)/$(key_id) private-keys-v1.d diff --git a/tests/gpgsm/t-decrypt.c b/tests/gpgsm/t-decrypt.c new file mode 100644 index 00000000..212fcf8f --- /dev/null +++ b/tests/gpgsm/t-decrypt.c @@ -0,0 +1,103 @@ +/* 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 + */ + +#include +#include +#include +#include +#include + +#include + +static const char test_text1[] = "Hallo Leute!\n"; +static const char test_cip1[] = +"-----BEGIN CMS OBJECT-----\n" +"MIAGCSqGSIb3DQEHA6CAMIACAQAxggEJMIIBBQIBADBwMGsxCzAJBgNVBAYTAkRF\n" +"MRMwEQYDVQQHFApE/HNzZWxkb3JmMRYwFAYDVQQKEw1nMTAgQ29kZSBHbWJIMRkw\n" +"FwYDVQQLExBBZWd5cHRlbiBQcm9qZWN0MRQwEgYDVQQDEwt0ZXN0IGNlcnQgMQIB\n" +"ADALBgkqhkiG9w0BAQEEgYBOFcOfUtAav+XjKGM1RJtF+8JLkbnu46S3T3709Iok\n" +"u+Z9dwpOyfHwxXOmjzkSKQSBBxxi6ar+sKjU/KfPIvaMpARwT+NfIVSCZRWIJ27z\n" +"wbSrav/kcRRDDA0wXV7dHVmSLPUJNCpiFMNZbkYtI+ai15g0PVeDw+szYd9zdsjJ\n" +"2zCABgkqhkiG9w0BBwEwFAYIKoZIhvcNAwcECA8gPQY2NtJToIAECAeoY3MIcz9h\n" +"BAiiytWtOSmqnwAA\n" +"-----END CMS OBJECT-----\n"; + +#define fail_if_err(a) do { if(a) { int my_errno = errno; \ + fprintf (stderr, "%s:%d: GpgmeError %s\n", \ + __FILE__, __LINE__, gpgme_strerror(a)); \ + if ((a) == GPGME_File_Error) \ + fprintf (stderr, "\terrno=`%s'\n", strerror (my_errno)); \ + exit (1); } \ + } while(0) + +static void +print_data ( GpgmeData dh ) +{ + char buf[100]; + size_t nread; + GpgmeError err; + + err = gpgme_data_rewind ( dh ); + fail_if_err (err); + while ( !(err = gpgme_data_read ( dh, buf, 100, &nread )) ) { + fwrite ( buf, nread, 1, stdout ); + } + if (err != GPGME_EOF) + fail_if_err (err); +} + +int +main (int argc, char **argv ) +{ + GpgmeCtx ctx; + GpgmeError err; + GpgmeData in, out, pwdata = NULL; + + do { + 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 ( &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" ) ); + + return 0; +} + +