Skip to content

Commit

Permalink
Several fixes (#313)
Browse files Browse the repository at this point in the history
* Refs #3760. Several fixes.

* Support of OpenSSL 1.0.2
* Fixing compilation error on ROS2
  • Loading branch information
richiware authored and MiguelCompany committed Nov 12, 2018
1 parent e01347e commit 7633a01
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
3 changes: 3 additions & 0 deletions cmake/packaging/Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ endif()
set_and_check(@PROJECT_NAME@_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
set_and_check(@PROJECT_NAME@_LIB_DIR "@PACKAGE_LIB_INSTALL_DIR@")

find_package(fastcdr REQUIRED)
@FASTRTPS_PACKAGE_OPT_DEPS@

include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake)
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Define variables for the FastRTPS version number.
#
m4_define([version_major],[1])
m4_define([version_minor],[6])
m4_define([version_minor],[7])
m4_define([version_micro],[0])

AC_INIT([fastrtps], [version_major.version_minor.version_micro], [support@eprosima.com], [eProsima FastRTPS], [http://eprosima.com/])
Expand Down
6 changes: 6 additions & 0 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,12 @@ elseif(NOT EPROSIMA_INSTALLER)
# Create CMake package config file
###############################################################################
include(CMakePackageConfigHelpers)

# Add fastrtps dependencies in its CMake config file.
if(SECURITY)
set(FASTRTPS_PACKAGE_OPT_DEPS "find_package(OpenSSL REQUIRED)")
endif()

configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/packaging/Config.cmake.in
${PROJECT_BINARY_DIR}/cmake/config/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${DATA_INSTALL_DIR}$/${PROJECT_NAME}/cmake${MSVCARCH_DIR_EXTENSION_EXT}
Expand Down
36 changes: 34 additions & 2 deletions src/cpp/security/authentication/PKIDH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,12 @@ static bool store_dh_public_key(EVP_PKEY* dhkey, std::vector<uint8_t>& buffer,
SecurityException& exception)
{
bool returnedValue = false;
DH* dh = EVP_PKEY_get0_DH(dhkey);
DH* dh =
#if IS_OPENSSL_1_1
EVP_PKEY_get0_DH(dhkey);
#else
dhkey->pkey.dh;
#endif

if(dh != nullptr)
{
Expand All @@ -705,11 +710,18 @@ static bool store_dh_public_key(EVP_PKEY* dhkey, std::vector<uint8_t>& buffer,
returnedValue = true;
}
else
{
exception = _SecurityException_("Cannot serialize public key");
}
}
else
{
EC_KEY* ec = EVP_PKEY_get0_EC_KEY(dhkey);
EC_KEY* ec =
#if IS_OPENSSL_1_1
EVP_PKEY_get0_EC_KEY(dhkey);
#else
dhkey->pkey.ec;
#endif
if (ec != nullptr)
{
auto grp = EC_KEY_get0_group(ec);
Expand Down Expand Up @@ -761,18 +773,26 @@ static EVP_PKEY* generate_dh_peer_key(const std::vector<uint8_t>& buffer, Securi
return key;
}
else
{
exception = _SecurityException_("OpenSSL library cannot set dh in pkey");
}

EVP_PKEY_free(key);
}
else
{
exception = _SecurityException_("OpenSSL library cannot create pkey");
}
}
else
{
exception = _SecurityException_("Cannot deserialize public key");
}
}
else
{
exception = _SecurityException_("OpenSSL library cannot create dh");
}
}
else
{
Expand All @@ -782,7 +802,11 @@ static EVP_PKEY* generate_dh_peer_key(const std::vector<uint8_t>& buffer, Securi
{
const unsigned char* pointer = buffer.data();

#if IS_OPENSSL_1_1
if(EC_KEY_oct2key(ec, pointer, buffer.size(), NULL) > 0)
#else
if(o2i_ECPublicKey(&ec, &pointer, buffer.size()) != nullptr)
#endif
{
EVP_PKEY* key = EVP_PKEY_new();

Expand All @@ -793,20 +817,28 @@ static EVP_PKEY* generate_dh_peer_key(const std::vector<uint8_t>& buffer, Securi
return key;
}
else
{
exception = _SecurityException_("OpenSSL library cannot set ec in pkey");
}

EVP_PKEY_free(key);
}
else
{
exception = _SecurityException_("OpenSSL library cannot create pkey");
}
}
else
{
exception = _SecurityException_("Cannot deserialize public key");
}

EC_KEY_free(ec);
}
else
{
exception = _SecurityException_("OpenSSL library cannot create ec");
}
}

return nullptr;
Expand Down

0 comments on commit 7633a01

Please sign in to comment.