dtls: use dtls_compression_t to store compression in use

Instead of storing the compression in use a char use dtls_compression_t.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: make the interface index in the session a u8

It is very unlikely that we have a device with more than 256 Ethernet
interfaces.

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

dtls_security_parameters_t is now divided into
dtls_security_parameters_t, which contains the values needed for the
current cipher in use and dtls_handshake_parameters_t, which contains
the values for the cipher which is currently negotiated in the
handshake. This makes it possible to just store one version of this
struct and save some memory per connection.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
test: fix a warning

() now wants a signed char.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: remove globale arrays _clear and _buf

These arrays are not referenced by any code

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
debug: use dtls_dsrv_log_addr() in dtls-client.c

Use dtls_dsrv_log_addr() in dtls-client.c

Now we do not have do export dsrv_print_addr() any more, because no one
calls this directly any more.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: make some functions static

This saves some code on flash memory, because the compiler is able to
reduce the code size better.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
ecc: do not export ecc_ec_double() and ecc_ec_add()

These functions are not used by any dtls code.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: move declarations of init() functions into the own header

when they are defined in the correct header file the compiler will
print a warning, if the prototype does not match the actual function.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: add constant for client and server random length

This replaces the magic value 32 and many sizeof()

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: share memory for master_secret and client and server random

Only in calculate_key_block() we access both values, and there is a new
stack var added. After that function just the master_secret is needed
and before that only the randoms are needed.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: remove nonce from aes struct

The nonce changes after encrypt and decrypt operation and can be
regenerated from the keyblock and some dtls header attributes on every
crypto operation.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: remove cipher form dtls_cipher_context_t, it was not used

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