aes: use integer types with explicit size

An int is just at least 16 bytes long and not 32 bytes on all systems.
Here we need integers with an explicit size therefor we should use
uint**_t. This makes the code compile for a 16 bit CPU.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: use functions to extract numbers

These defines did not had a good type check in it and just casted the
parameters. This caused problems on 16 bit CPUs as there int is 16 bits
and the default value for numbers. Now the compiler is able to change
the given integer to the needed size. This also fixes 2 bugs where the
wrong pointer was used in the code.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
ecc: fix bug when using this on 16Bit CPU

There is an integer overflow as int is 16 bits on 16Bit CPUs.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
debug: fix bug when using this on 16Bit CPU

There is an integer overflow as int is 16 bits on 16Bit CPUs.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
sha2: fix compilation without assert().

It was not possible to compile sha2 code without using assert().

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
sha2: undef BYTE_ORDER before using

some contiki targets are defining BYTE_ORDER somewhere else and this
conflicts with this definition.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Revert "sha2: undef BYTE_ORDER before using"

This reverts commit e01f3a6eacdc9999d75da7b2cb1f1c2b6c64b66c.

BYTE_ORDER should be set by the Makefile depending on the target this
is build for. A following commit will set this define in the makefile
for two new targets.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: add support for wismote and exp5438

The endianes has to be defined for wismote and exp5438.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
debug: Do not use snprintf() with a vaiable length

The compiler for the MSP430 on contiki thinks that the length is not a
build in constant and makes this function fail every time. The length
is already checked before, so it is save to use sprintf() instead.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
debug: do not add va_list to pirntf function

When the target does not support vprintf() (HAVE_VPRINTF is not set) do
not add the arguments normally added to vprintf to printf, but replace
our nice debug function  dsrv_log() with a call to printf().

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: add DTLS prefix in front of header define

This define is there to prevent this actual header from being included
more than one time, but this should be unique in all header files used
in all code tinydtls is compiled with. Add a prefix to prevent
collisions with other code we do not control. This is one part to make
tinydtls work better in combination with libcoap.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: add dtls prefix to prng functions

This should prevent collisions with other code compiled with tinydtls
into one binary. The include from crypto.h was removed to prevent this
file from being included in user applications using tinydtls.

The functions and defines in prng.h got some changes to make the easier
to read. This is one part to make tinydtls work better in combination
with libcoap.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
debug: rename function dtls_alert() to dtls_send_alert()

This change was done to rename the alert() function to dtls_alert()
later, this functions is used to print alert messages.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
debug: add dtls prefix in front of debug functions

Do not use dsrv_log() directly and add a dtls prefix in front of all
the short logging functions. This should prevent name collisions with
other functions in other code. This should make it easier to remove all
debug outputs from tinydtls with a compile option.

This is one part to make tinydtls work better in combination with libcoap.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
debug: replace calls to dtls_dsrv_hexdump_log()

Do not use dtls_dsrv_hexdump_log() directly, but use a short logging
function. This should make it easier to remove all debug outputs from
tinydtls with a compile option.

This is one part to make tinydtls work better in combination with libcoap.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
debug: add DTLS prefix to log level

This will prevent name collisions with other code compiled with
tiyndtls.

This is one part to make tinydtls work better in combination with libcoap.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
test: remove PRINTF()

PRINTF() is already defined in debug.h

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: rename and move struct str

struct str is just used in the test client and not in the normal
tinydtls code, move it there. This also collides with some struct str
defined in the stdlib.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: fix DTLS_CLIENT and DTLS_SERVER comments

These were left over when DTLS_CLIENT and DTLS_SERVER where changed.

Thank you Andreas Bender for reporting this.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: use dtls_send() for sending a handshake message

This changes dtls_send() to dtls_send_multi() which is able to take an
array of buffers to send and not just one. This is now also used in
dtls_send_handshake_msg_hash() to send the handshake messages, because
dtls_send() also handles retransmission and handshake messages should
be retransmitted when needed.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>