From 741c17ad1037e2762aa8fafa324c7794b37c0720 Mon Sep 17 00:00:00 2001 From: Dongsun Lee Date: Tue, 5 Sep 2023 16:25:39 +0900 Subject: [PATCH] Add basic files for gbs build --- .gitignore | 10 ++ AUTHORS | 1 + CMakeLists.txt | 89 ++++++++++++ LICENSE | 203 ++++++++++++++++++++++++++++ build/CMakeLists.txt | 25 ++++ build/webauthn-hal.pc | 8 ++ build/webauthn.pc.in | 10 ++ include/CMakeLists.txt | 5 + include/webauthn-hal.h | 36 +++++ include/webauthn.h | 114 ++++++++++++++++ packaging/webauthn-client-devel.manifest.in | 5 + packaging/webauthn-client.manifest.in | 5 + packaging/webauthn-common.manifest.in | 5 + packaging/webauthn-server.manifest.in | 5 + packaging/webauthn-unit-tests.manifest.in | 5 + packaging/webauthn.spec | 174 ++++++++++++++++++++++++ srcs/CMakeLists.txt | 8 ++ srcs/client/CMakeLists.txt | 50 +++++++ srcs/client/client.cpp | 40 ++++++ srcs/common/CMakeLists.txt | 48 +++++++ srcs/common/wauth-error.cpp | 34 +++++ srcs/server/CMakeLists.txt | 40 ++++++ srcs/server/main.cpp | 29 ++++ systemd/CMakeLists.txt | 11 ++ systemd/webauthn.service.in | 18 +++ systemd/webauthn.socket.in | 9 ++ tests/CMakeLists.txt | 37 +++++ tests/main.cpp | 25 ++++ 28 files changed, 1049 insertions(+) create mode 100644 .gitignore create mode 100644 AUTHORS create mode 100644 CMakeLists.txt create mode 100644 LICENSE create mode 100644 build/CMakeLists.txt create mode 100644 build/webauthn-hal.pc create mode 100644 build/webauthn.pc.in create mode 100644 include/CMakeLists.txt create mode 100644 include/webauthn-hal.h create mode 100644 include/webauthn.h create mode 100644 packaging/webauthn-client-devel.manifest.in create mode 100644 packaging/webauthn-client.manifest.in create mode 100644 packaging/webauthn-common.manifest.in create mode 100644 packaging/webauthn-server.manifest.in create mode 100644 packaging/webauthn-unit-tests.manifest.in create mode 100644 packaging/webauthn.spec create mode 100644 srcs/CMakeLists.txt create mode 100644 srcs/client/CMakeLists.txt create mode 100644 srcs/client/client.cpp create mode 100644 srcs/common/CMakeLists.txt create mode 100644 srcs/common/wauth-error.cpp create mode 100644 srcs/server/CMakeLists.txt create mode 100644 srcs/server/main.cpp create mode 100644 systemd/CMakeLists.txt create mode 100644 systemd/webauthn.service.in create mode 100644 systemd/webauthn.socket.in create mode 100644 tests/CMakeLists.txt create mode 100644 tests/main.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..44d6a2d --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +# cscope/ctag data # +#################### +/cscope.files +/cscope.out +/tags + +# Temporary files # +################### +*.swp +*~ diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..ab6e400 --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Dongsun Lee diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..30da874 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,89 @@ +# Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# @file CMakeLists.txt +# + +############################# Check minimum CMake version ##################### + +CMAKE_MINIMUM_REQUIRED(VERSION 3.18) +PROJECT(${SERVICE_NAME}) + +############################# cmake packages ################################## + +INCLUDE(FindPkgConfig) + +############################# compiler flags ################################## + +SET(CMAKE_C_FLAGS_PROFILING "-g -std=c99 -O0 -pg -Wp,-U_FORTIFY_SOURCE") +SET(CMAKE_CXX_FLAGS_PROFILING "-g -std=c++0x -O0 -pg -Wp,-U_FORTIFY_SOURCE") +SET(CMAKE_C_FLAGS_DEBUG "-g -std=c99 -O0 -ggdb -Wp,-U_FORTIFY_SOURCE") +SET(CMAKE_CXX_FLAGS_DEBUG "-g -std=c++0x -O0 -ggdb -Wp,-U_FORTIFY_SOURCE") +SET(CMAKE_C_FLAGS_RELEASE "-g -std=c99 -O2") +SET(CMAKE_CXX_FLAGS_RELEASE "-g -std=c++0x -O2") +SET(CMAKE_C_FLAGS_CCOV "-g -std=c99 -O2 --coverage") +SET(CMAKE_CXX_FLAGS_CCOV "-g -std=c++0x -O2 --coverage") + +# If supported for the target machine, emit position-independent code,suitable +# for dynamic linking and avoiding any limit on the size of the global offset +# table. This option makes a difference on the m68k, PowerPC and SPARC. +# (BJ: our ARM too?) +ADD_DEFINITIONS("-fPIC") + +# Set compiler warning flags +ADD_DEFINITIONS("-Werror") # Make all warnings into errors. +ADD_DEFINITIONS("-Wall") # Generate all warnings +ADD_DEFINITIONS("-Wextra") # Generate even more extra warnings + + +# IF (CMAKE_BUILD_TYPE MATCHES "DEBUG") + ADD_DEFINITIONS("-DTIZEN_DEBUG_ENABLE") + ADD_DEFINITIONS("-DBUILD_TYPE_DEBUG") +# ENDIF (CMAKE_BUILD_TYPE MATCHES "DEBUG") + + +################# common configurations for srcs and test ###################### +PKG_CHECK_MODULES(PROJECT_DEPS + REQUIRED + dlog + libtzplatform-config +) + +############################ Set Common Variables ################################ +SET(PRJ_SRC_PATH ${PROJECT_SOURCE_DIR}/srcs) +SET(PRJ_SRC_CLIENT_PATH ${PRJ_SRC_PATH}/client) +SET(PRJ_SRC_COMMON_PATH ${PRJ_SRC_PATH}/common) +SET(PRJ_SRC_SERVER_PATH ${PRJ_SRC_PATH}/server) +SET(PRJ_INCLUDE_PATH ${PROJECT_SOURCE_DIR}/include) +SET(PRJ_TEST_PATH ${PROJECT_SOURCE_DIR}/tests) + +############################ Target Setting ################################ +SET(TARGET_WEBAUTHN_SERVER "${SERVICE_NAME}-server") +SET(TARGET_WEBAUTHN_CLIENT "${SERVICE_NAME}-client") +SET(TARGET_WEBAUTHN_COMMON "${SERVICE_NAME}-common") +SET(TARGET_WEBAUTHN_UNIT_TESTS "${SERVICE_NAME}-unit-tests") + +############################ Configure manifest files ###################### +CONFIGURE_FILE(packaging/${TARGET_WEBAUTHN_SERVER}.manifest.in ${TARGET_WEBAUTHN_SERVER}.manifest @ONLY) +CONFIGURE_FILE(packaging/${TARGET_WEBAUTHN_CLIENT}.manifest.in ${TARGET_WEBAUTHN_CLIENT}.manifest @ONLY) +CONFIGURE_FILE(packaging/${TARGET_WEBAUTHN_CLIENT}-devel.manifest.in ${TARGET_WEBAUTHN_CLIENT}-devel.manifest @ONLY) +CONFIGURE_FILE(packaging/${TARGET_WEBAUTHN_COMMON}.manifest.in ${TARGET_WEBAUTHN_COMMON}.manifest @ONLY) +CONFIGURE_FILE(packaging/${TARGET_WEBAUTHN_UNIT_TESTS}.manifest.in ${TARGET_WEBAUTHN_UNIT_TESTS}.manifest @ONLY) + +############################ Add Sub Directories ################################ +ADD_SUBDIRECTORY(include) +ADD_SUBDIRECTORY(srcs) +ADD_SUBDIRECTORY(tests) +ADD_SUBDIRECTORY(build) +ADD_SUBDIRECTORY(systemd) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..247c97d --- /dev/null +++ b/LICENSE @@ -0,0 +1,203 @@ +Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt new file mode 100644 index 0000000..8b9053a --- /dev/null +++ b/build/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# @file CMakeLists.txt +# + +CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) + +INSTALL(FILES + ${CMAKE_BINARY_DIR}/build/${PROJECT_NAME}.pc + ${CMAKE_BINARY_DIR}/build/${PROJECT_NAME}-hal.pc + DESTINATION + ${LIB_INSTALL_DIR}/pkgconfig + ) diff --git a/build/webauthn-hal.pc b/build/webauthn-hal.pc new file mode 100644 index 0000000..dc656fe --- /dev/null +++ b/build/webauthn-hal.pc @@ -0,0 +1,8 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +includedir=${prefix}/include + +Name: @PROJECT_NAME@-hal +Description: HAL API for Authenticator +Version: @VERSION@ +Requires: +Cflags: -I${includedir} diff --git a/build/webauthn.pc.in b/build/webauthn.pc.in new file mode 100644 index 0000000..1008c46 --- /dev/null +++ b/build/webauthn.pc.in @@ -0,0 +1,10 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@LIB_INSTALL_DIR@ +includedir=${prefix}/include + +Name: @PROJECT_NAME@ +Description: Web Authentication API +Version: @VERSION@ +Requires: +Libs: -L${libdir} -l@PROJECT_NAME@-client -l@PROJECT_NAME@-common +Cflags: -I${includedir} diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt new file mode 100644 index 0000000..9b11598 --- /dev/null +++ b/include/CMakeLists.txt @@ -0,0 +1,5 @@ +INSTALL(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/webauthn.h + ${CMAKE_CURRENT_SOURCE_DIR}/webauthn-hal.h + DESTINATION ${INCLUDEDIR} + ) diff --git a/include/webauthn-hal.h b/include/webauthn-hal.h new file mode 100644 index 0000000..1aa8be1 --- /dev/null +++ b/include/webauthn-hal.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + * + * @file webauthn-hal.h + * @version 1.0 + * @brief APIs for hardware abrstraction layer of WebAuthn Authenticator. +*/ +#ifndef __WEBAUTHN_HAL__ +#define __WEBAUTHN_HAL__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "webauthn.h" + +int wah_make_credential(const char *param1, char **output1); +int wah_get_assertion(const char *param1, char **output1); + +#ifdef __cplusplus +} +#endif + +#endif /* __WEBAUTHN_HAL__ */ diff --git a/include/webauthn.h b/include/webauthn.h new file mode 100644 index 0000000..495aed2 --- /dev/null +++ b/include/webauthn.h @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + * + * @file webauthn.h + * @version 1.0 + * @brief Public APIs of WebAuthn module. +*/ +#ifndef __WEBAUTHN__ +#define __WEBAUTHN__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + + +/** + * @addtogroup CAPI_WEBAUTHN_MODULE + * @{ + */ + +/** + * @brief WebAuthn Errors. + * @since_tizen 9.0 + */ +typedef enum { + WAU_ERROR_NONE = 0x00, /**< Successful */ + WAU_ERROR_UNKNOWN = -0x01, /**< Unknown error */ + WAU_ERROR_INVALID_PARAMETER = -0x02, /**< Invalid function parameter */ + WAU_ERROR_PERMISSION_DENIED = -0x03, /**< Permission denied */ +} wau_error_e; + +/** + * @brief Returns stringified name of return code. + * + * @since_tizen 9.0 + * + * @param[in] error Item alias to be removed + * + * @return @c stringified name of return code. + */ +const char * wauth_error_to_string(int error); + +/** + * @brief Make a new web authentication credential and store it to authenticator. + * + * @since_tizen 9.0 + * + * @remarks something important to remember + * + * @param[in] param1 Item alias to be removed + * + * @param[out] output1 Output. + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #WAU_ERROR_NONE Successful + * @retval #WAU_ERROR_INVALID_PARAMETER Input parameter is invalid + * @retval #WAU_ERROR_PERMISSION_DENIED Failed to access key manager or the item to remove + * + * @pre Precondition + * + * @see wau_get_assertion() + */ +int wauth_make_credential(const char *param1, char **output1); + +/** + * @brief Get assertion from authenticator + * + * @since_tizen 9.0 + * + * @remarks something important to remember + * + * @param[in] param1 Item alias to be removed + * +* @param[out] output1 Output. + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #WAU_ERROR_NONE Successful + * @retval #WAU_ERROR_INVALID_PARAMETER Input parameter is invalid + * @retval #WAU_ERROR_PERMISSION_DENIED Failed to access key manager or the item to remove + * + * @pre Precondition + * + * @see wau_make_credential() + */ +int wauth_get_assertion(const char *param1, char **output1); + + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __WEBAUTHN__ */ diff --git a/packaging/webauthn-client-devel.manifest.in b/packaging/webauthn-client-devel.manifest.in new file mode 100644 index 0000000..a76fdba --- /dev/null +++ b/packaging/webauthn-client-devel.manifest.in @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/webauthn-client.manifest.in b/packaging/webauthn-client.manifest.in new file mode 100644 index 0000000..a76fdba --- /dev/null +++ b/packaging/webauthn-client.manifest.in @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/webauthn-common.manifest.in b/packaging/webauthn-common.manifest.in new file mode 100644 index 0000000..a76fdba --- /dev/null +++ b/packaging/webauthn-common.manifest.in @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/webauthn-server.manifest.in b/packaging/webauthn-server.manifest.in new file mode 100644 index 0000000..86dbb26 --- /dev/null +++ b/packaging/webauthn-server.manifest.in @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/webauthn-unit-tests.manifest.in b/packaging/webauthn-unit-tests.manifest.in new file mode 100644 index 0000000..86dbb26 --- /dev/null +++ b/packaging/webauthn-unit-tests.manifest.in @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/webauthn.spec b/packaging/webauthn.spec new file mode 100644 index 0000000..1453ef3 --- /dev/null +++ b/packaging/webauthn.spec @@ -0,0 +1,174 @@ +%{!?build_type:%global build_type RELEASE} + +%global version_major 0 +%global version_minor 0 +%global version_patch 1 +%global version_release 1 + +Name: webauthn +Summary: Web Authentication Service +Version: %{version_major}.%{version_minor}.%{version_patch} +Release: %{version_release} +Group: Security/Authentication +License: Apache-2.0 +Source0: %{name}-%{version}.tar.gz + +Requires: lib%{name}-common = %{version}-%{release} +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig + +BuildRequires: cmake +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(libtzplatform-config) + +%description +Web Authentication Service + +%package -n lib%{name}-common +Summary: Web Authentication Service (common libraries) +Group: Security/Libraries +License: Apache-2.0 +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig + +%description -n lib%{name}-common +Web Authentication Service (common libraries) + +%package -n lib%{name}-client +Summary: Web Authentication Service (client) +Group: Security/Libraries +License: Apache-2.0 +Requires: %{name} = %{version}-%{release} +Requires: lib%{name}-common = %{version}-%{release} +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig + +%description -n lib%{name}-client +Web Authentication Service (client) + +%package -n lib%{name}-client-devel +Summary: Web Authentication Service (development files) +License: Apache-2.0 +Group: Security/Development +Requires: %{name} = %{version}-%{release} + +%description -n lib%{name}-client-devel +Web Authentication Service (development files) + +%package -n %{name}-hal-devel +Summary: HAL API of Web Authentication Service (development files) +License: Apache-2.0 +Group: Security/Development + +%description -n %{name}-hal-devel +HAL API of Web Authentication Service (development files) + +%package unit-test +Summary: Web Authentication Service (unit test) +License: Apache-2.0 +Group: Security/Development +BuildRequires: gtest +Requires: %{name} = %{version}-%{release} + +%description unit-test +Web Authentication Service (unit test) + +%define user_name security_fw +%define group_name security_fw +%define smack_domain System +%define bin_dir %TZ_SYS_BIN +%define rw_share_dir %TZ_SYS_SHARE +%define service_name %{name} + +%global rw_data_dir /opt/data/ +%global bin_dir %{?TZ_SYS_BIN:%TZ_SYS_BIN}%{!?TZ_SYS_BIN:%_bindir} +%global ro_etc_dir %{?TZ_SYS_RO_ETC:%TZ_SYS_RO_ETC}%{!?TZ_SYS_RO_ETC:/etc} +%global run_dir %{?TZ_SYS_RUN:%TZ_SYS_RUN}%{!?TZ_SYS_RUN:/var/run} + +%prep +%setup -q + +%build +%cmake . -DPREFIX=%{_prefix} \ + -DEXEC_PREFIX=%{_exec_prefix} \ + -DINCLUDEDIR=%{_includedir} \ + -DLIBDIR=%{_libdir} \ + -DSYSTEMD_UNIT_DIR=%{_unitdir} \ + -DSYSTEMD_ENV_FILE=%{ro_etc_dir}"/sysconfig/central-key-manager" \ + -DCMAKE_BUILD_TYPE=%{build_type} \ + -DRW_SHARE_DIR=%rw_share_dir \ + -DUSER_NAME=%user_name \ + -DGROUP_NAME=%group_name \ + -DSMACK_DOMAIN=%smack_domain \ + -DSERVICE_NAME=%service_name \ + -DBINDIR=%bin_dir \ + -DVERSION_MAJOR=%version_major \ + -DVERSION_MINOR=%version_minor \ + -DVERSION_PATCH=%version_patch +make %{?jobs:-j%jobs} + +%install +%make_install +%install_service multi-user.target.wants %{name}.service +%install_service sockets.target.wants %{name}.socket + +%post +/sbin/ldconfig +systemctl daemon-reload +if [ $1 = 1 ]; then + # installation + systemctl start %{name}.service +fi + +if [ $1 = 2 ]; then + # update + systemctl restart %{name}.service +fi + +%postun +/sbin/ldconfig +if [ $1 = 0 ]; then + # uninstall + systemctl daemon-reload +fi + +%post -n lib%{name}-common -p /sbin/ldconfig +%post -n lib%{name}-client -p /sbin/ldconfig +%postun -n lib%{name}-common -p /sbin/ldconfig +%postun -n lib%{name}-client -p /sbin/ldconfig + +%files +%manifest %{name}-server.manifest +%license LICENSE +%{bin_dir}/%{name}-server +%{_unitdir}/multi-user.target.wants/%{name}.service +%{_unitdir}/%{name}.service +%{_unitdir}/sockets.target.wants/%{name}.socket +%{_unitdir}/%{name}.socket + +%files -n lib%{name}-common +#%manifest %{_datadir}/%{name}-common.manifest +%license LICENSE +%{_libdir}/lib%{name}-common.so.* + +%files -n lib%{name}-client +#%manifest %{_datadir}/%{name}-client.manifest +%license LICENSE +%{_libdir}/lib%{name}-client.so.* + +%files -n lib%{name}-client-devel +#%manifest %{_datadir}/%{name}-client-devel.manifest +%license LICENSE +%{_includedir}/webauthn.h +%{_libdir}/pkgconfig/%{name}.pc +%{_libdir}/lib*.so + +%files -n %{name}-hal-devel +%license LICENSE +%{_includedir}/webauthn*.h +%{_libdir}/pkgconfig/%{name}-hal.pc + +%files -n %{name}-unit-test +#%manifest %{name}-unit-test.manifest +%license LICENSE +%{bin_dir}/%{name}-unit-tests diff --git a/srcs/CMakeLists.txt b/srcs/CMakeLists.txt new file mode 100644 index 0000000..ce1ed7e --- /dev/null +++ b/srcs/CMakeLists.txt @@ -0,0 +1,8 @@ + +############################ Set common variables ################################ +SET(SRC_COMMON_PATH ${PROJECT_SOURCE_DIR}/srcs/common) + +############################ Add Sub Directories ################################ +ADD_SUBDIRECTORY(client) +ADD_SUBDIRECTORY(common) +ADD_SUBDIRECTORY(server) diff --git a/srcs/client/CMakeLists.txt b/srcs/client/CMakeLists.txt new file mode 100644 index 0000000..340b67b --- /dev/null +++ b/srcs/client/CMakeLists.txt @@ -0,0 +1,50 @@ +PKG_CHECK_MODULES(CLIENT_DEPS + REQUIRED + dlog + ) + + +SET(CLIENT_VERSION_MAJOR ${VERSION_MAJOR}) +SET(CLIENT_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) + +SET(CLIENT_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/client.cpp +) + +SET_SOURCE_FILES_PROPERTIES( + ${CLIENT_SOURCES} + PROPERTIES + COMPILE_FLAGS "-D_GNU_SOURCE -fvisibility=hidden") + +INCLUDE_DIRECTORIES(SYSTEM + ${WEBATUHN_DEPS_INCLUDE_DIRS} + ${CLIENT_DEPS_INCLUDE_DIRS} + ) + +INCLUDE_DIRECTORIES( + ${PRJ_INCLUDE_PATH} + ${SRC_COMMON_PATH} + ) + +LINK_DIRECTORIES( + ${PROJECT_DEPS_LIBRARY_DIRS} + ${CLIENT_DEPS_LIBRARY_DIRS} + ) + +ADD_LIBRARY(${TARGET_WEBAUTHN_CLIENT} SHARED ${CLIENT_SOURCES}) + +SET_TARGET_PROPERTIES( + ${TARGET_WEBAUTHN_CLIENT} + PROPERTIES + COMPILE_FLAGS "-D_GNU_SOURCE -fvisibility=hidden -Wno-deprecated-declarations" + SOVERSION ${CLIENT_VERSION_MAJOR} + VERSION ${CLIENT_VERSION} + ) + +TARGET_LINK_LIBRARIES(${TARGET_WEBAUTHN_CLIENT} + ${PROJECT_DEPS_LIBRARIES} + ${CLIENT_DEPS_LIBRARIES} + ${TARGET_WEBAUTHN_COMMON} + ) + +INSTALL(TARGETS ${TARGET_WEBAUTHN_CLIENT} DESTINATION ${LIB_INSTALL_DIR}) diff --git a/srcs/client/client.cpp b/srcs/client/client.cpp new file mode 100644 index 0000000..9aafdea --- /dev/null +++ b/srcs/client/client.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + * + * + * @file client.cpp + * @version 1.0 + * @brief Wrap C++ functions to provide C APIs + */ + +#include + +#define WEBAUTHN_CAPI __attribute__((visibility("default"))) + +WEBAUTHN_CAPI +int wau_make_credential(const char *param1, char **output1) +{ + (void) param1; + (void) output1; + return WAU_ERROR_NONE; +} + +WEBAUTHN_CAPI +int wau_get_assertion(const char *param1, char **output1) +{ + (void) param1; + (void) output1; + return WAU_ERROR_NONE; +} diff --git a/srcs/common/CMakeLists.txt b/srcs/common/CMakeLists.txt new file mode 100644 index 0000000..c96d3a4 --- /dev/null +++ b/srcs/common/CMakeLists.txt @@ -0,0 +1,48 @@ +PKG_CHECK_MODULES(COMMON_DEPS + REQUIRED + dlog + ) + + +SET(COMMON_VERSION_MAJOR ${VERSION_MAJOR}) +SET(COMMON_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) + +SET(COMMON_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/wauth-error.cpp +) + +SET_SOURCE_FILES_PROPERTIES( + ${COMMON_SOURCES} + PROPERTIES + COMPILE_FLAGS "-D_GNU_SOURCE -fvisibility=hidden") + +INCLUDE_DIRECTORIES(SYSTEM + ${WEBATUHN_DEPS_INCLUDE_DIRS} + ${COMMON_DEPS_INCLUDE_DIRS} + ) + +INCLUDE_DIRECTORIES( + ${PRJ_INCLUDE_PATH} + ) + +LINK_DIRECTORIES( + ${PROJECT_DEPS_LIBRARY_DIRS} + ${COMMON_DEPS_LIBRARY_DIRS} + ) + +ADD_LIBRARY(${TARGET_WEBAUTHN_COMMON} SHARED ${COMMON_SOURCES}) + +SET_TARGET_PROPERTIES( + ${TARGET_WEBAUTHN_COMMON} + PROPERTIES + COMPILE_FLAGS "-D_GNU_SOURCE -fvisibility=hidden -Wno-deprecated-declarations" + SOVERSION ${COMMON_VERSION_MAJOR} + VERSION ${COMMON_VERSION} + ) + +TARGET_LINK_LIBRARIES(${TARGET_WEBAUTHN_COMMON} + ${PROJECT_DEPS_LIBRARIES} + ${COMMON_DEPS_LIBRARIES} + ) + +INSTALL(TARGETS ${TARGET_WEBAUTHN_COMMON} DESTINATION ${LIB_INSTALL_DIR}) diff --git a/srcs/common/wauth-error.cpp b/srcs/common/wauth-error.cpp new file mode 100644 index 0000000..c963f40 --- /dev/null +++ b/srcs/common/wauth-error.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ +/* + * @file ckm-error.cpp + * @author Tomasz Swierczek (t.swierczek@samsung.com) + * @version 1.0 + */ + +#include + + +#define WAU_CODE_DESCRIBE(name) case name: return #name + +const char * wauth_error_to_string(int error) { + switch (error) { + WAU_CODE_DESCRIBE(WAU_ERROR_NONE); + WAU_CODE_DESCRIBE(WAU_ERROR_UNKNOWN); + WAU_CODE_DESCRIBE(WAU_ERROR_INVALID_PARAMETER); + default: return "Code not defined"; + } +} diff --git a/srcs/server/CMakeLists.txt b/srcs/server/CMakeLists.txt new file mode 100644 index 0000000..6b8d35b --- /dev/null +++ b/srcs/server/CMakeLists.txt @@ -0,0 +1,40 @@ +PKG_CHECK_MODULES(SERVER_DEPS + REQUIRED + dlog + ) + +SET(SERVER_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp +) + +SET_SOURCE_FILES_PROPERTIES( + ${SERVER_SOURCES} + PROPERTIES + COMPILE_FLAGS "-D_GNU_SOURCE -fvisibility=hidden") + +INCLUDE_DIRECTORIES(SYSTEM + ${PROJECT_DEPS_INCLUDE_DIRS} + ${SERVER_DEPS_INCLUDE_DIRS} + ) + +INCLUDE_DIRECTORIES( + ${PRJ_INCLUDE_PATH} + ${SRC_COMMON_PATH} + ) + +LINK_DIRECTORIES( + ${PROJECT_DEPS_LIBRARY_DIRS} + ${SERVER_DEPS_LIBRARY_DIRS} + ) + +ADD_EXECUTABLE(${TARGET_WEBAUTHN_SERVER} ${SERVER_SOURCES}) + +TARGET_LINK_LIBRARIES(${TARGET_WEBAUTHN_SERVER} + ${CMAKE_THREAD_LIBS_INIT} + ${PROJECT_DEPS_LIBRARIES} + ${SERVER_DEPS_LIBRARIES} + ${TARGET_WEBAUTHN_COMMON} + -ldl + ) + +INSTALL(TARGETS ${TARGET_WEBAUTHN_SERVER} DESTINATION ${BIN_DIR}) diff --git a/srcs/server/main.cpp b/srcs/server/main.cpp new file mode 100644 index 0000000..d38317d --- /dev/null +++ b/srcs/server/main.cpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + * + * + * @file main.cpp + * @version 1.0 + * @brief Implementation of webauthn + */ + +namespace { + +} // anonymous namespace + +int main(void) +{ + return 0; +} \ No newline at end of file diff --git a/systemd/CMakeLists.txt b/systemd/CMakeLists.txt new file mode 100644 index 0000000..03c0d70 --- /dev/null +++ b/systemd/CMakeLists.txt @@ -0,0 +1,11 @@ +CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/systemd/${SERVICE_NAME}.service.in + ${CMAKE_SOURCE_DIR}/systemd/${SERVICE_NAME}.service @ONLY) +CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/systemd/${SERVICE_NAME}.socket.in + ${CMAKE_SOURCE_DIR}/systemd/${SERVICE_NAME}.socket @ONLY) + +INSTALL(FILES + ${CMAKE_SOURCE_DIR}/systemd/${SERVICE_NAME}.service + ${CMAKE_SOURCE_DIR}/systemd/${SERVICE_NAME}.socket + DESTINATION + ${SYSTEMD_UNIT_DIR} +) diff --git a/systemd/webauthn.service.in b/systemd/webauthn.service.in new file mode 100644 index 0000000..851e730 --- /dev/null +++ b/systemd/webauthn.service.in @@ -0,0 +1,18 @@ +[Unit] +Description=Start WebAuthn Service +DefaultDependencies=no +RequiresMountsFor=/opt +Requires=webauthn.socket + +[Service] +User=@USER_NAME@ +Group=@GROUP_NAME@ +SmackProcessLabel=@SMACK_DOMAIN_NAME@ +Type=notify +ExecStart=@BIN_DIR@/@SERVICE_FILE@ +EnvironmentFile=-@SYSTEMD_ENV_FILE@ +RuntimeDirectory=@SERVICE_NAME@ +@WATCHDOG_DECLARE@ + +[Install] +WantedBy=multi-user.target diff --git a/systemd/webauthn.socket.in b/systemd/webauthn.socket.in new file mode 100644 index 0000000..a6f5d46 --- /dev/null +++ b/systemd/webauthn.socket.in @@ -0,0 +1,9 @@ +[Socket] +ListenStream=/tmp/.@SERVICE_NAME@.sock +SocketMode=0777 +SmackLabelIPIn=* +SmackLabelIPOut=@ +Service=@SERVICE_NAME@.service + +[Install] +WantedBy=sockets.target diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..3b3bb96 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,37 @@ +PKG_CHECK_MODULES(UNIT_TESTS_DEPS + REQUIRED + dlog + ) + +SET(UNIT_TESTS_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp +) + +SET_SOURCE_FILES_PROPERTIES( + ${UNIT_TESTS_SOURCES} + PROPERTIES + COMPILE_FLAGS "-D_GNU_SOURCE -fvisibility=hidden") + +INCLUDE_DIRECTORIES(SYSTEM + ${WEBATUHN_DEPS_INCLUDE_DIRS} + ${UNIT_TESTS_DEPS_INCLUDE_DIRS} + ) + +INCLUDE_DIRECTORIES( + ${PRJ_SRC_CLIENT_PATH} + ${PRJ_SRC_COMMON_PATH} + ${PRJ_SRC_SERVER_PATH} + ) + +LINK_DIRECTORIES(${UNIT_TESTS_DEPS_LIBRARY_DIRS}) + +ADD_EXECUTABLE(${TARGET_WEBAUTHN_UNIT_TESTS} ${UNIT_TESTS_SOURCES}) + +TARGET_LINK_LIBRARIES(${TARGET_WEBAUTHN_UNIT_TESTS} + ${CMAKE_THREAD_LIBS_INIT} + ${UNIT_TESTS_DEPS_LIBRARIES} + ${TARGET_WEBAUTHN_COMMON} + -ldl + ) + +INSTALL(TARGETS ${TARGET_WEBAUTHN_UNIT_TESTS} DESTINATION ${BIN_DIR}) diff --git a/tests/main.cpp b/tests/main.cpp new file mode 100644 index 0000000..06a3173 --- /dev/null +++ b/tests/main.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + * + * + * @file main.cpp + * @version 1.0 + * @brief unit tests for webauthn + */ + +int main(void) +{ + return 0; +} -- 2.7.4