aboutsummaryrefslogtreecommitdiff
path: root/ssl/d1_msg.c
diff options
context:
space:
mode:
authorEnji Cooper <ngie@FreeBSD.org>2025-05-07 21:18:24 +0000
committerEnji Cooper <ngie@FreeBSD.org>2025-05-07 22:37:22 +0000
commit29536654cc41bf41b92dc836c47496dc6fe0b00c (patch)
tree368a3c5b14e610bb5f6b71657f61a41e373eaf97 /ssl/d1_msg.c
parent1c34280346af8284acdc0eae39496811d37df25d (diff)
Diffstat (limited to 'ssl/d1_msg.c')
-rw-r--r--ssl/d1_msg.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/ssl/d1_msg.c b/ssl/d1_msg.c
index 10438a395545..6613f0f4c87a 100644
--- a/ssl/d1_msg.c
+++ b/ssl/d1_msg.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2020 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2005-2025 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -8,14 +8,19 @@
*/
#include "ssl_local.h"
+#include "internal/ssl_unwrap.h"
-int dtls1_write_app_data_bytes(SSL *s, int type, const void *buf_, size_t len,
- size_t *written)
+int dtls1_write_app_data_bytes(SSL *s, uint8_t type, const void *buf_,
+ size_t len, size_t *written)
{
int i;
+ SSL_CONNECTION *sc = SSL_CONNECTION_FROM_SSL_ONLY(s);
- if (SSL_in_init(s) && !ossl_statem_get_in_handshake(s)) {
- i = s->handshake_func(s);
+ if (sc == NULL)
+ return -1;
+
+ if (SSL_in_init(s) && !ossl_statem_get_in_handshake(sc)) {
+ i = sc->handshake_func(s);
if (i < 0)
return i;
if (i == 0) {
@@ -29,42 +34,46 @@ int dtls1_write_app_data_bytes(SSL *s, int type, const void *buf_, size_t len,
return -1;
}
- return dtls1_write_bytes(s, type, buf_, len, written);
+ return dtls1_write_bytes(sc, type, buf_, len, written);
}
-int dtls1_dispatch_alert(SSL *s)
+int dtls1_dispatch_alert(SSL *ssl)
{
int i, j;
void (*cb) (const SSL *ssl, int type, int val) = NULL;
unsigned char buf[DTLS1_AL_HEADER_LENGTH];
unsigned char *ptr = &buf[0];
size_t written;
+ SSL_CONNECTION *s = SSL_CONNECTION_FROM_SSL_ONLY(ssl);
+
+ if (s == NULL)
+ return 0;
- s->s3.alert_dispatch = 0;
+ s->s3.alert_dispatch = SSL_ALERT_DISPATCH_NONE;
memset(buf, 0, sizeof(buf));
*ptr++ = s->s3.send_alert[0];
*ptr++ = s->s3.send_alert[1];
- i = do_dtls1_write(s, SSL3_RT_ALERT, &buf[0], sizeof(buf), 0, &written);
+ i = do_dtls1_write(s, SSL3_RT_ALERT, &buf[0], sizeof(buf), &written);
if (i <= 0) {
s->s3.alert_dispatch = 1;
- /* fprintf( stderr, "not done with alert\n" ); */
+ /* fprintf(stderr, "not done with alert\n"); */
} else {
(void)BIO_flush(s->wbio);
if (s->msg_callback)
s->msg_callback(1, s->version, SSL3_RT_ALERT, s->s3.send_alert,
- 2, s, s->msg_callback_arg);
+ 2, ssl, s->msg_callback_arg);
if (s->info_callback != NULL)
cb = s->info_callback;
- else if (s->ctx->info_callback != NULL)
- cb = s->ctx->info_callback;
+ else if (ssl->ctx->info_callback != NULL)
+ cb = ssl->ctx->info_callback;
if (cb != NULL) {
j = (s->s3.send_alert[0] << 8) | s->s3.send_alert[1];
- cb(s, SSL_CB_WRITE_ALERT, j);
+ cb(ssl, SSL_CB_WRITE_ALERT, j);
}
}
return i;