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

Diff of /trunk/Src/wptPassphraseCB.cpp

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

revision 28 by twoaday, Thu Oct 20 12:35:59 2005 UTC revision 32 by twoaday, Mon Oct 24 08:03:48 2005 UTC
# Line 50  const char* get_symkey_algo (int algo); Line 50  const char* get_symkey_algo (int algo);
50  static void  static void
51  burn_passphrase (char **pwd)  burn_passphrase (char **pwd)
52  {  {
53      char *pass = *pwd;        char *pass = *pwd;
54      memset (pass, 0, strlen (pass));      wipememory (pass, strlen (pass));
55      delete []pass;      delete []pass;
56      *pwd = NULL;      *pwd = NULL;
57  }  }
# Line 70  passphrase_callback_proc (HWND dlg, UINT Line 70  passphrase_callback_proc (HWND dlg, UINT
70      char *info;      char *info;
71      int n;      int n;
72    
     /* XXX: we need a timer to update the 'enc_to' entries. */  
73      switch (msg) {      switch (msg) {
74      case WM_INITDIALOG:      case WM_INITDIALOG:
75          c = (passphrase_cb_s *)lparam;          c = (passphrase_cb_s *)lparam;
# Line 78  passphrase_callback_proc (HWND dlg, UINT Line 77  passphrase_callback_proc (HWND dlg, UINT
77              BUG (0);              BUG (0);
78          SetWindowText (dlg, c->title);          SetWindowText (dlg, c->title);
79          if (c->gpg_cmd == GPG_CMD_DECRYPT) {          if (c->gpg_cmd == GPG_CMD_DECRYPT) {
80              SetDlgItemText( dlg, IDC_DECRYPT_LISTINF,              SetDlgItemText (dlg, IDC_DECRYPT_LISTINF,
81                  _("Encrypted with the following public key(s)") );                              _("Encrypted with the following public key(s)"));
82              CheckDlgButton( dlg, IDC_DECRYPT_HIDE, BST_CHECKED );              CheckDlgButton (dlg, IDC_DECRYPT_HIDE, BST_CHECKED);
83          }          }
84          else if (c->gpg_cmd == GPG_CMD_SIGN)          else if (c->gpg_cmd == GPG_CMD_SIGN)
85              CheckDlgButton (dlg, IDC_DECRYPT_SIGN_HIDE, BST_CHECKED);              CheckDlgButton (dlg, IDC_DECRYPT_SIGN_HIDE, BST_CHECKED);
# Line 150  passphrase_callback_proc (HWND dlg, UINT Line 149  passphrase_callback_proc (HWND dlg, UINT
149    
150          case WM_SYSCOMMAND:          case WM_SYSCOMMAND:
151              if (LOWORD (wparam) == SC_CLOSE) {              if (LOWORD (wparam) == SC_CLOSE) {
152                  SetDlgItemText (dlg, item_ctrl_id( c->gpg_cmd ), "");                  SetDlgItemText (dlg, item_ctrl_id (c->gpg_cmd), "");
153                  c->cancel = 1;                  c->cancel = 1;
154                  EndDialog (dlg, TRUE);                  EndDialog (dlg, TRUE);
155              }              }
156              break;              break;
157    
158          case WM_COMMAND:          case WM_COMMAND:
159              switch( HIWORD( wparam ) ) {              switch (HIWORD (wparam)) {
160              case BN_CLICKED:              case BN_CLICKED:
161                  if ( LOWORD( wparam ) == IDC_DECRYPT_HIDE                  if  (LOWORD (wparam) == IDC_DECRYPT_HIDE
162                      || LOWORD( wparam ) == IDC_DECRYPT_SIGN_HIDE ) {                      || LOWORD (wparam) == IDC_DECRYPT_SIGN_HIDE) {
163                      HWND hwnd;                      HWND hwnd;
164                      int hide = IsDlgButtonChecked (dlg, item_ctrl_id2 (c->gpg_cmd));                      int hide = IsDlgButtonChecked (dlg, item_ctrl_id2 (c->gpg_cmd));
165                      hwnd = GetDlgItem (dlg, item_ctrl_id (c->gpg_cmd));                      hwnd = GetDlgItem (dlg, item_ctrl_id (c->gpg_cmd));
# Line 171  passphrase_callback_proc (HWND dlg, UINT Line 170  passphrase_callback_proc (HWND dlg, UINT
170    
171              switch (LOWORD (wparam)) {              switch (LOWORD (wparam)) {
172              case IDOK:                case IDOK:  
173                  /* fixme: the item is even cached when the passphrase is not                  /* XXX: the item is even cached when the passphrase is not
174                            correct, which means that the user needs to delete all                          correct, which means that the user needs to delete all
175                            cached entries to continue. */                          cached entries to continue. */
176                  if (c->pwd)                  if (c->pwd)
177                      burn_passphrase (&c->pwd);                      burn_passphrase (&c->pwd);
178                  n = item_get_text_length (dlg, item_ctrl_id (c->gpg_cmd));                  n = item_get_text_length (dlg, item_ctrl_id (c->gpg_cmd));
# Line 199  passphrase_callback_proc (HWND dlg, UINT Line 198  passphrase_callback_proc (HWND dlg, UINT
198                      else                      else
199                          agent_put_cache (c->keyid, c->pwd, reg_prefs.cache_time);                          agent_put_cache (c->keyid, c->pwd, reg_prefs.cache_time);
200                  }                  }
201                    c->cancel = 0;
202                  EndDialog (dlg, TRUE);                  EndDialog (dlg, TRUE);
203                  return TRUE;                  return TRUE;
204                                    
205              case IDCANCEL:              case IDCANCEL:
206                  SetDlgItemText (dlg, item_ctrl_id (c->gpg_cmd), "" );                  SetDlgItemText (dlg, item_ctrl_id (c->gpg_cmd), "");
207                  c->cancel = 1;                  c->cancel = 1;
208                  EndDialog (dlg, FALSE);                  EndDialog (dlg, FALSE);
209                  return FALSE;                  return FALSE;
# Line 241  parse_gpg_description (const char *uid_h Line 241  parse_gpg_description (const char *uid_h
241                         char *desc, int size)                         char *desc, int size)
242  {  {
243      gpgme_pubkey_algo_t algo;      gpgme_pubkey_algo_t algo;
244      char usedkey[16+1], mainkey[16+1];      char usedkey[16+1];
245        char mainkey[16+1];
246      char *uid, *p;      char *uid, *p;
247      int n=0;      int n=0;
248    
249        /* Each uid_hint contains a long key-ID so it is at least 16 bytes. */
250      if (strlen (uid_hint) < 17) {      if (strlen (uid_hint) < 17) {
251          *desc = 0;          *desc = 0;
252          return -1;          return -1;
# Line 279  parse_gpg_description (const char *uid_h Line 281  parse_gpg_description (const char *uid_h
281  }  }
282    
283    
 /*  
 static int inline  
 is_hexstring (const char * p)  
 {  
     size_t i;  
   
     for (i=0; i < strlen (p); i++) {  
         if (!isxdigit (p[i]))  
             return -1;  
     }  
     return 0;  
 }  
 */  
   
   
284  /* Extract the serial number from the card ID @id and return it. */  /* Extract the serial number from the card ID @id and return it. */
285  const char*  const char*
286  extract_serial_no (const char *id)  extract_serial_no (const char *id)
# Line 334  passphrase_cb (void *hook, const char *u Line 321  passphrase_cb (void *hook, const char *u
321    
322      if (passphrase_info) {      if (passphrase_info) {
323          if (strlen (passphrase_info) < 16 &&          if (strlen (passphrase_info) < 16 &&
324              !strstr (passphrase_info, "OPENPGP")) {/* assume symetric encryption. */              !strstr (passphrase_info, "OPENPGP")) {
325                /* assume symetric encryption. */
326              int n=2;              int n=2;
327              c->sym.sym_algo = atoi (passphrase_info);              c->sym.sym_algo = atoi (passphrase_info);
328              if (c->sym.sym_algo > 9)              if (c->sym.sym_algo > 9)
# Line 386  passphrase_cb (void *hook, const char *u Line 374  passphrase_cb (void *hook, const char *u
374                                   (LPARAM)c);                                   (LPARAM)c);
375          }          }
376          if (rc == -1) {          if (rc == -1) {
377              WriteFile (hd, "\n", 1, &n, NULL);              if (!WriteFile (hd, "\n", 1, &n, NULL))
378                    log_debug ("passphrase_cb: WriteFile() failed ec=%d\n", w32_errno);
379              return 0;              return 0;
380          }          }
381          c->pwd_init = 0;          c->pwd_init = 0;
382      }      }
383      if (c->cancel) {      if (c->cancel) {
384          WriteFile (hd, "\n", 1, &n, NULL);          if (!WriteFile (hd, "\n", 1, &n, NULL))
385                log_debug ("passphrase_cb: WriteFile() failed ec=%d\n", w32_errno);
386          return 0;          return 0;
387      }      }
388    
# Line 448  check_passwd_quality (const char *pass, Line 438  check_passwd_quality (const char *pass,
438          return -1;          return -1;
439    
440      for (i=0; i < n; i++) {      for (i=0; i < n; i++) {
441          if (isdigit (pass[i])) nd++;          if (isdigit (pass[i]))
442          if (isalpha (pass[i])) nc++;              nd++;
443            if (isalpha (pass[i]))
444                nc++;
445      }      }
446    
447        /* check that the passphrase contains letters and numbers. */
448      if (nd == n || nc == n)      if (nd == n || nc == n)
449          return -1;          return -1;
450    

Legend:
Removed from v.28  
changed lines
  Added in v.32

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26