1 /* decrypt-verify.c - Decrypt and verify function.
2 Copyright (C) 2000 Werner Koch (dd9jn)
3 Copyright (C) 2001, 2002, 2003, 2004 g10 Code GmbH
5 This file is part of GPGME.
7 GPGME is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of
10 the License, or (at your option) any later version.
12 GPGME is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
32 decrypt_verify_status_handler (void *priv, gpgme_status_code_t code,
37 err = _gpgme_progress_status_handler (priv, code, args);
39 err = _gpgme_decrypt_status_handler (priv, code, args);
41 err = _gpgme_verify_status_handler (priv, code, args);
47 decrypt_verify_start (gpgme_ctx_t ctx, int synchronous,
48 gpgme_data_t cipher, gpgme_data_t plain)
52 err = _gpgme_op_reset (ctx, synchronous);
56 err = _gpgme_op_decrypt_init_result (ctx);
60 err = _gpgme_op_verify_init_result (ctx);
65 return gpg_error (GPG_ERR_NO_DATA);
67 return gpg_error (GPG_ERR_INV_VALUE);
69 if (ctx->passphrase_cb)
71 err = _gpgme_engine_set_command_handler
72 (ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
77 _gpgme_engine_set_status_handler (ctx->engine,
78 decrypt_verify_status_handler, ctx);
80 return _gpgme_engine_op_decrypt_verify (ctx->engine, cipher, plain,
81 ctx->export_session_keys,
82 ctx->override_session_key);
86 /* Decrypt ciphertext CIPHER and make a signature verification within
87 CTX and store the resulting plaintext in PLAIN. */
89 gpgme_op_decrypt_verify_start (gpgme_ctx_t ctx, gpgme_data_t cipher,
94 TRACE_BEG2 (DEBUG_CTX, "gpgme_op_decrypt_verify_start", ctx,
95 "cipher=%p, plain=%p", cipher, plain);
98 return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
100 err = decrypt_verify_start (ctx, 0, cipher, plain);
101 return TRACE_ERR (err);
105 /* Decrypt ciphertext CIPHER and make a signature verification within
106 CTX and store the resulting plaintext in PLAIN. */
108 gpgme_op_decrypt_verify (gpgme_ctx_t ctx, gpgme_data_t cipher,
113 TRACE_BEG2 (DEBUG_CTX, "gpgme_op_decrypt_verify", ctx,
114 "cipher=%p, plain=%p", cipher, plain);
117 return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
119 err = decrypt_verify_start (ctx, 1, cipher, plain);
121 err = _gpgme_wait_one (ctx);
122 return TRACE_ERR (err);