Skip to content

Commit

Permalink
Fix broken build with NSS crypto back end
Browse files Browse the repository at this point in the history
OpenSCAP had 2 alternatives of crypto libraries, GCrypt and NSS.
GCrypt is the default backend. We discovered that building with
the NSS backend is broken at this moment. This patch fixes the
broken build. Use `cmake -DWITH_CRYPTO=nss ..` to configure
with NSS.
  • Loading branch information
jan-cerny committed Feb 5, 2024
1 parent 192f545 commit f1291ad
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ check_library_exists(pthread pthread_setname_np "" HAVE_PTHREAD_SETNAME_NP)
check_library_exists(pthread pthread_getname_np "" HAVE_PTHREAD_GETNAME_NP)

# WITH_CRYPTO
set(WITH_CRYPTO "gcrypt" CACHE STRING "gcrypt|nss3")
if(NOT (${WITH_CRYPTO} EQUAL "nss3"))
# gcrypt
find_package(GCrypt)
else()
# nss3
set(WITH_CRYPTO "gcrypt" CACHE STRING "gcrypt|nss")
if(${WITH_CRYPTO} STREQUAL "nss")
message("-- Using NSS")
find_package(NSS)
else()
message("-- Using GCrypt")
find_package(GCrypt)
endif()
if(GCRYPT_FOUND OR NSS_FOUND)
set(CRYPTO_FOUND TRUE)
Expand Down
2 changes: 0 additions & 2 deletions cmake/FindNSS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

include(FindLibraryWithDebug)

if (NSS_LIBRARIES)
set(NSS_FIND_QUIETLY TRUE)
endif ()
Expand Down
4 changes: 2 additions & 2 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#cmakedefine HAVE_GCRYCTL_SET_ENFORCED_FIPS_FLAG
#endif

#cmakedefine NSS3_FOUND
#if defined(NSS3_FOUND)
#cmakedefine NSS_FOUND
#if defined(NSS_FOUND)
#define HAVE_NSS3
#endif

Expand Down
4 changes: 2 additions & 2 deletions tests/API/crypt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ set(CRAPI_HEADERS "${CMAKE_SOURCE_DIR}/src/OVAL/probes/crapi/")
file(GLOB_RECURSE CRAPI_SOURCES "${CMAKE_SOURCE_DIR}/src/OVAL/probes/crapi/*.c")
add_oscap_test_executable(test_crapi_digest "test_crapi_digest.c" ${CRAPI_SOURCES})
add_oscap_test_executable(test_crapi_mdigest "test_crapi_mdigest.c" ${CRAPI_SOURCES})
target_include_directories(test_crapi_digest PUBLIC ${PROBE_HEADERS} ${CRAPI_HEADERS})
target_include_directories(test_crapi_mdigest PUBLIC ${PROBE_HEADERS} ${CRAPI_HEADERS})
target_include_directories(test_crapi_digest PUBLIC ${PROBE_HEADERS} ${CRAPI_HEADERS} ${NSS_INCLUDE_DIRS})
target_include_directories(test_crapi_mdigest PUBLIC ${PROBE_HEADERS} ${CRAPI_HEADERS} ${NSS_INCLUDE_DIRS})
target_link_libraries(test_crapi_digest openscap)
target_link_libraries(test_crapi_mdigest openscap)
add_oscap_test("test_api_crypt.sh")

0 comments on commit f1291ad

Please sign in to comment.