|
Packit |
d7e8d0 |
/* t-decrypt.c - Regression test.
|
|
Packit |
d7e8d0 |
Copyright (C) 2000 Werner Koch (dd9jn)
|
|
Packit |
d7e8d0 |
Copyright (C) 2001, 2003, 2004 g10 Code GmbH
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
This file is part of GPGME.
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
GPGME is free software; you can redistribute it and/or modify it
|
|
Packit |
d7e8d0 |
under the terms of the GNU Lesser General Public License as
|
|
Packit |
d7e8d0 |
published by the Free Software Foundation; either version 2.1 of
|
|
Packit |
d7e8d0 |
the License, or (at your option) any later version.
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
GPGME is distributed in the hope that it will be useful, but
|
|
Packit |
d7e8d0 |
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
d7e8d0 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
d7e8d0 |
Lesser General Public License for more details.
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
d7e8d0 |
License along with this program; if not, write to the Free Software
|
|
Packit |
d7e8d0 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
Packit |
d7e8d0 |
02111-1307, USA. */
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/* We need to include config.h so that we know whether we are building
|
|
Packit |
d7e8d0 |
with large file system (LFS) support. */
|
|
Packit |
d7e8d0 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
d7e8d0 |
#include <config.h>
|
|
Packit |
d7e8d0 |
#endif
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#include <stdlib.h>
|
|
Packit |
d7e8d0 |
#include <stdio.h>
|
|
Packit |
d7e8d0 |
#include <string.h>
|
|
Packit |
d7e8d0 |
#include <errno.h>
|
|
Packit |
d7e8d0 |
#include <unistd.h>
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#include <gpgme.h>
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#include "t-support.h"
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
int
|
|
Packit |
d7e8d0 |
main (int argc, char *argv[])
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
gpgme_ctx_t ctx;
|
|
Packit |
d7e8d0 |
gpgme_error_t err;
|
|
Packit |
d7e8d0 |
gpgme_data_t in, out;
|
|
Packit |
d7e8d0 |
gpgme_decrypt_result_t result;
|
|
Packit |
d7e8d0 |
char *cipher_1_asc = make_filename ("cipher-1.asc");
|
|
Packit |
d7e8d0 |
char *agent_info;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
(void)argc;
|
|
Packit |
d7e8d0 |
(void)argv;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
init_gpgme (GPGME_PROTOCOL_OpenPGP);
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
err = gpgme_new (&ctx;;
|
|
Packit |
d7e8d0 |
fail_if_err (err);
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
agent_info = getenv("GPG_AGENT_INFO");
|
|
Packit |
d7e8d0 |
if (!(agent_info && strchr (agent_info, ':')))
|
|
Packit |
d7e8d0 |
gpgme_set_passphrase_cb (ctx, passphrase_cb, NULL);
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
err = gpgme_data_new_from_file (&in, cipher_1_asc, 1);
|
|
Packit |
d7e8d0 |
free (cipher_1_asc);
|
|
Packit |
d7e8d0 |
fail_if_err (err);
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
err = gpgme_data_new (&out;;
|
|
Packit |
d7e8d0 |
fail_if_err (err);
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
err = gpgme_op_decrypt (ctx, in, out);
|
|
Packit |
d7e8d0 |
fail_if_err (err);
|
|
Packit |
d7e8d0 |
result = gpgme_op_decrypt_result (ctx);
|
|
Packit |
d7e8d0 |
if (result->unsupported_algorithm)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
fprintf (stderr, "%s:%i: unsupported algorithm: %s\n",
|
|
Packit |
d7e8d0 |
__FILE__, __LINE__, result->unsupported_algorithm);
|
|
Packit |
d7e8d0 |
exit (1);
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
print_data (out);
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
gpgme_data_release (in);
|
|
Packit |
d7e8d0 |
gpgme_data_release (out);
|
|
Packit |
d7e8d0 |
gpgme_release (ctx);
|
|
Packit |
d7e8d0 |
return 0;
|
|
Packit |
d7e8d0 |
}
|