aes: do not include aes decryption tables

The aes decryption tables are only needed when we do aes decrypt, which
is not done here.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
netq: remove al the casts to netq_t and use list_t directly

instead of casting every list to netq_t and somewhere in the function
back to list_t, use list_t directly.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: show handshake complete message

When the handshake is finished show a message in the log.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: return length in decrypt_verify()

Instead of writing the length to a given parameter just return it in
the function, in a error case a negative number will be returned.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: move hs_state into handshake

The hs_state is only needed in the handshake and it should be stored
there and not in the normal dtls connection struct. In a later patch
the handshake struct will only be allocated when a handshake is done
and we can same some space in the other cases.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: use only one cipher context globally

Instead of having at least 2 cipher contexts per connection, one for
encryption and one for decryption, only use one and initialize it new
for every package to be decrypted or encrypted. In DTLS we have to be
able to decrypt and encrypt every package independently of the other
packages so we do not have to store any state expect for the keys
itself. This should save lots of memory per connection.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: allocate handshake struct only when needed

Instead of giving every dtls connection a dedicated handshake struct to
store temporary handshake data in it, make it possible to allocate such
a struct when needed. A dtls connection will allocate such a struct
when a handshake is started and will free it when the handshake
finished. This makes it possible to support e.g. 3 concurrent dtls
connections, but only one handshake at a time without wasting too much
memory.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: move security parameter to own struct

Instead of storing two security parameter structs in the dtls
connection struct, allocate them separately, because we do not need two
every time. Two structs are only needed at the end of a handshake when
the ChangeChipherSpec is send with the old security settings and the
immediately following finish message is send with the new ones. When
the ChangeChipherSpec has to be retransmitted the old security settings
are still needed.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: fix some signedness warnings

When making gcc complain about more problems these where shown.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: move epoch to security parameter

The epoch is not stored in the dtls connection any more, but now in the
dtls security parameter. When the epoch was changed there is more than
one valid security parameter and each of them has a own valid epoch.
For sending it now uses the first security parameter and the second
could be null or it could contain some alternative security parameter,
when we are currently in the change process and there still could
arrive an old package we want to receive.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: do not forward the epoch, but the security parameters

Instead of using the epoch to identity the security parameters to use,
use the security parameters directly.

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