Pass explicit hs parameters into custom_extensions.c.
Change-Id: Id8543a88929091eb004a5205a30b483253cdaa25
Reviewed-on: https://boringssl-review.googlesource.com/12319
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
diff --git a/ssl/custom_extensions.c b/ssl/custom_extensions.c
index 46b5efb..10fbfc8 100644
--- a/ssl/custom_extensions.c
+++ b/ssl/custom_extensions.c
@@ -58,7 +58,8 @@
return 1;
}
-static int custom_ext_add_hello(SSL *ssl, CBB *extensions) {
+static int custom_ext_add_hello(SSL_HANDSHAKE *hs, CBB *extensions) {
+ SSL *const ssl = hs->ssl;
STACK_OF(SSL_CUSTOM_EXTENSION) *stack = ssl->ctx->client_custom_extensions;
if (ssl->server) {
stack = ssl->ctx->server_custom_extensions;
@@ -72,7 +73,7 @@
const SSL_CUSTOM_EXTENSION *ext = sk_SSL_CUSTOM_EXTENSION_value(stack, i);
if (ssl->server &&
- !(ssl->s3->hs->custom_extensions.received & (1u << i))) {
+ !(hs->custom_extensions.received & (1u << i))) {
/* Servers cannot echo extensions that the client didn't send. */
continue;
}
@@ -102,8 +103,8 @@
}
if (!ssl->server) {
- assert((ssl->s3->hs->custom_extensions.sent & (1u << i)) == 0);
- ssl->s3->hs->custom_extensions.sent |= (1u << i);
+ assert((hs->custom_extensions.sent & (1u << i)) == 0);
+ hs->custom_extensions.sent |= (1u << i);
}
break;
@@ -121,12 +122,13 @@
return 1;
}
-int custom_ext_add_clienthello(SSL *ssl, CBB *extensions) {
- return custom_ext_add_hello(ssl, extensions);
+int custom_ext_add_clienthello(SSL_HANDSHAKE *hs, CBB *extensions) {
+ return custom_ext_add_hello(hs, extensions);
}
-int custom_ext_parse_serverhello(SSL *ssl, int *out_alert, uint16_t value,
- const CBS *extension) {
+int custom_ext_parse_serverhello(SSL_HANDSHAKE *hs, int *out_alert,
+ uint16_t value, const CBS *extension) {
+ SSL *const ssl = hs->ssl;
unsigned index;
const SSL_CUSTOM_EXTENSION *ext =
custom_ext_find(ssl->ctx->client_custom_extensions, &index, value);
@@ -134,7 +136,7 @@
if (/* Unknown extensions are not allowed in a ServerHello. */
ext == NULL ||
/* Also, if we didn't send the extension, that's also unacceptable. */
- !(ssl->s3->hs->custom_extensions.sent & (1u << index))) {
+ !(hs->custom_extensions.sent & (1u << index))) {
OPENSSL_PUT_ERROR(SSL, SSL_R_UNEXPECTED_EXTENSION);
ERR_add_error_dataf("extension %u", (unsigned)value);
*out_alert = SSL_AD_UNSUPPORTED_EXTENSION;
@@ -152,8 +154,9 @@
return 1;
}
-int custom_ext_parse_clienthello(SSL *ssl, int *out_alert, uint16_t value,
- const CBS *extension) {
+int custom_ext_parse_clienthello(SSL_HANDSHAKE *hs, int *out_alert,
+ uint16_t value, const CBS *extension) {
+ SSL *const ssl = hs->ssl;
unsigned index;
const SSL_CUSTOM_EXTENSION *ext =
custom_ext_find(ssl->ctx->server_custom_extensions, &index, value);
@@ -162,8 +165,8 @@
return 1;
}
- assert((ssl->s3->hs->custom_extensions.received & (1u << index)) == 0);
- ssl->s3->hs->custom_extensions.received |= (1u << index);
+ assert((hs->custom_extensions.received & (1u << index)) == 0);
+ hs->custom_extensions.received |= (1u << index);
if (ext->parse_callback &&
!ext->parse_callback(ssl, value, CBS_data(extension), CBS_len(extension),
@@ -176,8 +179,8 @@
return 1;
}
-int custom_ext_add_serverhello(SSL *ssl, CBB *extensions) {
- return custom_ext_add_hello(ssl, extensions);
+int custom_ext_add_serverhello(SSL_HANDSHAKE *hs, CBB *extensions) {
+ return custom_ext_add_hello(hs, extensions);
}
/* MAX_NUM_CUSTOM_EXTENSIONS is the maximum number of custom extensions that
diff --git a/ssl/internal.h b/ssl/internal.h
index b401fe4..534f276 100644
--- a/ssl/internal.h
+++ b/ssl/internal.h
@@ -509,12 +509,12 @@
void SSL_CUSTOM_EXTENSION_free(SSL_CUSTOM_EXTENSION *custom_extension);
-int custom_ext_add_clienthello(SSL *ssl, CBB *extensions);
-int custom_ext_parse_serverhello(SSL *ssl, int *out_alert, uint16_t value,
- const CBS *extension);
-int custom_ext_parse_clienthello(SSL *ssl, int *out_alert, uint16_t value,
- const CBS *extension);
-int custom_ext_add_serverhello(SSL *ssl, CBB *extensions);
+int custom_ext_add_clienthello(SSL_HANDSHAKE *hs, CBB *extensions);
+int custom_ext_parse_serverhello(SSL_HANDSHAKE *hs, int *out_alert,
+ uint16_t value, const CBS *extension);
+int custom_ext_parse_clienthello(SSL_HANDSHAKE *hs, int *out_alert,
+ uint16_t value, const CBS *extension);
+int custom_ext_add_serverhello(SSL_HANDSHAKE *hs, CBB *extensions);
/* Handshake hash.
diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c
index a908a99..a87bee1 100644
--- a/ssl/t1_lib.c
+++ b/ssl/t1_lib.c
@@ -2775,7 +2775,7 @@
}
}
- if (!custom_ext_add_clienthello(ssl, &extensions)) {
+ if (!custom_ext_add_clienthello(hs, &extensions)) {
goto err;
}
@@ -2864,7 +2864,7 @@
}
}
- if (!custom_ext_add_serverhello(ssl, &extensions)) {
+ if (!custom_ext_add_serverhello(hs, &extensions)) {
goto err;
}
@@ -2918,7 +2918,7 @@
tls_extension_find(&ext_index, type);
if (ext == NULL) {
- if (!custom_ext_parse_clienthello(ssl, out_alert, type, &extension)) {
+ if (!custom_ext_parse_clienthello(hs, out_alert, type, &extension)) {
OPENSSL_PUT_ERROR(SSL, SSL_R_ERROR_PARSING_EXTENSION);
return 0;
}
@@ -3019,7 +3019,7 @@
tls_extension_find(&ext_index, type);
if (ext == NULL) {
- if (!custom_ext_parse_serverhello(ssl, out_alert, type, &extension)) {
+ if (!custom_ext_parse_serverhello(hs, out_alert, type, &extension)) {
return 0;
}
continue;