diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libssl/tls13_tlsext.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/src/lib/libssl/tls13_tlsext.c b/src/lib/libssl/tls13_tlsext.c index 394933674d..a06cc0869e 100644 --- a/src/lib/libssl/tls13_tlsext.c +++ b/src/lib/libssl/tls13_tlsext.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls13_tlsext.c,v 1.2 2019/01/17 02:55:48 beck Exp $ */ | 1 | /* $OpenBSD: tls13_tlsext.c,v 1.3 2019/01/17 06:44:10 beck Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2016, 2017 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2016, 2017 Joel Sing <jsing@openbsd.org> |
4 | * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> | 4 | * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> |
@@ -1360,16 +1360,26 @@ tls_extension_find(uint16_t type, size_t *tls_extensions_idx) | |||
1360 | } | 1360 | } |
1361 | 1361 | ||
1362 | static struct tls_extension_funcs * | 1362 | static struct tls_extension_funcs * |
1363 | tls13_tlsext_funcs(struct tls_extension *tlsext, int is_serverhello) | 1363 | tls13_tlsext_funcs(struct tls_extension *tlsext, uint16_t msg) |
1364 | { | 1364 | { |
1365 | if (is_serverhello) | 1365 | switch (msg) { |
1366 | case TLS13_TLSEXT_MSG_CH: | ||
1367 | return &tlsext->clienthello; | ||
1368 | case TLS13_TLSEXT_MSG_SH: | ||
1366 | return &tlsext->serverhello; | 1369 | return &tlsext->serverhello; |
1367 | 1370 | case TLS13_TLSEXT_MSG_EE: | |
1368 | return &tlsext->clienthello; | 1371 | case TLS13_TLSEXT_MSG_CT: |
1372 | case TLS13_TLSEXT_MSG_CR: | ||
1373 | case TLS13_TLSEXT_MSG_NST: | ||
1374 | case TLS13_TLSEXT_MSG_HRR: | ||
1375 | default: | ||
1376 | break; | ||
1377 | } | ||
1378 | return NULL; | ||
1369 | } | 1379 | } |
1370 | 1380 | ||
1371 | static int | 1381 | static int |
1372 | tls13_tlsext_build(SSL *s, CBB *cbb, int is_serverhello) | 1382 | tls13_tlsext_build(SSL *s, CBB *cbb, uint16_t msg) |
1373 | { | 1383 | { |
1374 | struct tls_extension_funcs *ext; | 1384 | struct tls_extension_funcs *ext; |
1375 | struct tls_extension *tlsext; | 1385 | struct tls_extension *tlsext; |
@@ -1382,7 +1392,7 @@ tls13_tlsext_build(SSL *s, CBB *cbb, int is_serverhello) | |||
1382 | 1392 | ||
1383 | for (i = 0; i < N_TLS_EXTENSIONS; i++) { | 1393 | for (i = 0; i < N_TLS_EXTENSIONS; i++) { |
1384 | tlsext = &tls_extensions[i]; | 1394 | tlsext = &tls_extensions[i]; |
1385 | ext = tls13_tlsext_funcs(tlsext, is_serverhello); | 1395 | ext = tls13_tlsext_funcs(tlsext, msg); |
1386 | 1396 | ||
1387 | if (!ext->needs(s)) | 1397 | if (!ext->needs(s)) |
1388 | continue; | 1398 | continue; |
@@ -1408,7 +1418,7 @@ tls13_tlsext_build(SSL *s, CBB *cbb, int is_serverhello) | |||
1408 | } | 1418 | } |
1409 | 1419 | ||
1410 | static int | 1420 | static int |
1411 | tls13_tlsext_parse(SSL *s, CBS *cbs, int *alert, int is_serverhello, uint16_t msg) | 1421 | tls13_tlsext_parse(SSL *s, CBS *cbs, int *alert, uint16_t msg) |
1412 | { | 1422 | { |
1413 | struct tls_extension_funcs *ext; | 1423 | struct tls_extension_funcs *ext; |
1414 | struct tls_extension *tlsext; | 1424 | struct tls_extension *tlsext; |
@@ -1433,8 +1443,9 @@ tls13_tlsext_parse(SSL *s, CBS *cbs, int *alert, int is_serverhello, uint16_t ms | |||
1433 | return 0; | 1443 | return 0; |
1434 | 1444 | ||
1435 | if (s->internal->tlsext_debug_cb != NULL) | 1445 | if (s->internal->tlsext_debug_cb != NULL) |
1436 | s->internal->tlsext_debug_cb(s, is_serverhello, type, | 1446 | s->internal->tlsext_debug_cb(s, |
1437 | (unsigned char *)CBS_data(&extension_data), | 1447 | msg == TLS13_TLSEXT_MSG_SH, /* XXX */ |
1448 | type, (unsigned char *)CBS_data(&extension_data), | ||
1438 | CBS_len(&extension_data), | 1449 | CBS_len(&extension_data), |
1439 | s->internal->tlsext_debug_arg); | 1450 | s->internal->tlsext_debug_arg); |
1440 | 1451 | ||
@@ -1453,7 +1464,7 @@ tls13_tlsext_parse(SSL *s, CBS *cbs, int *alert, int is_serverhello, uint16_t ms | |||
1453 | return 0; | 1464 | return 0; |
1454 | extensions_seen |= (1 << idx); | 1465 | extensions_seen |= (1 << idx); |
1455 | 1466 | ||
1456 | ext = tls13_tlsext_funcs(tlsext, is_serverhello); | 1467 | ext = tls13_tlsext_funcs(tlsext, msg); |
1457 | if (!ext->parse(s, &extension_data, alert)) | 1468 | if (!ext->parse(s, &extension_data, alert)) |
1458 | return 0; | 1469 | return 0; |
1459 | 1470 | ||
@@ -1487,7 +1498,7 @@ tls13_tlsext_clienthello_parse(SSL *s, CBS *cbs, int *alert, uint16_t msg) | |||
1487 | /* XXX - this possibly should be done by the caller... */ | 1498 | /* XXX - this possibly should be done by the caller... */ |
1488 | tls13_tlsext_clienthello_reset_state(s); | 1499 | tls13_tlsext_clienthello_reset_state(s); |
1489 | 1500 | ||
1490 | return tls13_tlsext_parse(s, cbs, alert, 0, msg); | 1501 | return tls13_tlsext_parse(s, cbs, alert, msg); |
1491 | } | 1502 | } |
1492 | 1503 | ||
1493 | static void | 1504 | static void |
@@ -1510,5 +1521,5 @@ tls13_tlsext_serverhello_parse(SSL *s, CBS *cbs, int *alert, uint16_t msg) | |||
1510 | /* XXX - this possibly should be done by the caller... */ | 1521 | /* XXX - this possibly should be done by the caller... */ |
1511 | tls13_tlsext_serverhello_reset_state(s); | 1522 | tls13_tlsext_serverhello_reset_state(s); |
1512 | 1523 | ||
1513 | return tls13_tlsext_parse(s, cbs, alert, 1, msg); | 1524 | return tls13_tlsext_parse(s, cbs, alert, msg); |
1514 | } | 1525 | } |