[svn] GpgOL - r265 - in trunk: forms src
svn author wk
cvs at cvs.gnupg.org
Tue Aug 5 16:08:39 CEST 2008
Author: wk
Date: 2008-08-05 16:08:38 +0200 (Tue, 05 Aug 2008)
New Revision: 265
Modified:
trunk/forms/encr-l.ico
trunk/forms/encr-s.ico
trunk/forms/sign-l.ico
trunk/forms/sign-s.ico
trunk/src/ChangeLog
trunk/src/engine.c
trunk/src/engine.h
trunk/src/ext-commands.cpp
trunk/src/message.cpp
trunk/src/mimeparser.c
trunk/src/mimeparser.h
trunk/src/olflange.cpp
trunk/src/olflange.h
Log:
yeah, we have icons for the Viewer pane.
Removed icons for protocol selection for OL2003.
Fixed signature verification of encrypted messages.
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2008-08-04 11:11:42 UTC (rev 264)
+++ trunk/src/ChangeLog 2008-08-05 14:08:38 UTC (rev 265)
@@ -1,3 +1,15 @@
+2008-08-05 Werner Koch <wk at g10code.com>
+
+ * ext-commands.cpp (InstallCommands): Display protocolicons only
+ for OL2007.
+ * olflange.cpp (get_ol_main_version): New.
+
+ * message.cpp (message_decrypt): Save a signature verification
+ result.
+ * mimeparser.c (mime_decrypt): Implement verification of included
+ signatrues. This feature got lost during the removal of nested
+ crypto operations.
+
2008-08-04 Werner Koch <wk at g10code.com>
* olflange.cpp (install_forms): New.
Modified: trunk/forms/encr-l.ico
===================================================================
(Binary files differ)
Modified: trunk/forms/encr-s.ico
===================================================================
(Binary files differ)
Modified: trunk/forms/sign-l.ico
===================================================================
(Binary files differ)
Modified: trunk/forms/sign-s.ico
===================================================================
(Binary files differ)
Modified: trunk/src/engine.c
===================================================================
--- trunk/src/engine.c 2008-08-04 11:11:42 UTC (rev 264)
+++ trunk/src/engine.c 2008-08-05 14:08:38 UTC (rev 265)
@@ -638,7 +638,7 @@
/* Set the FILTER in a mode which pushes an extra linefeed out. */
void
-engine_request_exra_lf (engine_filter_t filter)
+engine_request_extra_lf (engine_filter_t filter)
{
filter->add_extra_lf = 1;
}
Modified: trunk/src/engine.h
===================================================================
--- trunk/src/engine.h 2008-08-04 11:11:42 UTC (rev 264)
+++ trunk/src/engine.h 2008-08-05 14:08:38 UTC (rev 265)
@@ -63,7 +63,7 @@
int engine_create_filter (engine_filter_t *r_filter,
int (*outfnc) (void *, const void *, size_t),
void *outfncdata);
-void engine_request_exra_lf (engine_filter_t filter);
+void engine_request_extra_lf (engine_filter_t filter);
void engine_set_session_number (engine_filter_t filter, unsigned int value);
void engine_set_session_title (engine_filter_t filter, const char *title);
void engine_set_sender_address (engine_filter_t filter, const char *addr);
Modified: trunk/src/ext-commands.cpp
===================================================================
--- trunk/src/ext-commands.cpp 2008-08-04 11:11:42 UTC (rev 264)
+++ trunk/src/ext-commands.cpp 2008-08-05 14:08:38 UTC (rev 265)
@@ -515,6 +515,8 @@
case MSGTYPE_GPGOL_OPAQUE_ENCRYPTED:
case MSGTYPE_GPGOL_PGP_MESSAGE:
is_encrypted = 1;
+ if ( mapi_test_sig_status (message) )
+ is_encrypted++;
break;
default:
break;
@@ -538,9 +540,12 @@
&m_nCmdDebug3,
NULL);
- if ( !opt.disable_gpgol)
+ if (!opt.disable_gpgol)
add_toolbar (pTBEArray, nTBECnt,
- is_encrypted
+ is_encrypted == 2
+ ? _("This is a signed and encrypted message.\n"
+ "Click for more information. ")
+ : is_encrypted
? _("This is an encrypted message.\n"
"Click for more information. ")
: _("This is a signed message.\n"
@@ -561,14 +566,23 @@
_("&encrypt message with GnuPG"), &m_nCmdEncrypt,
_("&sign message with GnuPG"), &m_nCmdSign,
NULL );
+
+ /* We display the protocol icons only for Outlook 2007 becuase
+ there seems to be no way to add a plain menu item. */
+ if (get_ol_main_version () > 11)
+ add_toolbar (pTBEArray, nTBECnt,
+ "Encrypt", IDB_ENCRYPT, m_nCmdEncrypt,
+ "Sign", IDB_SIGN, m_nCmdSign,
+ "Autoselect", IDB_PROTO_AUTO, m_nCmdProtoAuto,
+ "Use PGP/MIME", IDB_PROTO_PGPMIME, m_nCmdProtoPgpmime,
+ "Use/MIME", IDB_PROTO_SMIME, m_nCmdProtoSmime,
+ NULL, 0, 0);
+ else
+ add_toolbar (pTBEArray, nTBECnt,
+ "Encrypt", IDB_ENCRYPT, m_nCmdEncrypt,
+ "Sign", IDB_SIGN, m_nCmdSign,
+ NULL, 0, 0);
- add_toolbar (pTBEArray, nTBECnt,
- "Encrypt", IDB_ENCRYPT, m_nCmdEncrypt,
- "Sign", IDB_SIGN, m_nCmdSign,
- "Autoselect", IDB_PROTO_AUTO, m_nCmdProtoAuto,
- "Use PGP/MIME", IDB_PROTO_PGPMIME, m_nCmdProtoPgpmime,
- "Use/MIME", IDB_PROTO_SMIME, m_nCmdProtoSmime,
- NULL, 0, 0);
m_pExchExt->m_protoSelection = opt.default_protocol;
update_protocol_menu (eecb);
Modified: trunk/src/message.cpp
===================================================================
--- trunk/src/message.cpp 2008-08-04 11:11:42 UTC (rev 264)
+++ trunk/src/message.cpp 2008-08-05 14:08:38 UTC (rev 265)
@@ -807,7 +807,7 @@
int tblidx;
int retval = -1;
LPSTREAM cipherstream;
- gpg_error_t err;
+ gpg_error_t err, sig_err;
int is_opaque = 0;
protocol_t protocol;
LPATTACH saved_attach = NULL;
@@ -1037,8 +1037,9 @@
goto leave; /* Problem getting the attachment. */
}
+ sig_err = gpg_error (GPG_ERR_NO_DATA);
err = mime_decrypt (protocol, cipherstream, message,
- need_rfc822_parser, is_simple_pgp, hwnd, 0);
+ need_rfc822_parser, is_simple_pgp, hwnd, 0, &sig_err);
log_debug ("mime_decrypt returned %d (%s)", err, gpg_strerror (err));
if (err && opt.enable_debug)
{
@@ -1060,6 +1061,25 @@
{
if (saved_attach)
mapi_set_attach_hidden (saved_attach);
+
+ if (gpg_err_code (sig_err) != GPG_ERR_NO_DATA)
+ {
+ /* Note: Saving the result of the signature in a property
+ will reveal that there is a signature inside the
+ encrypted message - however it does reveal only a
+ common assumption and thus it is acceptable to do
+ this. */
+ if (sig_err)
+ {
+ char buf[200];
+ snprintf (buf, sizeof buf, "- %s", gpg_strerror (sig_err));
+ mapi_set_sig_status (message, gpg_strerror (sig_err));
+ }
+ else
+ mapi_set_sig_status (message, "! Good signature");
+ mapi_save_changes (message, KEEP_OPEN_READWRITE);
+ }
+
}
cipherstream->Release ();
retval = 0;
Modified: trunk/src/mimeparser.c
===================================================================
--- trunk/src/mimeparser.c 2008-08-04 11:11:42 UTC (rev 264)
+++ trunk/src/mimeparser.c 2008-08-05 14:08:38 UTC (rev 265)
@@ -1223,6 +1223,7 @@
assert (messagelen >= len);
messagelen -= len;
}
+
/* Note: the last character should be a LF, if not we ignore such an
incomplete last line. */
if (ctx->sig_data && gpgme_data_write (ctx->sig_data, "", 1) == 1)
@@ -1651,20 +1652,25 @@
window to be used for message box and such. In PREVIEW_MODE no
verification will be done, no messages saved and no messages boxes
will pop up. If IS_RFC822 is set, the message is expected to be in
- rfc822 format. The caller should send SIMPLE_PGP is the input
- message is a simple PGP message. */
+ rfc822 format. The caller should send SIMPLE_PGP if the input
+ message is a simple (non-MIME) PGP message. If SIG_ERR is not null
+ and a signature was found and verified, its status is returned
+ there. If no signature was found SIG_ERR is not changed. */
int
mime_decrypt (protocol_t protocol, LPSTREAM instream, LPMESSAGE mapi_message,
- int is_rfc822, int simple_pgp, HWND hwnd, int preview_mode)
+ int is_rfc822, int simple_pgp, HWND hwnd, int preview_mode,
+ gpg_error_t *sig_err)
{
gpg_error_t err;
mime_context_t decctx, ctx;
engine_filter_t filter = NULL;
int opaque_signed = 0;
int last_part_counter = 0;
+ unsigned int session_number;
+ char *signature = NULL;
- log_debug ("%s:%s: enter (protocol=%d, is_rfc822=%d)",
- SRCNAME, __func__, protocol, is_rfc822);
+ log_debug ("%s:%s: enter (protocol=%d, is_rfc822=%d, simple_pgp=%d)",
+ SRCNAME, __func__, protocol, is_rfc822, simple_pgp);
if (is_rfc822)
{
@@ -1680,6 +1686,7 @@
ctx->protect_mode = 1;
ctx->hwnd = hwnd;
ctx->preview = preview_mode;
+ ctx->verify_mode = simple_pgp? 0 : 1;
ctx->mapi_message = mapi_message;
ctx->mimestruct_tail = &ctx->mimestruct;
ctx->no_mail_header = simple_pgp;
@@ -1706,13 +1713,12 @@
}
/* Prepare the decryption. */
-/* title = native_to_utf8 (_("[Encrypted S/MIME message]")); */
-/* title = native_to_utf8 (_("[Encrypted PGP/MIME message]")); */
if ((err=engine_create_filter (&filter, plaintext_handler, ctx)))
goto leave;
if (simple_pgp)
- engine_request_exra_lf (filter);
- engine_set_session_number (filter, engine_new_session_number ());
+ engine_request_extra_lf (filter);
+ session_number = engine_new_session_number ();
+ engine_set_session_number (filter, session_number);
{
char *tmp = mapi_get_subject (mapi_message);
engine_set_session_title (filter, tmp);
@@ -1790,8 +1796,81 @@
else if (ctx->line_too_long)
err = gpg_error (GPG_ERR_GENERAL);
+ /* Verify an optional inner signature. */
+ if (!err && !preview_mode
+ && ctx->sig_data && ctx->signed_data && !ctx->is_opaque_signed)
+ {
+ size_t sig_len;
+
+ assert (!filter);
+
+ if (gpgme_data_write (ctx->sig_data, "", 1) == 1)
+ {
+ signature = gpgme_data_release_and_get_mem (ctx->sig_data, &sig_len);
+ ctx->sig_data = NULL;
+ }
+
+ if (!err && signature)
+ {
+ gpgme_data_seek (ctx->signed_data, 0, SEEK_SET);
+
+ if ((err=engine_create_filter (&filter, NULL, NULL)))
+ goto leave;
+ engine_set_session_number (filter, session_number);
+ {
+ char *tmp = mapi_get_subject (mapi_message);
+ engine_set_session_title (filter, tmp);
+ xfree (tmp);
+ }
+ {
+ char *from = mapi_get_from_address (mapi_message);
+ err = engine_verify_start (filter, hwnd, signature, sig_len,
+ ctx->protocol, from);
+ xfree (from);
+ }
+ if (err)
+ goto leave;
+
+ /* Filter the data. */
+ do
+ {
+ int nread;
+ char buffer[4096];
+
+ nread = gpgme_data_read (ctx->signed_data, buffer,sizeof buffer);
+ if (nread < 0)
+ {
+ err = gpg_error_from_syserror ();
+ log_error ("%s:%s: gpgme_data_read failed in verify: %s",
+ SRCNAME, __func__, gpg_strerror (err));
+ }
+ else if (nread)
+ {
+ err = engine_filter (filter, buffer, nread);
+ }
+ else
+ break; /* EOF */
+ }
+ while (!err);
+ if (err)
+ goto leave;
+
+ /* Wait for the engine to finish. */
+ if ((err = engine_filter (filter, NULL, 0)))
+ goto leave;
+ err = engine_wait (filter);
+ if (sig_err)
+ *sig_err = err;
+ err = 0;
+ filter = NULL;
+ }
+ }
+
+
leave:
engine_cancel (filter);
+ xfree (signature);
+ signature = NULL;
if (ctx)
{
/* Cancel any left over attachment which means that the MIME
@@ -1871,11 +1950,16 @@
log_debug ("%s:%s: mime_verify_opaque returned %d",
SRCNAME, __func__, err);
+ if (sig_err)
+ *sig_err = err;
+ err = 0;
+
leave_verify:
xfree (plainbuffer);
mapi_release_attach_table (table);
}
+
return err;
}
Modified: trunk/src/mimeparser.h
===================================================================
--- trunk/src/mimeparser.h 2008-08-04 11:11:42 UTC (rev 264)
+++ trunk/src/mimeparser.h 2008-08-05 14:08:38 UTC (rev 265)
@@ -37,7 +37,8 @@
int start_part_counter);
int mime_decrypt (protocol_t protocol,
LPSTREAM instream, LPMESSAGE mapi_message, int is_rfc822,
- int simple_pgp, HWND hwnd, int preview_mode);
+ int simple_pgp, HWND hwnd, int preview_mode,
+ gpg_error_t *sig_err);
#ifdef __cplusplus
Modified: trunk/src/olflange.cpp
===================================================================
--- trunk/src/olflange.cpp 2008-08-04 11:11:42 UTC (rev 264)
+++ trunk/src/olflange.cpp 2008-08-05 14:08:38 UTC (rev 265)
@@ -69,7 +69,9 @@
static void install_forms (void);
+static char *olversion;
+
/* Return a string for the context NO. This never return NULL. */
const char *
@@ -96,6 +98,13 @@
}
+EXTERN_C int
+get_ol_main_version (void)
+{
+ return olversion? atoi (olversion): 0;
+}
+
+
/* Wrapper around UlRelease with error checking. */
// static void
// ul_release (LPVOID punk, const char *func)
@@ -533,7 +542,6 @@
GpgolExt::Install(LPEXCHEXTCALLBACK pEECB, ULONG lContext, ULONG lFlags)
{
static int version_shown;
- static char *olversion;
ULONG lBuildVersion;
ULONG lActualVersion;
ULONG lVirtualVersion;
@@ -662,7 +670,7 @@
case LANG_GERMAN: langsuffix = "de"; break;
default:
log_debug ("%s:%s: No forms available for primary language %d\n",
- SRCNAME, __func__, buffer);
+ SRCNAME, __func__, (int)langid);
/* Don't try again. */
opt.forms_revision = SVN_REVISION;
write_options ();
Modified: trunk/src/olflange.h
===================================================================
--- trunk/src/olflange.h 2008-08-04 11:11:42 UTC (rev 264)
+++ trunk/src/olflange.h 2008-08-05 14:08:38 UTC (rev 265)
@@ -74,5 +74,7 @@
EXTERN_C const char * __stdcall gpgol_check_version (const char *req_version);
+EXTERN_C int get_ol_main_version (void);
+
#endif /*OLFLANGE_H*/
More information about the Gnupg-commits
mailing list