diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libssl/tls13_server.c | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/src/lib/libssl/tls13_server.c b/src/lib/libssl/tls13_server.c index 029dd7211b..313c5026d0 100644 --- a/src/lib/libssl/tls13_server.c +++ b/src/lib/libssl/tls13_server.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: tls13_server.c,v 1.36 2020/05/09 10:17:58 tb Exp $ */ | 1 | /* $OpenBSD: tls13_server.c,v 1.37 2020/05/09 10:51:55 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2019, 2020 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2019, 2020 Joel Sing <jsing@openbsd.org> |
| 4 | * Copyright (c) 2020 Bob Beck <beck@openbsd.org> | 4 | * Copyright (c) 2020 Bob Beck <beck@openbsd.org> |
| @@ -210,17 +210,25 @@ tls13_client_hello_recv(struct tls13_ctx *ctx, CBS *cbs) | |||
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | static int | 212 | static int |
| 213 | tls13_server_hello_build(struct tls13_ctx *ctx, CBB *cbb) | 213 | tls13_server_hello_build(struct tls13_ctx *ctx, CBB *cbb, int hrr) |
| 214 | { | 214 | { |
| 215 | uint16_t tlsext_msg_type = SSL_TLSEXT_MSG_SH; | ||
| 216 | const uint8_t *server_random; | ||
| 215 | CBB session_id; | 217 | CBB session_id; |
| 216 | SSL *s = ctx->ssl; | 218 | SSL *s = ctx->ssl; |
| 217 | uint16_t cipher; | 219 | uint16_t cipher; |
| 218 | 220 | ||
| 219 | cipher = SSL_CIPHER_get_value(S3I(s)->hs.new_cipher); | 221 | cipher = SSL_CIPHER_get_value(S3I(s)->hs.new_cipher); |
| 222 | server_random = s->s3->server_random; | ||
| 223 | |||
| 224 | if (hrr) { | ||
| 225 | server_random = tls13_hello_retry_request_hash; | ||
| 226 | tlsext_msg_type = SSL_TLSEXT_MSG_HRR; | ||
| 227 | } | ||
| 220 | 228 | ||
| 221 | if (!CBB_add_u16(cbb, TLS1_2_VERSION)) | 229 | if (!CBB_add_u16(cbb, TLS1_2_VERSION)) |
| 222 | goto err; | 230 | goto err; |
| 223 | if (!CBB_add_bytes(cbb, s->s3->server_random, SSL3_RANDOM_SIZE)) | 231 | if (!CBB_add_bytes(cbb, server_random, SSL3_RANDOM_SIZE)) |
| 224 | goto err; | 232 | goto err; |
| 225 | if (!CBB_add_u8_length_prefixed(cbb, &session_id)) | 233 | if (!CBB_add_u8_length_prefixed(cbb, &session_id)) |
| 226 | goto err; | 234 | goto err; |
| @@ -231,7 +239,7 @@ tls13_server_hello_build(struct tls13_ctx *ctx, CBB *cbb) | |||
| 231 | goto err; | 239 | goto err; |
| 232 | if (!CBB_add_u8(cbb, 0)) | 240 | if (!CBB_add_u8(cbb, 0)) |
| 233 | goto err; | 241 | goto err; |
| 234 | if (!tlsext_server_build(s, cbb, SSL_TLSEXT_MSG_SH)) | 242 | if (!tlsext_server_build(s, cbb, tlsext_msg_type)) |
| 235 | goto err; | 243 | goto err; |
| 236 | 244 | ||
| 237 | if (!CBB_flush(cbb)) | 245 | if (!CBB_flush(cbb)) |
| @@ -313,13 +321,37 @@ tls13_server_engage_record_protection(struct tls13_ctx *ctx) | |||
| 313 | int | 321 | int |
| 314 | tls13_server_hello_retry_request_send(struct tls13_ctx *ctx, CBB *cbb) | 322 | tls13_server_hello_retry_request_send(struct tls13_ctx *ctx, CBB *cbb) |
| 315 | { | 323 | { |
| 316 | return 0; | 324 | int nid; |
| 325 | |||
| 326 | if (!tls13_synthetic_handshake_message(ctx)) | ||
| 327 | return 0; | ||
| 328 | |||
| 329 | if (ctx->hs->key_share != NULL) | ||
| 330 | return 0; | ||
| 331 | if ((nid = tls1_get_shared_curve(ctx->ssl)) == NID_undef) | ||
| 332 | return 0; | ||
| 333 | if ((ctx->hs->server_group = tls1_ec_nid2curve_id(nid)) == 0) | ||
| 334 | return 0; | ||
| 335 | |||
| 336 | if (!tls13_server_hello_build(ctx, cbb, 1)) | ||
| 337 | return 0; | ||
| 338 | |||
| 339 | return 1; | ||
| 317 | } | 340 | } |
| 318 | 341 | ||
| 319 | int | 342 | int |
| 320 | tls13_client_hello_retry_recv(struct tls13_ctx *ctx, CBS *cbs) | 343 | tls13_client_hello_retry_recv(struct tls13_ctx *ctx, CBS *cbs) |
| 321 | { | 344 | { |
| 322 | return 0; | 345 | SSL *s = ctx->ssl; |
| 346 | |||
| 347 | if (!tls13_client_hello_process(ctx, cbs)) | ||
| 348 | return 0; | ||
| 349 | |||
| 350 | /* XXX - need further checks. */ | ||
| 351 | if (s->method->internal->version < TLS1_3_VERSION) | ||
| 352 | return 0; | ||
| 353 | |||
| 354 | return 1; | ||
| 323 | } | 355 | } |
| 324 | 356 | ||
| 325 | int | 357 | int |
| @@ -327,11 +359,12 @@ tls13_server_hello_send(struct tls13_ctx *ctx, CBB *cbb) | |||
| 327 | { | 359 | { |
| 328 | if (ctx->hs->key_share == NULL) | 360 | if (ctx->hs->key_share == NULL) |
| 329 | return 0; | 361 | return 0; |
| 330 | |||
| 331 | if (!tls13_key_share_generate(ctx->hs->key_share)) | 362 | if (!tls13_key_share_generate(ctx->hs->key_share)) |
| 332 | return 0; | 363 | return 0; |
| 333 | 364 | ||
| 334 | if (!tls13_server_hello_build(ctx, cbb)) | 365 | ctx->hs->server_group = 0; |
| 366 | |||
| 367 | if (!tls13_server_hello_build(ctx, cbb, 0)) | ||
| 335 | return 0; | 368 | return 0; |
| 336 | 369 | ||
| 337 | return 1; | 370 | return 1; |
