]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - windows/winpgen.c
first pass
[PuTTY.git] / windows / winpgen.c
index ad3da837a7e7e8b159eafef8154368b427a7c255..c4f4de45b4b180de18a6dda492bc7d9e0c64d0e5 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;
@@ -296,10 +297,12 @@ static INT_PTR CALLBACK AboutProc(HWND hwnd, UINT msg,
        }
 
         {
+            char *buildinfo_text = buildinfo("\r\n");
             char *text = dupprintf
-                ("Pageant\r\n\r\n%s\r\n\r\n%s",
-                 ver,
+                ("PuTTYgen\r\n\r\n%s\r\n\r\n%s\r\n\r\n%s",
+                 ver, buildinfo_text,
                  "\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved.");
+            sfree(buildinfo_text);
             SetDlgItemText(hwnd, 1000, text);
             sfree(text);
         }
@@ -316,6 +319,12 @@ static INT_PTR CALLBACK AboutProc(HWND hwnd, UINT msg,
            EnableWindow(hwnd, 1);
            SetActiveWindow(hwnd);
            return 0;
+         case 102:
+           /* Load web browser */
+           ShellExecute(hwnd, "open",
+                        "http://www.chiark.greenend.org.uk/~sgtatham/putty/",
+                        0, 0, SW_SHOWDEFAULT);
+           return 0;
        }
        return 0;
       case WM_CLOSE:
@@ -342,7 +351,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 +1034,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 +1123,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 +1137,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;
@@ -1502,10 +1523,12 @@ void cleanup_exit(int code)
 
 int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
 {
-    int argc;
+    int argc, i;
     char **argv;
     int ret;
 
+    dll_hijacking_protection();
+
     InitCommonControls();
     hinst = inst;
     hwnd = NULL;
@@ -1517,16 +1540,21 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
 
     split_into_argv(cmdline, &argc, &argv, NULL);
 
-    if (argc > 0) {
-       if (!strcmp(argv[0], "-pgpfp")) {
+    for (i = 0; i < argc; i++) {
+       if (!strcmp(argv[i], "-pgpfp")) {
            pgp_fingerprints();
-           exit(1);
+           return 1;
+        } else if (!strcmp(argv[i], "-restrict-acl") ||
+                   !strcmp(argv[i], "-restrict_acl") ||
+                   !strcmp(argv[i], "-restrictacl")) {
+            restrict_process_acl();
        } else {
            /*
             * Assume the first argument to be a private key file, and
             * attempt to load it.
             */
-           cmdline_keyfile = argv[0];
+           cmdline_keyfile = argv[i];
+            break;
        }
     }