crypto: add Eclipse tinydtls support

This commit is contained in:
raiden00pl 2023-07-26 13:52:41 +02:00 committed by Xiang Xiao
parent 7f3246cfdf
commit 81f9fb5e08
4 changed files with 128 additions and 0 deletions

15
LICENSE
View File

@ -1807,3 +1807,18 @@ apps/testing/crypto/hmac.c
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
apps/crypto/tinydtls
======================
/*******************************************************************************
* Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016 Olaf Bergmann (TZI) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v. 1.0 which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
* Contributors:
* Olaf Bergmann - initial API and implementation
* Hauke Mehrtens - memory optimization, ECC integration
*******************************************************************************/

2
crypto/tinydtls/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/tinydtls
/*.tar.gz

View File

@ -0,0 +1,92 @@
# ##############################################################################
# apps/crypto/tinydtls/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you 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.
#
# ##############################################################################
if(CONFIG_CRYPTO_TINYDTLS)
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/tinydtls)
FetchContent_Declare(
tinydtls
DOWNLOAD_NAME "${CONFIG_TINYDTLS_VERSION}.tar.gz"
DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR}
URL "https://github.com/eclipse/tinydtls/archive/${CONFIG_TINYDTLS_VERSION}.tar.gz"
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/tinydtls
BINARY_DIR
${CMAKE_BINARY_DIR}/apps/crypto/tinydtls/tinydtls
CONFIGURE_COMMAND
""
BUILD_COMMAND
""
INSTALL_COMMAND
""
TEST_COMMAND
""
DOWNLOAD_NO_PROGRESS true
TIMEOUT 30)
FetchContent_GetProperties(tinydtls)
if(NOT tinydtls_POPULATED)
FetchContent_Populate(tinydtls)
endif()
endif()
add_subdirectory(tinydtls)
target_compile_definitions(
tinydtls
PRIVATE HAVE_ARPA_INET_H
HAVE_ASSERT_H
HAVE_FCNTL_H
HAVE_GETRANDOM
HAVE_INTTYPES_H
HAVE_MEMSET
HAVE_NETDB_H
HAVE_NETINET_IN_H
HAVE_RANDOM
HAVE_SELECT
HAVE_SOCKET
HAVE_STDDEF_H
HAVE_STDINT_H
HAVE_STDLIB_H
HAVE_STRDUP
HAVE_STRERROR
HAVE_STRINGS_H
HAVE_STRING_H
HAVE_STRNLEN
HAVE_SYS_SOCKET_H
HAVE_SYS_STAT_H
HAVE_SYS_TIME_H
HAVE_SYS_TYPES_H
HAVE_TIME_H
HAVE_UNISTD_H
HAVE_VPRINTF
HAVE_SNPRINTF)
target_compile_options(tinydtls PRIVATE -Wno-unused -Wno-inline)
# TODO: this should be function in nuttx/cmake/nuttx_add_library.cmake
set_property(GLOBAL APPEND PROPERTY NUTTX_EXTRA_LIBRARIES tinydtls)
nuttx_add_library_internal(tinydtls)
# allow #include "tinydtls/xxx.h"
target_include_directories(tinydtls PUBLIC .)
endif()

19
crypto/tinydtls/Kconfig Normal file
View File

@ -0,0 +1,19 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config CRYPTO_TINYDTLS
bool "Eclipse Tinydtls"
default n
depends on ALLOW_ECLIPSE_COMPONENTS
---help---
Enable Eclipse tinydtls - a minimal library for DTLS.
if CRYPTO_TINYDTLS
config TINYDTLS_VERSION
string "Tinydtls version"
default "ba830a390642d057fcf21bbb6bd57546d12e584c"
endif # CRYPTO_TINYDTLS