dtls: use common function to parse ECDSA signature

A ECDSA signature is created and checked in the server key exchange and
in the client certificate verify. The creation is already done in a
common function, but the checking is done in separate functions. This
patch adds a common function for that as well.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: add SignatureAndHashAlgorithm element into DigitallySigned element in server key exchange

RFC 5246 updates RFC 4492 in Section A.7 to include a
SignatureAndHashAlgorithm in the DigitallySigned element in the Server
key exchange for (D)TLS 1.2. This was missing in the previous
implementation and was a violation of RFC 5246.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: use ret variable name instead of i

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: use constants instead of hard coding the values.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: ignore unexpected handshake packages

When a peer receives an unexpected handshake package from a peer while
not being in handshake state just ignore it, it could be that this
package is from a previous handshake and it just took some time to get
to this peer.

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