[git] GpgOL - branch, async-enc, updated. gpgol-2.0.6-6-gc52f7ed
by Andre Heinecke
cvs at cvs.gnupg.org
Tue Jan 30 15:51:28 CET 2018
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG extension for MS Outlook".
The branch, async-enc has been updated
via c52f7ed9456ad1db74b09bc1eae32750b4277fee (commit)
from f622470a3a291cd8d39e9dc45fa5d6496e66089d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit c52f7ed9456ad1db74b09bc1eae32750b4277fee
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Tue Jan 30 15:49:26 2018 +0100
Implement MIME Sign in the new way
* src/cryptcontroller.cpp (create_sign_attach): New.
(CryptController::update_mail_mapi): Handle sign only.
* src/mimemaker.h, src/mimemaker.cpp: Expose more functions.
* src/mail.cpp (do_crypt): Remove sleep ;-)
diff --git a/src/cryptcontroller.cpp b/src/cryptcontroller.cpp
index c950cdf..2d14038 100644
--- a/src/cryptcontroller.cpp
+++ b/src/cryptcontroller.cpp
@@ -295,6 +295,103 @@ write_data (sink_t sink, GpgME::Data &data)
}
static int
+create_sign_attach (sink_t sink, protocol_t protocol,
+ GpgME::Data &signature,
+ GpgME::Data &signedData)
+{
+ char boundary[BOUNDARYSIZE+1];
+ char top_header[BOUNDARYSIZE+200];
+ int rc = 0;
+
+ /* Write the top header. */
+ generate_boundary (boundary);
+ create_top_signing_header (top_header, sizeof top_header,
+ protocol, 1, boundary,
+ protocol == PROTOCOL_SMIME ? "sha1":"pgp-sha1");
+
+ if ((rc = write_string (sink, top_header)))
+ {
+ TRACEPOINT;
+ return rc;
+ }
+
+ /* Write the boundary so that it is not included in the hashing. */
+ if ((rc = write_boundary (sink, boundary, 0)))
+ {
+ TRACEPOINT;
+ return rc;
+ }
+
+ /* Write the signed mime structure */
+ if ((rc = write_data (sink, signedData)))
+ {
+ TRACEPOINT;
+ return rc;
+ }
+
+ /* Write the signature attachment */
+ if ((rc = write_boundary (sink, boundary, 0)))
+ {
+ TRACEPOINT;
+ return rc;
+ }
+
+ if (protocol == PROTOCOL_OPENPGP)
+ {
+ rc = write_string (sink,
+ "Content-Type: application/pgp-signature\r\n");
+ }
+ else
+ {
+ rc = write_string (sink,
+ "Content-Transfer-Encoding: base64\r\n"
+ "Content-Type: application/pkcs7-signature\r\n");
+ /* rc = write_string (sink, */
+ /* "Content-Type: application/x-pkcs7-signature\r\n" */
+ /* "\tname=\"smime.p7s\"\r\n" */
+ /* "Content-Transfer-Encoding: base64\r\n" */
+ /* "Content-Disposition: attachment;\r\n" */
+ /* "\tfilename=\"smime.p7s\"\r\n"); */
+
+ }
+
+ if (rc)
+ {
+ TRACEPOINT;
+ return rc;
+ }
+
+ if ((rc = write_string (sink, "\r\n")))
+ {
+ TRACEPOINT;
+ return rc;
+ }
+
+ // Write the signature data
+ if ((rc = write_data (sink, signature)))
+ {
+ TRACEPOINT;
+ return rc;
+ }
+
+ // Add an extra linefeed with should not harm.
+ if ((rc = write_string (sink, "\r\n")))
+ {
+ TRACEPOINT;
+ return rc;
+ }
+
+ /* Write the final boundary. */
+ if ((rc = write_boundary (sink, boundary, 1)))
+ {
+ TRACEPOINT;
+ return rc;
+ }
+
+ return rc;
+}
+
+static int
create_encrypt_attach (sink_t sink, protocol_t protocol,
GpgME::Data &encryptedData)
{
@@ -367,10 +464,19 @@ CryptController::update_mail_mapi ()
PROTOCOL_SMIME :
PROTOCOL_OPENPGP;
int rc = 0;
- if (m_encrypt)
+ if (m_sign && m_encrypt)
{
+ // FIXME we need some doubling here for S/MIME.
rc = create_encrypt_attach (sink, protocol, m_output);
}
+ else if (m_encrypt)
+ {
+ rc = create_encrypt_attach (sink, protocol, m_output);
+ }
+ else if (m_sign)
+ {
+ rc = create_sign_attach (sink, protocol, m_output, m_input);
+ }
// Close our attachment
if (!rc)
@@ -381,7 +487,8 @@ CryptController::update_mail_mapi ()
// Set message class etc.
if (!rc)
{
- rc = finalize_message (message, att_table, protocol, 1, false);
+ rc = finalize_message (message, att_table, protocol, m_encrypt ? 1 : 0,
+ false);
}
// only on error.
diff --git a/src/mail.cpp b/src/mail.cpp
index 0b270e0..53f2890 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -765,7 +765,6 @@ do_crypt (LPVOID arg)
/* This can take a while */
int rc = crypter->do_crypto();
- Sleep(3000);
gpgrt_lock_lock (&dtor_lock);
if (!Mail::is_valid_ptr (mail))
diff --git a/src/mimemaker.cpp b/src/mimemaker.cpp
index d638fb2..2693f49 100644
--- a/src/mimemaker.cpp
+++ b/src/mimemaker.cpp
@@ -273,7 +273,7 @@ write_buffer_for_cb (void *opaque, const void *data, size_t datalen)
/* Write the string TEXT to the IStream STREAM. Returns 0 on sucsess,
prints an error message and returns -1 on error. */
-static int
+int
write_string (sink_t sink, const char *text)
{
return write_buffer (sink, text, strlen (text));
@@ -1298,7 +1298,7 @@ collect_signature (void *opaque, const void *data, size_t datalen)
/* Helper to create the signing header. This includes enough space
for later fixup of the micalg parameter. The MIME version is only
written if FIRST is set. */
-static void
+void
create_top_signing_header (char *buffer, size_t buflen, protocol_t protocol,
int first, const char *boundary, const char *micalg)
{
diff --git a/src/mimemaker.h b/src/mimemaker.h
index cbf83a8..3f29ecc 100644
--- a/src/mimemaker.h
+++ b/src/mimemaker.h
@@ -88,7 +88,9 @@ int close_mapi_attachment (LPATTACH *attach, sink_t sink);
int finalize_message (LPMESSAGE message, mapi_attach_item_t *att_table,
protocol_t protocol, int encrypt, bool is_inline = false);
void cancel_mapi_attachment (LPATTACH *attach, sink_t sink);
-
+void create_top_signing_header (char *buffer, size_t buflen, protocol_t protocol,
+ int first, const char *boundary, const char *micalg);
+int write_string (sink_t sink, const char *text);
#ifdef __cplusplus
}
-----------------------------------------------------------------------
Summary of changes:
src/cryptcontroller.cpp | 111 +++++++++++++++++++++++++++++++++++++++++++++++-
src/mail.cpp | 1 -
src/mimemaker.cpp | 4 +-
src/mimemaker.h | 4 +-
4 files changed, 114 insertions(+), 6 deletions(-)
hooks/post-receive
--
GnuPG extension for MS Outlook
http://git.gnupg.org
More information about the Gnupg-commits
mailing list