Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libu2f-server] New Port #6781

Merged
merged 14 commits into from
Jun 27, 2019
2 changes: 1 addition & 1 deletion ports/gsoap/CONTROL
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Source: gsoap
Version: 2.8.82-2
Version: 2.8.84-1
Build-Depends: curl
Description: The gSOAP toolkit is a C and C++ software development toolkit for SOAP and REST XML Web services and generic C/C++ XML data bindings.
4 changes: 2 additions & 2 deletions ports/gsoap/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
include(vcpkg_common_functions)
set(GSOAP_VERSION 2.8)
set(GSOAP_SUB_VERSION .82)
set(GSOAP_SUB_VERSION .84)
set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/gsoap-${GSOAP_VERSION})

vcpkg_download_distfile(ARCHIVE
URLS "https://ayera.dl.sourceforge.net/project/gsoap2/gsoap-${GSOAP_VERSION}/gsoap_${GSOAP_VERSION}${GSOAP_SUB_VERSION}.zip"
FILENAME "gsoap_${GSOAP_VERSION}${GSOAP_SUB_VERSION}.zip"
SHA512 daf6a1870fe43beb20d0faf646b171c92629885708baabea5bbce79fa5a8030f014dbe5c0bf4024031df993dd3ed3a90449db813946cfdfa9c12318096b57eec
SHA512 ec050119cd3e480b266cad36823f4862fe0ac21045ce901c3c91a552eae2fbf9e1cd515458835807cce54c04df7835a980a299d37f418190cd57684fd6bdcf79
)

vcpkg_extract_source_archive_ex(
Expand Down
29 changes: 29 additions & 0 deletions ports/libu2f-server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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>)

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"
)
4 changes: 4 additions & 0 deletions ports/libu2f-server/CONTROL
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Source: libu2f-server
Version: 1.1.0
Build-Depends: openssl, json-c
Description: Yubico Universal 2nd Factor (U2F) Server C Library
35 changes: 35 additions & 0 deletions ports/libu2f-server/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
include(vcpkg_common_functions)

vcpkg_check_linkage(ONLY_STATIC_LIBRARY)

if(NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME MATCHES "WindowsStore")
set(WIN_PATCHES strdup-fix.patch strncpy-fix.patch)
endif()

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
${WIN_PATCHES}
)

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_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
)

vcpkg_install_cmake()

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)
130 changes: 130 additions & 0 deletions ports/libu2f-server/strdup-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
diff --git a/u2f-server/core.c b/u2f-server/core.c
index 81a63b6b..b6255caf 100644
--- a/u2f-server/core.c
+++ b/u2f-server/core.c
@@ -221,7 +221,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;
@@ -376,7 +376,7 @@ u2fs_rc u2fs_set_origin(u2fs_ctx_t * ctx, const char *origin)
ctx->origin = NULL;
}

- ctx->origin = strdup(origin);
+ ctx->origin = _strdup(origin);
if (ctx->origin == NULL)
return U2FS_MEMORY_ERROR;

@@ -403,7 +403,7 @@ u2fs_rc u2fs_set_appid(u2fs_ctx_t * ctx, const char *appid)
ctx->appid = NULL;
}

- ctx->appid = strdup(appid);
+ ctx->appid = _strdup(appid);
if (ctx->appid == NULL)
return U2FS_MEMORY_ERROR;

@@ -443,7 +443,7 @@ static int registration_challenge_json(const char *challenge,
json_string = json_object_to_json_string(json_output);
if (json_string == NULL)
rc = U2FS_JSON_ERROR;
- else if ((*output = strdup(json_string)) == NULL)
+ else if ((*output = _strdup(json_string)) == NULL)
rc = U2FS_MEMORY_ERROR;
else
rc = U2FS_OK;
@@ -493,7 +493,7 @@ parse_clientData(const char *clientData, char **challenge, char **origin)
if (p == NULL)
return U2FS_JSON_ERROR;

- *challenge = strdup(p);
+ *challenge = _strdup(p);
if (*challenge == NULL)
return U2FS_MEMORY_ERROR;

@@ -504,7 +504,7 @@ parse_clientData(const char *clientData, char **challenge, char **origin)
if (p == NULL)
return U2FS_JSON_ERROR;

- *origin = strdup(p);
+ *origin = _strdup(p);
if (*origin == NULL)
return U2FS_JSON_ERROR;

@@ -534,7 +534,7 @@ parse_registration_response(const char *response, char **registrationData,
p = json_object_get_string(k);
if (p == NULL)
return U2FS_JSON_ERROR;
- *registrationData = strdup(p);
+ *registrationData = _strdup(p);
if (*registrationData == NULL)
return U2FS_MEMORY_ERROR;

@@ -543,7 +543,7 @@ parse_registration_response(const char *response, char **registrationData,
p = json_object_get_string(k);
if (p == NULL)
return U2FS_JSON_ERROR;
- *clientData = strdup(p);
+ *clientData = _strdup(p);
if (*clientData == NULL)
return U2FS_MEMORY_ERROR;

@@ -736,7 +736,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;
@@ -880,7 +880,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)
@@ -1026,7 +1026,7 @@ static int authentication_challenge_json(const char *challenge,

if (json_string == NULL)
rc = U2FS_JSON_ERROR;
- else if ((*output = strdup(json_string)) == NULL)
+ else if ((*output = _strdup(json_string)) == NULL)
rc = U2FS_MEMORY_ERROR;
else
rc = U2FS_OK;
@@ -1139,7 +1139,7 @@ parse_authentication_response(const char *response, char **signatureData,
p = json_object_get_string(k);
if (p == NULL)
return U2FS_JSON_ERROR;
- *signatureData = strdup(p);
+ *signatureData = _strdup(p);
if (*signatureData == NULL)
return U2FS_MEMORY_ERROR;

@@ -1148,7 +1148,7 @@ parse_authentication_response(const char *response, char **signatureData,
p = json_object_get_string(k);
if (p == NULL)
return U2FS_JSON_ERROR;
- *clientData = strdup(p);
+ *clientData = _strdup(p);
if (*clientData == NULL)
return U2FS_MEMORY_ERROR;

@@ -1157,7 +1157,7 @@ parse_authentication_response(const char *response, char **signatureData,
p = json_object_get_string(k);
if (p == NULL)
return U2FS_JSON_ERROR;
- *keyHandle = strdup(p);
+ *keyHandle = _strdup(p);
if (*keyHandle == NULL)
return U2FS_MEMORY_ERROR;

13 changes: 13 additions & 0 deletions ports/libu2f-server/strncpy-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/u2f-server/core.c b/u2f-server/core.c
index ef657744..d88ebac4 100644
--- a/u2f-server/core.c
+++ b/u2f-server/core.c
@@ -196,7 +196,7 @@ u2fs_rc u2fs_set_challenge(u2fs_ctx_t * ctx, const char *challenge)
if (strlen(challenge) != U2FS_CHALLENGE_B64U_LEN)
return U2FS_CHALLENGE_ERROR;

- strncpy(ctx->challenge, challenge, U2FS_CHALLENGE_B64U_LEN);
+ strncpy_s(ctx->challenge, strlen(ctx->challenge), challenge, U2FS_CHALLENGE_B64U_LEN);

return U2FS_OK;
}
96 changes: 96 additions & 0 deletions ports/libu2f-server/u2f-server-version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* 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.1"

/**
* 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 0x01010100

/**
* 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 1

const char *u2fs_check_version(const char *req_version);

#ifndef TRUE
#define TRUE 1
#endif

#ifndef FALSE
#define FALSE 0
#endif

#ifdef __cplusplus
}
#endif
#endif
Loading