Impose a lower limit of 256 on key lengths. This is mostly because
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 25 Oct 2000 14:29:28 +0000 (14:29 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 25 Oct 2000 14:29:28 +0000 (14:29 +0000)
the primegen() function doesn't work well with <100 bits, so RSA
keys need to be >=200 to be generated correctly, and I thought 256
was a nice round number beyond that just to be sure. Perhaps I
should also have a security warning on any key less than 768; or
perhaps I should let people shoot themselves in the feet if they
really want to.

git-svn-id: svn://svn.tartarus.org/sgt/putty@767 cda61777-01e9-0310-a592-d414129be87e

puttygen.c

index 4fae90c..2d6653a 100644 (file)
@@ -455,6 +455,22 @@ static int CALLBACK MainDlgProc (HWND hwnd, UINT msg,
           case IDC_GENERATE:
             state = (struct MainDlgState *)GetWindowLong(hwnd, GWL_USERDATA);
             if (!state->generation_thread_exists) {
+                BOOL ok;
+                state->keysize = GetDlgItemInt(hwnd, IDC_BITS,
+                                               &ok, FALSE);
+                if (!ok) state->keysize = DEFAULT_KEYSIZE;
+                if (state->keysize < 256) {
+                    int ret = MessageBox(hwnd,
+                                         "PuTTYgen will not generate a key"
+                                         " smaller than 256 bits.\n"
+                                         "Key length reset to 256. Continue?",
+                                         "PuTTYgen Warning",
+                                         MB_ICONWARNING | MB_OKCANCEL);
+                    if (ret != IDOK)
+                        break;
+                    state->keysize = 256;
+                    SetDlgItemInt(hwnd, IDC_BITS, 256, FALSE);
+                }
                 hidemany(hwnd, nokey_ids, TRUE);
                 hidemany(hwnd, generating_ids, FALSE);
                 hidemany(hwnd, gotkey_ids, TRUE);
@@ -464,12 +480,6 @@ static int CALLBACK MainDlgProc (HWND hwnd, UINT msg,
                 state->key_exists = FALSE;
                 SetDlgItemText(hwnd, IDC_GENERATING, entropy_msg);
                 state->collecting_entropy = TRUE;
-               {
-                   BOOL ok;
-                   state->keysize = GetDlgItemInt(hwnd, IDC_BITS,
-                                                  &ok, FALSE);
-                   if (!ok) state->keysize = DEFAULT_KEYSIZE;
-               }
 
                 /*
                  * My brief statistical tests on mouse movements