Commit Graph

22 Commits

Author SHA1 Message Date
Jon Shallow
65ac5c3ca1 CMake: Force all Warnings to Errors when doing github actions
Add new option WARNING_TO_ERROR for CMakeLists.txt and tests/CMakelist.txt
and update github workflows to use it.

Do the cmake in a sub-directory.

Fix warnings generated by mac-os build in dtls.c and sha2.c.

Signed-off-by: Jon Shallow <supjps-libcoap@jpshallow.com>
2022-09-28 13:53:04 +02:00
Jan Romann
9320251212 Add Windows support 2022-09-27 14:31:54 +02:00
Jon Shallow
86f4988fc4 github: Add in build and test workflow
Unfortunately out of path builds do not work at present.

Signed-off-by: Jon Shallow <supjps-libcoap@jpshallow.com>
2022-08-08 09:55:21 +02:00
Achim Kraus
5e40624ec0 dtls_time.h: conditionally include time header files.
Include time.h and sys/time.h based on HAVE_TIME_H and HAVE_SYS_TIME_H.

Signed-off-by: Achim Kraus <achim.kraus@bosch.io>
2022-01-07 11:47:49 +01:00
Olaf Bergmann
1c5d2feaca sha2.c: Fixed wrong memory clear operation in finalization functions
The functions dtls_sha*_final() and dtls_sha*_end() need to clean the
state buffer (context) at the end. To clean the entire buffer properly,
the pointer passed to sizeof() needs to be dereferenced.
2021-10-04 09:44:29 +02:00
Olaf Bergmann
c8e41c88e3 sha2.c: fixed warnings due to inconsistent array bounds
Fix warning from GCC 11 that complains when function prototypes
and implementations differ in the declared array bounds.
2021-10-04 09:44:29 +02:00
Jon Shallow
f06e787335 compile warnings: Include WARNING_CFLAGS in all Makefile.in
Fix all the compile warnings generated following adding WARNING_CFLAGS
to all the Makefile.in files.

Fix tests/unit-tests/testdriver failures caused by dtls_prng() return value.

Signed-off-by: Jon Shallow <supjps-libcoap@jpshallow.com>
2021-06-01 20:08:13 +01:00
Olaf Bergmann
5c83d4bb91 Make: add uninstall target for Makefiles
make uninstall deletes all files that would have been installed
by make install and removes the directories make install would
have created. Directories that are not empty after uninstalling
the files will be preserved.

Change-Id: I53587dfd765e112e99fb6ab078a33a6174828987
2020-06-25 15:30:27 +02:00
Fabrice Fontaine
78a2d32f47 sha2/sha2.c: fix build on big endian
Build is broken since 865ec9ba1d because
tmp is undefined in put32be and put64be:

/home/buildroot/autobuild/instance-1/output-1/host/bin/m68k-linux-gcc -DSHA2_USE_INTTYPES_H -Wall -std=c99 -pedantic -fPIC -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -DDTLSv12 -DWITH_SHA256 -I..  -c -o sha2.o sha2.c
sha2.c: In function 'get32be':
sha2.c:164:2: warning: implicit declaration of function 'MEMCPY_BCOPY' [-Wimplicit-function-declaration]
  MEMCPY_BCOPY(&tmp, data, sizeof(tmp));
  ^~~~~~~~~~~~
sha2.c: In function 'put32be':
sha2.c:177:34: error: 'tmp' undeclared (first use in this function)
  MEMCPY_BCOPY(data, &val, sizeof(tmp));
                                  ^~~

Fix this error by replacing tmp by val

Moreover, move MEMCPY_BCOPY before its usage or linking step will fail

Fixes:
 - http://autobuild.buildroot.org/results/e8704e02fdede7b63e22da552292977b23380b32

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2020-06-20 13:12:16 +02:00
Fabrice Fontaine
3b03c3850a Update Makefile.in to allow cross-compilation
Use DESTDIR and LDFLAGS environment variables passed to configure in
Makefile.in files

[Retrieved (and slightly updated) from:
https://git.buildroot.net/buildroot/tree/package/tinydtls/0001-Update-Makefile.in-to-allow-cross-compilation.patch]

Signed-off-by: Fabrice Fontaine <fabrice.fontaine@orange.com>
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2020-05-18 17:27:30 +02:00
Olaf Bergmann
428ed50a82 sha2prog.c: Add missing header includes
Change-Id: Ie4b7607c16c320ab779af8b6b5a47167f53a65a9
2019-04-25 14:57:18 +02:00
Jon Shallow
865ec9ba1d sha2.c: Fix for systems that do not support non word alignment
dtls_sha256_transform() fails for esp-idf systems as the data parameter
is a uint32 and may not be aligned to a word boundary when
processing the server-hello handshake.

sha2/sha2.c:

Make the data parameter byte aligned (as does most other sha256
implementations) for function dtls_sha{256|512}_transform().

Replace REVERSE32 and REVERSE64 macros with get32be(), put32be(),
get64be() and put64be() functions which are byte aligned.

Remove some of the now unneeded "#if BYTE_ORDER == LITTLE_ENDIAN".

sha2/sha2.h:

Allow sha384 to be built (not been tested).

Signed-off-by: Jon Shallow <supjps-libcoap@jpshallow.com>
2019-04-25 13:30:43 +01:00
Jon Shallow
a37ba81034 Use of -Wwrite-strings and -Wextra throw up compiler warnings
dtls.c:
Add in const for dtls_handshake_type_to_name()

dtls_debug.[ch]:

Add in const where appropriate for dsrv_log().
In addition, get dsrv_log() to check printf syntax.

sha2/sha2.c:

Re-order "const static" to "static const" and add in needed const.

Signed-off-by: Jon Shallow <supjps-libcoap@jpshallow.com>
2019-04-01 15:43:01 +01:00
Sören Tempel
3d654f02d5 Compile with -DSHA2_USE_INTTYPES_H by default
By default the code in sha2/ uses u_intXX_t types which are not mandated
by POSIX. To make it use the uintXX_t types mandated by POSIX.1‐2008
the code needs to be compiled with `-DSHA2_USE_INTTYPES_H` which ensures
that `inittypes.h` is included (even though the correct header to
include here would be `stdint.h`).

A better solution to this would probably be adjusting the code in sha2/
in a way that ensures that uintXX_t types are always used. This approach
was taken because it was easier to implemented.

This fixes the build on musl libc based linux systems and increases the
portability of the code base.

Change-Id: I3837ad239e09cff45da199ecfee7789a889d9fc7
Signed-off-by: Sören Tempel <tempel@uni-bremen.de>
Signed-off-by: Olaf Bergmann <bergmann@tzi.org>
2018-07-18 14:19:11 +02:00
Olaf Bergmann
1e9efad288 sha2: fix strict-aliasing compile error
This change has been suggested by smlng in [1].

[1] https://git.eclipse.org/r/114407

Change-Id: I20f77de2b8a50732937f84fc87a41db5acc17fb0
Signed-off-by: Raul Fuentes <ra.fuentes.sam@gmail.com>
Signed-off-by: smlng <s@mlng.net>
2018-02-16 12:34:53 +01:00
Raul Fuentes
ab511fca72 sha2/sha2.c Trailing whitespaces
Signed-off-by: Raul Fuentes <ra.fuentes.sam@gmail.com>
2018-02-15 18:11:19 +01:00
Olaf Bergmann
cc5863fa0e fixed Makefile variables for cross-compilation
When configured for a different host, the variables CC, AR and
RANLIB have not been set correctly. With this fix, tinydtls can
be compiled for another platform when it is configured as a
submodule of an automake-enabled project.

For example, when the dtls branch of libcoap[1] can be cross-compiled
for the raspberry pi as follows:

  ./configure --with-host=arm-linux-gnueabihf --disable-shared

Note that cross-compilation does not yet work without automake as the
m4 macro AM_PROG_AR depends on automake.

[1] https://github.com/obgm/libcoap/tree/dtls

Change-Id: If23080dc7754a48434e7ac787c0bddda1dd9530b
2017-04-18 16:19:38 +02:00
Olaf Bergmann
c04557d2bd sha2.c: Changed address calculation to avoid type punning.
Use pointer arithmetics instead of taking the address of a
dereferenced array value to quiet warning about type punned pointer.

Change-Id: I6c833dafbf26502c8b4d132f21a733cc4f133bdb
2017-03-01 13:29:04 +01:00
Gaëtan Harter
c9adbab655 tinydtls.h: include dtls_config.h in tinydtls.h
Fixes dtls_config.h not visible in headers
Include dtls_config.h in tinydtls.h and include tinydtls.h in all necessary
headers.

Remaining headers do not use 'ifdef', but they may require it too.

Change-Id: I39c86dffc8bbc8bd7551e74386994f92f49d00ec
Signed-off-by: Gaëtan Harter <gaetan.harter@inria.fr>
2017-02-27 18:05:10 +01:00
Kyungsun Cho
1ddeffa2a9 bug 490467: Renamed |SHA| symbol names on |sha2| module
this change is for resolving |sha2| symbol-conflict in using
|tinydtls| with other crypto modules. this symbol-conflict could
occur on the |tinydtls|-deployed systems with using |OpenSSL| or
|OpenSSL|-like, which has another |SHA| symbols.
In case of |iotivity-tinydtls|, the conflict occurs between
|iotivity-tinydtls| and the deployed |crypto| library, which has
also another |SHA|.

[patch #1] initial commit
[patch #2-3] updated commit message
[patch #4] reverted renaming for internal symbols
[patch #5] updated symbols with lower-case
[patch #6] fixed typo for calling API

bugs: https://bugs.eclipse.org/bugs/show_bug.cgi?id=490467

Change-Id: I6942870c7c31544e89a20209d21730406ffb08d2
Signed-off-by: Kyungsun Cho <goodsun.cho@samsung.com>
2016-04-20 16:36:39 +09:00
Olaf Bergmann
b11921d72f Re-added sha2 implementation
Covered by CQ 10515:
http://dev.eclipse.org/ipzilla/show_bug.cgi?id=10515
2016-02-02 18:56:30 +01:00
Olaf Bergmann
e1388b3980 New initial commit 2016-02-02 18:39:21 +01:00