winpr: start porting to non-OpenSSL
This commit is contained in:
parent
8e3baed882
commit
94a2f9533e
@ -287,13 +287,13 @@ if(WIN32)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWIN32_LEAN_AND_MEAN")
|
||||
|
||||
# Set product and vendor for dll and exe version information.
|
||||
set(RC_VERSION_VENDOR ${VENDOR})
|
||||
set(RC_VERSION_PRODUCT ${PRODUCT})
|
||||
set(RC_VERSION_PATCH ${BUILD_NUMBER})
|
||||
set(RC_VERSION_DESCRIPTION ${GIT_REVISION})
|
||||
# Set product and vendor for dll and exe version information.
|
||||
set(RC_VERSION_VENDOR ${VENDOR})
|
||||
set(RC_VERSION_PRODUCT ${PRODUCT})
|
||||
set(RC_VERSION_PATCH ${BUILD_NUMBER})
|
||||
set(RC_VERSION_DESCRIPTION ${GIT_REVISION})
|
||||
|
||||
string(TIMESTAMP RC_VERSION_YEAR "%Y")
|
||||
string(TIMESTAMP RC_VERSION_YEAR "%Y")
|
||||
|
||||
if(NOT DEFINED CMAKE_WINDOWS_VERSION)
|
||||
set(CMAKE_WINDOWS_VERSION "WINXP")
|
||||
@ -640,6 +640,14 @@ if(TARGET_ARCH MATCHES "x86|x64")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(OPENSSL_FOUND)
|
||||
add_definitions("-DWITH_OPENSSL")
|
||||
endif()
|
||||
|
||||
if(MBEDTLS_FOUND)
|
||||
add_definitions("-DWITH_MBEDTLS")
|
||||
endif()
|
||||
|
||||
if (TARGET_ARCH MATCHES "sparc")
|
||||
set(HAVE_ALIGNED_REQUIRED 1)
|
||||
endif()
|
||||
|
@ -103,13 +103,17 @@ winpr_module_add(${${MODULE_PREFIX}_SRCS}
|
||||
winpr_include_directory_add(
|
||||
"lodepng"
|
||||
"trio"
|
||||
"."
|
||||
${ZLIB_INCLUDE_DIRS}
|
||||
${OPENSSL_INCLUDE_DIR})
|
||||
".")
|
||||
|
||||
if(OPENSSL_FOUND)
|
||||
winpr_include_directory_add(${OPENSSL_INCLUDE_DIR})
|
||||
winpr_library_add(${OPENSSL_LIBRARIES})
|
||||
endif()
|
||||
|
||||
winpr_library_add(
|
||||
${ZLIB_LIBRARIES}
|
||||
${OPENSSL_LIBRARIES})
|
||||
if(MBEDTLS_FOUND)
|
||||
winpr_include_directory_add(${MBEDTLS_INCLUDE_DIR})
|
||||
winpr_library_add(${MBEDTLS_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
winpr_library_add(m)
|
||||
|
@ -25,8 +25,10 @@
|
||||
|
||||
#include <winpr/crt.h>
|
||||
|
||||
#ifdef WITH_OPENSSL
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/md4.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Define NTOWFv1(Password, User, Domain) as
|
||||
@ -36,17 +38,20 @@
|
||||
|
||||
BYTE* NTOWFv1W(LPWSTR Password, UINT32 PasswordLength, BYTE* NtHash)
|
||||
{
|
||||
MD4_CTX md4_ctx;
|
||||
|
||||
if (!Password)
|
||||
return NULL;
|
||||
|
||||
if (!NtHash && !(NtHash = malloc(16)))
|
||||
return NULL;
|
||||
|
||||
MD4_Init(&md4_ctx);
|
||||
MD4_Update(&md4_ctx, Password, PasswordLength);
|
||||
MD4_Final((void*) NtHash, &md4_ctx);
|
||||
#ifdef WITH_OPENSSL
|
||||
{
|
||||
MD4_CTX md4_ctx;
|
||||
MD4_Init(&md4_ctx);
|
||||
MD4_Update(&md4_ctx, Password, PasswordLength);
|
||||
MD4_Final((void*) NtHash, &md4_ctx);
|
||||
}
|
||||
#endif
|
||||
|
||||
return NtHash;
|
||||
}
|
||||
@ -105,7 +110,9 @@ BYTE* NTOWFv2W(LPWSTR Password, UINT32 PasswordLength, LPWSTR User,
|
||||
CopyMemory(&buffer[UserLength], Domain, DomainLength);
|
||||
|
||||
/* Compute the HMAC-MD5 hash of the above value using the NTLMv1 hash as the key, the result is the NTLMv2 hash */
|
||||
#ifdef WITH_OPENSSL
|
||||
HMAC(EVP_md5(), (void*) NtHashV1, 16, buffer, UserLength + DomainLength, (void*) NtHash, NULL);
|
||||
#endif
|
||||
|
||||
free(buffer);
|
||||
|
||||
@ -167,7 +174,9 @@ BYTE* NTOWFv2FromHashW(BYTE* NtHashV1, LPWSTR User, UINT32 UserLength, LPWSTR Do
|
||||
}
|
||||
|
||||
/* Compute the HMAC-MD5 hash of the above value using the NTLMv1 hash as the key, the result is the NTLMv2 hash */
|
||||
#ifdef WITH_OPENSSL
|
||||
HMAC(EVP_md5(), (void*) NtHashV1, 16, buffer, UserLength + DomainLength, (void*) NtHash, NULL);
|
||||
#endif
|
||||
|
||||
free(buffer);
|
||||
|
||||
|
@ -18,11 +18,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/synch.h>
|
||||
#include <winpr/ssl.h>
|
||||
#include <winpr/thread.h>
|
||||
|
||||
#ifdef WITH_OPENSSL
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
@ -277,3 +283,17 @@ BOOL winpr_CleanupSSL(DWORD flags)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
BOOL winpr_InitializeSSL(DWORD flags)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL winpr_CleanupSSL(DWORD flags)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -18,34 +18,28 @@
|
||||
set(MODULE_NAME "winpr-hash")
|
||||
set(MODULE_PREFIX "WINPR_TOOLS_HASH")
|
||||
|
||||
include_directories(${ZLIB_INCLUDE_DIRS})
|
||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
||||
|
||||
set(${MODULE_PREFIX}_SRCS
|
||||
hash.c)
|
||||
|
||||
# On windows create dll version information.
|
||||
# On windows create dll version information.
|
||||
# Vendor, product and year are already set in top level CMakeLists.txt
|
||||
if (WIN32)
|
||||
set (RC_VERSION_MAJOR ${WINPR_VERSION_MAJOR})
|
||||
set (RC_VERSION_MINOR ${WINPR_VERSION_MINOR})
|
||||
set (RC_VERSION_BUILD ${WINPR_VERSION_REVISION})
|
||||
set (RC_VERSION_FILE "${MODULE_NAME}${CMAKE_EXECUTABLE_SUFFIX}" )
|
||||
set(RC_VERSION_MAJOR ${WINPR_VERSION_MAJOR})
|
||||
set(RC_VERSION_MINOR ${WINPR_VERSION_MINOR})
|
||||
set(RC_VERSION_BUILD ${WINPR_VERSION_REVISION})
|
||||
set(RC_VERSION_FILE "${MODULE_NAME}${CMAKE_EXECUTABLE_SUFFIX}")
|
||||
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/version.rc
|
||||
@ONLY)
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/version.rc
|
||||
@ONLY)
|
||||
|
||||
set ( ${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
|
||||
set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
|
||||
endif()
|
||||
|
||||
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
|
||||
|
||||
set(${MODULE_PREFIX}_LIBS
|
||||
${ZLIB_LIBRARIES}
|
||||
${OPENSSL_LIBRARIES}
|
||||
winpr)
|
||||
set(${MODULE_PREFIX}_LIBS winpr)
|
||||
|
||||
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
|
||||
|
||||
|
@ -20,15 +20,25 @@ set(MODULE_PREFIX "WINPR_MAKECERT_TOOL")
|
||||
|
||||
set(${MODULE_PREFIX}_SRCS makecert.c)
|
||||
|
||||
include_directories(${ZLIB_INCLUDE_DIRS})
|
||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
||||
if(OPENSSL_FOUND)
|
||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
if(MBEDTLS_FOUND)
|
||||
include_directories(${MBEDTLS_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
add_library(${MODULE_NAME} STATIC ${${MODULE_PREFIX}_SRCS})
|
||||
|
||||
set(${MODULE_PREFIX}_LIBS
|
||||
${ZLIB_LIBRARIES}
|
||||
${OPENSSL_LIBRARIES}
|
||||
winpr)
|
||||
set(${MODULE_PREFIX}_LIBS winpr)
|
||||
|
||||
if(OPENSSL_FOUND)
|
||||
list(APPEND ${MODULE_PREFIX}_LIBS ${OPENSSL_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(MBEDTLS_FOUND)
|
||||
list(APPEND ${MODULE_PREFIX}_LIBS ${MBEDTLS_LIBRARIES})
|
||||
endif()
|
||||
|
||||
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
|
||||
|
||||
|
@ -23,20 +23,20 @@ include_directories(..)
|
||||
set(${MODULE_PREFIX}_SRCS
|
||||
main.c)
|
||||
|
||||
# On windows create dll version information.
|
||||
# On windows create dll version information.
|
||||
# Vendor, product and year are already set in top level CMakeLists.txt
|
||||
if (WIN32)
|
||||
set (RC_VERSION_MAJOR ${WINPR_VERSION_MAJOR})
|
||||
set (RC_VERSION_MINOR ${WINPR_VERSION_MINOR})
|
||||
set (RC_VERSION_BUILD ${WINPR_VERSION_REVISION})
|
||||
set (RC_VERSION_FILE "${MODULE_NAME}${CMAKE_EXECUTABLE_SUFFIX}" )
|
||||
set(RC_VERSION_MAJOR ${WINPR_VERSION_MAJOR})
|
||||
set(RC_VERSION_MINOR ${WINPR_VERSION_MINOR})
|
||||
set(RC_VERSION_BUILD ${WINPR_VERSION_REVISION})
|
||||
set(RC_VERSION_FILE "${MODULE_NAME}${CMAKE_EXECUTABLE_SUFFIX}")
|
||||
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/version.rc
|
||||
@ONLY)
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/version.rc
|
||||
@ONLY)
|
||||
|
||||
set ( ${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
|
||||
set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
|
||||
endif()
|
||||
|
||||
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
|
||||
|
@ -17,19 +17,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/path.h>
|
||||
#include <winpr/cmdline.h>
|
||||
#include <winpr/sysinfo.h>
|
||||
|
||||
#ifdef WITH_OPENSSL
|
||||
#include <openssl/conf.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/pkcs12.h>
|
||||
#include <openssl/x509v3.h>
|
||||
#endif
|
||||
|
||||
#include <winpr/tools/makecert.h>
|
||||
|
||||
@ -38,10 +36,12 @@ struct _MAKECERT_CONTEXT
|
||||
int argc;
|
||||
char** argv;
|
||||
|
||||
#ifdef WITH_OPENSSL
|
||||
RSA* rsa;
|
||||
X509* x509;
|
||||
EVP_PKEY* pkey;
|
||||
PKCS12* pkcs12;
|
||||
#endif
|
||||
|
||||
BOOL live;
|
||||
BOOL silent;
|
||||
@ -265,6 +265,7 @@ int makecert_print_command_line_help(int argc, char** argv)
|
||||
|
||||
int x509_add_ext(X509* cert, int nid, char* value)
|
||||
{
|
||||
#ifdef WITH_OPENSSL
|
||||
X509V3_CTX ctx;
|
||||
X509_EXTENSION* ext;
|
||||
|
||||
@ -278,6 +279,7 @@ int x509_add_ext(X509* cert, int nid, char* value)
|
||||
|
||||
X509_add_ext(cert, ext, -1);
|
||||
X509_EXTENSION_free(ext);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -309,7 +311,7 @@ char* x509_get_default_name()
|
||||
CHAR* computerName = NULL;
|
||||
DWORD nSize = 0;
|
||||
|
||||
if (GetComputerNameExA(ComputerNamePhysicalDnsFullyQualified, NULL, &nSize) ||
|
||||
if (GetComputerNameExA(ComputerNamePhysicalDnsFullyQualified, NULL, &nSize) ||
|
||||
GetLastError() != ERROR_MORE_DATA)
|
||||
goto fallback;
|
||||
|
||||
@ -320,10 +322,10 @@ char* x509_get_default_name()
|
||||
if (!GetComputerNameExA(ComputerNamePhysicalDnsFullyQualified, computerName, &nSize))
|
||||
goto fallback;
|
||||
|
||||
return computerName;
|
||||
return computerName;
|
||||
|
||||
fallback:
|
||||
free(computerName);
|
||||
free(computerName);
|
||||
|
||||
if (GetComputerNameExA(ComputerNamePhysicalNetBIOS, NULL, &nSize) ||
|
||||
GetLastError() != ERROR_MORE_DATA)
|
||||
@ -493,6 +495,7 @@ int makecert_context_set_output_file_name(MAKECERT_CONTEXT* context, char* name)
|
||||
|
||||
int makecert_context_output_certificate_file(MAKECERT_CONTEXT* context, char* path)
|
||||
{
|
||||
#ifdef WITH_OPENSSL
|
||||
FILE* fp = NULL;
|
||||
int status;
|
||||
int length;
|
||||
@ -741,10 +744,14 @@ out_fail:
|
||||
free(fullpath);
|
||||
|
||||
return ret;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int makecert_context_output_private_key_file(MAKECERT_CONTEXT* context, char* path)
|
||||
{
|
||||
#ifdef WITH_OPENSSL
|
||||
FILE* fp = NULL;
|
||||
int status;
|
||||
int length;
|
||||
@ -853,10 +860,14 @@ out_fail:
|
||||
free(fullpath);
|
||||
|
||||
return ret;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int makecert_context_process(MAKECERT_CONTEXT* context, int argc, char** argv)
|
||||
{
|
||||
#ifdef WITH_OPENSSL
|
||||
int length;
|
||||
char* entry;
|
||||
int key_length;
|
||||
@ -1100,7 +1111,7 @@ int makecert_context_process(MAKECERT_CONTEXT* context, int argc, char** argv)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1125,15 +1136,16 @@ void makecert_context_free(MAKECERT_CONTEXT* context)
|
||||
{
|
||||
free(context->password);
|
||||
|
||||
X509_free(context->x509);
|
||||
EVP_PKEY_free(context->pkey);
|
||||
|
||||
free(context->default_name);
|
||||
free(context->common_name);
|
||||
free(context->output_file);
|
||||
free(context->output_path);
|
||||
|
||||
#ifdef WITH_OPENSSL
|
||||
X509_free(context->x509);
|
||||
EVP_PKEY_free(context->pkey);
|
||||
CRYPTO_cleanup_all_ex_data();
|
||||
#endif
|
||||
|
||||
free(context);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user