aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.h
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2021-06-14 17:51:28 +0000
committerWerner Koch <[email protected]>2021-06-14 17:51:28 +0000
commitfde20940b5ca6986dc12215209e8858601bb0c2e (patch)
treec6f91404915bac0ccd6308fa8cce7c0c50bd68aa /src/data.h
parentcore: Also detect AuthEnvelopedData (AEAD for CMS) (diff)
downloadgpgme-fde20940b5ca6986dc12215209e8858601bb0c2e.tar.gz
gpgme-fde20940b5ca6986dc12215209e8858601bb0c2e.zip
core: New data flags "io-buffer-size" and "sensitive".
* src/data.c (_gpgme_data_release): Free buffers. (gpgme_data_seek): Adjust from renamed fields. (gpgme_data_set_flag): Implement new flags. (_gpgme_data_inbound_handler): Allow the use of a malloced buffer. (_gpgme_data_outbound_handler): Ditto. * src/data.h (BUFFER_SIZE): Move out of the struct definition. (struct gpgme_data): Remove pending filed and introduce inbound and outbound fields. * src/conversion.c (_gpgme_wipememory): New. Taken from GnuPG. * src/cJSON.c (wipememory): Use this here too. * tests/run-decrypt.c (main): Add options "--large-buffers" and "--sensitive". -- GnuPG-bug-id: 5478 Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'src/data.h')
-rw-r--r--src/data.h53
1 files changed, 37 insertions, 16 deletions
diff --git a/src/data.h b/src/data.h
index 90e0a883..648d976f 100644
--- a/src/data.h
+++ b/src/data.h
@@ -33,6 +33,22 @@
#include "gpgme.h"
+/* Figure out the standard size for internal data buffers. */
+#ifdef PIPE_BUF
+# define BUFFER_SIZE PIPE_BUF
+#else
+# ifdef _POSIX_PIPE_BUF
+# define BUFFER_SIZE _POSIX_PIPE_BUF
+# else
+# ifdef HAVE_W32_SYSTEM
+# define BUFFER_SIZE 4096
+# else
+# define BUFFER_SIZE 512
+# endif
+# endif
+#endif
+
+
/* Read up to SIZE bytes into buffer BUFFER from the data object with
the handle DH. Return the number of characters read, 0 on EOF and
@@ -76,28 +92,33 @@ struct gpgme_data
gpgme_data_encoding_t encoding;
unsigned int propidx; /* Index into the property table. */
-#ifdef PIPE_BUF
-#define BUFFER_SIZE PIPE_BUF
-#else
-#ifdef _POSIX_PIPE_BUF
-#define BUFFER_SIZE _POSIX_PIPE_BUF
-#else
-#ifdef HAVE_W32_SYSTEM
-#define BUFFER_SIZE 4096
-#else
-#define BUFFER_SIZE 512
-#endif
-#endif
-#endif
- char pending[BUFFER_SIZE];
- int pending_len;
-
/* File name of the data object. */
char *file_name;
/* Hint on the to be expected total size of the data. */
gpgme_off_t size_hint;
+ /* If no 0 the size of an allocated inbound or outpund buffers. The
+ * value is at least BUFFER_SIZE and capped at 1MiB. */
+ unsigned int io_buffer_size;
+
+ /* If not NULL a malloced buffer used for inbound data used instead
+ * of the handler's static buffer. Its size is io_buffer_size. */
+ char *inbound_buffer;
+
+ /* A default memory space for the outbound handler and the number of
+ * actual pending bytes. If outbound_buffer is not NULL, this is a
+ * malloced buffer used instead of the outboundspace. Its malloced
+ * size is io_buffer_size. */
+ char outboundspace[BUFFER_SIZE];
+ unsigned int outbound_pending;
+ char *outbound_buffer;
+
+ /* If set sensitive data is conveyed via the internal buffer. This
+ * flags overwrites the memory of the buffers with zero before they
+ * are released. */
+ unsigned int sensitive:1;
+
union
{
/* For gpgme_data_new_from_fd. */