diff options
| author | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
|---|---|---|
| committer | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
| commit | 54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch) | |
| tree | d915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/ports/libu2f-server | |
Diffstat (limited to 'vcpkg/ports/libu2f-server')
| -rw-r--r-- | vcpkg/ports/libu2f-server/CMakeLists.txt | 31 | ||||
| -rw-r--r-- | vcpkg/ports/libu2f-server/portfile.cmake | 34 | ||||
| -rw-r--r-- | vcpkg/ports/libu2f-server/strndup-fix.patch | 31 | ||||
| -rw-r--r-- | vcpkg/ports/libu2f-server/u2f-server-version.h | 94 | ||||
| -rw-r--r-- | vcpkg/ports/libu2f-server/vcpkg.json | 16 | ||||
| -rw-r--r-- | vcpkg/ports/libu2f-server/windows.patch | 41 |
6 files changed, 247 insertions, 0 deletions
diff --git a/vcpkg/ports/libu2f-server/CMakeLists.txt b/vcpkg/ports/libu2f-server/CMakeLists.txt new file mode 100644 index 0000000..8bff872 --- /dev/null +++ b/vcpkg/ports/libu2f-server/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.5)
+
+project(libu2f-server C)
+
+file(GLOB_RECURSE LIBU2F_SERVER_HEADERS u2f-server/*.h)
+file(GLOB_RECURSE LIBU2F_SERVER_SOURCE u2f-server/*.c)
+
+add_library(libu2f-server ${LIBU2F_SERVER_SOURCE})
+
+target_include_directories(libu2f-server PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include>)
+target_compile_definitions(libu2f-server PRIVATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996")
+
+find_package(json-c CONFIG REQUIRED)
+find_package(OpenSSL REQUIRED)
+target_link_libraries(libu2f-server PRIVATE OpenSSL::SSL OpenSSL::Crypto json-c::json-c)
+
+install(TARGETS libu2f-server
+ EXPORT libu2f-serverConfig
+ RUNTIME DESTINATION "bin"
+ ARCHIVE DESTINATION "lib"
+ LIBRARY DESTINATION "lib"
+)
+
+INSTALL(FILES ${LIBU2F_SERVER_HEADERS} DESTINATION "include/libu2f-server")
+
+install(EXPORT libu2f-serverConfig
+ FILE libu2f-serverConfig.cmake
+ NAMESPACE libu2f-server::
+ DESTINATION "share/libu2f-server"
+)
\ No newline at end of file diff --git a/vcpkg/ports/libu2f-server/portfile.cmake b/vcpkg/ports/libu2f-server/portfile.cmake new file mode 100644 index 0000000..b63bf5b --- /dev/null +++ b/vcpkg/ports/libu2f-server/portfile.cmake @@ -0,0 +1,34 @@ +vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
+
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO Yubico/libu2f-server
+ REF libu2f-server-1.1.0
+ SHA512 085f8e7d74c1efb347747b8930386f18ba870f668f82e9bd479c9f8431585c5dc7f95b2f6b82bdd3a6de0c06f8cb2fbf51c363ced54255a936ab96536158ee59
+ HEAD_REF master
+ PATCHES
+ windows.patch
+ strndup-fix.patch
+)
+
+file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
+file(COPY "${CMAKE_CURRENT_LIST_DIR}/u2f-server-version.h" DESTINATION "${SOURCE_PATH}/u2f-server")
+
+vcpkg_cmake_configure(
+ SOURCE_PATH "${SOURCE_PATH}"
+)
+
+vcpkg_cmake_install()
+
+# The include file must be patched after the build has completed, because the source files use the wrong subdirectory name!
+vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/libu2f-server/u2f-server.h"
+ "#include <u2f-server/u2f-server-version.h>"
+ "#include <libu2f-server/u2f-server-version.h>"
+)
+
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
+vcpkg_copy_pdbs()
+
+# Handle copyright
+configure_file("${SOURCE_PATH}/COPYING" "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright" COPYONLY)
diff --git a/vcpkg/ports/libu2f-server/strndup-fix.patch b/vcpkg/ports/libu2f-server/strndup-fix.patch new file mode 100644 index 0000000..f5b7ffd --- /dev/null +++ b/vcpkg/ports/libu2f-server/strndup-fix.patch @@ -0,0 +1,31 @@ +diff --git a/u2f-server/core.c b/u2f-server/core.c
+index 294c94b..746932b 100644
+--- a/u2f-server/core.c
++++ b/u2f-server/core.c
+@@ -211,7 +211,7 @@ u2fs_rc u2fs_set_keyHandle(u2fs_ctx_t * ctx, const char *keyHandle)
+ ctx->keyHandle = NULL;
+ }
+
+- ctx->keyHandle = strndup(keyHandle, strlen(keyHandle));
++ ctx->keyHandle = strdup(keyHandle);
+
+ if (ctx->keyHandle == NULL)
+ return U2FS_MEMORY_ERROR;
+@@ -726,7 +726,7 @@ static u2fs_rc decode_clientData(const char *clientData, char **output)
+ fprintf(stderr, "clientData: %s\n", data);
+ }
+
+- *output = strndup(data, strlen(data));
++ *output = strdup(data);
+
+ free(data);
+ data = NULL;
+@@ -870,7 +870,7 @@ u2fs_rc u2fs_registration_verify(u2fs_ctx_t * ctx, const char *response,
+ goto failure;
+
+ u2fs_EC_KEY_t *key_ptr;
+- (*output)->keyHandle = strndup(buf, strlen(buf));
++ (*output)->keyHandle = strdup(buf);
+
+ rc = decode_user_key(user_public_key, &key_ptr);
+ if (rc != U2FS_OK)
diff --git a/vcpkg/ports/libu2f-server/u2f-server-version.h b/vcpkg/ports/libu2f-server/u2f-server-version.h new file mode 100644 index 0000000..b38ccac --- /dev/null +++ b/vcpkg/ports/libu2f-server/u2f-server-version.h @@ -0,0 +1,94 @@ +/*
+* Copyright (c) 2014 Yubico AB
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are
+* met:
+*
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+*
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef U2F_SERVER_VERSION_H
+#define U2F_SERVER_VERSION_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * U2FS_VERSION_STRING
+ *
+ * Pre-processor symbol with a string that describe the header file
+ * version number. Used together with u2fs_check_version() to verify
+ * header file and run-time library consistency.
+ */
+#define U2FS_VERSION_STRING "1.1.0"
+
+/**
+ * U2FS_VERSION_NUMBER
+ *
+ * Pre-processor symbol with a hexadecimal value describing the header
+ * file version number. For example, when the header version is 1.2.3
+ * this symbol will have the value 0x01020300. The last two digits
+ * are only used between public releases, and will otherwise be 00.
+ */
+#define U2FS_VERSION_NUMBER 0x01010000
+
+/**
+ * U2FS_VERSION_MAJOR
+ *
+ * Pre-processor symbol with a decimal value that describe the major
+ * level of the header file version number. For example, when the
+ * header version is 1.2.3 this symbol will be 1.
+ */
+#define U2FS_VERSION_MAJOR 1
+
+/**
+ * U2FS_VERSION_MINOR
+ *
+ * Pre-processor symbol with a decimal value that describe the minor
+ * level of the header file version number. For example, when the
+ * header version is 1.2.3 this symbol will be 2.
+ */
+#define U2FS_VERSION_MINOR 1
+
+/**
+ * U2FS_VERSION_PATCH
+ *
+ * Pre-processor symbol with a decimal value that describe the patch
+ * level of the header file version number. For example, when the
+ * header version is 1.2.3 this symbol will be 3.
+ */
+#define U2FS_VERSION_PATCH 0
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/vcpkg/ports/libu2f-server/vcpkg.json b/vcpkg/ports/libu2f-server/vcpkg.json new file mode 100644 index 0000000..a3e291e --- /dev/null +++ b/vcpkg/ports/libu2f-server/vcpkg.json @@ -0,0 +1,16 @@ +{ + "name": "libu2f-server", + "version": "1.1.0", + "port-version": 5, + "description": "Yubico Universal 2nd Factor (U2F) Server C Library", + "homepage": "https://developers.yubico.com/libu2f-server/", + "supports": "(x86 | x64) & windows", + "dependencies": [ + "json-c", + "openssl", + { + "name": "vcpkg-cmake", + "host": true + } + ] +} diff --git a/vcpkg/ports/libu2f-server/windows.patch b/vcpkg/ports/libu2f-server/windows.patch new file mode 100644 index 0000000..2cc68ec --- /dev/null +++ b/vcpkg/ports/libu2f-server/windows.patch @@ -0,0 +1,41 @@ +diff --git a/u2f-server/cdecode.c b/u2f-server/cdecode.c
+index 6fff114..dc05ca5 100644
+--- a/u2f-server/cdecode.c
++++ b/u2f-server/cdecode.c
+@@ -5,7 +5,7 @@ This is part of the libb64 project, and has been placed in the public domain.
+ For details, see http://sourceforge.net/projects/libb64
+ */
+
+-#include <b64/cdecode.h>
++#include "b64/cdecode.h"
+
+ int base64_decode_value(char value_in)
+ {
+diff --git a/u2f-server/cencode.c b/u2f-server/cencode.c
+index eebb24a..f3b7fa4 100644
+--- a/u2f-server/cencode.c
++++ b/u2f-server/cencode.c
+@@ -5,7 +5,7 @@ This is part of the libb64 project, and has been placed in the public domain.
+ For details, see http://sourceforge.net/projects/libb64
+ */
+
+-#include <b64/cencode.h>
++#include "b64/cencode.h"
+
+ const int CHARS_PER_LINE = 72;
+
+diff --git a/u2f-server/core.c b/u2f-server/core.c
+index da440ec..294c94b 100644
+--- a/u2f-server/core.c
++++ b/u2f-server/core.c
+@@ -30,8 +30,7 @@
+ #include "internal.h"
+
+ #include <string.h>
+-#include <unistd.h>
+-#include <json.h>
++#include <json-c/json.h>
+ #include "crypto.h"
+ #include "b64/cencode.h"
+ #include "b64/cdecode.h"
+
\ No newline at end of file |