Add encryption selection, and Blowfish as second option
[u/mdw/putty] / windlg.c
index 757300d..a1e463e 100644 (file)
--- a/windlg.c
+++ b/windlg.c
@@ -5,8 +5,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "putty.h"
 #include "ssh.h"
+#include "putty.h"
 #include "win_res.h"
 
 #define NPANELS 7
@@ -149,6 +149,8 @@ static void save_settings (char *section, int do_host) {
     }
     wpps (sesskey, "UserName", cfg.username);
     wppi (sesskey, "NoPTY", cfg.nopty);
+    wpps (sesskey, "Cipher", cfg.cipher == CIPHER_BLOWFISH ? "blowfish" :
+                             "3des");
     wppi (sesskey, "RFCEnviron", cfg.rfc_environ);
     wppi (sesskey, "BackspaceIsDelete", cfg.bksp_is_delete);
     wppi (sesskey, "RXVTHomeEnd", cfg.rxvt_homeend);
@@ -224,6 +226,7 @@ static void load_settings (char *section, int do_host) {
     }
 
     free(p);
+    RegCloseKey(subkey1);
 
     if (do_host) {
        char prot[10];
@@ -264,6 +267,14 @@ static void load_settings (char *section, int do_host) {
     }
     gpps (sesskey, "UserName", "", cfg.username, sizeof(cfg.username));
     gppi (sesskey, "NoPTY", 0, &cfg.nopty);
+    {
+       char cipher[10];
+       gpps (sesskey, "Cipher", "3des", cipher, 10);
+       if (!strcmp(cipher, "blowfish"))
+           cfg.cipher = CIPHER_BLOWFISH;
+       else
+           cfg.cipher = CIPHER_3DES;
+    }
     gppi (sesskey, "RFCEnviron", 0, &cfg.rfc_environ);
     gppi (sesskey, "BackspaceIsDelete", 1, &cfg.bksp_is_delete);
     gppi (sesskey, "RXVTHomeEnd", 0, &cfg.rxvt_homeend);
@@ -865,6 +876,9 @@ static int CALLBACK SshProc (HWND hwnd, UINT msg,
        SetDlgItemText (hwnd, IDC3_TTEDIT, cfg.termtype);
        SetDlgItemText (hwnd, IDC3_LOGEDIT, cfg.username);
        CheckDlgButton (hwnd, IDC3_NOPTY, cfg.nopty);
+       CheckRadioButton (hwnd, IDC3_CIPHER3DES, IDC3_CIPHERBLOWF,
+                         cfg.cipher == CIPHER_BLOWFISH ? IDC3_CIPHERBLOWF :
+                         IDC3_CIPHER3DES);
        break;
       case WM_COMMAND:
        switch (LOWORD(wParam)) {
@@ -883,6 +897,16 @@ static int CALLBACK SshProc (HWND hwnd, UINT msg,
                HIWORD(wParam) == BN_DOUBLECLICKED)
                cfg.nopty = IsDlgButtonChecked (hwnd, IDC3_NOPTY);
            break;
+         case IDC3_CIPHER3DES:
+         case IDC3_CIPHERBLOWF:
+           if (HIWORD(wParam) == BN_CLICKED ||
+               HIWORD(wParam) == BN_DOUBLECLICKED) {
+               if (IsDlgButtonChecked (hwnd, IDC3_CIPHER3DES))
+                   cfg.cipher = CIPHER_3DES;
+               else if (IsDlgButtonChecked (hwnd, IDC3_CIPHERBLOWF))
+                   cfg.cipher = CIPHER_BLOWFISH;
+           }
+           break;
        }
        break;
     }