Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the s_server -dtls option #12179

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/lib/s_cb.c
Expand Up @@ -745,6 +745,7 @@ int generate_cookie_callback(SSL *ssl, unsigned char *cookie,
EVP_MAC *hmac = NULL;
EVP_MAC_CTX *ctx = NULL;
OSSL_PARAM params[3], *p = params;
size_t mac_len;

/* Initialize a random secret */
if (!cookie_initialized) {
Expand Down Expand Up @@ -808,10 +809,11 @@ int generate_cookie_callback(SSL *ssl, unsigned char *cookie,
BIO_printf(bio_err, "HMAC context update failed\n");
goto end;
}
if (!EVP_MAC_final(ctx, cookie, NULL, (size_t)cookie_len)) {
if (!EVP_MAC_final(ctx, cookie, &mac_len, DTLS1_COOKIE_LENGTH)) {
BIO_printf(bio_err, "HMAC context final failed\n");
goto end;
}
*cookie_len = (int)mac_len;
res = 1;
end:
OPENSSL_free(buffer);
Expand Down
7 changes: 2 additions & 5 deletions include/openssl/dtls1.h
Expand Up @@ -36,11 +36,8 @@ extern "C" {
# define DTLS_ANY_VERSION 0x1FFFF

/* lengths of messages */
/*
* Actually the max cookie length in DTLS is 255. But we can't change this now
* due to compatibility concerns.
*/
# define DTLS1_COOKIE_LENGTH 256

# define DTLS1_COOKIE_LENGTH 255

# define DTLS1_RT_HEADER_LENGTH 13

Expand Down
2 changes: 1 addition & 1 deletion ssl/statem/statem_srvr.c
Expand Up @@ -1312,7 +1312,7 @@ int dtls_construct_hello_verify_request(SSL *s, WPACKET *pkt)
if (s->ctx->app_gen_cookie_cb == NULL ||
s->ctx->app_gen_cookie_cb(s, s->d1->cookie,
&cookie_leni) == 0 ||
cookie_leni > 255) {
cookie_leni > DTLS1_COOKIE_LENGTH) {
SSLfatal(s, SSL_AD_NO_ALERT, SSL_F_DTLS_CONSTRUCT_HELLO_VERIFY_REQUEST,
SSL_R_COOKIE_GEN_CALLBACK_FAILURE);
return 0;
Expand Down