[svn] GPGol - r143 - in trunk: . po src

svn author wk cvs at cvs.gnupg.org
Mon Mar 27 21:31:09 CEST 2006


Author: wk
Date: 2006-03-27 21:31:08 +0200 (Mon, 27 Mar 2006)
New Revision: 143

Modified:
   trunk/NEWS
   trunk/configure.ac
   trunk/po/de.po
   trunk/src/ChangeLog
   trunk/src/engine-gpgme.c
   trunk/src/engine.h
   trunk/src/gpgmsg.cpp
   trunk/src/intern.h
   trunk/src/main.c
   trunk/src/olflange.cpp
   trunk/src/pgpmime.c
   trunk/src/pgpmime.h
   trunk/src/rfc822parse.c
   trunk/src/rfc822parse.h
Log:
Support verification of (some) PGP/MIME messages.


Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2006-03-21 15:57:47 UTC (rev 142)
+++ trunk/NEWS	2006-03-27 19:31:08 UTC (rev 143)
@@ -1,3 +1,9 @@
+Noteworthy changes for version 0.9.8
+=================================================
+
+* PGP/MIME signature verification may now work in some cases.
+
+
 Noteworthy changes for version 0.9.7 (2006-03-21)
 =================================================
 

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2006-03-21 15:57:47 UTC (rev 142)
+++ trunk/configure.ac	2006-03-27 19:31:08 UTC (rev 143)
@@ -16,7 +16,7 @@
 # Version number: Remember to change it immediately *after* a release.
 #                 Make sure to run  "svn up" before a "make dist".
 #                 Add a "-cvs" prefix for non-released code.
-AC_INIT(gpgol, 0.9.7, bug-gpgol at g10code.com)
+AC_INIT(gpgol, 0.9.8-cvs, bug-gpgol at g10code.com)
 
 NEED_GPGME_API=1
 NEED_GPGME_VERSION=1.1.0

Modified: trunk/po/de.po
===================================================================
--- trunk/po/de.po	2006-03-21 15:57:47 UTC (rev 142)
+++ trunk/po/de.po	2006-03-27 19:31:08 UTC (rev 143)
@@ -7,74 +7,78 @@
 msgstr ""
 "Project-Id-Version: GPGol 0.9.4\n"
 "Report-Msgid-Bugs-To: bug-gpgol at g10code.com\n"
-"POT-Creation-Date: 2006-01-16 12:15+0100\n"
-"PO-Revision-Date: 2006-01-16 12:16+0100\n"
+"POT-Creation-Date: 2006-03-27 20:56+0200\n"
+"PO-Revision-Date: 2006-03-27 21:01+0200\n"
 "Last-Translator: Werner Koch <wk at gnupg.org>\n"
 "Language-Team: de\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=utf-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-#: src/config-dialog.c:289
+#: src/common.c:101
+msgid "GPG - Save decrypted attachment"
+msgstr "GPG - Sichern der entschlüsselten Anlage"
+
+#: src/config-dialog.c:290
 msgid "Select GPG Key Manager"
 msgstr "Das Schlüsselverwaltungsprogramm festlegen"
 
-#: src/engine-gpgme.c:942
+#: src/engine-gpgme.c:978
 msgid "Fingerprint: "
 msgstr "Fingerabdruck: "
 
-#: src/engine-gpgme.c:999
+#: src/engine-gpgme.c:1035
 msgid "This signature is valid\n"
 msgstr "Diese Unterschrift ist korrekt\n"
 
-#: src/engine-gpgme.c:1001
+#: src/engine-gpgme.c:1037
 msgid "signature state is \"green\"\n"
 msgstr "Status der Unterschrift ist \"grün\"\n"
 
-#: src/engine-gpgme.c:1003
+#: src/engine-gpgme.c:1039
 msgid "signature state is \"red\"\n"
 msgstr "Status der Unterschrift ist \"rot\"\n"
 
-#: src/engine-gpgme.c:1007
+#: src/engine-gpgme.c:1043
 msgid "Warning: One of the keys has been revoked\n"
 msgstr "Warnung: Einer der Schlüssel wurde widerrufen\n"
 
-#: src/engine-gpgme.c:1017
+#: src/engine-gpgme.c:1053
 msgid "Warning: The key used to create the signature expired at: "
 msgstr ""
 "Warnung: Der Schlüssel mit der diese Unterschrift erzeugt wurde verfiel am: "
 
-#: src/engine-gpgme.c:1023
+#: src/engine-gpgme.c:1059
 msgid "Warning: At least one certification key has expired\n"
 msgstr ""
 "Warnung: Mindestens einer der Zertifizierungsschlüssel ist abgelaufen\n"
 
-#: src/engine-gpgme.c:1029
+#: src/engine-gpgme.c:1065
 msgid "Warning: The signature expired at: "
 msgstr "Die Unterschrift verfiel am: "
 
-#: src/engine-gpgme.c:1035
+#: src/engine-gpgme.c:1071
 msgid "Can't verify due to a missing key or certificate\n"
 msgstr ""
 "Aufrund eines fehlenden Schlüssels ist eine Überprüfung nicht möglich\n"
 
-#: src/engine-gpgme.c:1039
+#: src/engine-gpgme.c:1075
 msgid "The CRL is not available\n"
 msgstr "Die CRL ist nicht verfügbar\n"
 
-#: src/engine-gpgme.c:1045
+#: src/engine-gpgme.c:1081
 msgid "Available CRL is too old\n"
 msgstr "Die vorhandene CRL ist zu alt\n"
 
-#: src/engine-gpgme.c:1050
+#: src/engine-gpgme.c:1086
 msgid "A policy requirement was not met\n"
 msgstr "Eine Richtlinie wurde nicht erfüllt\n"
 
-#: src/engine-gpgme.c:1056
+#: src/engine-gpgme.c:1092
 msgid "A system error occured"
 msgstr "Ein Systemfehler ist aufgetreten"
 
-#: src/engine-gpgme.c:1093
+#: src/engine-gpgme.c:1129
 msgid ""
 "WARNING: We have NO indication whether the key belongs to the person named "
 "as shown above\n"
@@ -82,12 +86,12 @@
 "WARNUNG: Es gibt keinen Hinweis darauf, ob der Schlüssel wirklich der Person "
 "gehört, die oben angezeigt ist\n"
 
-#: src/engine-gpgme.c:1100
+#: src/engine-gpgme.c:1136
 msgid "WARNING: The key does NOT BELONG to the person named as shown above\n"
 msgstr ""
 "WARNUNG: Der Schlüssel gehört NICHT der Person die oben angezeigt ist\n"
 
-#: src/engine-gpgme.c:1104
+#: src/engine-gpgme.c:1140
 msgid ""
 "WARNING: It is NOT certain that the key belongs to the person named as shown "
 "above\n"
@@ -95,72 +99,89 @@
 "WARNING: Es ist nicht sicher, daß der Schlüssel der Person gehört, die oben "
 "angezeigt ist\n"
 
-#: src/engine-gpgme.c:1137
+#: src/engine-gpgme.c:1173
 msgid "Verification started at: "
 msgstr "Überprüfung begann am: "
 
-#: src/engine-gpgme.c:1142
+#: src/engine-gpgme.c:1178
 msgid "Verification result for: "
 msgstr "Prüfungsresultat für: "
 
-#: src/engine-gpgme.c:1143
+#: src/engine-gpgme.c:1179
 msgid "[unnamed part]"
 msgstr "[Unbenannter Teil]"
 
-#: src/engine-gpgme.c:1161 src/engine-gpgme.c:1191
+#: src/engine-gpgme.c:1197 src/engine-gpgme.c:1227
 msgid "Good signature from: "
 msgstr "Korrekte Unterschrift von: "
 
-#: src/engine-gpgme.c:1168
+#: src/engine-gpgme.c:1204
 msgid "                aka: "
 msgstr "                    alias: "
 
-#: src/engine-gpgme.c:1172 src/engine-gpgme.c:1194
+#: src/engine-gpgme.c:1208 src/engine-gpgme.c:1230
 msgid "            created: "
 msgstr "                  erzeugt: "
 
-#: src/engine-gpgme.c:1181
+#: src/engine-gpgme.c:1217
 msgid "*BAD* signature claimed to be from: "
 msgstr "*FALSCHE* Unterschrift, vorgeblich von: "
 
-#: src/engine-gpgme.c:1204
+#: src/engine-gpgme.c:1240
 msgid "Error checking signature"
-msgstr "Fehler beim Prüfen der Unetrschrift"
+msgstr "Fehler beim Prüfen der Unterschrift"
 
-#: src/engine-gpgme.c:1220
+#: src/engine-gpgme.c:1256
 msgid "*** Begin Notation (signature by: "
 msgstr "*** Anfang Notation (Unterschrift von: "
 
-#: src/engine-gpgme.c:1240
+#: src/engine-gpgme.c:1276
 msgid "*** End Notation ***\n"
 msgstr "*** Ende Notation ***\n"
 
-#: src/gpgmsg.cpp:1039
+#: src/gpgmsg.cpp:1186
 msgid "No valid OpenPGP data found."
 msgstr "Keine gültigen OpenPGP Daten gefunden"
 
-#: src/gpgmsg.cpp:1040 src/gpgmsg.cpp:1084 src/gpgmsg.cpp:1098
-#: src/gpgmsg.cpp:1114 src/gpgmsg.cpp:1279
+#: src/gpgmsg.cpp:1187 src/gpgmsg.cpp:1270 src/gpgmsg.cpp:1284
+#: src/gpgmsg.cpp:1300 src/gpgmsg.cpp:1466
 msgid "Decryption"
 msgstr "Entschlüsselung"
 
-#: src/gpgmsg.cpp:1075
+#: src/gpgmsg.cpp:1239
+msgid ""
+"Note: This is a PGP/MIME signed message.  The GPGol plugin is not always "
+"able to verify such a message due to missing support in Outlook.\n"
+"\n"
+"(This message will be shown only once per session)"
+msgstr ""
+"Hinweis: Dies is eine PGP/MIME signierte Nachricht.  Das GPGol Plugin\n"
+"ist nicht immer in der Lage, eine solche Nachricht zu verifizieren.\n"
+"Der Grund hierzu liegt in der fehlenden Unterstützung von Outlook.\n"
+"\n"
+"(Dieser Hinweis wird nur einmalif je Session angezeigt)"
+
+#: src/gpgmsg.cpp:1243
+msgid "Verification"
+msgstr "Überprüfung"
+
+#: src/gpgmsg.cpp:1261
 msgid "[This is a PGP/MIME message]"
 msgstr "[PGP/MIME Nachricht]"
 
-#: src/gpgmsg.cpp:1083 src/gpgmsg.cpp:1097 src/gpgmsg.cpp:1113
+#: src/gpgmsg.cpp:1269 src/gpgmsg.cpp:1283 src/gpgmsg.cpp:1299
 msgid "Problem decrypting PGP/MIME message"
 msgstr "Problem bei Entschlüsseln einer PGP/MIME Nachricht"
 
-#: src/gpgmsg.cpp:1234
+#: src/gpgmsg.cpp:1421
 msgid "Verification Failure"
 msgstr "Überprüfungsfehler"
 
-#: src/gpgmsg.cpp:1237
+#: src/gpgmsg.cpp:1424
 msgid "Decryption Failure"
 msgstr "Entschlüsselungsfehler"
 
-#: src/gpgmsg.cpp:1273
+#: src/gpgmsg.cpp:1460
 msgid ""
 "The message text cannot be displayed.\n"
 "You have to save the decrypted message to view it.\n"
@@ -176,7 +197,7 @@
 
 #. TRANSLATORS: Keep the @LIST@ verbatim on a separate line; it
 #. will be expanded to a list of atatchment names.
-#: src/gpgmsg.cpp:1300
+#: src/gpgmsg.cpp:1487
 msgid ""
 "Signed attachments found.\n"
 "\n"
@@ -188,13 +209,13 @@
 "@LIST@\n"
 "Möchten Sie diese Unterschriften überprüfen?"
 
-#: src/gpgmsg.cpp:1308
+#: src/gpgmsg.cpp:1495
 msgid "Attachment Verification"
 msgstr "Überprüfung der Anhänge"
 
 #. TRANSLATORS: Keep the @LIST@ verbatim on a separate line; it
 #. will be expanded to a list of atatchment names.
-#: src/gpgmsg.cpp:1329
+#: src/gpgmsg.cpp:1516
 msgid ""
 "Encrypted attachments found.\n"
 "\n"
@@ -206,31 +227,31 @@
 "@LIST@\n"
 "Möchten Sie diese entschlüsseln und abspeichern?"
 
-#: src/gpgmsg.cpp:1336
+#: src/gpgmsg.cpp:1523
 msgid "Attachment Decryption"
 msgstr "Entschlüsselung eines Anhangs"
 
-#: src/gpgmsg.cpp:1405
+#: src/gpgmsg.cpp:1592
 msgid "Signing Failure"
 msgstr "Unterschrifterstellungsfehler"
 
-#: src/gpgmsg.cpp:1581
+#: src/gpgmsg.cpp:1768
 msgid "Encryption Failure"
 msgstr "Verschlüsselungsfehler"
 
-#: src/gpgmsg.cpp:1635 src/gpgmsg.cpp:2930
+#: src/gpgmsg.cpp:1822 src/gpgmsg.cpp:3117
 msgid "Attachment Encryption Failure"
 msgstr "Verschlüsselungsfehler eines Anhangs"
 
-#: src/gpgmsg.cpp:2337
+#: src/gpgmsg.cpp:2524
 msgid "Attachment Verification Failure"
 msgstr "Überprüfungsfehler eines Anhangs"
 
-#: src/gpgmsg.cpp:2520 src/gpgmsg.cpp:2569
+#: src/gpgmsg.cpp:2707 src/gpgmsg.cpp:2756
 msgid "Attachment Decryption Failure"
 msgstr "Entschlüsselungsfehler eines Anhangs"
 
-#: src/gpgmsg.cpp:2739
+#: src/gpgmsg.cpp:2926
 msgid "Attachment Signing Failure"
 msgstr "Unterschrifterstellungsfehler eines Anhangs"
 
@@ -238,7 +259,7 @@
 msgid "The default key may not contain any spaces."
 msgstr "Der Standardschlüssel darf keine Leerzeichen enthalten."
 
-#: src/olflange.cpp:748
+#: src/olflange.cpp:750
 msgid ""
 "This version of Outlook is too old!\n"
 "\n"
@@ -255,7 +276,7 @@
 "\n"
 "Bitte updaten Sie auf SP2 bevor Sie versuchen eine Nachricht zu versenden."
 
-#: src/olflange.cpp:937
+#: src/olflange.cpp:939
 msgid ""
 "Sorry, we can only encrypt plain text messages and\n"
 "no RTF messages. Please make sure that only the text\n"
@@ -266,51 +287,51 @@
 "Sie sicher, daß lediglich das Text Format ausgewählt wurde.\n"
 "(In der Menüleiste: \"Format\" => \"Nur Text\")"
 
-#: src/olflange.cpp:1327
+#: src/olflange.cpp:1329
 msgid "&Decrypt and verify message"
 msgstr "Entschlüsseln/Prüfen der Nachricht"
 
-#: src/olflange.cpp:1365
+#: src/olflange.cpp:1367
 msgid "GPG &encrypt message"
 msgstr "Mit GPG &verschlüsseln"
 
-#: src/olflange.cpp:1371
+#: src/olflange.cpp:1373
 msgid "GPG &sign message"
 msgstr "Mit GPG unter&schreiben"
 
-#: src/olflange.cpp:1417
+#: src/olflange.cpp:1419
 msgid "GPG Key &Manager"
 msgstr "GPG Schlüssel&verwaltung"
 
-#: src/olflange.cpp:1549
+#: src/olflange.cpp:1551
 msgid "Could not start Key-Manager"
 msgstr "Dei Schlüsselverwaltung konnte nicht aufgerufen werden"
 
-#: src/olflange.cpp:1595
+#: src/olflange.cpp:1597
 msgid "Decrypt and verify the message."
 msgstr "Entschlüsseln und Prüfen der Nachricht."
 
-#: src/olflange.cpp:1603
+#: src/olflange.cpp:1605
 msgid "Select this option to encrypt the message."
 msgstr "Wählen Sie diese Option zum Verschlüsseln der Nachricht."
 
-#: src/olflange.cpp:1609
+#: src/olflange.cpp:1611
 msgid "Select this option to sign the message."
 msgstr "Wählen Sie diese Option zum Unterschreiben der Nachricht."
 
-#: src/olflange.cpp:1618 src/olflange.cpp:1679 src/olflange.cpp:1761
+#: src/olflange.cpp:1620 src/olflange.cpp:1681 src/olflange.cpp:1763
 msgid "Open GPG Key Manager"
 msgstr "Die GPG Schlüsselverwaltung öffnen"
 
-#: src/olflange.cpp:1648 src/olflange.cpp:1712
+#: src/olflange.cpp:1650 src/olflange.cpp:1714
 msgid "Decrypt message and verify signature"
 msgstr "Nachricht entschlüsseln und Unterschrift prüfen"
 
-#: src/olflange.cpp:1659 src/olflange.cpp:1730
+#: src/olflange.cpp:1661 src/olflange.cpp:1732
 msgid "Encrypt message with GPG"
 msgstr "Nachricht mit GPG verschlüsseln"
 
-#: src/olflange.cpp:1668 src/olflange.cpp:1745
+#: src/olflange.cpp:1670 src/olflange.cpp:1747
 msgid "Sign message with GPG"
 msgstr "Nachricht mit GPG unterschreiben"
 
@@ -318,11 +339,15 @@
 msgid "No key hint given."
 msgstr "Kein Hinweis auf den Schlüssel"
 
-#: src/passphrase-dialog.c:322 src/passphrase-dialog.c:464
+#: src/passphrase-dialog.c:325 src/passphrase-dialog.c:469
 msgid "Invalid passphrase; please try again..."
 msgstr "Ungültige Passphrase; bitte nochmal versuchen..."
 
-#: src/passphrase-dialog.c:404 src/passphrase-dialog.c:523
+#: src/passphrase-dialog.c:342
+msgid "Select Signing Key"
+msgstr "Signaturschlüssel auswählen"
+
+#: src/passphrase-dialog.c:409 src/passphrase-dialog.c:528
 msgid ""
 "If you cancel this dialog, the message will be sent in cleartext!\n"
 "\n"
@@ -333,7 +358,7 @@
 "\n"
 "Möchten Sie wirklich abbrechen?"
 
-#: src/passphrase-dialog.c:410
+#: src/passphrase-dialog.c:415
 msgid ""
 "If you cancel this dialog, the message will be sent without signing.\n"
 "\n"
@@ -344,11 +369,11 @@
 "\n"
 "Möchten Sie wirklich abbrechen?"
 
-#: src/passphrase-dialog.c:419 src/passphrase-dialog.c:538
+#: src/passphrase-dialog.c:424 src/passphrase-dialog.c:543
 msgid "Secret Key Dialog"
 msgstr "Auswahl des geheimen Schlüssels"
 
-#: src/passphrase-dialog.c:529
+#: src/passphrase-dialog.c:534
 msgid ""
 "If you cancel this dialog, the message will be sent without signing.\n"
 "Do you really want to cancel?"
@@ -358,7 +383,7 @@
 "\n"
 "Möchten Sie wirklich abbrechen?"
 
-#: src/pgpmime.c:421
+#: src/pgpmime.c:485
 msgid ""
 "Error creating file\n"
 "Please select another one"
@@ -366,23 +391,39 @@
 "Fehler bei der Erstellung der Datei.\n"
 "Bitte wählen Sie eine anderen Namen."
 
-#: src/pgpmime.c:423 src/pgpmime.c:557
+#: src/pgpmime.c:487 src/pgpmime.c:638
 msgid "I/O-Error"
 msgstr "Ein-/Ausgabefehler"
 
-#: src/pgpmime.c:556
+#: src/pgpmime.c:637
 msgid "Error writing file"
 msgstr "Dateischreibfehler"
 
-#: src/pgpmime.c:613
+#: src/pgpmime.c:713
 msgid "[PGP/MIME message]"
 msgstr "[PGP/MIME Nachricht]"
 
-#: src/pgpmime.c:630
+#: src/pgpmime.c:730
 msgid "[PGP/MIME message without plain text body]"
 msgstr "[PGP/MIME Nachricht ohne reinen Textkörper]"
 
-#: src/recipient-dialog.c:477
+#: src/pgpmime.c:802
+msgid "[PGP/MIME signed message without a plain text body]"
+msgstr "[PGP/MIME signierte Nachricht ohne reinen Textkörper]"
+
+#: src/pgpmime.c:812
+msgid "[PGP/MIME signature]"
+msgstr "[PGP/MIME Signatur]"
+
+#: src/recipient-dialog.c:423
+msgid "Please select at least one recipient key."
+msgstr "Bitte wählen Sie mindestens einen Empfängerschlüssel."
+
+#: src/recipient-dialog.c:424 src/recipient-dialog.c:485
+msgid "Recipient Dialog"
+msgstr "Auswahl des Empfängerschlüssels"
+
+#: src/recipient-dialog.c:482
 msgid ""
 "If you cancel this dialog, the message will be sent in cleartext.\n"
 "\n"
@@ -393,60 +434,56 @@
 "\n"
 "Möchten Sie wirklich abbrechen?"
 
-#: src/recipient-dialog.c:480
-msgid "Recipient Dialog"
-msgstr "Auswahl des Empfängerschlüssels"
-
-#: src/recipient-dialog.c:555 src/verify-dialog.c:152
+#: src/recipient-dialog.c:560 src/verify-dialog.c:157
 msgid "User-ID not found"
 msgstr "User-ID nicht gefunden"
 
-#: src/verify-dialog.c:121
+#: src/verify-dialog.c:125
 msgid "Good signature"
 msgstr "Korrekte Unterschrift"
 
-#: src/verify-dialog.c:123
+#: src/verify-dialog.c:127
 msgid "BAD signature!"
 msgstr "FALSCHE Unterschrift!"
 
-#: src/verify-dialog.c:125
+#: src/verify-dialog.c:129
 msgid "Good signature from revoked key"
 msgstr "Korrekte Unterschrift; aber Schlüssel wurde widerrufen"
 
-#: src/verify-dialog.c:127
+#: src/verify-dialog.c:131
 msgid "Good signature from expired key"
 msgstr "Korrekte Unterschrift; allerdings ist der Schlüssel abgelaufen"
 
-#: src/verify-dialog.c:129
+#: src/verify-dialog.c:133
 msgid "Good expired signature"
 msgstr "Korrekte aber abgelaufene Unterschrift"
 
-#: src/verify-dialog.c:132
+#: src/verify-dialog.c:136
 msgid "Could not check signature: missing key"
 msgstr "Unterschrift konnte nicht geprüft werden:  Schlüssel fehlt"
 
-#: src/verify-dialog.c:136
+#: src/verify-dialog.c:140
 msgid "Verification error"
 msgstr "Überprüfungsfehler"
 
-#: src/verify-dialog.c:164
+#: src/verify-dialog.c:169
 msgid "This may be due to a wrong option setting"
 msgstr "Möglicherweise durch falsche Einstellungen verursacht"
 
-#: src/verify-dialog.c:170
+#: src/verify-dialog.c:175
 #, c-format
 msgid "Signature expired on %s"
 msgstr "Unterschrift abgelaufen am %s"
 
-#: src/verify-dialog.c:182
+#: src/verify-dialog.c:187
 msgid "Signature issued by a key we do NOT trust."
 msgstr "Die Unterschrift stammt von einem Schlüssel dem wir NICHT vertrauen."
 
-#: src/verify-dialog.c:189
+#: src/verify-dialog.c:194
 msgid "Signature issued by a non-valid key."
 msgstr "Die Unterschrift stammt von einem ungültigen Schlüssel."
 
-#: src/verify-dialog.c:211
+#: src/verify-dialog.c:216
 msgid "Verification Result"
 msgstr "Prüfungsresultat"
 

Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2006-03-21 15:57:47 UTC (rev 142)
+++ trunk/src/ChangeLog	2006-03-27 19:31:08 UTC (rev 143)
@@ -1,3 +1,21 @@
+2006-03-27  Werner Koch  <wk at g10code.com>
+
+	* engine-gpgme.c (op_verify_detached_sig_gpgme): New.
+
+	* pgpmime.c (pgpmime_verify): New. First take on a PGP/MIME
+	signature verification.
+
+	* gpgmsg.cpp (is_pgpmime): Renamed to is_pgpmime_enc.
+	(class GpgMsgImpl): Niew members media_type. media_subtype and
+	ct_protocol.
+	(get_msg_content_type): New.
+	(decrypt): Show a warning for PGP/MIME signed messages.
+
+2006-03-26  Werner Koch  <wk at g10code.com>
+
+	* intern.h: New option PREFER_HTML.
+	* main.c (write_options, read_options): Ditto.
+
 2006-03-20  Werner Koch <wk at g10code.com>
 
 	* olflange.cpp (Install): Also check major part of build version.
@@ -12,7 +30,7 @@
 	* recipient-dialog.c (recipient_dlg_proc): Likewise.
 	* verify-dialog.c (load_akalist): Likewise.
 	(load_sigbox): Likewise.
-	* common.c (utf_to_wincp): New.
+	* common.c (utf8_to_wincp): New.
 
 2006-03-15  Werner Koch  <wk at g10code.com>
 

Modified: trunk/src/engine-gpgme.c
===================================================================
--- trunk/src/engine-gpgme.c	2006-03-21 15:57:47 UTC (rev 142)
+++ trunk/src/engine-gpgme.c	2006-03-27 19:31:08 UTC (rev 143)
@@ -1,5 +1,5 @@
 /* engine-gpgme.c - Crypto engine with GPGME
- *	Copyright (C) 2005 g10 Code GmbH
+ *	Copyright (C) 2005, 2006 g10 Code GmbH
  *
  * This file is part of GPGol.
  *
@@ -917,6 +917,42 @@
 }
 
 
+/* Verify a detached message where the data is in the gpgme object
+   DATA and the signature is the gpgme object SIG.  FILENAME will be
+   shown by the verification status dialog box.  If ATTESTATION is not
+   NULL a text with the result of the signature verification will get
+   printed to it.  */ 
+int
+op_verify_detached_sig_gpgme (gpgme_data_t data, gpgme_data_t sig,
+                              const char *filename, gpgme_data_t attestation)
+{
+  gpgme_ctx_t ctx = NULL;
+  gpgme_error_t err;
+  gpgme_verify_result_t res = NULL;
+
+  op_init ();
+
+  err = gpgme_new (&ctx);
+  if (err)
+    goto leave;
+
+  err = gpgme_op_verify (ctx, sig, data, NULL);
+  if (!err)
+    {
+      res = gpgme_op_verify_result (ctx);
+      if (res) 
+        verify_dialog_box (res, filename);
+      if (res && attestation)
+        add_verify_attestation (attestation, ctx, res, filename);
+    }
+
+ leave:
+  if (ctx)
+    gpgme_release (ctx);
+  return err;
+}
+
+
 
 static void
 at_puts (gpgme_data_t a, const char *s)
@@ -1133,7 +1169,7 @@
 
   if (!gpgme_data_seek (a, 0, SEEK_CUR))
     {
-      /* Nothing yet written to the stream.  Insert the curretn time. */
+      /* Nothing yet written to the stream.  Insert the current time. */
       at_puts (a, _("Verification started at: "));
       at_print_time (a, time (NULL));
       at_puts (a, "\n\n");

Modified: trunk/src/engine.h
===================================================================
--- trunk/src/engine.h	2006-03-21 15:57:47 UTC (rev 142)
+++ trunk/src/engine.h	2006-03-27 19:31:08 UTC (rev 143)
@@ -75,6 +75,9 @@
 int op_verify_detached_sig_mem (const char *data_string,
                                 const char *sig_string, const char *filename,
                                 gpgme_data_t attestation);
+int op_verify_detached_sig_gpgme (gpgme_data_t data, gpgme_data_t sig,
+                                  const char *filename,
+                                  gpgme_data_t attestation);
 
 
 int op_export_keys (const char *pattern[], const char *outfile);

Modified: trunk/src/gpgmsg.cpp
===================================================================
--- trunk/src/gpgmsg.cpp	2006-03-21 15:57:47 UTC (rev 142)
+++ trunk/src/gpgmsg.cpp	2006-03-27 19:31:08 UTC (rev 143)
@@ -1,5 +1,5 @@
 /* gpgmsg.cpp - Implementation ofthe GpgMsg class
- *	Copyright (C) 2005 g10 Code GmbH
+ *	Copyright (C) 2005, 2006 g10 Code GmbH
  *
  * This file is part of GPGol.
  * 
@@ -37,7 +37,9 @@
 #include "pgpmime.h"
 #include "engine.h"
 #include "display.h"
+#include "rfc822parse.h"
 
+
 static const char oid_mimetag[] =
   {0x2A, 0x86, 0x48, 0x86, 0xf7, 0x14, 0x03, 0x0a, 0x04};
 
@@ -99,10 +101,16 @@
   {
     message = NULL;
     exchange_cb = NULL;
-    is_pgpmime = false;
+    is_pgpmime_enc = false;
     has_attestation = false;
     preview = false;
 
+    got_message_ct = false;
+    media_type = NULL;
+    media_subtype = NULL;
+    ct_protocol = NULL;
+    transport_message_headers = NULL;
+
     attestation = NULL;
 
     attach.att_table = NULL;
@@ -111,6 +119,11 @@
 
   ~GpgMsgImpl ()
   {
+    xfree (media_type);
+    xfree (media_subtype);
+    xfree (ct_protocol);
+    xfree (transport_message_headers);
+
     if (message)
       message->Release ();
 
@@ -136,6 +149,7 @@
       {
         message->Release ();
         message = NULL;
+        got_message_ct = false;
       }
     if (msg)
       {
@@ -186,15 +200,21 @@
 private:
   LPMESSAGE message;  /* Pointer to the message. */
   void *exchange_cb;  /* Call back used with the display function. */
-  bool is_pgpmime;    /* True if the message is a PGP/MIME encrypted one. */
+  bool is_pgpmime_enc;/* True if the message is a PGP/MIME encrypted one. */
   bool has_attestation;/* True if we found an attestation attachment. */
   bool preview;       /* Don't pop up message boxes and run only a
                          body decryption. */
 
   /* If not NULL, collect attestation information here. */
   gpgme_data_t attestation;
-  
 
+  /* Store information from the messages headers. */ 
+  bool got_message_ct;  /* Flag indicating whether we retrieved the info. */
+  char *media_type;     /* Media type from the content-type or NULL. */
+  char *media_subtype;  /* Media sybtype from the content-type or NULL. */
+  char *ct_protocol;    /* Protocol from the content_type or NULL. */
+  char *transport_message_headers;  /* Al the message headers as one string. */
+
   /* This structure collects the information about attachments. */
   struct 
   {
@@ -204,6 +224,7 @@
   
   void free_attach_info (void);
   char *loadBody (bool want_html);
+  void get_msg_content_type (void);
   bool isPgpmimeVersionPart (int pos);
   void writeAttestation (void);
   gpg_error_t createHtmlAttachment (const char *text);
@@ -363,7 +384,7 @@
 
 
 
-/* Load the body from the MAP and return it as an UTF8 string.
+/* Load the body from the MAPI and return it as an UTF8 string.
    Returns NULL on error.  */
 char *
 GpgMsgImpl::loadBody (bool want_html)
@@ -561,6 +582,114 @@
 #endif
 
 
+
+/* Helper for get_msg_content_type() */
+static int
+get_msg_content_type_cb (void *dummy_arg,
+                         rfc822parse_event_t event, rfc822parse_t msg)
+{
+  if (event == RFC822PARSE_T2BODY)
+    return 42; /* Hack to stop immediately the parsing.  This is
+                  required because the code would else prepare for
+                  MIME handling and we don't want this to happen. In
+                  general it would be better to do any parsing of the
+                  headers here but we need to access instance
+                  variables and it is more complex to do this in a
+                  callback. */
+  return 0;
+}
+
+
+/* Find Content-Type of the current message.  The result will be put
+   into instance variables.  */
+void
+GpgMsgImpl::get_msg_content_type (void)
+{
+  HRESULT hr;
+  LPSPropValue propval = NULL;
+  rfc822parse_t msg;
+  const char *header_lines, *s;
+  rfc822parse_field_t ctx;
+  size_t length;
+
+  if (got_message_ct)
+    return;
+  got_message_ct = 1;
+
+  xfree (media_type);
+  media_type = NULL;
+  xfree (media_subtype);
+  media_subtype = NULL;
+  xfree (ct_protocol);
+  ct_protocol = NULL;
+  xfree (transport_message_headers);
+  transport_message_headers = NULL;
+
+  hr = HrGetOneProp ((LPMAPIPROP)message,
+                     PR_TRANSPORT_MESSAGE_HEADERS_A, &propval);
+  if (FAILED (hr))
+    {
+      log_error ("%s:%s: error getting the headers lines: hr=%#lx",
+                 SRCNAME, __func__, hr);
+      return; 
+    }
+  if ( PROP_TYPE (propval->ulPropTag) != PT_STRING8 )
+    {
+      /* As per rfc822, header lines must be plain ascii, so no need to
+         cope withy unicode etc. */
+      log_error ("%s:%s: proptag=%#lx not supported\n",
+                 SRCNAME, __func__, propval->ulPropTag);
+      MAPIFreeBuffer (propval);
+      return;
+    }
+
+  header_lines = propval->Value.lpszA;
+
+  /* Save the header lines in case we need them for signature
+     verification. */
+  transport_message_headers = xstrdup (header_lines);
+
+  /* Read the headers into an rfc822 object. */
+  msg = rfc822parse_open (get_msg_content_type_cb, NULL);
+  if (!msg)
+    {
+      log_error ("%s:%s: rfc822parse_open failed\n", SRCNAME, __func__);
+      MAPIFreeBuffer (propval);
+      return;
+    }
+  
+  while ((s = strchr (header_lines, '\n')))
+    {
+      length = (s - header_lines);
+      if (length && s[-1] == '\r')
+        length--;
+      rfc822parse_insert (msg, (const unsigned char*)header_lines, length);
+      header_lines = s+1;
+    }
+  
+  /* Parse the content-type field. */
+  ctx = rfc822parse_parse_field (msg, "Content-Type", -1);
+  if (ctx)
+    {
+      const char *s1, *s2;
+      s1 = rfc822parse_query_media_type (ctx, &s2);
+      if (s1)
+        {
+          media_type = xstrdup (s1);
+          media_subtype = xstrdup (s2);
+          s = rfc822parse_query_parameter (ctx, "protocol", 0);
+          if (s)
+            ct_protocol = xstrdup (s);
+        }
+      rfc822parse_release_field (ctx);
+    }
+
+  rfc822parse_close (msg);
+  MAPIFreeBuffer (propval);
+}
+
+
+
 /* Return the type of a message with the body text in TEXT. */
 openpgp_t
 GpgMsgImpl::getMessageType (const char *text)
@@ -949,6 +1078,7 @@
   unsigned int n_attach = 0;
   unsigned int n_encrypted = 0;
   unsigned int n_signed = 0;
+  int is_pgpmime_sig = 0;
   int have_pgphtml_sig = 0;
   int have_pgphtml_enc = 0;
   unsigned int pgphtml_pos = 0;
@@ -957,6 +1087,21 @@
   int is_html = 0;
   char *body;
 
+  get_msg_content_type ();
+  log_debug ("%s:%s: parsed content-type: media=%s/%s protocol=%s\n",
+             SRCNAME, __func__,
+             media_type? media_type:"[none]",
+             media_subtype? media_subtype:"[none]",
+             ct_protocol? ct_protocol : "[none]");
+  if (media_type && media_subtype && ct_protocol
+      && !strcmp (media_type, "multipart")
+      && !strcmp (media_subtype, "signed")
+      && !strcmp (ct_protocol, "application/pgp-signature"))
+    {
+      /* This is a PGP/MIME signature.  */
+      is_pgpmime_sig = 1;
+    }
+  
   /* Load the body text into BODY.  Note that body may be NULL but in
      this case MTYPE will be OPENPGP_NONE. */
   body = loadBody (false);
@@ -966,9 +1111,10 @@
      attachments.  We check right now because we need to get into the
      decryption code even if the body is not encrypted but attachments
      are available. */
-  table = gatherAttachmentInfo ();
+  table = is_pgpmime_sig? NULL : gatherAttachmentInfo ();
   if (table)
     {
+      /* Fixup for the special pgphtml attachment. */
       for (pos=0; !table[pos].end_of_table; pos++)
         if (table[pos].is_encrypted)
           {
@@ -1005,8 +1151,9 @@
   log_debug ("%s:%s: message has %u attachments with "
              "%u signed and %d encrypted\n",
              SRCNAME, __func__, n_attach, n_signed, n_encrypted);
+
   if (mtype == OPENPGP_NONE && !n_encrypted && !n_signed
-      && !have_pgphtml_enc && !have_pgphtml_sig) 
+      && !have_pgphtml_enc && !have_pgphtml_sig && !is_pgpmime_sig) 
     {
       /* Because we usually work around the OL object model, it can't
          notice that we changed the windows's text behind its back (by
@@ -1060,8 +1207,47 @@
     gpgme_data_new (&attestation);
   
   /* Process according to type of message. */
-  if (is_pgpmime)
+  if (is_pgpmime_sig)
     {
+      static int warning_shown;
+      
+      /* We need to do duplicate some work: For retrieving the headers
+         we already used our own rfc822 parser.  For actually
+         verifying the signature we need to concatentate the body with
+         these hesaders and passs it down to pgpmime.c where they will
+         be parsed again. Probably easier to maintain than merging the
+         MAPI access with our rc822 parser code. */
+      const char *mybody = body? body: "";
+      char *tmp;
+      
+      assert (transport_message_headers);
+      tmp = (char*)xmalloc (strlen (transport_message_headers)
+                            + strlen (mybody));
+      strcpy (stpcpy (tmp, transport_message_headers), mybody);
+
+      /* Note, that we don't do an attestation.  This is becuase we
+         don't run the code to check for duplicate attestations. */
+      err = pgpmime_verify (tmp,
+                            opt.passwd_ttl, &plaintext, NULL,
+                            hwnd, preview);
+      xfree (tmp);
+
+      if (err && !warning_shown)
+        {
+          warning_shown = 1;
+          MessageBox
+            (hwnd, _("Note: This is a PGP/MIME signed message.  The GPGol "
+                     "plugin is not always able to verify such a message "
+                     "due to missing support in Outlook.\n\n"
+                     "(This message will be shown only once per session)"),
+                      _("Verification"), MB_ICONWARNING|MB_OK);
+        }
+      
+      if (!err)
+        pgpmime_succeeded = 1;
+    }
+  else if (is_pgpmime_enc)
+    {
       LPATTACH att;
       int method;
       LPSTREAM from;
@@ -1225,9 +1411,10 @@
     }
   else
     err = gpg_error (GPG_ERR_NO_DATA);
+
   if (err)
     {
-      if (!is_pgpmime && n_attach && gpg_err_code (err) == GPG_ERR_NO_DATA)
+      if (!is_pgpmime_enc && n_attach && gpg_err_code (err) == GPG_ERR_NO_DATA)
         ;
       else if (mtype == OPENPGP_CLEARSIG)
         MessageBox (hwnd, op_strerror (err),
@@ -2102,7 +2289,7 @@
   unsigned int attestation_count = 0;
   unsigned int invalid_count = 0;
 
-  is_pgpmime = false;
+  is_pgpmime_enc = false;
   has_attestation = false;
   n_attach = getAttachments ();
   log_debug ("%s:%s: message has %u attachments\n",
@@ -2251,7 +2438,7 @@
       log_debug ("\tThis is a PGP/MIME encrypted message - table adjusted");
       table[0].is_encrypted = 0;
       table[1].is_encrypted = 1;
-      is_pgpmime = true;
+      is_pgpmime_enc = true;
     }
 
   return table;

Modified: trunk/src/intern.h
===================================================================
--- trunk/src/intern.h	2006-03-21 15:57:47 UTC (rev 142)
+++ trunk/src/intern.h	2006-03-27 19:31:08 UTC (rev 143)
@@ -100,6 +100,7 @@
   char *default_key;         /* The key we want to always encrypt to. */
   int enable_default_key;    /* Enable the use of DEFAULT_KEY. */
   int preview_decrypt;       /* Decrypt in preview window. */
+  int prefer_html;           /* Prefer html in html/text alternatives. */
 
   /* The compatibility flags. */
   struct 

Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c	2006-03-21 15:57:47 UTC (rev 142)
+++ trunk/src/main.c	2006-03-27 19:31:08 UTC (rev 143)
@@ -406,6 +406,10 @@
   set_default_key (val);
   xfree (val); val = NULL;
 
+  load_extension_value ("preferHtml", &val);
+  opt.prefer_html = val == NULL || *val != '1'? 0 : 1;
+  xfree (val); val = NULL;
+
   /* Note, that on purpose these flags are only Registry changeable.
      The format of the entry is a string of of "0" and "1" digits; see
      the switch below for a description. */
@@ -457,6 +461,7 @@
     {"logFile",                  2, 0, logfile},
     {"defaultKey",               2, 0, opt.default_key},
     {"enableDefaultKey",         0, opt.enable_default_key},
+    {"preferHtml",               0, opt.prefer_html},
     {NULL, 0}
   };
   char buf[32];

Modified: trunk/src/olflange.cpp
===================================================================
--- trunk/src/olflange.cpp	2006-03-21 15:57:47 UTC (rev 142)
+++ trunk/src/olflange.cpp	2006-03-27 19:31:08 UTC (rev 143)
@@ -706,7 +706,7 @@
                lFlags);
   
   /* Check version. */
-  log_debug ("GPGol: this is %s\n", SRCNAME, __func__, PACKAGE_STRING);
+  log_debug ("GPGol: this is %s\n", PACKAGE_STRING);
   pEECB->GetVersion (&lBuildVersion, EECBGV_GETBUILDVERSION);
   pEECB->GetVersion (&lActualVersion, EECBGV_GETACTUALVERSION);
   pEECB->GetVersion (&lVirtualVersion, EECBGV_GETVIRTUALVERSION);

Modified: trunk/src/pgpmime.c
===================================================================
--- trunk/src/pgpmime.c	2006-03-21 15:57:47 UTC (rev 142)
+++ trunk/src/pgpmime.c	2006-03-27 19:31:08 UTC (rev 143)
@@ -89,15 +89,28 @@
   rfc822parse_t msg;  /* The handle of the RFC822 parser. */
 
   int preview;        /* Do only decryption and pop up no  message bozes.  */
+  
+  int verify_mode;    /* True if we want to verify a PGP/MIME signature. */
 
   int nesting_level;  /* Current MIME nesting level. */
   int in_data;        /* We are currently in data (body or attachment). */
 
+  gpgme_data_t signed_data;/* NULL or the data object used to collect
+                              the signed data. It would bet better to
+                              just hash it but there is no support in
+                              gpgme for this yet. */
+  gpgme_data_t sig_data;  /* NULL or data object to collect the
+                             signature attachment which should be a
+                             signature then.  */
   
   gpgme_data_t body;      /* NULL or a data object used to collect the
                              body part we are going to display later. */
   int collect_body;       /* True if we are collecting the body lines. */
   int collect_attachment; /* True if we are collecting an attachment. */
+  int collect_signeddata; /* True if we are collecting the signed data. */
+  int collect_signature;  /* True if we are collecting a signature.  */
+  int start_hashing;      /* Flag used to start collecting signed data. */
+  int hashing_level;      /* MIME level where we started hashing. */
   int is_qp_encoded;      /* Current part is QP encoded. */
   int is_base64_encoded;  /* Current part is base 64 encoded. */
   int is_utf8;            /* Current part has charset utf-8. */
@@ -292,10 +305,26 @@
   HRESULT hr;
 
   debug_message_event (ctx, event);
+
+  if (event == RFC822PARSE_BEGIN_HEADER || event == RFC822PARSE_T2BODY)
+    {
+      /* We need to check here whether to start collecting signed data
+         because attachments might come without header lines and thus
+         we won't see the BEGIN_HEADER event. */
+      if (ctx->start_hashing == 1)
+        {
+          ctx->start_hashing = 2;
+          ctx->hashing_level = ctx->nesting_level;
+          ctx->collect_signeddata = 1;
+          gpgme_data_new (&ctx->signed_data);
+        }
+    }
+
+
   if (event == RFC822PARSE_T2BODY)
     {
       rfc822parse_field_t field;
-      const char *s1, *s2;
+      const char *s1, *s2, *s3;
       size_t off;
       char *p;
       int is_text = 0;
@@ -318,12 +347,42 @@
 
                      For now encapsulated signed or encrypted
                      containers are not processed in a special way as
-                     they should. */
+                     they should.  Except for the simple verify
+                     mode. */
+                  if (ctx->verify_mode && !ctx->signed_data
+                      && !strcmp (s2,"signed")
+                      && (s3 = rfc822parse_query_parameter (field,
+                                                            "protocol", 0))
+                      && !strcmp (s3, "application/pgp-signature"))
+                    {
+                      /* Need to start the hashing after the next
+                         boundary. */
+                      ctx->start_hashing = 1;
+                    }
                 }
               else if (!strcmp (s1, "text"))
                 {
                   is_text = 1;
                 }
+              else if (ctx->verify_mode
+                       && ctx->nesting_level == 1
+                       && !ctx->sig_data
+                       && !strcmp (s1, "application")
+                       && !strcmp (s2, "pgp-signature"))
+                {
+                  /* This is the second part of a PGP/MIME signature.
+                     We only support here full messages thus checking
+                     the nesting level is sufficient. We do this only
+                     for the first signature (i.e. if sig_data has not
+                     been set yet). We do this only while in verify
+                     mode because we don't want to write a full MUA
+                     (although this would be easier than to tame this
+                     Outlook beast). */
+                  if (!ctx->preview && !gpgme_data_new (&ctx->sig_data))
+                    {
+                      ctx->collect_signature = 1;
+                    }
+                }
               else /* Other type. */
                 {
                   if (!ctx->preview)
@@ -345,6 +404,9 @@
         }
       ctx->in_data = 1;
 
+      log_debug ("%s: this body: nesting=%d part_counter=%d is_text=%d\n", 
+                 SRCNAME, ctx->nesting_level, ctx->part_counter, is_text);
+
       /* Need to figure out the encoding. */
       ctx->is_qp_encoded = 0;
       ctx->is_base64_encoded = 0;
@@ -382,9 +444,11 @@
             ctx->collect_attachment = 1;
         }
 
-      /* Now that if we have an attachment prepare for writing it out. */
+
       if (ctx->collect_attachment)
         {
+          /* Now that if we have an attachment prepare for writing it
+             out. */
           p = NULL;
           field = rfc822parse_parse_field (msg, "Content-Disposition", -1);
           if (field)
@@ -457,6 +521,11 @@
           IStream_Release (ctx->outstream);
           ctx->outstream = NULL;
         }
+      if (ctx->start_hashing == 2 && ctx->hashing_level == ctx->nesting_level)
+        {
+          ctx->start_hashing = 3; /* Avoid triggering it again. */
+          ctx->collect_signeddata = 0;
+        }
     }
   else if (event == RFC822PARSE_BEGIN_HEADER)
     {
@@ -502,10 +571,22 @@
               return 0; /* Error. */
             }
 
+
+          if (ctx->collect_signeddata && ctx->signed_data)
+            {
+              /* Save the signed data.  Note that we need to delay
+                 the CR/LF because the last line ending belongs to the
+                 next boundary. */
+              if (ctx->collect_signeddata == 2)
+                gpgme_data_write (ctx->signed_data, "\r\n", 2);
+              gpgme_data_write (ctx->signed_data, ctx->linebuf, pos);
+              ctx->collect_signeddata = 2;
+            }
+
           if (ctx->in_data && ctx->collect_body && ctx->body)
             {
               /* We are inside the body of the message.  Save it away
-                 to a gpgme data object.  Note that this gets only
+                 to a gpgme data object.  Note that this is only
                  used for the first text part. */
               if (ctx->collect_body == 1)  /* Need to skip the first line. */
                 ctx->collect_body = 2;
@@ -560,6 +641,25 @@
                     }
                 }
             }
+          else if (ctx->in_data && ctx->collect_signature)
+            {
+              /* We are inside of a signature attachment part.  */
+              if (ctx->collect_signature == 1)  /* Skip the first line. */
+                ctx->collect_signature = 2;
+              else if (ctx->sig_data)
+                {
+                  if (ctx->is_qp_encoded)
+                    len = qp_decode (ctx->linebuf, pos);
+                  else if (ctx->is_base64_encoded)
+                    len = base64_decode (ctx, ctx->linebuf, pos);
+                  else
+                    len = pos;
+                  if (len)
+                    gpgme_data_write (ctx->sig_data, ctx->linebuf, len);
+                  if (!ctx->is_base64_encoded)
+                    gpgme_data_write (ctx->sig_data, "\r\n", 2);
+                }
+            }
           
           /* Continue with next line. */
           pos = 0;
@@ -648,3 +748,89 @@
     }
   return err;
 }
+
+
+
+int
+pgpmime_verify (const char *message, int ttl, char **body,
+                gpgme_data_t attestation, HWND hwnd, int preview_mode)
+{
+  gpg_error_t err = 0;
+  pgpmime_context_t ctx;
+  const char *s;
+
+  *body = NULL;
+
+  ctx = xcalloc (1, sizeof *ctx + LINEBUFSIZE);
+  ctx->linebufsize = LINEBUFSIZE;
+  ctx->hwnd = hwnd;
+  ctx->preview = preview_mode;
+  ctx->verify_mode = 1;
+
+  ctx->msg = rfc822parse_open (message_cb, ctx);
+  if (!ctx->msg)
+    {
+      err = gpg_error_from_errno (errno);
+      log_error ("failed to open the RFC822 parser: %s", strerror (errno));
+      goto leave;
+    }
+
+  /* Need to pass the data line by line to the handler. */
+  for (;(s = strchr (message, '\n')); message = s+1)
+    {
+      plaintext_handler (ctx, message, (s - message) + 1);
+      if (ctx->parser_error || ctx->line_too_long)
+        {
+          err = gpg_error (GPG_ERR_GENERAL);
+          break;
+        }
+    }
+
+  /* Unless there is an error we should return the body. */
+  if (!err)
+    {
+      if (ctx->body)
+        {
+          /* Return the buffer but first make sure it is a string. */
+          if (gpgme_data_write (ctx->body, "", 1) == 1)
+            {
+              *body = gpgme_data_release_and_get_mem (ctx->body, NULL);
+              ctx->body = NULL; 
+            }
+        }
+      else
+        *body = xstrdup (_("[PGP/MIME signed message without a "
+                           "plain text body]"));
+    }
+
+  /* Now actually verify the signature. */
+  if (!err && ctx->signed_data && ctx->sig_data)
+    {
+      gpgme_data_seek (ctx->signed_data, 0, SEEK_SET);
+      gpgme_data_seek (ctx->sig_data, 0, SEEK_SET);
+      err = op_verify_detached_sig_gpgme (ctx->signed_data, ctx->sig_data,
+                                          _("[PGP/MIME signature]"),
+                                          attestation);
+    }
+
+
+ leave:
+  if (ctx)
+    {
+      if (ctx->outstream)
+        {
+          IStream_Revert (ctx->outstream);
+          IStream_Release (ctx->outstream);
+        }
+      rfc822parse_close (ctx->msg);
+      if (ctx->body)
+        gpgme_data_release (ctx->body);
+      if (ctx->signed_data)
+        gpgme_data_release (ctx->signed_data);
+      if (ctx->sig_data)
+        gpgme_data_release (ctx->sig_data);
+      xfree (ctx->filename);
+      xfree (ctx);
+    }
+  return err;
+}

Modified: trunk/src/pgpmime.h
===================================================================
--- trunk/src/pgpmime.h	2006-03-21 15:57:47 UTC (rev 142)
+++ trunk/src/pgpmime.h	2006-03-27 19:31:08 UTC (rev 143)
@@ -31,9 +31,10 @@
 int pgpmime_decrypt (LPSTREAM instream, int ttl, char **body,
                      gpgme_data_t attestation, HWND hwnd,
                      int preview_mode);
+int pgpmime_verify (const char *message, int ttl, char **body,
+                    gpgme_data_t attestation, HWND hwnd, int preview_mode);
 
 
-
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/src/rfc822parse.c
===================================================================
--- trunk/src/rfc822parse.c	2006-03-21 15:57:47 UTC (rev 142)
+++ trunk/src/rfc822parse.c	2006-03-27 19:31:08 UTC (rev 143)
@@ -1005,9 +1005,9 @@
    in RFC2045.
    Returns a pointer to the value which is valid as long as the
    parse context is valid; NULL is returned in case that attr is not
-   defined in the header, a missing value is reppresented by an empty string.
+   defined in the header, a missing value is represented by an empty string.
  
-   With LOWER_VALUE set to true, a matching field valuebe be
+   With LOWER_VALUE set to true, a matching field value will be
    lowercased.
  
    Note, that ATTR should be lowercase.

Modified: trunk/src/rfc822parse.h
===================================================================
--- trunk/src/rfc822parse.h	2006-03-21 15:57:47 UTC (rev 142)
+++ trunk/src/rfc822parse.h	2006-03-27 19:31:08 UTC (rev 143)
@@ -20,7 +20,14 @@
 
 #ifndef RFC822PARSE_H
 #define RFC822PARSE_H
+#ifdef __cplusplus
+extern "C" {
+#if 0
+}
+#endif
+#endif
 
+
 struct rfc822parse_context;
 typedef struct rfc822parse_context *rfc822parse_t;
 
@@ -78,4 +85,7 @@
 const char *rfc822parse_query_media_type (rfc822parse_field_t ctx,
                                           const char **subtype);
 
+#ifdef __cplusplus
+}
+#endif
 #endif /*RFC822PARSE_H */




More information about the Gnupg-commits mailing list