From 2c7e659e37f201d4cc666acf78173580c3032c69 Mon Sep 17 00:00:00 2001 From: Manoj Ampalam Date: Sun, 8 May 2016 21:05:49 -0700 Subject: [PATCH] 5-8 C3 --- contrib/win32/openssh/ssh-agent.vcxproj | 9 +++--- contrib/win32/openssh/ssh-pubkey.vcxproj | 1 + contrib/win32/ssh-pubkey/pubkeyfd.h | 17 +---------- contrib/win32/ssh-pubkey/ssh-pubkeydefs.h | 22 +++++++++++++++ .../ssh-agent/pubkeyagent-request.c | 28 ++++++++++++++++++- 5 files changed, 56 insertions(+), 21 deletions(-) create mode 100644 contrib/win32/ssh-pubkey/ssh-pubkeydefs.h diff --git a/contrib/win32/openssh/ssh-agent.vcxproj b/contrib/win32/openssh/ssh-agent.vcxproj index 06a5397..eb8f876 100644 --- a/contrib/win32/openssh/ssh-agent.vcxproj +++ b/contrib/win32/openssh/ssh-agent.vcxproj @@ -106,7 +106,7 @@ Disabled _WIN32_WINNT=0x600;WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) false - $(SolutionDir);$(OpenSSL-Win32-Debug-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat\includes;$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) + $(SolutionDir);$(OpenSSL-Win32-Debug-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat\includes;$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories);$(OpenSSH-Src-Path)contrib\win32\ssh-pubkey CompileAsC MultiThreadedDebug Sync @@ -129,7 +129,7 @@ Disabled _WIN32_WINNT=0x600;WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) false - $(SolutionDir);$(OpenSSL-x64-Debug-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat\includes;$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) + $(SolutionDir);$(OpenSSL-x64-Debug-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat\includes;$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories);$(OpenSSH-Src-Path)contrib\win32\ssh-pubkey CompileAsC MultiThreadedDebug ProgramDatabase @@ -153,7 +153,7 @@ true _WIN32_WINNT=0x600;_LIB;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) false - $(SolutionDir);$(OpenSSL-Win32-Release-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat\includes;$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) + $(SolutionDir);$(OpenSSL-Win32-Release-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat\includes;$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories);$(OpenSSH-Src-Path)contrib\win32\ssh-pubkey MultiThreaded @@ -177,7 +177,7 @@ true _WIN32_WINNT=0x600;_LIB;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) false - $(SolutionDir);$(OpenSSL-x64-Release-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat\includes;$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories) + $(SolutionDir);$(OpenSSL-x64-Release-Path)include;$(OpenSSH-Src-Path)includes;$(OpenSSH-Src-Path);$(OpenSSH-Src-Path)contrib\win32\win32compat\includes;$(OpenSSH-Src-Path)contrib\win32\win32compat;$(OpenSSH-Src-Path)libkrb;$(OpenSSH-Src-Path)libkrb\libKrb5;%(AdditionalIncludeDirectories);$(OpenSSH-Src-Path)contrib\win32\ssh-pubkey MultiThreaded true @@ -195,6 +195,7 @@ + diff --git a/contrib/win32/openssh/ssh-pubkey.vcxproj b/contrib/win32/openssh/ssh-pubkey.vcxproj index 2095103..818addd 100644 --- a/contrib/win32/openssh/ssh-pubkey.vcxproj +++ b/contrib/win32/openssh/ssh-pubkey.vcxproj @@ -24,6 +24,7 @@ + diff --git a/contrib/win32/ssh-pubkey/pubkeyfd.h b/contrib/win32/ssh-pubkey/pubkeyfd.h index 466c4ce..54974ae 100644 --- a/contrib/win32/ssh-pubkey/pubkeyfd.h +++ b/contrib/win32/ssh-pubkey/pubkeyfd.h @@ -2,22 +2,7 @@ #ifndef PUBKEYFD_H #define PUBKEYFD_H -#define PK_REQUEST_ADD "add" -#define PK_REQUEST_LIST "list" -#define PK_REQUEST_REMOVE "remove" -#define PK_REQUEST_REMOVE_ALL "removeall" -#define PK_REQUEST_REMOVE_BY_FP "removebyfp" - -#define SSH_PUBLICKEY_SUCCESS 0 -#define SSH_PUBLICKEY_ACCESS_DENIED 1 -#define SSH_PUBLICKEY_STORAGE_EXCEEDED 2 -#define SSH_PUBLICKEY_VERSION_NOT_SUPPORTED 3 -#define SSH_PUBLICKEY_KEY_NOT_FOUND 4 -#define SSH_PUBLICKEY_KEY_NOT_SUPPORTED 5 -#define SSH_PUBLICKEY_KEY_ALREADY_PRESENT 6 -#define SSH_PUBLICKEY_GENERAL_FAILURE 7 -#define SSH_PUBLICKEY_REQUEST_NOT_SUPPORTED 8 -#define SSH_PUBLICKEY_ATTRIBUTE_NOT_SUPPORTED 9 +#include "ssh-pubkeydefs.h" int ssh_add_pubkey(int sock, struct sshkey *key, const char *comment, const char* password); int ssh_list_pubkeys(int sock, struct ssh_identitylist **idlp); diff --git a/contrib/win32/ssh-pubkey/ssh-pubkeydefs.h b/contrib/win32/ssh-pubkey/ssh-pubkeydefs.h new file mode 100644 index 0000000..51413e7 --- /dev/null +++ b/contrib/win32/ssh-pubkey/ssh-pubkeydefs.h @@ -0,0 +1,22 @@ + +#ifndef PUBKEYDEFS_H +#define PUBKEYDEFS_H + +#define PK_REQUEST_ADD "add" +#define PK_REQUEST_LIST "list" +#define PK_REQUEST_REMOVE "remove" +#define PK_REQUEST_REMOVE_ALL "removeall" +#define PK_REQUEST_REMOVE_BY_FP "removebyfp" + +#define SSH_PUBLICKEY_SUCCESS 0 +#define SSH_PUBLICKEY_ACCESS_DENIED 1 +#define SSH_PUBLICKEY_STORAGE_EXCEEDED 2 +#define SSH_PUBLICKEY_VERSION_NOT_SUPPORTED 3 +#define SSH_PUBLICKEY_KEY_NOT_FOUND 4 +#define SSH_PUBLICKEY_KEY_NOT_SUPPORTED 5 +#define SSH_PUBLICKEY_KEY_ALREADY_PRESENT 6 +#define SSH_PUBLICKEY_GENERAL_FAILURE 7 +#define SSH_PUBLICKEY_REQUEST_NOT_SUPPORTED 8 +#define SSH_PUBLICKEY_ATTRIBUTE_NOT_SUPPORTED 9 + +#endif diff --git a/contrib/win32/win32compat/ssh-agent/pubkeyagent-request.c b/contrib/win32/win32compat/ssh-agent/pubkeyagent-request.c index 362b343..acae41f 100644 --- a/contrib/win32/win32compat/ssh-agent/pubkeyagent-request.c +++ b/contrib/win32/win32compat/ssh-agent/pubkeyagent-request.c @@ -31,7 +31,33 @@ #include "agent.h" #include "agent-request.h" +#include "ssh-pubkeydefs.h" + + +static int +process_add_request(struct sshbuf* request, struct sshbuf* response, struct agent_connection* con) { + return -1; +} + + int process_pubkeyagent_request(struct sshbuf* request, struct sshbuf* response, struct agent_connection* con) { - return -1; + int r = 0; + const u_char *op; + size_t op_len; + + if ((r = sshbuf_get_string_direct(request, &op, &op_len)) != 0) + goto done; + + if (op_len > 10) { + r = EINVAL; + goto done; + } + + if ((op_len == 3) && (strncmp(op, PK_REQUEST_ADD, 3) == 0)) + r = 0; + + +done: + return r; } \ No newline at end of file