This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit 81f9fb5e08e686c0fe7b70c3a283f2ec41be25be
Author: raiden00pl <[email protected]>
AuthorDate: Wed Jul 26 13:52:41 2023 +0200

    crypto: add Eclipse tinydtls support
---
 LICENSE                        | 15 +++++++
 crypto/tinydtls/.gitignore     |  2 +
 crypto/tinydtls/CMakeLists.txt | 92 ++++++++++++++++++++++++++++++++++++++++++
 crypto/tinydtls/Kconfig        | 19 +++++++++
 4 files changed, 128 insertions(+)

diff --git a/LICENSE b/LICENSE
index d024e6793..3ad839e0f 100644
--- a/LICENSE
+++ b/LICENSE
@@ -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
+  
*******************************************************************************/
diff --git a/crypto/tinydtls/.gitignore b/crypto/tinydtls/.gitignore
new file mode 100644
index 000000000..bc1a4e3d2
--- /dev/null
+++ b/crypto/tinydtls/.gitignore
@@ -0,0 +1,2 @@
+/tinydtls
+/*.tar.gz
diff --git a/crypto/tinydtls/CMakeLists.txt b/crypto/tinydtls/CMakeLists.txt
new file mode 100644
index 000000000..129f3750f
--- /dev/null
+++ b/crypto/tinydtls/CMakeLists.txt
@@ -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()
diff --git a/crypto/tinydtls/Kconfig b/crypto/tinydtls/Kconfig
new file mode 100644
index 000000000..509d79631
--- /dev/null
+++ b/crypto/tinydtls/Kconfig
@@ -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

Reply via email to