]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - windows/winpgen.c
Document SSH IUTF8 mode.
[PuTTY.git] / windows / winpgen.c
index ad3da837a7e7e8b159eafef8154368b427a7c255..98319608c3ca1f562b57c95fa83b9e276e9c754d 100644 (file)
@@ -12,6 +12,7 @@
 #include "putty.h"
 #include "ssh.h"
 #include "licence.h"
+#include "winsecur.h"
 
 #include <commctrl.h>
 
@@ -133,7 +134,7 @@ static void progress_update(void *param, int action, int phase, int iprogress)
     }
 }
 
-extern char ver[];
+extern const char ver[];
 
 struct PassphraseProcStruct {
     char **passphrase;
@@ -297,7 +298,7 @@ static INT_PTR CALLBACK AboutProc(HWND hwnd, UINT msg,
 
         {
             char *text = dupprintf
-                ("Pageant\r\n\r\n%s\r\n\r\n%s",
+                ("PuTTYgen\r\n\r\n%s\r\n\r\n%s",
                  ver,
                  "\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved.");
             SetDlgItemText(hwnd, 1000, text);
@@ -342,7 +343,7 @@ struct rsa_key_thread_params {
         struct ec_key *eckey;
     };
 };
-static DWORD WINAPI generate_rsa_key_thread(void *param)
+static DWORD WINAPI generate_key_thread(void *param)
 {
     struct rsa_key_thread_params *params =
        (struct rsa_key_thread_params *) param;
@@ -1025,7 +1026,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg,
                params->key = &state->key;
                params->dsskey = &state->dsskey;
 
-               if (!CreateThread(NULL, 0, generate_rsa_key_thread,
+               if (!CreateThread(NULL, 0, generate_key_thread,
                                  params, 0, &threadid)) {
                    MessageBox(hwnd, "Out of thread resources",
                               "Key generation error",
@@ -1114,6 +1115,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg,
                 } else if (IsDlgButtonChecked(hwnd, IDC_KEYSSH2ED25519)) {
                     state->keytype = ED25519;
                 }
+
                if ((state->keytype == RSA || state->keytype == DSA) &&
                     state->key_bits < 256) {
                     char *message = dupprintf
@@ -1127,7 +1129,18 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg,
                        break;
                    state->key_bits = DEFAULT_KEY_BITS;
                    SetDlgItemInt(hwnd, IDC_BITS, DEFAULT_KEY_BITS, FALSE);
-               }
+               } else if ((state->keytype == RSA || state->keytype == DSA) &&
+                           state->key_bits < DEFAULT_KEY_BITS) {
+                    char *message = dupprintf
+                        ("Keys shorter than %d bits are not recommended. "
+                         "Really generate this key?", DEFAULT_KEY_BITS);
+                   int ret = MessageBox(hwnd, message, "PuTTYgen Warning",
+                                        MB_ICONWARNING | MB_OKCANCEL);
+                    sfree(message);
+                   if (ret != IDOK)
+                       break;
+                }
+
                ui_set_state(hwnd, state, 1);
                SetDlgItemText(hwnd, IDC_GENERATING, entropy_msg);
                state->key_exists = FALSE;
@@ -1530,6 +1543,23 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
        }
     }
 
+#if !defined UNPROTECT && !defined NO_SECURITY
+    /*
+     * Protect our process.
+     */
+    {
+        char *error = NULL;
+        if (!setprocessacl(error)) {
+            char *message = dupprintf("Could not restrict process ACL: %s",
+                                      error);
+            MessageBox(NULL, message, "PuTTYgen Warning",
+                       MB_ICONWARNING | MB_OK);
+            sfree(message);
+            sfree(error);
+        }
+    }
+#endif
+
     random_ref();
     ret = DialogBox(hinst, MAKEINTRESOURCE(201), NULL, MainDlgProc) != IDOK;