Skip to content

Commit

Permalink
dtls.c: remove rudiments of renegotiation.
Browse files Browse the repository at this point in the history
Renegotiation has been removed.
Cleanup some leftovers internal renegotiation errors.

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
  • Loading branch information
boaks committed Jul 12, 2023
1 parent c9bbc03 commit 3159ca6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
1 change: 0 additions & 1 deletion alert.h
Expand Up @@ -56,7 +56,6 @@ typedef enum {
#define DTLS_EVENT_CONNECT 0x01DC /**< initiated handshake */
#define DTLS_EVENT_CONNECTED 0x01DE /**< handshake or re-negotiation
* has finished */
#define DTLS_EVENT_RENEGOTIATE 0x01DF /**< re-negotiation has started */

static inline int
dtls_alert_create(dtls_alert_level_t level, dtls_alert_t desc)
Expand Down
18 changes: 5 additions & 13 deletions dtls.c
Expand Up @@ -1234,11 +1234,7 @@ dtls_check_tls_extension(dtls_peer_t *peer,
return 0;

error:
if (is_client_hello && peer->state == DTLS_STATE_CONNECTED) {
return dtls_alert_create(DTLS_ALERT_LEVEL_WARNING, DTLS_ALERT_NO_RENEGOTIATION);
} else {
return dtls_alert_fatal_create(DTLS_ALERT_HANDSHAKE_FAILURE);
}
return dtls_alert_fatal_create(DTLS_ALERT_HANDSHAKE_FAILURE);
}

/**
Expand Down Expand Up @@ -1368,11 +1364,7 @@ dtls_update_parameters(dtls_context_t *ctx,

return dtls_check_tls_extension(peer, data, data_length, 1);
error:
if (peer->state == DTLS_STATE_CONNECTED) {
return dtls_alert_create(DTLS_ALERT_LEVEL_WARNING, DTLS_ALERT_NO_RENEGOTIATION);
} else {
return dtls_alert_fatal_create(DTLS_ALERT_HANDSHAKE_FAILURE);
}
return dtls_alert_fatal_create(DTLS_ALERT_HANDSHAKE_FAILURE);
}

/**
Expand Down Expand Up @@ -4634,7 +4626,9 @@ dtls_handle_message(dtls_context_t *ctx,

err = handle_handshake(ctx, peer, data, data_length);
if (err < 0) {
dtls_warn("error while handling handshake packet\n");
dtls_warn("error 0x%04x handling handshake packet of type: %s (%i),"
" state %d\n", -err, dtls_handshake_type_to_name(data[0]),
data[0], peer->state);
dtls_alert_send_from_err(ctx, peer, err);

if (peer && DTLS_ALERT_LEVEL_FATAL == ((-err) & 0xff00) >> 8) {
Expand Down Expand Up @@ -4803,8 +4797,6 @@ dtls_connect(dtls_context_t *ctx, const session_t *dst) {
* re-negotiation. */
if (res > 0) {
CALL(ctx, event, &peer->session, 0, DTLS_EVENT_CONNECT);
} else if (res == 0) {
CALL(ctx, event, &peer->session, 0, DTLS_EVENT_RENEGOTIATE);
}

return res;
Expand Down

0 comments on commit 3159ca6

Please sign in to comment.