Skip to content

Commit e853d9a

Browse files
author
Benjamin Sergeant
committed
build fixes
1 parent 4ec0d9b commit e853d9a

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

ixcobra/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ add_library(ixcobra STATIC
2222

2323
set(IXCOBRA_INCLUDE_DIRS
2424
.
25+
..
2526
../ixcore
2627
../ixcrypto
27-
../ixwebsocket
2828
../third_party)
2929

3030
target_include_directories( ixcobra PUBLIC ${IXCOBRA_INCLUDE_DIRS} )

ixcrypto/CMakeLists.txt

+27-2
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22
# Author: Benjamin Sergeant
33
# Copyright (c) 2019 Machine Zone, Inc. All rights reserved.
44
#
5+
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../CMake;${CMAKE_MODULE_PATH}")
56

67
set (IXCRYPTO_SOURCES
78
ixcrypto/IXHMac.cpp
89
ixcrypto/IXBase64.cpp
9-
ixcrypto/IXUUid.cpp
10+
ixcrypto/IXUuid.cpp
1011
ixcrypto/IXHash.cpp
1112
)
1213

1314
set (IXCRYPTO_HEADERS
1415
ixcrypto/IXHMac.h
1516
ixcrypto/IXBase64.h
16-
ixcrypto/IXUUid.h
17+
ixcrypto/IXUuid.h
1718
ixcrypto/IXHash.h
1819
)
1920

@@ -27,3 +28,27 @@ set(IXCRYPTO_INCLUDE_DIRS
2728
../ixcore)
2829

2930
target_include_directories( ixcrypto PUBLIC ${IXCRYPTO_INCLUDE_DIRS} )
31+
32+
# hmac computation needs a crypto library
33+
34+
if (WIN32)
35+
set(USE_MBED_TLS TRUE)
36+
endif()
37+
38+
target_compile_definitions(ixcrypto PUBLIC IXCRYPTO_USE_TLS)
39+
if (USE_MBED_TLS)
40+
find_package(MbedTLS REQUIRED)
41+
target_include_directories(ixcrypto PUBLIC ${MBEDTLS_INCLUDE_DIRS})
42+
target_link_libraries(ixcrypto ${MBEDTLS_LIBRARIES})
43+
target_compile_definitions(ixcrypto PUBLIC IXCRYPTO_USE_MBED_TLS)
44+
elseif (APPLE)
45+
elseif (WIN32)
46+
else()
47+
find_package(OpenSSL REQUIRED)
48+
add_definitions(${OPENSSL_DEFINITIONS})
49+
message(STATUS "OpenSSL: " ${OPENSSL_VERSION})
50+
include_directories(${OPENSSL_INCLUDE_DIR})
51+
target_link_libraries(ixcrypto ${OPENSSL_LIBRARIES})
52+
target_compile_definitions(ixcrypto PUBLIC IXCRYPTO_USE_OPEN_SSL)
53+
endif()
54+

ixcrypto/ixcrypto/IXHMac.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
#include "IXHMac.h"
88
#include "IXBase64.h"
99

10-
#if defined(IXWEBSOCKET_USE_MBED_TLS)
10+
#if defined(IXCRYPTO_USE_MBED_TLS)
1111
# include <mbedtls/md.h>
1212
#elif defined(__APPLE__)
1313
# include <CommonCrypto/CommonHMAC.h>
14-
#else
14+
#elif defined(IXCRYPTO_USE_OPEN_SSL)
1515
# include <openssl/hmac.h>
16+
#else
17+
# error "Unsupported configuration"
1618
#endif
1719

1820
namespace ix
@@ -22,7 +24,7 @@ namespace ix
2224
constexpr size_t hashSize = 16;
2325
unsigned char hash[hashSize];
2426

25-
#if defined(IXWEBSOCKET_USE_MBED_TLS)
27+
#if defined(IXCRYPTO_USE_MBED_TLS)
2628
mbedtls_md_hmac(mbedtls_md_info_from_type(MBEDTLS_MD_MD5),
2729
(unsigned char *) key.c_str(), key.size(),
2830
(unsigned char *) data.c_str(), data.size(),
@@ -32,11 +34,13 @@ namespace ix
3234
key.c_str(), key.size(),
3335
data.c_str(), data.size(),
3436
&hash);
35-
#else
37+
#elif defined(IXCRYPTO_USE_OPEN_SSL)
3638
HMAC(EVP_md5(),
3739
key.c_str(), (int) key.size(),
3840
(unsigned char *) data.c_str(), (int) data.size(),
3941
(unsigned char *) hash, nullptr);
42+
#else
43+
# error "Unsupported configuration"
4044
#endif
4145

4246
std::string hashString(reinterpret_cast<char*>(hash), hashSize);

0 commit comments

Comments
 (0)