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

Diff of /trunk/Src/wptSymEnc.cpp

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

revision 48 by werner, Mon Oct 31 21:14:11 2005 UTC revision 278 by twoaday, Mon Jan 15 22:02:04 2007 UTC
# Line 1  Line 1 
1  /* wptSymEnc.cpp - Symmetric encryption support  /* wptSymEnc.cpp - Symmetric encryption support
2   *      Copyright (C) 2002, 2003, 2004, 2005 Timo Schulz   *      Copyright (C) 2002-2006 Timo Schulz
3   *   *
4   * This file is part of WinPT.   * This file is part of WinPT.
5   *   *
# Line 12  Line 12 
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14   * General Public License for more details.   * 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  
15   */   */
   
16  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
17  #include <config.h>  #include <config.h>
18  #endif  #endif
# Line 47  sym_passphrase_cb (void *hook, const cha Line 42  sym_passphrase_cb (void *hook, const cha
42      if (!pass)      if (!pass)
43          return gpg_error (GPG_ERR_INV_ARG);          return gpg_error (GPG_ERR_INV_ARG);
44    
     /* XXX: check for passphrase.enter. */  
45      if (!WriteFile (hd, pass, strlen (pass), &n, NULL))      if (!WriteFile (hd, pass, strlen (pass), &n, NULL))
46          log_debug ("sym_passphrase_cb: WriteFile() failed ec=%d\n", w32_errno);          log_debug ("sym_passphrase_cb: WriteFile() failed ec=%d\n", w32_errno);
47      if (!WriteFile (hd, "\n", 1, &n, NULL))      if (!WriteFile (hd, "\n", 1, &n, NULL))
# Line 59  sym_passphrase_cb (void *hook, const cha Line 53  sym_passphrase_cb (void *hook, const cha
53    
54  /* Perform symmetric encryption on the current clipboard data.  /* Perform symmetric encryption on the current clipboard data.
55     Return 0 for success. */     Return 0 for success. */
56  int  gpgme_error_t
57  gpg_encrypt_symmetric (void)  gpg_clip_sym_encrypt (void)
58  {  {
59      gpgme_ctx_t ctx;      gpgme_ctx_t ctx;
60      gpgme_data_t plain=NULL;      gpgme_data_t plain=NULL;
# Line 69  gpg_encrypt_symmetric (void) Line 63  gpg_encrypt_symmetric (void)
63      char *pass = NULL;      char *pass = NULL;
64      int cancel = 0;      int cancel = 0;
65            
66      pass = request_passphrase2 (_("Symmetric Encryption"), 0, &cancel);      pass = request_passphrase2 (_("Symmetric Encryption"),
67                                    PASSDLG_NOTEMPTY, &cancel);
68      if (cancel)      if (cancel)
69          return 0;          return 0;
70      rc = gpgme_new (&ctx);      rc = gpgme_new (&ctx);
# Line 79  gpg_encrypt_symmetric (void) Line 74  gpg_encrypt_symmetric (void)
74      if (rc)      if (rc)
75          goto leave;          goto leave;
76      rc = gpgme_data_new (&ciph);      rc = gpgme_data_new (&ciph);
77        if (rc)
78            goto leave;
79      gpgme_set_armor (ctx, 1);      gpgme_set_armor (ctx, 1);
80        gpgme_set_textmode (ctx, 1);
81    
82      gpgme_set_passphrase_cb (ctx, sym_passphrase_cb, pass);      gpgme_set_passphrase_cb (ctx, sym_passphrase_cb, pass);
83    
84      rc = gpgme_op_encrypt (ctx, NULL, (gpgme_encrypt_flags_t)0, plain, ciph);          rc = gpgme_op_encrypt (ctx, NULL, (gpgme_encrypt_flags_t)0, plain, ciph);
85      if (rc)      if (rc)
86          msg_box (NULL, gpgme_strerror (rc), _("Symmetric Encryption"), MB_ERR);          msg_box (NULL, gpgme_strerror (rc), _("Symmetric Encryption"), MB_ERR);
87      else {      else {
# Line 99  leave: Line 97  leave:
97          gpgme_data_release (ciph);          gpgme_data_release (ciph);
98      gpgme_release (ctx);      gpgme_release (ctx);
99      sfree_if_alloc (pass);      sfree_if_alloc (pass);
100      return rc? WPTERR_GENERAL : 0;      return rc;
101  }  }

Legend:
Removed from v.48  
changed lines
  Added in v.278

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26