aboutsummaryrefslogtreecommitdiffstats
path: root/gpgme/encrypt.c
diff options
context:
space:
mode:
authorMarcus Brinkmann <[email protected]>2002-03-06 01:40:25 +0000
committerMarcus Brinkmann <[email protected]>2002-03-06 01:40:25 +0000
commit748aa18dc6ca9cb25e534fcf2028fb61fde98318 (patch)
tree773bce7d68f48a235abad473663df6e02c8a65af /gpgme/encrypt.c
parent2002-03-06 Marcus Brinkmann <[email protected]> (diff)
downloadgpgme-748aa18dc6ca9cb25e534fcf2028fb61fde98318.tar.gz
gpgme-748aa18dc6ca9cb25e534fcf2028fb61fde98318.zip
doc/
2002-03-06 Marcus Brinkmann <[email protected]> * gpgme.texi (Encrypting a Plaintext): Document symmetric encryption. gpgme/ 2002-03-06 Marcus Brinkmann <[email protected]> * encrypt.c (_gpgme_encrypt_sym_status_handler): New function. (gpgme_op_encrypt_start): New variable SYMMETRIC, set it if RECP is null, and if it is set, use _gpgme_encrypt_sym_status_handler as status handler and run _gpgme_passphrase_start. * rungpg.c (_gpgme_gpg_op_encrypt): If RECP is zero, do symmetric encryption. * engine-gpgsm.c (_gpgme_gpgsm_op_encrypt): If RECP is zero, return error value. * rungpg.c (_gpgme_gpg_op_verify): Add "--" argument. tests/ 2002-03-06 Marcus Brinkmann <[email protected]> * gpg/t-encrypt-sym.c: New file. * gpg/Makefile.am (TESTS): Add t-encrypt-sym.
Diffstat (limited to '')
-rw-r--r--gpgme/encrypt.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/gpgme/encrypt.c b/gpgme/encrypt.c
index ffaf2d90..0a3970c1 100644
--- a/gpgme/encrypt.c
+++ b/gpgme/encrypt.c
@@ -135,11 +135,19 @@ _gpgme_encrypt_status_handler (GpgmeCtx ctx, GpgStatusCode code, char *args)
}
+void
+_gpgme_encrypt_sym_status_handler (GpgmeCtx ctx, GpgStatusCode code, char *args)
+{
+ _gpgme_passphrase_status_handler (ctx, code, args);
+}
+
+
GpgmeError
gpgme_op_encrypt_start (GpgmeCtx ctx, GpgmeRecipients recp, GpgmeData plain,
GpgmeData ciph)
{
int err = 0;
+ int symmetric = 0;
fail_on_pending_request (ctx);
ctx->pending = 1;
@@ -147,9 +155,10 @@ gpgme_op_encrypt_start (GpgmeCtx ctx, GpgmeRecipients recp, GpgmeData plain,
_gpgme_release_result (ctx);
/* Do some checks. */
- if (!gpgme_recipients_count (recp))
+ if (!recp)
+ symmetric = 1;
+ else if (!gpgme_recipients_count (recp))
{
- /* Fixme: In this case we should do symmentric encryption. */
err = mk_error (No_Recipients);
goto leave;
}
@@ -162,7 +171,17 @@ gpgme_op_encrypt_start (GpgmeCtx ctx, GpgmeRecipients recp, GpgmeData plain,
if (err)
goto leave;
- _gpgme_engine_set_status_handler (ctx->engine, _gpgme_encrypt_status_handler,
+ if (symmetric)
+ {
+ err = _gpgme_passphrase_start (ctx);
+ if (err)
+ goto leave;
+ }
+
+ _gpgme_engine_set_status_handler (ctx->engine,
+ symmetric
+ ? _gpgme_encrypt_sym_status_handler
+ : _gpgme_encrypt_status_handler,
ctx);
_gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity);