aboutsummaryrefslogtreecommitdiffstats
path: root/agent/pkdecrypt.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2004-12-20 08:32:56 +0000
committerWerner Koch <[email protected]>2004-12-20 08:32:56 +0000
commit18fd4964f66ab297a5540f38f5dd6fb22b8e4572 (patch)
tree4092463bbba4bd58f3b5deb54dac1984d78a86ef /agent/pkdecrypt.c
parent * query.c (initialize_module_query): New. (diff)
downloadgnupg-18fd4964f66ab297a5540f38f5dd6fb22b8e4572.tar.gz
gnupg-18fd4964f66ab297a5540f38f5dd6fb22b8e4572.zip
* call-scd.c (init_membuf, put_membuf, get_membuf): Removed. We
now use the identical implementation from ../common/membuf.c. * pksign.c (agent_pksign): Changed arg OUTFP to OUTBUF and use membuf functions to return the value. * pkdecrypt.c (agent_pkdecrypt): Ditto. * genkey.c (agent_genkey): Ditto. * command.c (cmd_pksign, cmd_pkdecrypt, cmd_genkey): Replaced assuan_get_data_fp() by a the membuf scheme. (clear_outbuf, write_and_clear_outbuf): New. * membuf.c (put_membuf): Wipe out buffer after a failed realloc.
Diffstat (limited to 'agent/pkdecrypt.c')
-rw-r--r--agent/pkdecrypt.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/agent/pkdecrypt.c b/agent/pkdecrypt.c
index eaa2b2254..7a93e58f8 100644
--- a/agent/pkdecrypt.c
+++ b/agent/pkdecrypt.c
@@ -37,7 +37,7 @@
int
agent_pkdecrypt (CTRL ctrl, const char *desc_text,
const unsigned char *ciphertext, size_t ciphertextlen,
- FILE *outfp)
+ membuf_t *outbuf)
{
gcry_sexp_t s_skey = NULL, s_cipher = NULL, s_plain = NULL;
unsigned char *shadow_info = NULL;
@@ -88,11 +88,16 @@ agent_pkdecrypt (CTRL ctrl, const char *desc_text,
log_error ("smartcard decryption failed: %s\n", gpg_strerror (rc));
goto leave;
}
- /* FIXME: don't use buffering and change the protocol to return
- a complete S-expression and not just a part. */
- fprintf (outfp, "%u:", (unsigned int)len);
- fwrite (buf, 1, len, outfp);
- putc (0, outfp);
+ /* FIXME: Change the protocol to return a complete S-expression
+ and not just a part. */
+ {
+ char tmpbuf[50];
+
+ sprintf (tmpbuf, "%u:", (unsigned int)len);
+ put_membuf (outbuf, tmpbuf, strlen (tmpbuf));
+ put_membuf (outbuf, buf, len);
+ put_membuf (outbuf, "", 1);
+ }
}
else
{ /* No smartcard, but a private key */
@@ -119,10 +124,7 @@ agent_pkdecrypt (CTRL ctrl, const char *desc_text,
buf = xmalloc (len);
len = gcry_sexp_sprint (s_plain, GCRYSEXP_FMT_CANON, buf, len);
assert (len);
- /* FIXME: we must make sure that no buffering takes place or we are
- in full control of the buffer memory (easy to do) - should go
- into assuan. */
- fwrite (buf, 1, len, outfp);
+ put_membuf (outbuf, buf, len);
}