Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
Resolved conflicts:

* dtls.c: Copyright year
* tests/dtls-client.c: fall-through for DTLS_PSK_HINT instead of
  return 0

Change-Id: Icb9fa31d3b4c8cd43a867cab2862ba026b6f4617
  • Loading branch information
obgm committed May 25, 2022
2 parents 7068882 + 2546738 commit 4cd793b
Show file tree
Hide file tree
Showing 76 changed files with 4,566 additions and 1,566 deletions.
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ core
*.cap
*.pcap
Makefile
aclocal.m4
ar-lib
autom4te.cache/
config.h
config.log
Expand All @@ -13,13 +15,15 @@ configure
doc/Doxyfile
doc/doxygen.out
doc/html/
install-sh
libtinydtls.a
libtinydtls.so
tests/ccm-test
tests/dtls-client
tests/dtls-server
tests/prf-test
tinydtls-0.6.0
./tinydtls-0.6.0/
tinydtls.pc
TAGS
*.patch
.gitignore
Expand Down Expand Up @@ -62,3 +66,7 @@ dtls_config.h
*.z1
*.z1sp
.project
# cmake
CMakeCache.txt
cmake_install.cmake
CMakeFiles
84 changes: 84 additions & 0 deletions AutoConf.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
###############################################################################
#
# Copyright (c) 2022 Contributors to the Eclipse Foundation
#
# See the LICENSE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0
# which is available at http://www.eclipse.org/legal/epl-2.0
# and the Eclipse Distribution License v. 1.0
# available at http://www.eclipse.org/org/documents/edl-v10.php
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Jimmy Björklund - initial version
# Achim Kraus - add getrandom and libcunit
# additional minor fixes
#
###############################################################################

include(CheckIncludeFile)
include(CheckFunctionExists)
include(CheckLibraryExists)
include(TestBigEndian)
include(CheckCSourceCompiles)
include(CheckStructHasMember)

check_include_file(assert.h HAVE_ASSERT_H)
check_include_file(arpa/inet.h HAVE_ARPA_INET_H)
check_include_file(fcntl.h HAVE_FCNTL_H)
check_include_file(inttypes.h HAVE_INTTYPES_H)
check_include_file(memory.h HAVE_MEMORY_H)
check_include_file(netdb.h HAVE_NETDB_H)
check_include_file(netinet/in.h HAVE_NETINET_IN_H)
check_include_file(stddef.h HAVE_STDDEF_H)
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(stdlib.h HAVE_STDLIB_H)
check_include_file(string.h HAVE_STRING_H)
check_include_file(strings.h HAVE_STRINGS_H)
check_include_file(time.h HAVE_TIME_H)
check_include_file(sys/param.h HAVE_SYS_PARAM_H)
check_include_file(sys/socket.h HAVE_SYS_SOCKET_H)
check_include_file(sys/stat.h HAVE_SYS_STAT_H)
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(float.h HAVE_FLOAT_H)
check_include_file(dlfcn.h HAVE_DLFCN_H)

check_function_exists (memset HAVE_MEMSET)
check_function_exists (select HAVE_SELECT)
check_function_exists (socket HAVE_SOCKET)
check_function_exists (strdup HAVE_STRDUP)
check_function_exists (strerror HAVE_STRERROR)
check_function_exists (strnlen HAVE_STRNLEN)
check_function_exists (fls HAVE_FLS)
check_function_exists (vprintf HAVE_VPRINTF)
check_function_exists (getrandom HAVE_GETRANDOM)

if( ${make_tests} )
if(BUILD_SHARED_LIBS)
check_library_exists (libcunit.so CU_initialize_registry "" HAVE_LIBCUNIT)
else()
# this link options only intended to be used for the cunit tests
set(CMAKE_REQUIRED_LINK_OPTIONS -no-pie)
check_library_exists (libcunit.a CU_initialize_registry "" HAVE_LIBCUNIT)
endif()
endif()

if( "${HAVE_STRING_H}" AND "${HAVE_STRINGS_H}" AND
"${HAVE_FLOAT_H}" AND "${HAVE_STDLIB_H}" AND
"${HAVE_STDDEF_H}" AND "${HAVE_STDINT_H}" AND
"${HAVE_INTTYPES_H}" AND "${HAVE_DLFCN_H}" )
set( STDC_HEADERS 1)
endif()

check_struct_has_member ("struct sockaddr_in6" sin6_len "netinet/in.h" HAVE_SOCKADDR_IN6_SIN6_LEN)

TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
if(IS_BIG_ENDIAN)
set(WORDS_BIGENDIAN 1)
endif()
77 changes: 77 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
###############################################################################
#
# Copyright (c) 2022 Contributors to the Eclipse Foundation
#
# See the LICENSE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0
# which is available at http://www.eclipse.org/legal/epl-2.0
# and the Eclipse Distribution License v. 1.0
# available at http://www.eclipse.org/org/documents/edl-v10.php
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Jimmy Björklund - initial version
# Achim Kraus - minor fixes
#
###############################################################################

cmake_minimum_required(VERSION 3.5)

project(tinydtls)

include (AutoConf.cmake)

option(BUILD_SHARED_LIBS "Link using shared libs" OFF)
option(make_tests "Make test programs and examples" OFF)

if(NOT PLATFORM)
set(PLATFORM "posix" CACHE STRING "Choose platform." FORCE)
set_property(CACHE PLATFORM PROPERTY STRINGS "contiki" "espidf" "posix" "riot")
endif()

set(PACKAGE_NAME "tinydtls")
set(PACKAGE_VERSION "0.8.6" )
set(SOVERSION "0" )

option(DTLS_ECC "disable/enable support for TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8" ON )
option(DTLS_PSK "disable/enable support for TLS_PSK_WITH_AES_128_CCM_8" ON)

configure_file(dtls_config.h.cmake.in dtls_config.h )

add_library(tinydtls)

target_sources(tinydtls PRIVATE
dtls.c
netq.c
peer.c
session.c
crypto.c
ccm.c
hmac.c
dtls_time.c
dtls_debug.c
dtls_prng.c
aes/rijndael.c
aes/rijndael_wrap.c
sha2/sha2.c
ecc/ecc.c)

target_include_directories(tinydtls PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
target_compile_definitions(tinydtls PUBLIC DTLSv12 WITH_SHA256 SHA2_USE_INTTYPES_H DTLS_CHECK_CONTENTTYPE)
target_compile_options(tinydtls PRIVATE -fPIC -pedantic -std=c99 -Wall -Wextra -Wformat-security -Winline -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wshadow -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wunused)

set_target_properties(tinydtls PROPERTIES VERSION ${PACKAGE_VERSION} SOVERSION ${SOVERSION})

if( ${make_tests} )
add_subdirectory(tests)
endif()

if(BUILD_SHARED_LIBS)
install(TARGETS tinydtls LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
else()
install(TARGETS tinydtls DESTINATION ${CMAKE_INSTALL_LIBDIR} )
endif()
70 changes: 48 additions & 22 deletions Makefile.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Makefile for tinydtls
#
#
# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016 Olaf Bergmann (TZI) and others.
# Copyright (c) 2011-2021 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.
Expand All @@ -12,6 +12,7 @@
#
# Contributors:
# Olaf Bergmann - initial API and implementation
# Hugo Damer - support for pkg-config
#

# the library's version
Expand All @@ -36,39 +37,48 @@ includedir = @includedir@/@PACKAGE_NAME@
package = @PACKAGE_TARNAME@-@PACKAGE_VERSION@

install := cp
RMDIR?=rmdir

# files and flags
SOURCES:= dtls.c crypto.c ccm.c hmac.c netq.c peer.c dtls_time.c session.c dtls_debug.c
SUB_OBJECTS:=aes/rijndael.o @OPT_OBJS@
SOURCES:= dtls.c crypto.c ccm.c hmac.c netq.c peer.c dtls_time.c session.c dtls_debug.c dtls_prng.c
SUB_OBJECTS:=aes/rijndael.o aes/rijndael_wrap.o @OPT_OBJS@
OBJECTS:= $(patsubst %.c, %.o, $(SOURCES)) $(SUB_OBJECTS)
HEADERS:=dtls.h hmac.h dtls_debug.h dtls_config.h uthash.h numeric.h crypto.h global.h ccm.h \
netq.h alert.h utlist.h prng.h peer.h state.h dtls_time.h session.h \
tinydtls.h
CFLAGS:=-Wall -pedantic -std=c99 @CFLAGS@ @WARNING_CFLAGS@
netq.h alert.h utlist.h dtls_prng.h peer.h state.h dtls_time.h session.h \
tinydtls.h dtls_mutex.h
PKG_CONFIG_FILES:=tinydtls.pc
CFLAGS:=-Wall -pedantic -std=c99 -DSHA2_USE_INTTYPES_H @CFLAGS@ @WARNING_CFLAGS@
CPPFLAGS:=@CPPFLAGS@ -DDTLS_CHECK_CONTENTTYPE -I$(top_srcdir)
SUBDIRS:=tests doc platform-specific sha2 aes ecc
SUBDIRS:=tests tests/unit-tests doc platform-specific sha2 aes ecc
DISTSUBDIRS:=$(SUBDIRS)
DISTDIR=$(top_builddir)/$(package)
FILES:=Makefile.in configure configure.in dtls_config.h.in tinydtls.h.in \
FILES:=Makefile.in configure configure.ac dtls_config.h.in \
Makefile.tinydtls $(SOURCES) $(HEADERS)
LIB:=libtinydtls.a
LDFLAGS:=@LIBS@
LIB:=libtinydtls
LIBS:=$(LIB).a
ifeq ("@ENABLE_SHARED@", "1")
LIBS:=$(LIBS) $(LIB).so
endif
LDFLAGS:=@LDFLAGS@ @LIBS@
ARFLAGS:=cru
doc:=doc

.PHONY: all dirs clean install dist distclean .gitignore doc TAGS
.PHONY: all dirs clean install dist distclean .gitignore doc TAGS uninstall

ifneq ("@WITH_CONTIKI@", "1")
.SUFFIXES:
.SUFFIXES: .c .o

all: $(LIB) dirs
all: $(LIBS) dirs

check:
check: tests
echo DISTDIR: $(DISTDIR)
echo top_builddir: $(top_builddir)
$(MAKE) -C tests check

tests: $(LIBS)
$(MAKE) -C tests

dirs: $(SUBDIRS)
for dir in $^; do \
$(MAKE) -C $$dir ; \
Expand All @@ -77,12 +87,15 @@ dirs: $(SUBDIRS)
$(SUB_OBJECTS)::
$(MAKE) -C $(@D) $(@F)

$(LIB): $(OBJECTS)
$(LIB).so: $(OBJECTS)
$(LINK.c) $(LDFLAGS) -shared $^ -o $@

$(LIB).a: $(OBJECTS)
$(AR) $(ARFLAGS) $@ $^
$(RANLIB) $@

clean:
@rm -f $(PROGRAM) main.o $(LIB) $(OBJECTS)
@rm -f $(PROGRAM) main.o $(LIBS) $(OBJECTS)
for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir clean ; \
done
Expand All @@ -103,15 +116,28 @@ dist: $(FILES) $(DISTSUBDIRS)
done
tar czf $(package).tar.gz $(DISTDIR)

install: $(LIB) $(HEADERS) $(SUBDIRS)
test -d $(libdir) || mkdir -p $(libdir)
test -d $(includedir) || mkdir -p $(includedir)
$(install) $(LIB) $(libdir)/
$(install) $(HEADERS) $(includedir)/
install: $(LIBS) $(HEADERS) $(SUBDIRS)
test -d $(DESTDIR)$(libdir)/pkgconfig/ || mkdir -p $(DESTDIR)$(libdir)/pkgconfig
test -d $(DESTDIR)$(includedir) || mkdir -p $(DESTDIR)$(includedir)
$(install) $(LIBS) $(DESTDIR)$(libdir)/
$(install) $(HEADERS) $(DESTDIR)$(includedir)/
$(install) $(PKG_CONFIG_FILES) $(DESTDIR)$(libdir)/pkgconfig/
for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir install="$(install)" includedir=$(includedir) install; \
done

uninstall:
for file in $(LIBS); do \
if test -f $(DESTDIR)$(libdir)/$$file ; then $(RM) $(DESTDIR)$(libdir)/$$file ; fi ;\
done
for file in $(HEADERS); do \
if test -f $(DESTDIR)$(includedir)/$$file ; then $(RM) $(DESTDIR)$(includedir)/$$file ; fi ;\
done
for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir install="$(install)" includedir=$(includedir) RMDIR=$(RMDIR) uninstall; \
done
if test -d $(DESTDIR)$(includedir) ; then $(RMDIR) $(DESTDIR)$(includedir) ; fi

TAGS:
$(ETAGS) -o $@.new $(SOURCES)
$(ETAGS) -a -o $@.new $(HEADERS)
Expand All @@ -120,8 +146,8 @@ TAGS:
# files that should be ignored by git
GITIGNOREDS:= core \*~ \*.[oa] \*.gz \*.cap \*.pcap Makefile \
autom4te.cache/ config.h config.log config.status configure \
doc/Doxyfile doc/doxygen.out doc/html/ $(LIB) tests/ccm-test \
tests/dtls-client tests/dtls-server tests/prf-test $(package) \
doc/Doxyfile doc/doxygen.out doc/html/ $(LIBS) tests/ccm-test \
tests/dtls-client tests/dtls-server $(package) \
$(DISTDIR)/ TAGS \*.patch .gitignore ecc/testecc ecc/testfield \
\*.d \*.hex \*.elf \*.map obj_\* tinydtls.h dtls_config.h \
$(addprefix \*., $(notdir $(wildcard ../../platform/*))) \
Expand Down
7 changes: 7 additions & 0 deletions Makefile.riot
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MODULE = tinydtls

CFLAGS += -DDTLSv12 -DWITH_SHA256

SRC := ccm.c crypto.c dtls.c dtls_debug.c dtls_time.c hmac.c netq.c peer.c session.c dtls_prng.c

include $(RIOTBASE)/Makefile.base
2 changes: 1 addition & 1 deletion Makefile.tinydtls
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This is a -*- Makefile -*-

CFLAGS += -DDTLSv12 -DWITH_SHA256
tinydtls_src = dtls.c crypto.c hmac.c rijndael.c sha2.c ccm.c netq.c ecc.c dtls_time.c peer.c session.c
tinydtls_src = dtls.c crypto.c hmac.c rijndael.c rijndael_wrap.c sha2.c ccm.c netq.c ecc.c dtls_time.c peer.c session.c dtls_prng.c

# This activates debugging support
# CFLAGS += -DNDEBUG
Expand Down
30 changes: 0 additions & 30 deletions README

This file was deleted.

Loading

0 comments on commit 4cd793b

Please sign in to comment.