[svn] GpgOL - r281 - in trunk: . po src
svn author wk
cvs at cvs.gnupg.org
Wed Oct 29 14:01:29 CET 2008
Author: wk
Date: 2008-10-29 14:01:28 +0100 (Wed, 29 Oct 2008)
New Revision: 281
Modified:
trunk/NEWS
trunk/po/de.po
trunk/po/sv.po
trunk/src/ChangeLog
trunk/src/engine.c
trunk/src/mimemaker.c
Log:
Made atatchment encryption faster.
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2008-10-27 18:23:30 UTC (rev 280)
+++ trunk/src/ChangeLog 2008-10-29 13:01:28 UTC (rev 281)
@@ -1,3 +1,8 @@
+2008-10-29 Werner Koch <wk at g10code.com>
+
+ * engine.c (engine_filter): Collect more data in the in buffer.
+ * mimemaker.c (write_b64): Buffer up to 2k of output.
+
2008-10-27 Werner Koch <wk at g10code.com>
* mimemaker.c (mime_encrypt): Check for an empty message before
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2008-10-27 18:23:30 UTC (rev 280)
+++ trunk/NEWS 2008-10-29 13:01:28 UTC (rev 281)
@@ -5,7 +5,9 @@
* Fixed PGP cleartext signature verification.
+ * Encryption of attachments is now much faster.
+
Noteworthy changes for version 0.10.15 (2008-08-06)
===================================================
Modified: trunk/po/de.po [not shown]
Modified: trunk/po/sv.po [not shown]
Modified: trunk/src/engine.c
===================================================================
--- trunk/src/engine.c 2008-10-27 18:23:30 UTC (rev 280)
+++ trunk/src/engine.c 2008-10-29 13:01:28 UTC (rev 281)
@@ -555,13 +555,17 @@
/* Fill the input buffer, relinquish control to the callback
processor and loop until all input data has been
processed. */
- if (!filter->in.length && indatalen)
+ if (indatalen && filter->in.length < FILTER_BUFFER_SIZE )
{
- filter->in.length = (indatalen > FILTER_BUFFER_SIZE
- ? FILTER_BUFFER_SIZE : indatalen);
- memcpy (filter->in.buffer, indata, filter->in.length);
- indata += filter->in.length;
- indatalen -= filter->in.length;
+ size_t tmplen;
+
+ tmplen = FILTER_BUFFER_SIZE - filter->in.length;
+ tmplen = (indatalen > tmplen? tmplen : indatalen);
+
+ memcpy (filter->in.buffer+filter->in.length, indata, tmplen);
+ filter->in.length += tmplen;
+ indata += tmplen;
+ indatalen -= tmplen;
any = 1;
}
/* Terminate the loop if the filter queue is empty OR the filter
Modified: trunk/src/mimemaker.c
===================================================================
--- trunk/src/mimemaker.c 2008-10-27 18:23:30 UTC (rev 280)
+++ trunk/src/mimemaker.c 2008-10-29 13:01:28 UTC (rev 281)
@@ -310,45 +310,62 @@
const unsigned char *p;
unsigned char inbuf[4];
int idx, quads;
- char outbuf[4];
+ char outbuf[2048];
+ size_t outlen;
log_debug (" writing base64 of length %d\n", (int)datalen);
idx = quads = 0;
+ outlen = 0;
for (p = data; datalen; p++, datalen--)
{
inbuf[idx++] = *p;
if (idx > 2)
{
- outbuf[0] = bintoasc[(*inbuf>>2)&077];
- outbuf[1] = bintoasc[(((*inbuf<<4)&060)|((inbuf[1] >> 4)&017))&077];
- outbuf[2] = bintoasc[(((inbuf[1]<<2)&074)|((inbuf[2]>>6)&03))&077];
- outbuf[3] = bintoasc[inbuf[2]&077];
- if ((rc = write_buffer (sink, outbuf, 4)))
- return rc;
+ /* We need space for a quad and a possible CR,LF. */
+ if (outlen+4+2 >= sizeof outbuf)
+ {
+ if ((rc = write_buffer (sink, outbuf, outlen)))
+ return rc;
+ outlen = 0;
+ }
+ outbuf[outlen++] = bintoasc[(*inbuf>>2)&077];
+ outbuf[outlen++] = bintoasc[(((*inbuf<<4)&060)
+ |((inbuf[1] >> 4)&017))&077];
+ outbuf[outlen++] = bintoasc[(((inbuf[1]<<2)&074)
+ |((inbuf[2]>>6)&03))&077];
+ outbuf[outlen++] = bintoasc[inbuf[2]&077];
idx = 0;
if (++quads >= (64/4))
{
quads = 0;
- if ((rc = write_buffer (sink, "\r\n", 2)))
- return rc;
+ outbuf[outlen++] = '\r';
+ outbuf[outlen++] = '\n';
}
}
}
+ /* We need space for a quad and a final CR,LF. */
+ if (outlen+4+2 >= sizeof outbuf)
+ {
+ if ((rc = write_buffer (sink, outbuf, outlen)))
+ return rc;
+ outlen = 0;
+ }
if (idx)
{
- outbuf[0] = bintoasc[(*inbuf>>2)&077];
+ outbuf[outlen++] = bintoasc[(*inbuf>>2)&077];
if (idx == 1)
{
- outbuf[1] = bintoasc[((*inbuf<<4)&060)&077];
- outbuf[2] = '=';
- outbuf[3] = '=';
+ outbuf[outlen++] = bintoasc[((*inbuf<<4)&060)&077];
+ outbuf[outlen++] = '=';
+ outbuf[outlen++] = '=';
}
else
{
- outbuf[1] = bintoasc[(((*inbuf<<4)&060)|((inbuf[1]>>4)&017))&077];
- outbuf[2] = bintoasc[((inbuf[1]<<2)&074)&077];
- outbuf[3] = '=';
+ outbuf[outlen++] = bintoasc[(((*inbuf<<4)&060)
+ |((inbuf[1]>>4)&017))&077];
+ outbuf[outlen++] = bintoasc[((inbuf[1]<<2)&074)&077];
+ outbuf[outlen++] = '=';
}
if ((rc = write_buffer (sink, outbuf, 4)))
return rc;
@@ -356,9 +373,17 @@
}
if (quads)
- if ((rc = write_buffer (sink, "\r\n", 2)))
- return rc;
+ {
+ outbuf[outlen++] = '\r';
+ outbuf[outlen++] = '\n';
+ }
+ if (outlen)
+ {
+ if ((rc = write_buffer (sink, outbuf, outlen)))
+ return rc;
+ }
+
return 0;
}
More information about the Gnupg-commits
mailing list