From c763e0be7221cc055d61eec9d30c1ff8a4a0fc32 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 7 Jun 2021 20:48:09 +0300 Subject: fixes #2912 (Drop WinCrypto API support) --- include/m_netlib.h | 50 ++++++++++++++++++++++------------- include/m_ssl.h | 72 -------------------------------------------------- include/newpluginapi.h | 1 - 3 files changed, 32 insertions(+), 91 deletions(-) delete mode 100644 include/m_ssl.h (limited to 'include') diff --git a/include/m_netlib.h b/include/m_netlib.h index 7cc1524cb4..b821af977a 100644 --- a/include/m_netlib.h +++ b/include/m_netlib.h @@ -403,12 +403,6 @@ struct NETLIBCONNINFO EXTERN_C MIR_APP_DLL(int) Netlib_GetConnectionInfo(HNETLIBCONN hConnection, NETLIBCONNINFO *connInfo); -///////////////////////////////////////////////////////////////////////////////////////// -// Gets TLS channel binging data for a socket -// Returns true if successful - -EXTERN_C MIR_APP_DLL(void*) Netlib_GetTlsUnique(HNETLIBCONN nlc, int &cbLen); - ///////////////////////////////////////////////////////////////////////////////////////// // Gets connection Information // @@ -743,13 +737,6 @@ EXTERN_C MIR_APP_DLL(int) Netlib_GetMorePackets(HANDLE hReceiver, NETLIBPACKETRE EXTERN_C MIR_APP_DLL(int) Netlib_SetPollingTimeout(HNETLIBCONN hConnection, int iTimeout); -///////////////////////////////////////////////////////////////////////////////////////// -// Makes connection SSL -// -// Returns 0 on failure 1 on success - -EXTERN_C MIR_APP_DLL(int) Netlib_StartSsl(HNETLIBCONN hConnection, const char *host); - ///////////////////////////////////////////////////////////////////////////////////////// // netlib log funcitons @@ -764,20 +751,47 @@ EXTERN_C MIR_APP_DLL(void) Netlib_Dump(HNETLIBCONN nlc, const void *buf, size_t // Inits a required security provider. Right now only NTLM is supported // Returns HANDLE = NULL on error or non-null value on success // Known providers: Basic, NTLM, Negotiate, Kerberos, GSSAPI - (Kerberos SASL) - EXTERN_C MIR_APP_DLL(HANDLE) Netlib_InitSecurityProvider(const wchar_t *szProviderName, const wchar_t *szPrincipal = nullptr); -///////////////////////////////////////////////////////////////////////////////////////// // Destroys a security provider's handle, provided by Netlib_InitSecurityProvider. // Right now only NTLM is supported - EXTERN_C MIR_APP_DLL(void) Netlib_DestroySecurityProvider(HANDLE hProvider); -///////////////////////////////////////////////////////////////////////////////////////// // Returns the NTLM response string. The result value should be freed using mir_free - EXTERN_C MIR_APP_DLL(char*) Netlib_NtlmCreateResponse(HANDLE hProvider, const char *szChallenge, wchar_t *szLogin, wchar_t *szPass, unsigned &complete); +///////////////////////////////////////////////////////////////////////////////////////// +// SSL/TLS support + +#if !defined(HSSL_DEFINED) +DECLARE_HANDLE(HSSL); +#endif + +// Makes connection SSL +// Returns 0 on failure 1 on success +EXTERN_C MIR_APP_DLL(int) Netlib_StartSsl(HNETLIBCONN hConnection, const char *host); + +// negotiates SSL session, verifies cert, returns NULL if failed +EXTERN_C MIR_APP_DLL(HSSL) Netlib_SslConnect(SOCKET s, const char* host, int verify); + +// return true if there is either unsend or buffered received data (ie. after peek) +EXTERN_C MIR_APP_DLL(BOOL) Netlib_SslPending(HSSL ssl); + +// reads number of bytes, keeps in buffer if peek != 0 +EXTERN_C MIR_APP_DLL(int) Netlib_SslRead(HSSL ssl, char *buf, int num, int peek); + +// writes data to the SSL socket +EXTERN_C MIR_APP_DLL(int) Netlib_SslWrite(HSSL ssl, const char *buf, int num); + +// closes SSL session, but keeps socket open +EXTERN_C MIR_APP_DLL(void) Netlib_SslShutdown(HSSL ssl); + +// frees all data associated with the SSL socket +EXTERN_C MIR_APP_DLL(void) Netlib_SslFree(HSSL ssl); + +// gets TLS channel binging data for a socket +EXTERN_C MIR_APP_DLL(void*) Netlib_GetTlsUnique(HNETLIBCONN nlc, int &cbLen); + ///////////////////////////////////////////////////////////////////////////////////////// // WebSocket support diff --git a/include/m_ssl.h b/include/m_ssl.h deleted file mode 100644 index 3365aacf71..0000000000 --- a/include/m_ssl.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (C) 2012-21 Miranda NG team (https://miranda-ng.org) -Copyright (c) 2000-08 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef M_SSL_H__ -#define M_SSL_H__ 1 - -#include - -#if !defined(HSSL_DEFINED) - DECLARE_HANDLE(HSSL); -#endif - -typedef HSSL (__cdecl *pfnConnect)(SOCKET s, const char* host, int verify); -typedef BOOL (__cdecl *pfnPending)(HSSL ssl); -typedef int (__cdecl *pfnRead)(HSSL ssl, char *buf, int num, int peek); -typedef int (__cdecl *pfnWrite)(HSSL ssl, const char *buf, int num); -typedef void (__cdecl *pfnShutdown)(HSSL ssl); -typedef void (__cdecl *pfnSfree)(HSSL ssl); -typedef void *(__cdecl *pfnUnique)(HSSL ssl, int *cbLen); - -struct SSL_API -{ - int cbSize; - - pfnConnect connect; - pfnPending pending; - pfnRead read; - pfnWrite write; - pfnShutdown shutdown; - pfnSfree sfree; - pfnUnique unique; -}; - -/* -a service to obtain the SSL API - -wParam = 0; -lParam = (LPARAM)(SSL_API*). - -returns TRUE if all is Ok, and FALSE otherwise -*/ - -#define MS_SYSTEM_GET_SI "Miranda/System/GetSslApi" - -__forceinline INT_PTR mir_getSI(SSL_API *dest) -{ - dest->cbSize = sizeof(*dest); - return CallService(MS_SYSTEM_GET_SI, 0, (LPARAM)dest); -} - -#endif // M_SSL_H__ diff --git a/include/newpluginapi.h b/include/newpluginapi.h index 515fda9205..21ec09fd54 100644 --- a/include/newpluginapi.h +++ b/include/newpluginapi.h @@ -83,7 +83,6 @@ MIR_APP_DLL(void) SetPluginOnWhiteList(const char *szPluginName, bool bAllow); #define MIID_AUTOAWAY {0x9c87f7dc, 0x3bd7, 0x4983, {0xb7, 0xfb, 0xb8, 0x48, 0xfd, 0xbc, 0x91, 0xf0}} #define MIID_USERONLINE {0x130829e0, 0x2463, 0x4ff8, {0xbb, 0xc8, 0xce, 0x73, 0xc0, 0x18, 0x84, 0x42}} #define MIID_CRYPTO {0x415ca6e1, 0x895f, 0x40e6, {0x87, 0xbd, 0x9b, 0x39, 0x60, 0x16, 0xd0, 0xe5}} -#define MIID_SSL {0x3bbbbd20, 0x20e6, 0x479b, {0xbd, 0x4b, 0xe8, 0x4d, 0xe2, 0x62, 0x71, 0x20}} #define MIID_POPUP {0xb275f4a4, 0xe347, 0x4515, {0xaf, 0x71, 0x77, 0xd0, 0x1e, 0xef, 0x54, 0x41}} ///////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3