- Update to 20180802

- Use cmake
- Remove ONLY_FOR_ARCHS (reported by greg@unrelenting.technology) [1]
- Add TEST option and patch to disable tests
- Fix build on i386

PR:		230421 [1]
This commit is contained in:
Danilo Egea Gondolfo 2018-08-08 14:23:53 +00:00
parent 0e43adc685
commit 5c06339e63
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=476644
7 changed files with 150 additions and 25 deletions

View file

@ -2,7 +2,7 @@
# $FreeBSD$
PORTNAME= s2n
PORTVERSION= 20170425
PORTVERSION= 20180802
CATEGORIES= security
MAINTAINER= danilo@FreeBSD.org
@ -10,20 +10,21 @@ COMMENT= C99 implementation of the TLS/SSL protocols
LICENSE= APACHE20
ONLY_FOR_ARCHS= amd64
USES= cmake ssl
USE_GITHUB= yes
GH_ACCOUNT= awslabs
GH_TAGNAME= 02ade5e
GH_TAGNAME= 15fa0de
OPTIONS_DEFINE= DOCS EXAMPLES
OPTIONS_DEFINE= DOCS EXAMPLES TEST
USES= gmake ssl
USE_LDCONFIG= yes
NO_CONFIGURE= yes
CFLAGS+= -D__USE_BSD=1
SUB_FILES= pkg-message Makefile
ALL_TARGET= bin
SUB_FILES= pkg-message
TEST_CMAKE_BOOL= BUILD_TESTING
TEST_BUILD_DEPENDS= gmake:devel/gmake
post-patch:
@${REINPLACE_CMD} -e 's|CRYPTO_LDFLAGS |&+|' \
@ -32,18 +33,15 @@ post-patch:
@${REINPLACE_CMD} -e 's|-ldl||g' ${WRKSRC}/tests/LD_PRELOAD/Makefile \
${WRKSRC}/tests/fuzz/LD_PRELOAD/Makefile
do-install:
${INSTALL_LIB} ${WRKSRC}/lib/libs2n.so* ${STAGEDIR}${LOCALBASE}/lib
post-build-TEST-on:
${GMAKE} PLATFORM=FreeBSD S2N_DONT_MLOCK=yes \
CRYPTO_LDFLAGS=-L${LOCALBASE}/lib -C ${WRKSRC}/tests
post-install:
${LN} -s libs2n.so ${STAGEDIR}${LOCALBASE}/lib/libs2n.so.0
${INSTALL_DATA} ${WRKSRC}/api/s2n* ${STAGEDIR}${LOCALBASE}/include
@${MKDIR} ${STAGEDIR}${DOCSDIR}
${CP} -r ${WRKSRC}/docs/* ${STAGEDIR}${DOCSDIR}
@${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
${INSTALL_DATA} ${WRKSRC}/bin/*.c ${STAGEDIR}${EXAMPLESDIR}
${INSTALL_DATA} ${WRKDIR}/Makefile ${STAGEDIR}${EXAMPLESDIR}
tests: build
${GMAKE} PLATFORM=FreeBSD S2N_DONT_MLOCK=yes \
CRYPTO_LDFLAGS=-L${LOCALBASE}/lib -C ${WRKSRC}/tests
.include <bsd.port.mk>

View file

@ -1,3 +1,3 @@
TIMESTAMP = 1494191538
SHA256 (awslabs-s2n-20170425-02ade5e_GH0.tar.gz) = 4f89efda891d21db99ac2c446eae523cd41cae37bb4ccd0d690d36bf0d05faae
SIZE (awslabs-s2n-20170425-02ade5e_GH0.tar.gz) = 748394
TIMESTAMP = 1533600732
SHA256 (awslabs-s2n-20180802-15fa0de_GH0.tar.gz) = 0b1a4322c264911650e25a802a84faf8ce4f36534c68c318487c3ae8ba4d09c5
SIZE (awslabs-s2n-20180802-15fa0de_GH0.tar.gz) = 1342691

View file

@ -1,5 +0,0 @@
CFLAGS+= -I%%PREFIX%%/include
LDFLAGS+= -L%%PREFIX%%/lib -ls2n -lcrypto
all:
${CC} -o s2nd echo.c s2nd.c ${CFLAGS} ${LDFLAGS}
${CC} -o s2nc echo.c s2nc.c ${CFLAGS} ${LDFLAGS}

View file

@ -0,0 +1,89 @@
--- CMakeLists.txt.orig 2018-08-02 17:06:27 UTC
+++ CMakeLists.txt
@@ -8,6 +8,8 @@ set(INSTALL_LIB_DIR lib CACHE PATH "Installaction dire
set(INSTALL_INCLUDE_DIR include CACHE PATH "installaction directory for header files")
set(INSTALL_CMAKE_DIR lib/cmake CACHE PATH "Installation directory for cmake files")
+option(BUILD_TESTING "Build tests" ON)
+
##header files
file(GLOB API_HEADERS
"api/*.h"
@@ -97,7 +99,7 @@ file(GLOB S2N_HEADERS
${UTILS_SRC}
)
-add_library(s2n ${S2N_HEADERS} ${S2N_SRC})
+add_library(s2n SHARED ${S2N_HEADERS} ${S2N_SRC})
set_target_properties(s2n PROPERTIES LINKER_LANGUAGE C)
set(CMAKE_C_FLAGS_DEBUGOPT "")
@@ -127,39 +129,41 @@ target_include_directories(s2n PUBLIC $<BUILD_INTERFAC
target_include_directories(s2n PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/api> $<INSTALL_INTERFACE:include>)
target_include_directories(s2n PUBLIC $<TARGET_PROPERTY:LibCrypto::Crypto,INTERFACE_INCLUDE_DIRECTORIES>)
-file(GLOB TESTLIB_SRC "tests/testlib/*.c")
-file(GLOB TESTLIB_HEADERS "tests/testlib/*.h")
+if(BUILD_TESTING)
+ file(GLOB TESTLIB_SRC "tests/testlib/*.c")
+ file(GLOB TESTLIB_HEADERS "tests/testlib/*.h")
-add_library(testss2n ${TESTLIB_HEADERS} ${TESTLIB_SRC})
-target_include_directories(testss2n PRIVATE tests)
-target_compile_options(testss2n PRIVATE -std=c99)
-target_link_libraries(testss2n PUBLIC s2n)
+ add_library(testss2n ${TESTLIB_HEADERS} ${TESTLIB_SRC})
+ target_include_directories(testss2n PRIVATE tests)
+ target_compile_options(testss2n PRIVATE -std=c99)
+ target_link_libraries(testss2n PUBLIC s2n)
-#run unit tests
-file (GLOB TEST_LD_PRELOAD "tests/LD_PRELOAD/*.c")
-add_library(allocator_overrides SHARED ${TEST_LD_PRELOAD})
+ #run unit tests
+ file (GLOB TEST_LD_PRELOAD "tests/LD_PRELOAD/*.c")
+ add_library(allocator_overrides SHARED ${TEST_LD_PRELOAD})
-include(CTest)
-enable_testing()
+ include(CTest)
+ enable_testing()
-file(GLOB UNITTESTS_SRC "tests/unit/*.c")
- foreach(test_case ${UNITTESTS_SRC})
- string(REGEX REPLACE ".+\\/(.+)\\.c" "\\1" test_case_name ${test_case})
- add_executable(${test_case_name} ${test_case})
- target_link_libraries(${test_case_name} PRIVATE testss2n PRIVATE m pthread)
- target_include_directories(${test_case_name} PRIVATE api)
- target_include_directories(${test_case_name} PRIVATE ./)
- target_include_directories(${test_case_name} PRIVATE tests)
- target_compile_options(${test_case_name} PRIVATE -Wno-implicit-function-declaration -std=c99)
- add_test(NAME ${test_case_name} COMMAND $<TARGET_FILE:${test_case_name}> WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit)
+ file(GLOB UNITTESTS_SRC "tests/unit/*.c")
+ foreach(test_case ${UNITTESTS_SRC})
+ string(REGEX REPLACE ".+\\/(.+)\\.c" "\\1" test_case_name ${test_case})
+ add_executable(${test_case_name} ${test_case})
+ target_link_libraries(${test_case_name} PRIVATE testss2n PRIVATE m pthread)
+ target_include_directories(${test_case_name} PRIVATE api)
+ target_include_directories(${test_case_name} PRIVATE ./)
+ target_include_directories(${test_case_name} PRIVATE tests)
+ target_compile_options(${test_case_name} PRIVATE -Wno-implicit-function-declaration -std=c99)
+ add_test(NAME ${test_case_name} COMMAND $<TARGET_FILE:${test_case_name}> WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit)
- set_property(
- TEST
- ${test_case_name}
- PROPERTY
- ENVIRONMENT LD_PRELOAD=$<TARGET_FILE:allocator_overrides>)
+ set_property(
+ TEST
+ ${test_case_name}
+ PROPERTY
+ ENVIRONMENT LD_PRELOAD=$<TARGET_FILE:allocator_overrides>)
-endforeach(test_case)
+ endforeach(test_case)
+endif()
add_executable(s2nc "bin/s2nc.c" "bin/echo.c")
target_link_libraries(s2nc s2n)

View file

@ -0,0 +1,11 @@
--- cmake/modules/FindLibCrypto.cmake.orig 2018-06-25 03:06:06 UTC
+++ cmake/modules/FindLibCrypto.cmake
@@ -28,7 +28,7 @@ find_path(LibCrypto_INCLUDE_DIR
)
find_library(LibCrypto_LIBRARY
- NAMES libcrypto.a libcrypto.so
+ NAMES libcrypto.so
HINTS ${LibCrypto_ROOT_DIR}/build/crypto
${LibCrypto_ROOT_DIR}/build
${LibCrypto_ROOT_DIR}

View file

@ -0,0 +1,26 @@
--- utils/s2n_random.c.orig 2018-08-07 15:09:08 UTC
+++ utils/s2n_random.c
@@ -324,8 +324,13 @@ int s2n_get_rdrand_data(struct s2n_blob *out)
int space_remaining = 0;
struct s2n_stuffer stuffer = {{0}};
union {
- uint64_t u64;
+#if defined(__x86_64__)
+ uint64_t value;
uint8_t u8[8];
+#else
+ uint32_t value;
+ uint8_t u8[4];
+#endif
} output;
GUARD(s2n_stuffer_init(&stuffer, out));
@@ -334,7 +339,7 @@ int s2n_get_rdrand_data(struct s2n_blob *out)
int success = 0;
for (int tries = 0; tries < 10; tries++) {
- __asm__ __volatile__(".byte 0x48;\n" ".byte 0x0f;\n" ".byte 0xc7;\n" ".byte 0xf0;\n" "adcl $0x00, %%ebx;\n":"=b"(success), "=a"(output.u64)
+ __asm__ __volatile__(".byte 0x48;\n" ".byte 0x0f;\n" ".byte 0xc7;\n" ".byte 0xf0;\n" "adcl $0x00, %%ebx;\n":"=b"(success), "=a"(output.value)
:"b"(0)
:"cc");

View file

@ -1,15 +1,21 @@
include/s2n.h
lib/cmake/LibCrypto/LibCryptoConfig.cmake
lib/cmake/s2n/s2nConfig.cmake
lib/cmake/s2n/s2nTargets-%%CMAKE_BUILD_TYPE%%.cmake
lib/cmake/s2n/s2nTargets.cmake
lib/libs2n.so
lib/libs2n.so.0
%%PORTDOCS%%%%DOCSDIR%%/BINDINGS.md
%%PORTDOCS%%%%DOCSDIR%%/DEVELOPMENT-GUIDE.md
%%PORTDOCS%%%%DOCSDIR%%/READING-LIST.md
%%PORTDOCS%%%%DOCSDIR%%/USAGE-GUIDE.md
%%PORTDOCS%%%%DOCSDIR%%/images/s2n-logo-final.pdf
%%PORTDOCS%%%%DOCSDIR%%/images/s2n-logo-final.svg
%%PORTDOCS%%%%DOCSDIR%%/images/s2n-logo-github.svg
%%PORTDOCS%%%%DOCSDIR%%/images/s2n_lambda.png
%%PORTDOCS%%%%DOCSDIR%%/images/s2n_logo_github.png
%%PORTDOCS%%%%DOCSDIR%%/images/s2n_stuffer_layout.png
%%PORTDOCS%%%%DOCSDIR%%/images/s2n_tls_layers.png
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/Makefile
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/echo.c
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/s2nc.c
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/s2nd.c