Skip to content

Commit 70dfabd

Browse files
authored
Minor fixes (#435)
* Link nlohmann_json at the top level * Clean up TLS syntax library's use of integer types * clang-format
1 parent 8ec63dd commit 70dfabd

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

CMakeLists.txt

+8-1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ set(VCPKG_BUILD_TYPE release)
103103
# Internal libraries
104104
add_subdirectory(lib)
105105

106+
# External libraries
107+
find_package(nlohmann_json REQUIRED)
108+
106109
# Third-Party libraries in tree
107110
add_subdirectory(third_party)
108111

@@ -118,7 +121,11 @@ file(GLOB_RECURSE LIB_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src
118121

119122
add_library(${LIB_NAME} ${LIB_HEADERS} ${LIB_SOURCES})
120123
add_dependencies(${LIB_NAME} bytes tls_syntax hpke)
121-
target_link_libraries(${LIB_NAME} bytes tls_syntax hpke)
124+
target_link_libraries(${LIB_NAME}
125+
PRIVATE
126+
nlohmann_json::nlohmann_json
127+
PUBLIC
128+
bytes tls_syntax hpke)
122129
target_include_directories(${LIB_NAME}
123130
PUBLIC
124131
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>

lib/hpke/test/build.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
TEST_CASE("BoringSSL Define")
44
{
55
#if defined(__has_include)
6-
#if __has_include(<openssl/is_boringssl.h>)
7-
#if defined(WITH_BORINGSSL)
8-
REQUIRE(WITH_BORINGSSL);
9-
#else
10-
FAIL("Expect #WITH_BORINGSSL set when compiling with BoringSSL");
11-
#endif
12-
#else
13-
SKIP("Only applicable to BoringSSL");
14-
#endif
6+
#if __has_include(<openssl/is_boringssl.h>)
7+
#if defined(WITH_BORINGSSL)
8+
REQUIRE(WITH_BORINGSSL);
159
#else
16-
SKIP("Cannot ensure BoringSSL without __has_include()");
10+
FAIL("Expect #WITH_BORINGSSL set when compiling with BoringSSL");
11+
#endif
12+
#else
13+
SKIP("Only applicable to BoringSSL");
14+
#endif
15+
#else
16+
SKIP("Cannot ensure BoringSSL without __has_include()");
1717
#endif
1818
}

lib/tls_syntax/include/tls/tls_syntax.h

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <algorithm>
44
#include <array>
5+
#include <cstddef>
56
#include <cstdint>
67
#include <limits>
78
#include <map>
@@ -14,6 +15,13 @@
1415

1516
namespace MLS_NAMESPACE::tls {
1617

18+
using std::ptrdiff_t;
19+
using std::size_t;
20+
using std::uint16_t;
21+
using std::uint32_t;
22+
using std::uint64_t;
23+
using std::uint8_t;
24+
1725
// For indicating no min or max in vector definitions
1826
const size_t none = std::numeric_limits<size_t>::max();
1927

@@ -288,8 +296,9 @@ operator>>(istream& str, std::vector<T>& vec)
288296
// NB: Remember that we store the vector in reverse order
289297
// NB: This requires that T be default-constructible
290298
istream r;
299+
const auto size_diff = static_cast<ptrdiff_t>(size);
291300
r._buffer =
292-
std::vector<uint8_t>{ str._buffer.end() - size, str._buffer.end() };
301+
std::vector<uint8_t>{ str._buffer.end() - size_diff, str._buffer.end() };
293302

294303
vec.clear();
295304
while (r._buffer.size() > 0) {
@@ -298,7 +307,7 @@ operator>>(istream& str, std::vector<T>& vec)
298307
}
299308

300309
// Truncate the primary buffer
301-
str._buffer.erase(str._buffer.end() - size, str._buffer.end());
310+
str._buffer.erase(str._buffer.end() - size_diff, str._buffer.end());
302311

303312
return str;
304313
}

0 commit comments

Comments
 (0)