]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - windows/winpgnt.c
Merge shorter option name from 'pre-0.64'.
[PuTTY.git] / windows / winpgnt.c
index 1f6484f92513e852b5a57d708225296ca1371ccd..828747dac62a83bdb391f616d53c934bc510f730 100644 (file)
@@ -14,6 +14,7 @@
 #include "ssh.h"
 #include "misc.h"
 #include "tree234.h"
+#include "winsecur.h"
 
 #include <shellapi.h>
 
@@ -116,12 +117,6 @@ static void unmungestr(char *in, char *out, int outlen)
 static tree234 *rsakeys, *ssh2keys;
 
 static int has_security;
-#ifndef NO_SECURITY
-DECL_WINDOWS_FUNCTION(extern, DWORD, GetSecurityInfo,
-                     (HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION,
-                      PSID *, PSID *, PACL *, PACL *,
-                      PSECURITY_DESCRIPTOR *));
-#endif
 
 /*
  * Forward references
@@ -354,22 +349,24 @@ static void keylist_update(void)
        }
        for (i = 0; NULL != (skey = index234(ssh2keys, i)); i++) {
            char *listentry, *p;
-           int fp_len;
+           int pos, fp_len;
            /*
-            * Replace two spaces in the fingerprint with tabs, for
-            * nice alignment in the box.
+            * Replace spaces with tabs in the fingerprint prefix, for
+            * nice alignment in the list box, until we encounter a :
+            * meaning we're into the fingerprint proper.
             */
            p = skey->alg->fingerprint(skey->data);
             listentry = dupprintf("%s\t%s", p, skey->comment);
             fp_len = strlen(listentry);
             sfree(p);
 
-           p = strchr(listentry, ' ');
-           if (p && p < listentry + fp_len)
-               *p = '\t';
-           p = strchr(listentry, ' ');
-           if (p && p < listentry + fp_len)
-               *p = '\t';
+            pos = 0;
+            while (1) {
+                pos += strcspn(listentry + pos, " :");
+                if (listentry[pos] == ':')
+                    break;
+                listentry[pos++] = '\t';
+            }
 
            SendDlgItemMessage(keylist, 100, LB_ADDSTRING, 0,
                               (LPARAM) listentry);
@@ -1146,6 +1143,12 @@ static void answer_msg(void *msg)
                key->alg = &ssh_rsa;
            else if (alglen == 7 && !memcmp(alg, "ssh-dss", 7))
                key->alg = &ssh_dss;
+            else if (alglen == 19 && memcmp(alg, "ecdsa-sha2-nistp256", 19))
+                key->alg = &ssh_ecdsa_nistp256;
+            else if (alglen == 19 && memcmp(alg, "ecdsa-sha2-nistp384", 19))
+                key->alg = &ssh_ecdsa_nistp384;
+            else if (alglen == 19 && memcmp(alg, "ecdsa-sha2-nistp521", 19))
+                key->alg = &ssh_ecdsa_nistp521;
            else {
                sfree(key);
                goto failure;
@@ -1513,7 +1516,7 @@ static int CALLBACK KeyListProc(HWND hwnd, UINT msg,
 
        keylist = hwnd;
        {
-           static int tabs[] = { 35, 60, 210 };
+           static int tabs[] = { 35, 75, 250 };
            SendDlgItemMessage(hwnd, 100, LB_SETTABSTOPS,
                               sizeof(tabs) / sizeof(*tabs),
                               (LPARAM) tabs);
@@ -2039,7 +2042,6 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
 {
     WNDCLASS wndclass;
     MSG msg;
-    HMODULE advapi;
     char *command = NULL;
     int added_keys = 0;
     int argc, i;
@@ -2066,7 +2068,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
        /*
         * Attempt to get the security API we need.
         */
-        if (!init_advapi()) {
+        if (!got_advapi()) {
            MessageBox(NULL,
                       "Unable to access security APIs. Pageant will\n"
                       "not run, in case it causes a security breach.",
@@ -2080,8 +2082,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
                   "Pageant Fatal Error", MB_ICONERROR | MB_OK);
        return 1;
 #endif
-    } else
-       advapi = NULL;
+    }
 
     /*
      * See if we can find our Help file.
@@ -2134,8 +2135,6 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
     for (i = 0; i < argc; i++) {
        if (!strcmp(argv[i], "-pgpfp")) {
            pgp_fingerprints();
-           if (advapi)
-               FreeLibrary(advapi);
            return 1;
        } else if (!strcmp(argv[i], "-c")) {
            /*
@@ -2185,8 +2184,6 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
            MessageBox(NULL, "Pageant is already running", "Pageant Error",
                       MB_ICONERROR | MB_OK);
        }
-       if (advapi)
-           FreeLibrary(advapi);
        return 0;
     }
 
@@ -2266,9 +2263,6 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
 
     if (keypath) filereq_free(keypath);
 
-    if (advapi)
-       FreeLibrary(advapi);
-
     cleanup_exit(msg.wParam);
     return msg.wParam;                /* just in case optimiser complains */
 }