diff --git a/authfd.c b/authfd.c
index 6f898a0..d294560 100644
--- a/authfd.c
+++ b/authfd.c
@@ -94,6 +94,24 @@ ssh_get_authentication_socket(int *fdp)
if (fdp != NULL)
*fdp = -1;
+#ifdef WIN32_FIXME
+ HANDLE h = CreateFile(
+ "\\\\.\\pipe\\ssh-agent", // pipe name
+ GENERIC_READ | // read and write access
+ GENERIC_WRITE,
+ 0, // no sharing
+ NULL, // default security attributes
+ OPEN_EXISTING, // opens existing pipe
+ FILE_FLAG_OVERLAPPED, // attributes
+ NULL); // no template file
+ if (h == INVALID_HANDLE_VALUE) {
+ debug("cannot open auth socket\n");
+ return SSH_ERR_AGENT_NOT_PRESENT;
+ }
+
+ sock = w32_allocate_fd_for_handle(h, FALSE);
+
+#else
authsocket = getenv(SSH_AUTHSOCKET_ENV_NAME);
if (!authsocket)
return SSH_ERR_AGENT_NOT_PRESENT;
@@ -113,6 +131,7 @@ ssh_get_authentication_socket(int *fdp)
errno = oerrno;
return SSH_ERR_SYSTEM_ERROR;
}
+#endif
if (fdp != NULL)
*fdp = sock;
diff --git a/contrib/win32/openssh/Win32-OpenSSH.sln b/contrib/win32/openssh/Win32-OpenSSH.sln
index 1100178..d87f3fe 100644
--- a/contrib/win32/openssh/Win32-OpenSSH.sln
+++ b/contrib/win32/openssh/Win32-OpenSSH.sln
@@ -80,6 +80,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssh-shellhost", "ssh-shellh
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssh-agent", "ssh-agent.vcxproj", "{F6644EC5-D6B6-42A1-828C-75E2977470E0}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssh-add", "ssh-add.vcxproj", "{029797FF-C986-43DE-95CD-2E771E86AEBC}"
+ ProjectSection(ProjectDependencies) = postProject
+ {05E1115F-8529-46D0-AAAF-52A404CE79A7} = {05E1115F-8529-46D0-AAAF-52A404CE79A7}
+ {DD483F7D-C553-4740-BC1A-903805AD0174} = {DD483F7D-C553-4740-BC1A-903805AD0174}
+ {0D02F0F0-013B-4EE3-906D-86517F3822C0} = {0D02F0F0-013B-4EE3-906D-86517F3822C0}
+ {8660C2FE-9874-432D-B047-E042BB41DBE0} = {8660C2FE-9874-432D-B047-E042BB41DBE0}
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -200,6 +208,14 @@ Global
{F6644EC5-D6B6-42A1-828C-75E2977470E0}.Release|x64.Build.0 = Release|x64
{F6644EC5-D6B6-42A1-828C-75E2977470E0}.Release|x86.ActiveCfg = Release|Win32
{F6644EC5-D6B6-42A1-828C-75E2977470E0}.Release|x86.Build.0 = Release|Win32
+ {029797FF-C986-43DE-95CD-2E771E86AEBC}.Debug|x64.ActiveCfg = Debug|x64
+ {029797FF-C986-43DE-95CD-2E771E86AEBC}.Debug|x64.Build.0 = Debug|x64
+ {029797FF-C986-43DE-95CD-2E771E86AEBC}.Debug|x86.ActiveCfg = Debug|Win32
+ {029797FF-C986-43DE-95CD-2E771E86AEBC}.Debug|x86.Build.0 = Debug|Win32
+ {029797FF-C986-43DE-95CD-2E771E86AEBC}.Release|x64.ActiveCfg = Release|x64
+ {029797FF-C986-43DE-95CD-2E771E86AEBC}.Release|x64.Build.0 = Release|x64
+ {029797FF-C986-43DE-95CD-2E771E86AEBC}.Release|x86.ActiveCfg = Release|Win32
+ {029797FF-C986-43DE-95CD-2E771E86AEBC}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/contrib/win32/openssh/ssh-add.vcxproj b/contrib/win32/openssh/ssh-add.vcxproj
index c59028b..be6b18d 100644
--- a/contrib/win32/openssh/ssh-add.vcxproj
+++ b/contrib/win32/openssh/ssh-add.vcxproj
@@ -78,21 +78,25 @@
true
$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\
$(Platform)\$(Configuration)\$(TargetName)\
+ $(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);
true
$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\
$(Platform)\$(Configuration)\$(TargetName)\
+ $(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);
false
$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\
$(Platform)\$(Configuration)\$(TargetName)\
+ $(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);
false
$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\
$(Platform)\$(Configuration)\$(TargetName)\
+ $(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);
@@ -109,7 +113,7 @@
Console
true
- bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ win32iocompat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Debug-Path)lib;%(AdditionalLibraryDirectories)
@@ -128,7 +132,7 @@
Console
true
- bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ win32iocompat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Debug-Path)lib;%(AdditionalLibraryDirectories)
@@ -150,7 +154,7 @@
No
true
true
- bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ win32iocompat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)
@@ -172,7 +176,7 @@
No
true
true
- bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ win32iocompat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)
diff --git a/contrib/win32/openssh/ssh-agent.vcxproj b/contrib/win32/openssh/ssh-agent.vcxproj
index d045ce6..708f8f3 100644
--- a/contrib/win32/openssh/ssh-agent.vcxproj
+++ b/contrib/win32/openssh/ssh-agent.vcxproj
@@ -116,7 +116,7 @@
Console
true
- kernel32.lib;user32.lib;%(AdditionalDependencies)
+ win32iocompat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;Netapi32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Debug-Path)lib;%(AdditionalLibraryDirectories)
@@ -135,7 +135,7 @@
Console
true
- %(AdditionalDependencies)
+ win32iocompat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;Netapi32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Debug-Path)lib;%(AdditionalLibraryDirectories)
@@ -157,7 +157,7 @@
No
true
true
- kernel32.lib;user32.lib;%(AdditionalDependencies)
+ win32iocompat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;Netapi32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)
@@ -171,7 +171,7 @@
true
_WIN32_WINNT=0x600;_LIB;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
false
- $(OpenSSH-Src-Path);$(OpenSSL-64-Release-Path)include
+ $(OpenSSH-Src-Path);$(OpenSSL-x64-Release-Path)include
MultiThreaded
@@ -179,7 +179,8 @@
No
true
true
- kernel32.lib;user32.lib;%(AdditionalDependencies)
+ win32iocompat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;Netapi32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)
diff --git a/contrib/win32/win32compat/ssh-agent/agent-request.c b/contrib/win32/win32compat/ssh-agent/agent-request.c
index d00d6aa..da1b2ee 100644
--- a/contrib/win32/win32compat/ssh-agent/agent-request.c
+++ b/contrib/win32/win32compat/ssh-agent/agent-request.c
@@ -31,8 +31,108 @@
#include "agent-request.h"
+#define KEY_ROOT L"SYSTEM\\CurrentControlSet\\Control\\SSH\\Host\\Keys"
+#define MAX_KEY_LENGTH 255
+#define MAX_VALUE_NAME 16383
+
int
process_add_identity(struct sshbuf* request, struct sshbuf* response, HANDLE client) {
+ struct sshkey* key = NULL;
+ int r = 0, r1 = 0, blob_len;
+ size_t comment_len;
+ char *thumbprint = NULL, *blob, *comment;
+ HKEY reg = 0, sub = 0;
- return 0;
+ blob = sshbuf_ptr(request);
+ if ((r = sshkey_private_deserialize(request, &key)) != 0)
+ goto done;
+ blob_len = (sshbuf_ptr(request) - blob) & 0xffffffff;
+
+ if ((r = sshbuf_peek_string_direct(request, &comment, &comment_len)) != 0)
+ goto done;
+
+ if ((thumbprint = sshkey_fingerprint(key, SSH_FP_HASH_DEFAULT, SSH_FP_DEFAULT)) == NULL)
+ goto done;
+
+ if ((r = RegOpenKeyEx(HKEY_LOCAL_MACHINE, KEY_ROOT,
+ 0, KEY_WRITE, ®)) != 0)
+ goto done;
+
+ if ((r = RegCreateKeyExA(reg, thumbprint, 0, 0, 0, KEY_WRITE, NULL, &sub, NULL)) != 0)
+ goto done;
+
+ if ((r = RegSetValueEx(sub, NULL, 0, REG_BINARY, blob, blob_len)) != 0)
+ goto done;
+
+ if ((r = RegSetValueEx(sub, L"Type", 0, REG_DWORD, &key->type, 4)) != 0)
+ goto done;
+
+ if ((r = RegSetValueEx(sub, L"Comment", 0, REG_BINARY, comment, comment_len)) != 0)
+ goto done;
+
+done:
+
+ r1 = sshbuf_put_u8(response, (r==0) ? SSH_AGENT_SUCCESS : SSH_AGENT_FAILURE);
+
+ if (key)
+ sshkey_free(key);
+ if (thumbprint)
+ free(thumbprint);
+ if (reg)
+ RegCloseKey(reg);
+ if (sub)
+ RegCloseKey(sub);
+ return r1;
}
+
+static struct sshkey*
+retrieve_key(HKEY reg) {
+ char* reg_value[MAX_VALUE_NAME];
+}
+
+int
+process_request_identities(struct sshbuf* request, struct sshbuf* response, HANDLE client) {
+ int r, r1, count = 0, index = 0;
+ HKEY root = NULL, sub = NULL;
+ char* count_ptr = NULL;
+ wchar_t sub_name[MAX_KEY_LENGTH];
+ DWORD sub_name_len = MAX_KEY_LENGTH;
+
+ if ((r = RegOpenKeyEx(HKEY_LOCAL_MACHINE, KEY_ROOT,
+ 0, STANDARD_RIGHTS_READ | KEY_ENUMERATE_SUB_KEYS, &root)) != 0)
+ goto done;
+
+ if ((r = sshbuf_put_u8(response, SSH2_AGENT_IDENTITIES_ANSWER)) != 0)
+ goto done;
+
+ count_ptr = sshbuf_ptr(response);
+
+ while (1) {
+ sub_name_len = MAX_KEY_LENGTH;
+ if (sub) {
+ RegCloseKey(sub);
+ sub = NULL;
+ }
+ if ((r = RegEnumKeyEx(root, index++, sub_name, &sub_name_len, NULL, NULL, NULL, NULL)) == 0) {
+ if ((r = RegOpenKeyEx(root, sub_name, 0, KEY_READ, &sub)) == 0) {
+ //RegQueryValueEx(sub, NULL, 0, )
+ }
+ else if (r == ERROR_FILE_NOT_FOUND) {
+ r = 0;
+ continue;
+ }
+ else
+ goto done;
+ }
+ else if (r == ERROR_NO_MORE_ITEMS) {
+ r = 0;
+ break;
+ }
+ else
+ goto done;
+
+ }
+
+done:
+ return r1;
+}
\ No newline at end of file
diff --git a/contrib/win32/win32compat/ssh-agent/agent-request.h b/contrib/win32/win32compat/ssh-agent/agent-request.h
index dbb0da7..4cf920c 100644
--- a/contrib/win32/win32compat/ssh-agent/agent-request.h
+++ b/contrib/win32/win32compat/ssh-agent/agent-request.h
@@ -8,6 +8,7 @@ typedef unsigned __int64 u_int64_t;
#include "sshbuf.h"
#include "sshkey.h"
#include "authfd.h"
+#include "digest.h"
int process_add_identity(struct sshbuf*, struct sshbuf*, HANDLE);
\ No newline at end of file
diff --git a/contrib/win32/win32compat/ssh-agent/agent.c b/contrib/win32/win32compat/ssh-agent/agent.c
index 11d964d..925c481 100644
--- a/contrib/win32/win32compat/ssh-agent/agent.c
+++ b/contrib/win32/win32compat/ssh-agent/agent.c
@@ -58,9 +58,13 @@ void agent_sm_process_action_queue() {
else if (action_queue & ACTION_LISTEN) {
HANDLE h;
long prev_queue;
+ SECURITY_ATTRIBUTES sa;
struct agent_connection* con =
(struct agent_connection*)malloc(sizeof(struct agent_connection));
memset(con, 0, sizeof(struct agent_connection));
+ memset(&sa, 0, sizeof(sa));
+ sa.bInheritHandle = FALSE;
+ sa.lpSecurityDescriptor = NULL;
h = CreateNamedPipe(
AGENT_PIPE_ID, // pipe name
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, // read/write access
@@ -71,7 +75,7 @@ void agent_sm_process_action_queue() {
BUFSIZE, // output buffer size
BUFSIZE, // input buffer size
0, // client time-out
- NULL);
+ &sa);
/* remove action from queue before assigning iocp port*/
con->connection = h;
diff --git a/contrib/win32/win32compat/ssh-agent/connection.c b/contrib/win32/win32compat/ssh-agent/connection.c
index 3d147da..bb5162c 100644
--- a/contrib/win32/win32compat/ssh-agent/connection.c
+++ b/contrib/win32/win32compat/ssh-agent/connection.c
@@ -133,6 +133,10 @@ process_request(struct agent_connection* con) {
case SSH2_AGENTC_ADD_IDENTITY:
r = process_add_identity(request, response, con->client_token);
break;
+ case SSH2_AGENTC_REQUEST_IDENTITIES:
+ r = process_request_identities(request, response, con->client_token);
+ break;
+ case SSH2_AGENTC_SIGN_REQUEST:
default:
r = EINVAL;
goto done;
diff --git a/ssh-add.c b/ssh-add.c
index 722746f..f9f8287 100644
--- a/ssh-add.c
+++ b/ssh-add.c
@@ -492,9 +492,7 @@ main(int argc, char **argv)
* Allocate stdio inside our wrapper function.
*/
- allocate_standard_descriptor(STDIN_FILENO);
- allocate_standard_descriptor(STDOUT_FILENO);
- allocate_standard_descriptor(STDERR_FILENO);
+ w32posix_initialize();
#endif