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

Support for micro-ecc (WIP, Quick-Fixes) #229

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
CC: ["gcc", "clang" ]
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: setup
run: |
sudo apt-get update && sudo apt-get install -y libcunit1-dev libtool libtool-bin exuberant-ctags valgrind
Expand All @@ -48,6 +50,8 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Build tinydtls
run: |
cmake -E make_directory build_test
Expand All @@ -60,6 +64,8 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Build tinydtls
run: |
cmake -E make_directory build_test
Expand All @@ -73,6 +79,8 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Build tinydtls
run: |
cmake -E make_directory build_test
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "ext/micro-ecc"]
path = ext/micro-ecc
url = https://github.com/kmackay/micro-ecc.git
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ target_sources(tinydtls PRIVATE
aes/rijndael.c
aes/rijndael_wrap.c
sha2/sha2.c
ecc/ecc.c)
ext/micro-ecc/uECC.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)

set_source_files_properties(ext/micro-ecc/uECC.c PROPERTIES COMPILE_OPTIONS "-Wno-pedantic;-Wno-unused-parameter;-Wno-missing-prototypes;-Wno-missing-declarations;-Wno-unknown-pragmas")

if(CMAKE_GENERATOR MATCHES "Visual Studio")
option(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS "Export all symbols when compiling to a .dll" ON)
target_compile_options(tinydtls PRIVATE -Wall)
Expand Down
14 changes: 8 additions & 6 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@ HEADERS:=dtls.h hmac.h dtls_debug.h dtls_config.h uthash.h numeric.h crypto.h gl
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
__micro_ecc_path:=ext/micro-ecc
MICRO_ECC_FILES:=$(addprefix $(__micro_ecc_path)/, uECC.h uECC.c uECC_vli.h types.h) $(wildcard $(__micro_ecc_path)/*.inc)
CFLAGS:=-Wall -pedantic -std=c99 -DSHA2_USE_INTTYPES_H @CFLAGS@ \
@WARNING_CFLAGS@ $(EXTRA_CFLAGS)
CPPFLAGS:=@CPPFLAGS@ -DDTLS_CHECK_CONTENTTYPE -I$(top_srcdir)
SUBDIRS:=tests tests/unit-tests doc platform-specific sha2 aes ecc
SUBDIRS:=tests tests/unit-tests doc platform-specific sha2 aes
DISTSUBDIRS:=$(SUBDIRS)
DISTDIR=$(top_builddir)/$(package)
FILES:=Makefile.in configure configure.ac dtls_config.h.in \
Makefile.tinydtls $(SOURCES) $(HEADERS)
Makefile.tinydtls tinydtls.pc.in ar-lib $(SOURCES) $(HEADERS) $(MICRO_ECC_FILES)
LIB:=libtinydtls
LIBS:=$(LIB).a
ifeq ("@ENABLE_SHARED@", "1")
Expand Down Expand Up @@ -87,9 +89,6 @@ dirs: $(SUBDIRS)

dtls_prng.o:: $(wildcard platform-specific/dtls_prng_*.c)

$(SUB_OBJECTS)::
$(MAKE) -C $(@D) $(@F)

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

Expand All @@ -104,6 +103,9 @@ clean:
done
endif # WITH_CONTIKI

# Override several warnings for uECC.o
ext/micro-ecc/uECC.o:: CFLAGS+=-Wno-pedantic -Wno-unused-parameter -Wno-missing-prototypes -Wno-missing-declarations

doc:
$(MAKE) -C doc

Expand All @@ -113,7 +115,7 @@ distclean: clean

dist: $(FILES) $(DISTSUBDIRS)
test -d $(DISTDIR) || mkdir $(DISTDIR)
cp $(FILES) $(DISTDIR)
cp --parents $(FILES) $(DISTDIR)
for dir in $(DISTSUBDIRS); do \
$(MAKE) -C $$dir dist; \
done
Expand Down
19 changes: 15 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ AC_ARG_WITH(ecc,
[AS_HELP_STRING([--without-ecc],[disable support for TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8])],
[],
[AC_DEFINE(DTLS_ECC, 1, [Define to 1 if building with ECC support.])
OPT_OBJS="${OPT_OBJS} ecc/ecc.o"
OPT_OBJS="${OPT_OBJS} ext/micro-ecc/uECC.o"
dnl remove all ECC except for secp256r1
AC_DEFINE([uECC_SUPPORTS_secp160r1], [0], [Define to 1 if building with uECC curve secp160r1])
AC_DEFINE([uECC_SUPPORTS_secp192r1], [0], [Define to 1 if building with uECC curve secp192r1])
AC_DEFINE([uECC_SUPPORTS_secp224r1], [0], [Define to 1 if building with uECC curve secp224r1])
AC_DEFINE([uECC_SUPPORTS_secp256r1], [1], [Define to 1 if building with uECC curve secp256r1])
AC_DEFINE([uECC_SUPPORTS_secp256k1], [0], [Define to 1 if building with uECC curve secp256k1])
DTLS_ECC=1])

AC_ARG_WITH(psk,
Expand Down Expand Up @@ -116,7 +122,13 @@ AC_SUBST(NDEBUG)
AC_SUBST(DTLS_ECC)
AC_SUBST(DTLS_PSK)
AC_SUBST(ENABLE_SHARED)
AC_SUBST(AR)
AC_SUBST(AC)

AC_SUBST(uECC_SUPPORTS_secp160r1)
AC_SUBST(uECC_SUPPORTS_secp192r1)
AC_SUBST(uECC_SUPPORTS_secp224r1)
AC_SUBST(uECC_SUPPORTS_secp256r1)
AC_SUBST(uECC_SUPPORTS_secp256k1)

# Checks for header files.
AC_CHECK_HEADERS([assert.h arpa/inet.h fcntl.h inttypes.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h strings.h sys/param.h sys/socket.h unistd.h])
Expand Down Expand Up @@ -148,6 +160,5 @@ AC_CONFIG_FILES([Makefile
platform-specific/Makefile
tinydtls.pc
sha2/Makefile
aes/Makefile
ecc/Makefile])
aes/Makefile])
AC_OUTPUT
Loading
Loading