/[winpt]/trunk/Src/wptClipDecryptDlg.cpp
ViewVC logotype

Diff of /trunk/Src/wptClipDecryptDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 229 by twoaday, Mon Jun 19 14:04:31 2006 UTC revision 273 by twoaday, Fri Dec 8 10:22:17 2006 UTC
# Line 13  Line 13 
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Public License for more details.   * GNU General Public License for more details.
  *  
  * You should have received a copy of the GNU General Public License  
  * along with WinPT; if not, write to the Free Software Foundation,  
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA  
16   */   */
   
17  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
18  #include <config.h>  #include <config.h>
19  #endif  #endif
20    
21  #include <windows.h>  #include <windows.h>
22    #include <assert.h>
23    #include <time.h>
24    
25  #include "wptTypes.h"  #include "wptTypes.h"
26  #include "wptW32API.h"  #include "wptW32API.h"
# Line 49  char* Line 46  char*
46  get_key_userid (const char *keyid)  get_key_userid (const char *keyid)
47  {  {
48      winpt_key_s key;      winpt_key_s key;
49      const char *fmt;      const char *fmt, *userid;
50      char *uid;      char *uid;
51    
52        fmt = "\n    \"%s\"";
53      memset (&key, 0, sizeof (key));      memset (&key, 0, sizeof (key));
54      if (winpt_get_pubkey (keyid, &key))      if (winpt_get_pubkey (keyid, &key))
55          return m_strdup (_("user ID not found"));          userid = (_("user ID not found"));
56      fmt = "\n    \"%s\"";      else
57      uid = new char[strlen (key.ext->uids->uid) + strlen (fmt)+ 2];          userid = key.ext->uids->uid;
58        uid = new char[strlen (userid) + strlen (fmt)+ 2];
59      if (!uid)      if (!uid)
60          BUG (NULL);          BUG (NULL);
61      sprintf (uid, fmt, key.ext->uids->uid);      sprintf (uid, fmt, userid);
62      winpt_release_pubkey (&key);      winpt_release_pubkey (&key);
63      return uid;      return uid;
64  }  }
# Line 99  verify_get_key_ownertrust (gpgme_validit Line 98  verify_get_key_ownertrust (gpgme_validit
98  {  {
99      const char *s;      const char *s;
100    
101        if (novalid)
102            *novalid = 0; /* reset */
103      if (key_ot == GPGME_VALIDITY_FULL ||      if (key_ot == GPGME_VALIDITY_FULL ||
104          key_ot == GPGME_VALIDITY_ULTIMATE)          key_ot == GPGME_VALIDITY_ULTIMATE)
105          s = _("Signature status: created with a fully trusted key");              s = _("Signature status: created with a fully trusted key");    
106      else if (key_ot == GPGME_VALIDITY_MARGINAL)          else if (key_ot == GPGME_VALIDITY_MARGINAL)    
107          s = _("Signature status: created with a marginal trusted key");          s = _("Signature status: created with a marginal trusted key");
108      else if (key_ot == GPGME_VALIDITY_NEVER) {      else if (key_ot == GPGME_VALIDITY_NEVER) {
109          if (novalid) *novalid = 1;          if (novalid)
110                *novalid = 1;
111          s =  _("Signature status: created with an UNTRUSTED key");                s =  _("Signature status: created with an UNTRUSTED key");      
112      }      }
113      else      else
# Line 119  void Line 121  void
121  verify_get_clip_info (gpgme_signature_t sig, char **r_header, char **r_footer)  verify_get_clip_info (gpgme_signature_t sig, char **r_header, char **r_footer)
122  {  {
123      struct winpt_key_s pk;      struct winpt_key_s pk;
124      const char *head = "***** BEGIN PGP SIGNED TEXT *****\r\n"      const char *head = _("*** PGP SIGNATURE VERIFICATION ***\r\n"
125                         "***** Signature made %s using key ID 0x%s\r\n"                           "*** Signature made:    %s\r\n"
126                         "***** %s\r\n"                           "*** Signature verfied: %s\r\n"
127                         "***** \"%s\" from %s\r\n";                           "*** %s\r\n"
128      const char *foot = "***** END PGP SIGNED TEXT *****";                               "*** Signature result:  %s\r\n"
129      const char *s, *made, *ot;                           "*** Signer: %s (0x%s)\r\n"
130      char *p;                           "*** BEGIN PGP DECRYPTED TEXT ***\r\n");
131        const char *foot = _("\r\n*** END PGP DECRYPTED TEXT ***");
132        const char *s, *ver, *ot, *uid;
133        char *p, *made;
134    
135      if (winpt_get_pubkey (sig->fpr, &pk))      if (winpt_get_pubkey (sig->fpr, &pk)) {
136          BUG (0);          uid = _("user ID not found");
137      ot = verify_get_key_ownertrust (pk.ctx->owner_trust, NULL);          ot = verify_get_key_ownertrust (GPGME_VALIDITY_UNDEFINED, NULL);
138      made = strtimestamp (sig->timestamp);      }
139        else {
140            uid = pk.ext->uids->uid;
141            ot = verify_get_key_ownertrust (pk.ctx->owner_trust, NULL);
142        }
143        
144        made = m_strdup (strtimestamp (sig->timestamp));
145        ver = strtimestamp (time (NULL));
146      s = get_gpg_sigstat (sig->summary);      s = get_gpg_sigstat (sig->summary);
147      p = new char[strlen (head) + strlen (s) + strlen (made) +      p = new char[strlen (head) + strlen (s) + strlen (made) +
148                   strlen (sig->fpr) + strlen (ot) +                   strlen (sig->fpr) + strlen (ot) + strlen (ver) +
149                   strlen (pk.ext->uids->uid) + 1];                   strlen (uid) + 1];
150      if (!p)      if (!p)
151          BUG (0);          BUG (0);
152      sprintf (p, head, made, get_keyid_from_fpr (sig->fpr), ot, s, pk.ext->uids->uid);      sprintf (p, head, made, ver, ot, s, uid, get_keyid_from_fpr (sig->fpr));
153      *r_header = p;      *r_header = p;
154      *r_footer = m_strdup (foot);      *r_footer = m_strdup (foot);
155        free_if_alloc (made);
156  }  }
157    
158    
# Line 153  verify_show_signature_state (gpgme_signa Line 166  verify_show_signature_state (gpgme_signa
166      char *pka_info = NULL;      char *pka_info = NULL;
167      int novalid = 0;      int novalid = 0;
168    
169      if (!sig->fpr)      assert (sig->fpr != NULL);
         BUG (NULL);  
170                    
171      keyid = get_keyid_from_fpr (sig->fpr);      keyid = get_keyid_from_fpr (sig->fpr);
172      memset (&key, 0, sizeof (key));      memset (&key, 0, sizeof (key));
   
173      if (!winpt_get_pubkey (keyid, &key)) {      if (!winpt_get_pubkey (keyid, &key)) {
174          s = verify_get_key_ownertrust (key.ctx->owner_trust, &novalid);          s = verify_get_key_ownertrust (key.ctx->owner_trust, &novalid);
175          uid = key.ext->uids->uid;                uid = key.ext->uids->uid;      
176      }        }
177      else {      else {
178          s = "";          s = "";
179          uid = _("user ID not found");          uid = _("user ID not found");
# Line 198  clip_decrypt_dlg (HWND hwnd, int use_vie Line 209  clip_decrypt_dlg (HWND hwnd, int use_vie
209      gpgme_decrypt_result_t res;      gpgme_decrypt_result_t res;
210      gpgme_verify_result_t sigres;      gpgme_verify_result_t sigres;
211      passphrase_cb_s pwd;      passphrase_cb_s pwd;
     const char *s;      
212      int pgp_type = 0;      int pgp_type = 0;
213    
214      /* allow to verify data generated by 'gpg -a --sign foo' */      /* allow to verify data generated by 'gpg -a --sign foo' */
# Line 226  clip_decrypt_dlg (HWND hwnd, int use_vie Line 236  clip_decrypt_dlg (HWND hwnd, int use_vie
236          gpgme_recipient_t r = res->recipients;          gpgme_recipient_t r = res->recipients;
237          char *u = get_key_userid (r->keyid+8);          char *u = get_key_userid (r->keyid+8);
238          log_box (_("Decryption"), MB_ERR,          log_box (_("Decryption"), MB_ERR,
239                   _("Encrypted with %s key, ID %s.%s\n"                   _("Encrypted with %s key, ID 0x%s.%s\n"
240                     "Decryption failed: secret key not available."),                     "Decryption failed: secret key not available."),
241                     get_key_pubalgo (r->pubkey_algo), r->keyid+8, u);                     get_key_pubalgo (r->pubkey_algo), r->keyid+8, u);
242          free_if_alloc (u);          free_if_alloc (u);
# Line 246  clip_decrypt_dlg (HWND hwnd, int use_vie Line 256  clip_decrypt_dlg (HWND hwnd, int use_vie
256          goto leave;          goto leave;
257      }      }
258    
259      if (0) { /* XXX: Bad MDC */      #if 0
260          s = _("WARNING: encrypted message has been manipulated!\n"      if (status_bad_mdc) { /* XXX: Bad MDC */
261            const char *s =
262                _("WARNING: encrypted message has been manipulated!\n"
263              "\n"              "\n"
264              "Do *NOT* trust any text or data output from this file!\n"              "Do *NOT* trust any text or data output from this file!\n"
265              "It is likely, the data was corrupted during the transport\n"              "It is likely that the data was corrupted in transport\n"
266              "but it might be also possible that this is part of an attack.");              "but it might be also possible that this is part of an attack.");
267          msg_box (hwnd, s, _("*** IMPORTANT ***"), MB_INFO);          msg_box (hwnd, s, _("*** IMPORTANT ***"), MB_INFO);
268      }      }
269        #endif
270    
271      show_msg (GetDesktopWindow (), 1500, _("GnuPG Status: Finished"));      show_msg (GetDesktopWindow (), 1500, _("GnuPG Status: Finished"));
272    
# Line 266  clip_decrypt_dlg (HWND hwnd, int use_vie Line 279  clip_decrypt_dlg (HWND hwnd, int use_vie
279                              hwnd, clip_edit_dlg_proc,                              hwnd, clip_edit_dlg_proc,
280                              (LPARAM)sigres->signatures);                              (LPARAM)sigres->signatures);
281      }      }
282        else if (use_viewer)
283            DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CLIPEDIT,
284                                hwnd, clip_edit_dlg_proc, 0);
285    
286  leave:  leave:
287      release_gpg_passphrase_cb (&pwd);      release_gpg_passphrase_cb (&pwd);

Legend:
Removed from v.229  
changed lines
  Added in v.273

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26