diff options
author | jsing <> | 2021-03-21 18:36:34 +0000 |
---|---|---|
committer | jsing <> | 2021-03-21 18:36:34 +0000 |
commit | b4267956efe26acca04e81248b224852ab3b48df (patch) | |
tree | 04368005066ac217cbc5ba4c6633356e81eb6d00 /src | |
parent | 25064bbd608cffa42b7bf46d3ea7eeb88d693de4 (diff) | |
download | openbsd-b4267956efe26acca04e81248b224852ab3b48df.tar.gz openbsd-b4267956efe26acca04e81248b224852ab3b48df.tar.bz2 openbsd-b4267956efe26acca04e81248b224852ab3b48df.zip |
Move the TLSv1.3 handshake struct inside the shared handshake struct.
There are currently three different handshake structs that are in use -
the SSL_HANDSHAKE struct (as S3I(s)->hs), the SSL_HANDSHAKE_TLS13 struct
(as S3I(s)->hs_tls13 or ctx->hs in the TLSv1.3 code) and the infamous
'tmp' embedded in SSL3_STATE_INTERNAL (as S3I(s)->tmp)).
This is the first step towards cleaning up the handshake structs so that
shared data is in the SSL_HANDSHAKE struct, with sub-structs for TLSv1.2
and TLSv1.3 specific information. Place SSL_HANDSHAKE_TLS13 inside
SSL_HANDSHAKE and change ctx->hs to refer to the SSL_HANDSHAKE struct
instead of the SSL_HANDSHAKE_TLS13 struct. This allows the TLSv1.3 code
to access the shared handshake data without needing the SSL struct.
ok inoguchi@ tb@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libssl/s3_lib.c | 30 | ||||
-rw-r--r-- | src/lib/libssl/ssl_locl.h | 81 | ||||
-rw-r--r-- | src/lib/libssl/ssl_tlsext.c | 60 | ||||
-rw-r--r-- | src/lib/libssl/tls13_client.c | 112 | ||||
-rw-r--r-- | src/lib/libssl/tls13_handshake.c | 12 | ||||
-rw-r--r-- | src/lib/libssl/tls13_internal.h | 4 | ||||
-rw-r--r-- | src/lib/libssl/tls13_legacy.c | 18 | ||||
-rw-r--r-- | src/lib/libssl/tls13_lib.c | 44 | ||||
-rw-r--r-- | src/lib/libssl/tls13_server.c | 92 |
9 files changed, 227 insertions, 226 deletions
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c index 75f71c4c7d..5e39907d9c 100644 --- a/src/lib/libssl/s3_lib.c +++ b/src/lib/libssl/s3_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s3_lib.c,v 1.204 2021/02/07 15:26:32 jsing Exp $ */ | 1 | /* $OpenBSD: s3_lib.c,v 1.205 2021/03/21 18:36:34 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -1565,10 +1565,10 @@ ssl3_free(SSL *s) | |||
1565 | EC_KEY_free(S3I(s)->tmp.ecdh); | 1565 | EC_KEY_free(S3I(s)->tmp.ecdh); |
1566 | freezero(S3I(s)->tmp.x25519, X25519_KEY_LENGTH); | 1566 | freezero(S3I(s)->tmp.x25519, X25519_KEY_LENGTH); |
1567 | 1567 | ||
1568 | tls13_key_share_free(S3I(s)->hs_tls13.key_share); | 1568 | tls13_key_share_free(S3I(s)->hs.tls13.key_share); |
1569 | tls13_secrets_destroy(S3I(s)->hs_tls13.secrets); | 1569 | tls13_secrets_destroy(S3I(s)->hs.tls13.secrets); |
1570 | freezero(S3I(s)->hs_tls13.cookie, S3I(s)->hs_tls13.cookie_len); | 1570 | freezero(S3I(s)->hs.tls13.cookie, S3I(s)->hs.tls13.cookie_len); |
1571 | tls13_clienthello_hash_clear(&S3I(s)->hs_tls13); | 1571 | tls13_clienthello_hash_clear(&S3I(s)->hs.tls13); |
1572 | 1572 | ||
1573 | sk_X509_NAME_pop_free(S3I(s)->tmp.ca_names, X509_NAME_free); | 1573 | sk_X509_NAME_pop_free(S3I(s)->tmp.ca_names, X509_NAME_free); |
1574 | 1574 | ||
@@ -1605,15 +1605,15 @@ ssl3_clear(SSL *s) | |||
1605 | S3I(s)->hs.sigalgs = NULL; | 1605 | S3I(s)->hs.sigalgs = NULL; |
1606 | S3I(s)->hs.sigalgs_len = 0; | 1606 | S3I(s)->hs.sigalgs_len = 0; |
1607 | 1607 | ||
1608 | tls13_key_share_free(S3I(s)->hs_tls13.key_share); | 1608 | tls13_key_share_free(S3I(s)->hs.tls13.key_share); |
1609 | S3I(s)->hs_tls13.key_share = NULL; | 1609 | S3I(s)->hs.tls13.key_share = NULL; |
1610 | 1610 | ||
1611 | tls13_secrets_destroy(S3I(s)->hs_tls13.secrets); | 1611 | tls13_secrets_destroy(S3I(s)->hs.tls13.secrets); |
1612 | S3I(s)->hs_tls13.secrets = NULL; | 1612 | S3I(s)->hs.tls13.secrets = NULL; |
1613 | freezero(S3I(s)->hs_tls13.cookie, S3I(s)->hs_tls13.cookie_len); | 1613 | freezero(S3I(s)->hs.tls13.cookie, S3I(s)->hs.tls13.cookie_len); |
1614 | S3I(s)->hs_tls13.cookie = NULL; | 1614 | S3I(s)->hs.tls13.cookie = NULL; |
1615 | S3I(s)->hs_tls13.cookie_len = 0; | 1615 | S3I(s)->hs.tls13.cookie_len = 0; |
1616 | tls13_clienthello_hash_clear(&S3I(s)->hs_tls13); | 1616 | tls13_clienthello_hash_clear(&S3I(s)->hs.tls13); |
1617 | 1617 | ||
1618 | S3I(s)->hs.extensions_seen = 0; | 1618 | S3I(s)->hs.extensions_seen = 0; |
1619 | 1619 | ||
@@ -1678,8 +1678,8 @@ _SSL_get_peer_tmp_key(SSL *s, EVP_PKEY **key) | |||
1678 | } else if (sc->peer_x25519_tmp != NULL) { | 1678 | } else if (sc->peer_x25519_tmp != NULL) { |
1679 | if (!ssl_kex_dummy_ecdhe_x25519(pkey)) | 1679 | if (!ssl_kex_dummy_ecdhe_x25519(pkey)) |
1680 | goto err; | 1680 | goto err; |
1681 | } else if (S3I(s)->hs_tls13.key_share != NULL) { | 1681 | } else if (S3I(s)->hs.tls13.key_share != NULL) { |
1682 | if (!tls13_key_share_peer_pkey(S3I(s)->hs_tls13.key_share, | 1682 | if (!tls13_key_share_peer_pkey(S3I(s)->hs.tls13.key_share, |
1683 | pkey)) | 1683 | pkey)) |
1684 | goto err; | 1684 | goto err; |
1685 | } else { | 1685 | } else { |
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h index 99b72cc65e..33eb3bba7d 100644 --- a/src/lib/libssl/ssl_locl.h +++ b/src/lib/libssl/ssl_locl.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_locl.h,v 1.327 2021/03/17 17:42:53 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_locl.h,v 1.328 2021/03/21 18:36:34 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -410,6 +410,44 @@ typedef struct ssl_session_internal_st { | |||
410 | } SSL_SESSION_INTERNAL; | 410 | } SSL_SESSION_INTERNAL; |
411 | #define SSI(s) (s->session->internal) | 411 | #define SSI(s) (s->session->internal) |
412 | 412 | ||
413 | typedef struct cert_pkey_st { | ||
414 | X509 *x509; | ||
415 | EVP_PKEY *privatekey; | ||
416 | STACK_OF(X509) *chain; | ||
417 | } CERT_PKEY; | ||
418 | |||
419 | typedef struct ssl_handshake_tls13_st { | ||
420 | int use_legacy; | ||
421 | int hrr; | ||
422 | |||
423 | /* Certificate and sigalg selected for use (static pointers). */ | ||
424 | const CERT_PKEY *cpk; | ||
425 | const struct ssl_sigalg *sigalg; | ||
426 | |||
427 | /* Version proposed by peer server. */ | ||
428 | uint16_t server_version; | ||
429 | |||
430 | uint16_t server_group; | ||
431 | struct tls13_key_share *key_share; | ||
432 | struct tls13_secrets *secrets; | ||
433 | |||
434 | uint8_t *cookie; | ||
435 | size_t cookie_len; | ||
436 | |||
437 | /* Preserved transcript hash. */ | ||
438 | uint8_t transcript_hash[EVP_MAX_MD_SIZE]; | ||
439 | size_t transcript_hash_len; | ||
440 | |||
441 | /* Legacy session ID. */ | ||
442 | uint8_t legacy_session_id[SSL_MAX_SSL_SESSION_ID_LENGTH]; | ||
443 | size_t legacy_session_id_len; | ||
444 | |||
445 | /* ClientHello hash, used to validate following HelloRetryRequest */ | ||
446 | EVP_MD_CTX *clienthello_md_ctx; | ||
447 | unsigned char *clienthello_hash; | ||
448 | unsigned int clienthello_hash_len; | ||
449 | } SSL_HANDSHAKE_TLS13; | ||
450 | |||
413 | typedef struct ssl_handshake_st { | 451 | typedef struct ssl_handshake_st { |
414 | /* | 452 | /* |
415 | * Minimum and maximum versions supported for this handshake. These are | 453 | * Minimum and maximum versions supported for this handshake. These are |
@@ -428,6 +466,8 @@ typedef struct ssl_handshake_st { | |||
428 | */ | 466 | */ |
429 | uint16_t negotiated_tls_version; | 467 | uint16_t negotiated_tls_version; |
430 | 468 | ||
469 | SSL_HANDSHAKE_TLS13 tls13; | ||
470 | |||
431 | /* state contains one of the SSL3_ST_* values. */ | 471 | /* state contains one of the SSL3_ST_* values. */ |
432 | int state; | 472 | int state; |
433 | 473 | ||
@@ -449,44 +489,6 @@ typedef struct ssl_handshake_st { | |||
449 | uint8_t *sigalgs; | 489 | uint8_t *sigalgs; |
450 | } SSL_HANDSHAKE; | 490 | } SSL_HANDSHAKE; |
451 | 491 | ||
452 | typedef struct cert_pkey_st { | ||
453 | X509 *x509; | ||
454 | EVP_PKEY *privatekey; | ||
455 | STACK_OF(X509) *chain; | ||
456 | } CERT_PKEY; | ||
457 | |||
458 | typedef struct ssl_handshake_tls13_st { | ||
459 | int use_legacy; | ||
460 | int hrr; | ||
461 | |||
462 | /* Certificate and sigalg selected for use (static pointers). */ | ||
463 | const CERT_PKEY *cpk; | ||
464 | const struct ssl_sigalg *sigalg; | ||
465 | |||
466 | /* Version proposed by peer server. */ | ||
467 | uint16_t server_version; | ||
468 | |||
469 | uint16_t server_group; | ||
470 | struct tls13_key_share *key_share; | ||
471 | struct tls13_secrets *secrets; | ||
472 | |||
473 | uint8_t *cookie; | ||
474 | size_t cookie_len; | ||
475 | |||
476 | /* Preserved transcript hash. */ | ||
477 | uint8_t transcript_hash[EVP_MAX_MD_SIZE]; | ||
478 | size_t transcript_hash_len; | ||
479 | |||
480 | /* Legacy session ID. */ | ||
481 | uint8_t legacy_session_id[SSL_MAX_SSL_SESSION_ID_LENGTH]; | ||
482 | size_t legacy_session_id_len; | ||
483 | |||
484 | /* ClientHello hash, used to validate following HelloRetryRequest */ | ||
485 | EVP_MD_CTX *clienthello_md_ctx; | ||
486 | unsigned char *clienthello_hash; | ||
487 | unsigned int clienthello_hash_len; | ||
488 | } SSL_HANDSHAKE_TLS13; | ||
489 | |||
490 | struct tls12_record_layer; | 492 | struct tls12_record_layer; |
491 | 493 | ||
492 | struct tls12_record_layer *tls12_record_layer_new(void); | 494 | struct tls12_record_layer *tls12_record_layer_new(void); |
@@ -907,7 +909,6 @@ typedef struct ssl3_state_internal_st { | |||
907 | int in_read_app_data; | 909 | int in_read_app_data; |
908 | 910 | ||
909 | SSL_HANDSHAKE hs; | 911 | SSL_HANDSHAKE hs; |
910 | SSL_HANDSHAKE_TLS13 hs_tls13; | ||
911 | 912 | ||
912 | struct { | 913 | struct { |
913 | unsigned char cert_verify_md[EVP_MAX_MD_SIZE]; | 914 | unsigned char cert_verify_md[EVP_MAX_MD_SIZE]; |
diff --git a/src/lib/libssl/ssl_tlsext.c b/src/lib/libssl/ssl_tlsext.c index 4f4a39d4bb..5ffab919a2 100644 --- a/src/lib/libssl/ssl_tlsext.c +++ b/src/lib/libssl/ssl_tlsext.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_tlsext.c,v 1.87 2021/03/10 18:27:02 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_tlsext.c,v 1.88 2021/03/21 18:36:34 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2016, 2017, 2019 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2016, 2017, 2019 Joel Sing <jsing@openbsd.org> |
4 | * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> | 4 | * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> |
@@ -226,7 +226,7 @@ tlsext_supportedgroups_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, | |||
226 | uint16_t *groups; | 226 | uint16_t *groups; |
227 | int i; | 227 | int i; |
228 | 228 | ||
229 | if (S3I(s)->hs_tls13.hrr) { | 229 | if (S3I(s)->hs.tls13.hrr) { |
230 | if (SSI(s)->tlsext_supportedgroups == NULL) { | 230 | if (SSI(s)->tlsext_supportedgroups == NULL) { |
231 | *alert = SSL_AD_HANDSHAKE_FAILURE; | 231 | *alert = SSL_AD_HANDSHAKE_FAILURE; |
232 | return 0; | 232 | return 0; |
@@ -759,7 +759,7 @@ tlsext_sni_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
759 | goto err; | 759 | goto err; |
760 | } | 760 | } |
761 | 761 | ||
762 | if (s->internal->hit || S3I(s)->hs_tls13.hrr) { | 762 | if (s->internal->hit || S3I(s)->hs.tls13.hrr) { |
763 | if (s->session->tlsext_hostname == NULL) { | 763 | if (s->session->tlsext_hostname == NULL) { |
764 | *alert = TLS1_AD_UNRECOGNIZED_NAME; | 764 | *alert = TLS1_AD_UNRECOGNIZED_NAME; |
765 | goto err; | 765 | goto err; |
@@ -1416,7 +1416,7 @@ tlsext_keyshare_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | |||
1416 | if (!CBB_add_u16_length_prefixed(cbb, &client_shares)) | 1416 | if (!CBB_add_u16_length_prefixed(cbb, &client_shares)) |
1417 | return 0; | 1417 | return 0; |
1418 | 1418 | ||
1419 | if (!tls13_key_share_public(S3I(s)->hs_tls13.key_share, | 1419 | if (!tls13_key_share_public(S3I(s)->hs.tls13.key_share, |
1420 | &client_shares)) | 1420 | &client_shares)) |
1421 | return 0; | 1421 | return 0; |
1422 | 1422 | ||
@@ -1454,7 +1454,7 @@ tlsext_keyshare_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
1454 | */ | 1454 | */ |
1455 | if (S3I(s)->hs.our_max_tls_version < TLS1_3_VERSION) | 1455 | if (S3I(s)->hs.our_max_tls_version < TLS1_3_VERSION) |
1456 | continue; | 1456 | continue; |
1457 | if (S3I(s)->hs_tls13.key_share != NULL) | 1457 | if (S3I(s)->hs.tls13.key_share != NULL) |
1458 | continue; | 1458 | continue; |
1459 | 1459 | ||
1460 | /* XXX - consider implementing server preference. */ | 1460 | /* XXX - consider implementing server preference. */ |
@@ -1462,10 +1462,10 @@ tlsext_keyshare_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
1462 | continue; | 1462 | continue; |
1463 | 1463 | ||
1464 | /* Decode and store the selected key share. */ | 1464 | /* Decode and store the selected key share. */ |
1465 | S3I(s)->hs_tls13.key_share = tls13_key_share_new(group); | 1465 | S3I(s)->hs.tls13.key_share = tls13_key_share_new(group); |
1466 | if (S3I(s)->hs_tls13.key_share == NULL) | 1466 | if (S3I(s)->hs.tls13.key_share == NULL) |
1467 | goto err; | 1467 | goto err; |
1468 | if (!tls13_key_share_peer_public(S3I(s)->hs_tls13.key_share, | 1468 | if (!tls13_key_share_peer_public(S3I(s)->hs.tls13.key_share, |
1469 | group, &key_exchange)) | 1469 | group, &key_exchange)) |
1470 | goto err; | 1470 | goto err; |
1471 | } | 1471 | } |
@@ -1488,16 +1488,16 @@ int | |||
1488 | tlsext_keyshare_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | 1488 | tlsext_keyshare_server_build(SSL *s, uint16_t msg_type, CBB *cbb) |
1489 | { | 1489 | { |
1490 | /* In the case of a HRR, we only send the server selected group. */ | 1490 | /* In the case of a HRR, we only send the server selected group. */ |
1491 | if (S3I(s)->hs_tls13.hrr) { | 1491 | if (S3I(s)->hs.tls13.hrr) { |
1492 | if (S3I(s)->hs_tls13.server_group == 0) | 1492 | if (S3I(s)->hs.tls13.server_group == 0) |
1493 | return 0; | 1493 | return 0; |
1494 | return CBB_add_u16(cbb, S3I(s)->hs_tls13.server_group); | 1494 | return CBB_add_u16(cbb, S3I(s)->hs.tls13.server_group); |
1495 | } | 1495 | } |
1496 | 1496 | ||
1497 | if (S3I(s)->hs_tls13.key_share == NULL) | 1497 | if (S3I(s)->hs.tls13.key_share == NULL) |
1498 | return 0; | 1498 | return 0; |
1499 | 1499 | ||
1500 | if (!tls13_key_share_public(S3I(s)->hs_tls13.key_share, cbb)) | 1500 | if (!tls13_key_share_public(S3I(s)->hs.tls13.key_share, cbb)) |
1501 | return 0; | 1501 | return 0; |
1502 | 1502 | ||
1503 | return 1; | 1503 | return 1; |
@@ -1516,17 +1516,17 @@ tlsext_keyshare_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
1516 | if (CBS_len(cbs) == 0) { | 1516 | if (CBS_len(cbs) == 0) { |
1517 | /* HRR does not include an actual key share. */ | 1517 | /* HRR does not include an actual key share. */ |
1518 | /* XXX - we should know that we are in a HRR... */ | 1518 | /* XXX - we should know that we are in a HRR... */ |
1519 | S3I(s)->hs_tls13.server_group = group; | 1519 | S3I(s)->hs.tls13.server_group = group; |
1520 | return 1; | 1520 | return 1; |
1521 | } | 1521 | } |
1522 | 1522 | ||
1523 | if (!CBS_get_u16_length_prefixed(cbs, &key_exchange)) | 1523 | if (!CBS_get_u16_length_prefixed(cbs, &key_exchange)) |
1524 | return 0; | 1524 | return 0; |
1525 | 1525 | ||
1526 | if (S3I(s)->hs_tls13.key_share == NULL) | 1526 | if (S3I(s)->hs.tls13.key_share == NULL) |
1527 | return 0; | 1527 | return 0; |
1528 | 1528 | ||
1529 | if (!tls13_key_share_peer_public(S3I(s)->hs_tls13.key_share, | 1529 | if (!tls13_key_share_peer_public(S3I(s)->hs.tls13.key_share, |
1530 | group, &key_exchange)) | 1530 | group, &key_exchange)) |
1531 | goto err; | 1531 | goto err; |
1532 | 1532 | ||
@@ -1639,7 +1639,7 @@ tlsext_versions_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
1639 | } | 1639 | } |
1640 | 1640 | ||
1641 | /* XXX test between min and max once initialization code goes in */ | 1641 | /* XXX test between min and max once initialization code goes in */ |
1642 | S3I(s)->hs_tls13.server_version = selected_version; | 1642 | S3I(s)->hs.tls13.server_version = selected_version; |
1643 | 1643 | ||
1644 | return 1; | 1644 | return 1; |
1645 | } | 1645 | } |
@@ -1653,7 +1653,7 @@ int | |||
1653 | tlsext_cookie_client_needs(SSL *s, uint16_t msg_type) | 1653 | tlsext_cookie_client_needs(SSL *s, uint16_t msg_type) |
1654 | { | 1654 | { |
1655 | return (S3I(s)->hs.our_max_tls_version >= TLS1_3_VERSION && | 1655 | return (S3I(s)->hs.our_max_tls_version >= TLS1_3_VERSION && |
1656 | S3I(s)->hs_tls13.cookie_len > 0 && S3I(s)->hs_tls13.cookie != NULL); | 1656 | S3I(s)->hs.tls13.cookie_len > 0 && S3I(s)->hs.tls13.cookie != NULL); |
1657 | } | 1657 | } |
1658 | 1658 | ||
1659 | int | 1659 | int |
@@ -1664,8 +1664,8 @@ tlsext_cookie_client_build(SSL *s, uint16_t msg_type, CBB *cbb) | |||
1664 | if (!CBB_add_u16_length_prefixed(cbb, &cookie)) | 1664 | if (!CBB_add_u16_length_prefixed(cbb, &cookie)) |
1665 | return 0; | 1665 | return 0; |
1666 | 1666 | ||
1667 | if (!CBB_add_bytes(&cookie, S3I(s)->hs_tls13.cookie, | 1667 | if (!CBB_add_bytes(&cookie, S3I(s)->hs.tls13.cookie, |
1668 | S3I(s)->hs_tls13.cookie_len)) | 1668 | S3I(s)->hs.tls13.cookie_len)) |
1669 | return 0; | 1669 | return 0; |
1670 | 1670 | ||
1671 | if (!CBB_flush(cbb)) | 1671 | if (!CBB_flush(cbb)) |
@@ -1682,7 +1682,7 @@ tlsext_cookie_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
1682 | if (!CBS_get_u16_length_prefixed(cbs, &cookie)) | 1682 | if (!CBS_get_u16_length_prefixed(cbs, &cookie)) |
1683 | goto err; | 1683 | goto err; |
1684 | 1684 | ||
1685 | if (CBS_len(&cookie) != S3I(s)->hs_tls13.cookie_len) | 1685 | if (CBS_len(&cookie) != S3I(s)->hs.tls13.cookie_len) |
1686 | goto err; | 1686 | goto err; |
1687 | 1687 | ||
1688 | /* | 1688 | /* |
@@ -1690,8 +1690,8 @@ tlsext_cookie_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
1690 | * sent - client *MUST* send the same cookie with new CR after | 1690 | * sent - client *MUST* send the same cookie with new CR after |
1691 | * a cookie is sent by the server with an HRR. | 1691 | * a cookie is sent by the server with an HRR. |
1692 | */ | 1692 | */ |
1693 | if (!CBS_mem_equal(&cookie, S3I(s)->hs_tls13.cookie, | 1693 | if (!CBS_mem_equal(&cookie, S3I(s)->hs.tls13.cookie, |
1694 | S3I(s)->hs_tls13.cookie_len)) { | 1694 | S3I(s)->hs.tls13.cookie_len)) { |
1695 | /* XXX special cookie mismatch alert? */ | 1695 | /* XXX special cookie mismatch alert? */ |
1696 | *alert = SSL_AD_ILLEGAL_PARAMETER; | 1696 | *alert = SSL_AD_ILLEGAL_PARAMETER; |
1697 | return 0; | 1697 | return 0; |
@@ -1712,7 +1712,7 @@ tlsext_cookie_server_needs(SSL *s, uint16_t msg_type) | |||
1712 | * in order to send one, should only be sent with HRR. | 1712 | * in order to send one, should only be sent with HRR. |
1713 | */ | 1713 | */ |
1714 | return (S3I(s)->hs.our_max_tls_version >= TLS1_3_VERSION && | 1714 | return (S3I(s)->hs.our_max_tls_version >= TLS1_3_VERSION && |
1715 | S3I(s)->hs_tls13.cookie_len > 0 && S3I(s)->hs_tls13.cookie != NULL); | 1715 | S3I(s)->hs.tls13.cookie_len > 0 && S3I(s)->hs.tls13.cookie != NULL); |
1716 | } | 1716 | } |
1717 | 1717 | ||
1718 | int | 1718 | int |
@@ -1725,8 +1725,8 @@ tlsext_cookie_server_build(SSL *s, uint16_t msg_type, CBB *cbb) | |||
1725 | if (!CBB_add_u16_length_prefixed(cbb, &cookie)) | 1725 | if (!CBB_add_u16_length_prefixed(cbb, &cookie)) |
1726 | return 0; | 1726 | return 0; |
1727 | 1727 | ||
1728 | if (!CBB_add_bytes(&cookie, S3I(s)->hs_tls13.cookie, | 1728 | if (!CBB_add_bytes(&cookie, S3I(s)->hs.tls13.cookie, |
1729 | S3I(s)->hs_tls13.cookie_len)) | 1729 | S3I(s)->hs.tls13.cookie_len)) |
1730 | return 0; | 1730 | return 0; |
1731 | 1731 | ||
1732 | if (!CBB_flush(cbb)) | 1732 | if (!CBB_flush(cbb)) |
@@ -1745,8 +1745,8 @@ tlsext_cookie_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
1745 | * HRR from a server with a cookie to process after accepting | 1745 | * HRR from a server with a cookie to process after accepting |
1746 | * one from the server in the same handshake | 1746 | * one from the server in the same handshake |
1747 | */ | 1747 | */ |
1748 | if (S3I(s)->hs_tls13.cookie != NULL || | 1748 | if (S3I(s)->hs.tls13.cookie != NULL || |
1749 | S3I(s)->hs_tls13.cookie_len != 0) { | 1749 | S3I(s)->hs.tls13.cookie_len != 0) { |
1750 | *alert = SSL_AD_ILLEGAL_PARAMETER; | 1750 | *alert = SSL_AD_ILLEGAL_PARAMETER; |
1751 | return 0; | 1751 | return 0; |
1752 | } | 1752 | } |
@@ -1754,8 +1754,8 @@ tlsext_cookie_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) | |||
1754 | if (!CBS_get_u16_length_prefixed(cbs, &cookie)) | 1754 | if (!CBS_get_u16_length_prefixed(cbs, &cookie)) |
1755 | goto err; | 1755 | goto err; |
1756 | 1756 | ||
1757 | if (!CBS_stow(&cookie, &S3I(s)->hs_tls13.cookie, | 1757 | if (!CBS_stow(&cookie, &S3I(s)->hs.tls13.cookie, |
1758 | &S3I(s)->hs_tls13.cookie_len)) | 1758 | &S3I(s)->hs.tls13.cookie_len)) |
1759 | goto err; | 1759 | goto err; |
1760 | 1760 | ||
1761 | return 1; | 1761 | return 1; |
diff --git a/src/lib/libssl/tls13_client.c b/src/lib/libssl/tls13_client.c index 4de3d3693b..0f3d435c94 100644 --- a/src/lib/libssl/tls13_client.c +++ b/src/lib/libssl/tls13_client.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls13_client.c,v 1.74 2021/03/10 18:27:02 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_client.c,v 1.75 2021/03/21 18:36:34 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -31,12 +31,12 @@ tls13_client_init(struct tls13_ctx *ctx) | |||
31 | size_t groups_len; | 31 | size_t groups_len; |
32 | SSL *s = ctx->ssl; | 32 | SSL *s = ctx->ssl; |
33 | 33 | ||
34 | if (!ssl_supported_tls_version_range(s, &S3I(s)->hs.our_min_tls_version, | 34 | if (!ssl_supported_tls_version_range(s, &ctx->hs->our_min_tls_version, |
35 | &S3I(s)->hs.our_max_tls_version)) { | 35 | &ctx->hs->our_max_tls_version)) { |
36 | SSLerror(s, SSL_R_NO_PROTOCOLS_AVAILABLE); | 36 | SSLerror(s, SSL_R_NO_PROTOCOLS_AVAILABLE); |
37 | return 0; | 37 | return 0; |
38 | } | 38 | } |
39 | s->client_version = s->version = S3I(s)->hs.our_max_tls_version; | 39 | s->client_version = s->version = ctx->hs->our_max_tls_version; |
40 | 40 | ||
41 | tls13_record_layer_set_retry_after_phh(ctx->rl, | 41 | tls13_record_layer_set_retry_after_phh(ctx->rl, |
42 | (s->internal->mode & SSL_MODE_AUTO_RETRY) != 0); | 42 | (s->internal->mode & SSL_MODE_AUTO_RETRY) != 0); |
@@ -51,9 +51,9 @@ tls13_client_init(struct tls13_ctx *ctx) | |||
51 | tls1_get_group_list(s, 0, &groups, &groups_len); | 51 | tls1_get_group_list(s, 0, &groups, &groups_len); |
52 | if (groups_len < 1) | 52 | if (groups_len < 1) |
53 | return 0; | 53 | return 0; |
54 | if ((ctx->hs->key_share = tls13_key_share_new(groups[0])) == NULL) | 54 | if ((ctx->hs->tls13.key_share = tls13_key_share_new(groups[0])) == NULL) |
55 | return 0; | 55 | return 0; |
56 | if (!tls13_key_share_generate(ctx->hs->key_share)) | 56 | if (!tls13_key_share_generate(ctx->hs->tls13.key_share)) |
57 | return 0; | 57 | return 0; |
58 | 58 | ||
59 | arc4random_buf(s->s3->client_random, SSL3_RANDOM_SIZE); | 59 | arc4random_buf(s->s3->client_random, SSL3_RANDOM_SIZE); |
@@ -65,11 +65,11 @@ tls13_client_init(struct tls13_ctx *ctx) | |||
65 | * Appendix D.4). In the pre-TLSv1.3 case a zero length value is used. | 65 | * Appendix D.4). In the pre-TLSv1.3 case a zero length value is used. |
66 | */ | 66 | */ |
67 | if (ctx->middlebox_compat && | 67 | if (ctx->middlebox_compat && |
68 | S3I(s)->hs.our_max_tls_version >= TLS1_3_VERSION) { | 68 | ctx->hs->our_max_tls_version >= TLS1_3_VERSION) { |
69 | arc4random_buf(ctx->hs->legacy_session_id, | 69 | arc4random_buf(ctx->hs->tls13.legacy_session_id, |
70 | sizeof(ctx->hs->legacy_session_id)); | 70 | sizeof(ctx->hs->tls13.legacy_session_id)); |
71 | ctx->hs->legacy_session_id_len = | 71 | ctx->hs->tls13.legacy_session_id_len = |
72 | sizeof(ctx->hs->legacy_session_id); | 72 | sizeof(ctx->hs->tls13.legacy_session_id); |
73 | } | 73 | } |
74 | 74 | ||
75 | return 1; | 75 | return 1; |
@@ -92,7 +92,7 @@ tls13_client_hello_build(struct tls13_ctx *ctx, CBB *cbb) | |||
92 | SSL *s = ctx->ssl; | 92 | SSL *s = ctx->ssl; |
93 | 93 | ||
94 | /* Legacy client version is capped at TLS 1.2. */ | 94 | /* Legacy client version is capped at TLS 1.2. */ |
95 | client_version = S3I(s)->hs.our_max_tls_version; | 95 | client_version = ctx->hs->our_max_tls_version; |
96 | if (client_version > TLS1_2_VERSION) | 96 | if (client_version > TLS1_2_VERSION) |
97 | client_version = TLS1_2_VERSION; | 97 | client_version = TLS1_2_VERSION; |
98 | 98 | ||
@@ -103,8 +103,8 @@ tls13_client_hello_build(struct tls13_ctx *ctx, CBB *cbb) | |||
103 | 103 | ||
104 | if (!CBB_add_u8_length_prefixed(cbb, &session_id)) | 104 | if (!CBB_add_u8_length_prefixed(cbb, &session_id)) |
105 | goto err; | 105 | goto err; |
106 | if (!CBB_add_bytes(&session_id, ctx->hs->legacy_session_id, | 106 | if (!CBB_add_bytes(&session_id, ctx->hs->tls13.legacy_session_id, |
107 | ctx->hs->legacy_session_id_len)) | 107 | ctx->hs->tls13.legacy_session_id_len)) |
108 | goto err; | 108 | goto err; |
109 | 109 | ||
110 | if (!CBB_add_u16_length_prefixed(cbb, &cipher_suites)) | 110 | if (!CBB_add_u16_length_prefixed(cbb, &cipher_suites)) |
@@ -134,9 +134,7 @@ tls13_client_hello_build(struct tls13_ctx *ctx, CBB *cbb) | |||
134 | int | 134 | int |
135 | tls13_client_hello_send(struct tls13_ctx *ctx, CBB *cbb) | 135 | tls13_client_hello_send(struct tls13_ctx *ctx, CBB *cbb) |
136 | { | 136 | { |
137 | SSL *s = ctx->ssl; | 137 | if (ctx->hs->our_min_tls_version < TLS1_2_VERSION) |
138 | |||
139 | if (S3I(s)->hs.our_min_tls_version < TLS1_2_VERSION) | ||
140 | tls13_record_layer_set_legacy_version(ctx->rl, TLS1_VERSION); | 138 | tls13_record_layer_set_legacy_version(ctx->rl, TLS1_VERSION); |
141 | 139 | ||
142 | /* We may receive a pre-TLSv1.3 alert in response to the client hello. */ | 140 | /* We may receive a pre-TLSv1.3 alert in response to the client hello. */ |
@@ -231,7 +229,7 @@ tls13_server_hello_process(struct tls13_ctx *ctx, CBS *cbs) | |||
231 | goto err; | 229 | goto err; |
232 | 230 | ||
233 | if (tls13_server_hello_is_legacy(cbs)) { | 231 | if (tls13_server_hello_is_legacy(cbs)) { |
234 | if (S3I(s)->hs.our_max_tls_version >= TLS1_3_VERSION) { | 232 | if (ctx->hs->our_max_tls_version >= TLS1_3_VERSION) { |
235 | /* | 233 | /* |
236 | * RFC 8446 section 4.1.3: we must not downgrade if | 234 | * RFC 8446 section 4.1.3: we must not downgrade if |
237 | * the server random value contains the TLS 1.2 or 1.1 | 235 | * the server random value contains the TLS 1.2 or 1.1 |
@@ -252,7 +250,7 @@ tls13_server_hello_process(struct tls13_ctx *ctx, CBS *cbs) | |||
252 | if (!CBS_skip(cbs, CBS_len(cbs))) | 250 | if (!CBS_skip(cbs, CBS_len(cbs))) |
253 | goto err; | 251 | goto err; |
254 | 252 | ||
255 | ctx->hs->use_legacy = 1; | 253 | ctx->hs->tls13.use_legacy = 1; |
256 | return 1; | 254 | return 1; |
257 | } | 255 | } |
258 | 256 | ||
@@ -265,7 +263,7 @@ tls13_server_hello_process(struct tls13_ctx *ctx, CBS *cbs) | |||
265 | if (CBS_mem_equal(&server_random, tls13_hello_retry_request_hash, | 263 | if (CBS_mem_equal(&server_random, tls13_hello_retry_request_hash, |
266 | sizeof(tls13_hello_retry_request_hash))) { | 264 | sizeof(tls13_hello_retry_request_hash))) { |
267 | tlsext_msg_type = SSL_TLSEXT_MSG_HRR; | 265 | tlsext_msg_type = SSL_TLSEXT_MSG_HRR; |
268 | ctx->hs->hrr = 1; | 266 | ctx->hs->tls13.hrr = 1; |
269 | } | 267 | } |
270 | 268 | ||
271 | if (!tlsext_client_parse(s, tlsext_msg_type, cbs, &alert_desc)) { | 269 | if (!tlsext_client_parse(s, tlsext_msg_type, cbs, &alert_desc)) { |
@@ -278,16 +276,16 @@ tls13_server_hello_process(struct tls13_ctx *ctx, CBS *cbs) | |||
278 | * Ensure that it was 0x0304 and that legacy version is set to 0x0303 | 276 | * Ensure that it was 0x0304 and that legacy version is set to 0x0303 |
279 | * (RFC 8446 section 4.2.1). | 277 | * (RFC 8446 section 4.2.1). |
280 | */ | 278 | */ |
281 | if (ctx->hs->server_version != TLS1_3_VERSION || | 279 | if (ctx->hs->tls13.server_version != TLS1_3_VERSION || |
282 | legacy_version != TLS1_2_VERSION) { | 280 | legacy_version != TLS1_2_VERSION) { |
283 | ctx->alert = TLS13_ALERT_PROTOCOL_VERSION; | 281 | ctx->alert = TLS13_ALERT_PROTOCOL_VERSION; |
284 | goto err; | 282 | goto err; |
285 | } | 283 | } |
286 | S3I(s)->hs.negotiated_tls_version = ctx->hs->server_version; | 284 | ctx->hs->negotiated_tls_version = ctx->hs->tls13.server_version; |
287 | 285 | ||
288 | /* The session_id must match. */ | 286 | /* The session_id must match. */ |
289 | if (!CBS_mem_equal(&session_id, ctx->hs->legacy_session_id, | 287 | if (!CBS_mem_equal(&session_id, ctx->hs->tls13.legacy_session_id, |
290 | ctx->hs->legacy_session_id_len)) { | 288 | ctx->hs->tls13.legacy_session_id_len)) { |
291 | ctx->alert = TLS13_ALERT_ILLEGAL_PARAMETER; | 289 | ctx->alert = TLS13_ALERT_ILLEGAL_PARAMETER; |
292 | goto err; | 290 | goto err; |
293 | } | 291 | } |
@@ -305,8 +303,8 @@ tls13_server_hello_process(struct tls13_ctx *ctx, CBS *cbs) | |||
305 | ctx->alert = TLS13_ALERT_ILLEGAL_PARAMETER; | 303 | ctx->alert = TLS13_ALERT_ILLEGAL_PARAMETER; |
306 | goto err; | 304 | goto err; |
307 | } | 305 | } |
308 | /* XXX - move this to hs_tls13? */ | 306 | /* XXX - move this to hs.tls13? */ |
309 | S3I(s)->hs.new_cipher = cipher; | 307 | ctx->hs->new_cipher = cipher; |
310 | 308 | ||
311 | if (compression_method != 0) { | 309 | if (compression_method != 0) { |
312 | ctx->alert = TLS13_ALERT_ILLEGAL_PARAMETER; | 310 | ctx->alert = TLS13_ALERT_ILLEGAL_PARAMETER; |
@@ -336,21 +334,21 @@ tls13_client_engage_record_protection(struct tls13_ctx *ctx) | |||
336 | 334 | ||
337 | /* Derive the shared key and engage record protection. */ | 335 | /* Derive the shared key and engage record protection. */ |
338 | 336 | ||
339 | if (!tls13_key_share_derive(ctx->hs->key_share, &shared_key, | 337 | if (!tls13_key_share_derive(ctx->hs->tls13.key_share, &shared_key, |
340 | &shared_key_len)) | 338 | &shared_key_len)) |
341 | goto err; | 339 | goto err; |
342 | 340 | ||
343 | s->session->cipher = S3I(s)->hs.new_cipher; | 341 | s->session->cipher = ctx->hs->new_cipher; |
344 | s->session->ssl_version = ctx->hs->server_version; | 342 | s->session->ssl_version = ctx->hs->tls13.server_version; |
345 | 343 | ||
346 | if ((ctx->aead = tls13_cipher_aead(S3I(s)->hs.new_cipher)) == NULL) | 344 | if ((ctx->aead = tls13_cipher_aead(ctx->hs->new_cipher)) == NULL) |
347 | goto err; | 345 | goto err; |
348 | if ((ctx->hash = tls13_cipher_hash(S3I(s)->hs.new_cipher)) == NULL) | 346 | if ((ctx->hash = tls13_cipher_hash(ctx->hs->new_cipher)) == NULL) |
349 | goto err; | 347 | goto err; |
350 | 348 | ||
351 | if ((secrets = tls13_secrets_create(ctx->hash, 0)) == NULL) | 349 | if ((secrets = tls13_secrets_create(ctx->hash, 0)) == NULL) |
352 | goto err; | 350 | goto err; |
353 | ctx->hs->secrets = secrets; | 351 | ctx->hs->tls13.secrets = secrets; |
354 | 352 | ||
355 | /* XXX - pass in hash. */ | 353 | /* XXX - pass in hash. */ |
356 | if (!tls1_transcript_hash_init(s)) | 354 | if (!tls1_transcript_hash_init(s)) |
@@ -367,7 +365,7 @@ tls13_client_engage_record_protection(struct tls13_ctx *ctx) | |||
367 | goto err; | 365 | goto err; |
368 | 366 | ||
369 | /* Handshake secrets. */ | 367 | /* Handshake secrets. */ |
370 | if (!tls13_derive_handshake_secrets(ctx->hs->secrets, shared_key, | 368 | if (!tls13_derive_handshake_secrets(ctx->hs->tls13.secrets, shared_key, |
371 | shared_key_len, &context)) | 369 | shared_key_len, &context)) |
372 | goto err; | 370 | goto err; |
373 | 371 | ||
@@ -409,10 +407,10 @@ tls13_server_hello_retry_request_recv(struct tls13_ctx *ctx, CBS *cbs) | |||
409 | * This may have been a TLSv1.2 or earlier ServerHello that just happened | 407 | * This may have been a TLSv1.2 or earlier ServerHello that just happened |
410 | * to have matching server random... | 408 | * to have matching server random... |
411 | */ | 409 | */ |
412 | if (ctx->hs->use_legacy) | 410 | if (ctx->hs->tls13.use_legacy) |
413 | return tls13_use_legacy_client(ctx); | 411 | return tls13_use_legacy_client(ctx); |
414 | 412 | ||
415 | if (!ctx->hs->hrr) | 413 | if (!ctx->hs->tls13.hrr) |
416 | return 0; | 414 | return 0; |
417 | 415 | ||
418 | if (!tls13_synthetic_handshake_message(ctx)) | 416 | if (!tls13_synthetic_handshake_message(ctx)) |
@@ -420,7 +418,7 @@ tls13_server_hello_retry_request_recv(struct tls13_ctx *ctx, CBS *cbs) | |||
420 | if (!tls13_handshake_msg_record(ctx)) | 418 | if (!tls13_handshake_msg_record(ctx)) |
421 | return 0; | 419 | return 0; |
422 | 420 | ||
423 | ctx->hs->hrr = 0; | 421 | ctx->hs->tls13.hrr = 0; |
424 | 422 | ||
425 | return 1; | 423 | return 1; |
426 | } | 424 | } |
@@ -433,17 +431,17 @@ tls13_client_hello_retry_send(struct tls13_ctx *ctx, CBB *cbb) | |||
433 | * supported groups and is not the same as the key share we previously | 431 | * supported groups and is not the same as the key share we previously |
434 | * offered. | 432 | * offered. |
435 | */ | 433 | */ |
436 | if (!tls1_check_curve(ctx->ssl, ctx->hs->server_group)) | 434 | if (!tls1_check_curve(ctx->ssl, ctx->hs->tls13.server_group)) |
437 | return 0; /* XXX alert */ | 435 | return 0; /* XXX alert */ |
438 | if (ctx->hs->server_group == tls13_key_share_group(ctx->hs->key_share)) | 436 | if (ctx->hs->tls13.server_group == tls13_key_share_group(ctx->hs->tls13.key_share)) |
439 | return 0; /* XXX alert */ | 437 | return 0; /* XXX alert */ |
440 | 438 | ||
441 | /* Switch to new key share. */ | 439 | /* Switch to new key share. */ |
442 | tls13_key_share_free(ctx->hs->key_share); | 440 | tls13_key_share_free(ctx->hs->tls13.key_share); |
443 | if ((ctx->hs->key_share = | 441 | if ((ctx->hs->tls13.key_share = |
444 | tls13_key_share_new(ctx->hs->server_group)) == NULL) | 442 | tls13_key_share_new(ctx->hs->tls13.server_group)) == NULL) |
445 | return 0; | 443 | return 0; |
446 | if (!tls13_key_share_generate(ctx->hs->key_share)) | 444 | if (!tls13_key_share_generate(ctx->hs->tls13.key_share)) |
447 | return 0; | 445 | return 0; |
448 | 446 | ||
449 | if (!tls13_client_hello_build(ctx, cbb)) | 447 | if (!tls13_client_hello_build(ctx, cbb)) |
@@ -470,13 +468,13 @@ tls13_server_hello_recv(struct tls13_ctx *ctx, CBS *cbs) | |||
470 | return 0; | 468 | return 0; |
471 | } | 469 | } |
472 | 470 | ||
473 | if (ctx->hs->use_legacy) { | 471 | if (ctx->hs->tls13.use_legacy) { |
474 | if (!(ctx->handshake_stage.hs_type & WITHOUT_HRR)) | 472 | if (!(ctx->handshake_stage.hs_type & WITHOUT_HRR)) |
475 | return 0; | 473 | return 0; |
476 | return tls13_use_legacy_client(ctx); | 474 | return tls13_use_legacy_client(ctx); |
477 | } | 475 | } |
478 | 476 | ||
479 | if (ctx->hs->hrr) { | 477 | if (ctx->hs->tls13.hrr) { |
480 | /* The server has sent two HelloRetryRequests. */ | 478 | /* The server has sent two HelloRetryRequests. */ |
481 | ctx->alert = TLS13_ALERT_ILLEGAL_PARAMETER; | 479 | ctx->alert = TLS13_ALERT_ILLEGAL_PARAMETER; |
482 | return 0; | 480 | return 0; |
@@ -687,8 +685,8 @@ tls13_server_certificate_verify_recv(struct tls13_ctx *ctx, CBS *cbs) | |||
687 | goto err; | 685 | goto err; |
688 | if (!CBB_add_u8(&cbb, 0)) | 686 | if (!CBB_add_u8(&cbb, 0)) |
689 | goto err; | 687 | goto err; |
690 | if (!CBB_add_bytes(&cbb, ctx->hs->transcript_hash, | 688 | if (!CBB_add_bytes(&cbb, ctx->hs->tls13.transcript_hash, |
691 | ctx->hs->transcript_hash_len)) | 689 | ctx->hs->tls13.transcript_hash_len)) |
692 | goto err; | 690 | goto err; |
693 | if (!CBB_finish(&cbb, &sig_content, &sig_content_len)) | 691 | if (!CBB_finish(&cbb, &sig_content, &sig_content_len)) |
694 | goto err; | 692 | goto err; |
@@ -738,7 +736,7 @@ tls13_server_certificate_verify_recv(struct tls13_ctx *ctx, CBS *cbs) | |||
738 | int | 736 | int |
739 | tls13_server_finished_recv(struct tls13_ctx *ctx, CBS *cbs) | 737 | tls13_server_finished_recv(struct tls13_ctx *ctx, CBS *cbs) |
740 | { | 738 | { |
741 | struct tls13_secrets *secrets = ctx->hs->secrets; | 739 | struct tls13_secrets *secrets = ctx->hs->tls13.secrets; |
742 | struct tls13_secret context = { .data = "", .len = 0 }; | 740 | struct tls13_secret context = { .data = "", .len = 0 }; |
743 | struct tls13_secret finished_key; | 741 | struct tls13_secret finished_key; |
744 | uint8_t transcript_hash[EVP_MAX_MD_SIZE]; | 742 | uint8_t transcript_hash[EVP_MAX_MD_SIZE]; |
@@ -767,8 +765,8 @@ tls13_server_finished_recv(struct tls13_ctx *ctx, CBS *cbs) | |||
767 | if (!HMAC_Init_ex(hmac_ctx, finished_key.data, finished_key.len, | 765 | if (!HMAC_Init_ex(hmac_ctx, finished_key.data, finished_key.len, |
768 | ctx->hash, NULL)) | 766 | ctx->hash, NULL)) |
769 | goto err; | 767 | goto err; |
770 | if (!HMAC_Update(hmac_ctx, ctx->hs->transcript_hash, | 768 | if (!HMAC_Update(hmac_ctx, ctx->hs->tls13.transcript_hash, |
771 | ctx->hs->transcript_hash_len)) | 769 | ctx->hs->tls13.transcript_hash_len)) |
772 | goto err; | 770 | goto err; |
773 | verify_data_len = HMAC_size(hmac_ctx); | 771 | verify_data_len = HMAC_size(hmac_ctx); |
774 | if ((verify_data = calloc(1, verify_data_len)) == NULL) | 772 | if ((verify_data = calloc(1, verify_data_len)) == NULL) |
@@ -900,8 +898,8 @@ tls13_client_certificate_send(struct tls13_ctx *ctx, CBB *cbb) | |||
900 | if (!tls13_client_select_certificate(ctx, &cpk, &sigalg)) | 898 | if (!tls13_client_select_certificate(ctx, &cpk, &sigalg)) |
901 | goto err; | 899 | goto err; |
902 | 900 | ||
903 | ctx->hs->cpk = cpk; | 901 | ctx->hs->tls13.cpk = cpk; |
904 | ctx->hs->sigalg = sigalg; | 902 | ctx->hs->tls13.sigalg = sigalg; |
905 | 903 | ||
906 | if (!CBB_add_u8_length_prefixed(cbb, &cert_request_context)) | 904 | if (!CBB_add_u8_length_prefixed(cbb, &cert_request_context)) |
907 | goto err; | 905 | goto err; |
@@ -950,9 +948,9 @@ tls13_client_certificate_verify_send(struct tls13_ctx *ctx, CBB *cbb) | |||
950 | 948 | ||
951 | memset(&sig_cbb, 0, sizeof(sig_cbb)); | 949 | memset(&sig_cbb, 0, sizeof(sig_cbb)); |
952 | 950 | ||
953 | if ((cpk = ctx->hs->cpk) == NULL) | 951 | if ((cpk = ctx->hs->tls13.cpk) == NULL) |
954 | goto err; | 952 | goto err; |
955 | if ((sigalg = ctx->hs->sigalg) == NULL) | 953 | if ((sigalg = ctx->hs->tls13.sigalg) == NULL) |
956 | goto err; | 954 | goto err; |
957 | pkey = cpk->privatekey; | 955 | pkey = cpk->privatekey; |
958 | 956 | ||
@@ -966,8 +964,8 @@ tls13_client_certificate_verify_send(struct tls13_ctx *ctx, CBB *cbb) | |||
966 | goto err; | 964 | goto err; |
967 | if (!CBB_add_u8(&sig_cbb, 0)) | 965 | if (!CBB_add_u8(&sig_cbb, 0)) |
968 | goto err; | 966 | goto err; |
969 | if (!CBB_add_bytes(&sig_cbb, ctx->hs->transcript_hash, | 967 | if (!CBB_add_bytes(&sig_cbb, ctx->hs->tls13.transcript_hash, |
970 | ctx->hs->transcript_hash_len)) | 968 | ctx->hs->tls13.transcript_hash_len)) |
971 | goto err; | 969 | goto err; |
972 | if (!CBB_finish(&sig_cbb, &sig_content, &sig_content_len)) | 970 | if (!CBB_finish(&sig_cbb, &sig_content, &sig_content_len)) |
973 | goto err; | 971 | goto err; |
@@ -1024,7 +1022,7 @@ tls13_client_end_of_early_data_send(struct tls13_ctx *ctx, CBB *cbb) | |||
1024 | int | 1022 | int |
1025 | tls13_client_finished_send(struct tls13_ctx *ctx, CBB *cbb) | 1023 | tls13_client_finished_send(struct tls13_ctx *ctx, CBB *cbb) |
1026 | { | 1024 | { |
1027 | struct tls13_secrets *secrets = ctx->hs->secrets; | 1025 | struct tls13_secrets *secrets = ctx->hs->tls13.secrets; |
1028 | struct tls13_secret context = { .data = "", .len = 0 }; | 1026 | struct tls13_secret context = { .data = "", .len = 0 }; |
1029 | struct tls13_secret finished_key = { .data = NULL, .len = 0 }; | 1027 | struct tls13_secret finished_key = { .data = NULL, .len = 0 }; |
1030 | uint8_t transcript_hash[EVP_MAX_MD_SIZE]; | 1028 | uint8_t transcript_hash[EVP_MAX_MD_SIZE]; |
@@ -1082,7 +1080,7 @@ tls13_client_finished_send(struct tls13_ctx *ctx, CBB *cbb) | |||
1082 | int | 1080 | int |
1083 | tls13_client_finished_sent(struct tls13_ctx *ctx) | 1081 | tls13_client_finished_sent(struct tls13_ctx *ctx) |
1084 | { | 1082 | { |
1085 | struct tls13_secrets *secrets = ctx->hs->secrets; | 1083 | struct tls13_secrets *secrets = ctx->hs->tls13.secrets; |
1086 | 1084 | ||
1087 | /* | 1085 | /* |
1088 | * Any records following the client finished message must be encrypted | 1086 | * Any records following the client finished message must be encrypted |
diff --git a/src/lib/libssl/tls13_handshake.c b/src/lib/libssl/tls13_handshake.c index b3cecc77ef..c18a2dfe06 100644 --- a/src/lib/libssl/tls13_handshake.c +++ b/src/lib/libssl/tls13_handshake.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls13_handshake.c,v 1.64 2020/07/30 16:23:17 tb Exp $ */ | 1 | /* $OpenBSD: tls13_handshake.c,v 1.65 2021/03/21 18:36:34 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018-2019 Theo Buehler <tb@openbsd.org> | 3 | * Copyright (c) 2018-2019 Theo Buehler <tb@openbsd.org> |
4 | * Copyright (c) 2019 Joel Sing <jsing@openbsd.org> | 4 | * Copyright (c) 2019 Joel Sing <jsing@openbsd.org> |
@@ -428,8 +428,9 @@ tls13_handshake_send_action(struct tls13_ctx *ctx, | |||
428 | 428 | ||
429 | if (action->send_preserve_transcript_hash) { | 429 | if (action->send_preserve_transcript_hash) { |
430 | if (!tls1_transcript_hash_value(ctx->ssl, | 430 | if (!tls1_transcript_hash_value(ctx->ssl, |
431 | ctx->hs->transcript_hash, sizeof(ctx->hs->transcript_hash), | 431 | ctx->hs->tls13.transcript_hash, |
432 | &ctx->hs->transcript_hash_len)) | 432 | sizeof(ctx->hs->tls13.transcript_hash), |
433 | &ctx->hs->tls13.transcript_hash_len)) | ||
433 | return TLS13_IO_FAILURE; | 434 | return TLS13_IO_FAILURE; |
434 | } | 435 | } |
435 | 436 | ||
@@ -471,8 +472,9 @@ tls13_handshake_recv_action(struct tls13_ctx *ctx, | |||
471 | 472 | ||
472 | if (action->recv_preserve_transcript_hash) { | 473 | if (action->recv_preserve_transcript_hash) { |
473 | if (!tls1_transcript_hash_value(ctx->ssl, | 474 | if (!tls1_transcript_hash_value(ctx->ssl, |
474 | ctx->hs->transcript_hash, sizeof(ctx->hs->transcript_hash), | 475 | ctx->hs->tls13.transcript_hash, |
475 | &ctx->hs->transcript_hash_len)) | 476 | sizeof(ctx->hs->tls13.transcript_hash), |
477 | &ctx->hs->tls13.transcript_hash_len)) | ||
476 | return TLS13_IO_FAILURE; | 478 | return TLS13_IO_FAILURE; |
477 | } | 479 | } |
478 | 480 | ||
diff --git a/src/lib/libssl/tls13_internal.h b/src/lib/libssl/tls13_internal.h index c339a8ef10..973661acc9 100644 --- a/src/lib/libssl/tls13_internal.h +++ b/src/lib/libssl/tls13_internal.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls13_internal.h,v 1.88 2021/01/05 17:40:11 tb Exp $ */ | 1 | /* $OpenBSD: tls13_internal.h,v 1.89 2021/03/21 18:36:34 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2018 Bob Beck <beck@openbsd.org> |
4 | * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> |
@@ -274,7 +274,7 @@ struct tls13_ctx { | |||
274 | struct tls13_error error; | 274 | struct tls13_error error; |
275 | 275 | ||
276 | SSL *ssl; | 276 | SSL *ssl; |
277 | struct ssl_handshake_tls13_st *hs; | 277 | struct ssl_handshake_st *hs; |
278 | uint8_t mode; | 278 | uint8_t mode; |
279 | struct tls13_handshake_stage handshake_stage; | 279 | struct tls13_handshake_stage handshake_stage; |
280 | int handshake_started; | 280 | int handshake_started; |
diff --git a/src/lib/libssl/tls13_legacy.c b/src/lib/libssl/tls13_legacy.c index f611aa061d..19271ef787 100644 --- a/src/lib/libssl/tls13_legacy.c +++ b/src/lib/libssl/tls13_legacy.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls13_legacy.c,v 1.22 2021/02/25 17:06:05 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_legacy.c,v 1.23 2021/03/21 18:36:34 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -361,7 +361,7 @@ tls13_use_legacy_client(struct tls13_ctx *ctx) | |||
361 | s->internal->handshake_func = s->method->internal->ssl_connect; | 361 | s->internal->handshake_func = s->method->internal->ssl_connect; |
362 | s->client_version = s->version = s->method->internal->max_tls_version; | 362 | s->client_version = s->version = s->method->internal->max_tls_version; |
363 | 363 | ||
364 | S3I(s)->hs.state = SSL3_ST_CR_SRVR_HELLO_A; | 364 | ctx->hs->state = SSL3_ST_CR_SRVR_HELLO_A; |
365 | 365 | ||
366 | return 1; | 366 | return 1; |
367 | } | 367 | } |
@@ -378,7 +378,7 @@ tls13_use_legacy_server(struct tls13_ctx *ctx) | |||
378 | s->client_version = s->version = s->method->internal->max_tls_version; | 378 | s->client_version = s->version = s->method->internal->max_tls_version; |
379 | s->server = 1; | 379 | s->server = 1; |
380 | 380 | ||
381 | S3I(s)->hs.state = SSL3_ST_SR_CLNT_HELLO_A; | 381 | ctx->hs->state = SSL3_ST_SR_CLNT_HELLO_A; |
382 | 382 | ||
383 | return 1; | 383 | return 1; |
384 | } | 384 | } |
@@ -396,7 +396,7 @@ tls13_legacy_accept(SSL *ssl) | |||
396 | } | 396 | } |
397 | ssl->internal->tls13 = ctx; | 397 | ssl->internal->tls13 = ctx; |
398 | ctx->ssl = ssl; | 398 | ctx->ssl = ssl; |
399 | ctx->hs = &S3I(ssl)->hs_tls13; | 399 | ctx->hs = &S3I(ssl)->hs; |
400 | 400 | ||
401 | if (!tls13_server_init(ctx)) { | 401 | if (!tls13_server_init(ctx)) { |
402 | if (ERR_peek_error() == 0) | 402 | if (ERR_peek_error() == 0) |
@@ -406,13 +406,13 @@ tls13_legacy_accept(SSL *ssl) | |||
406 | } | 406 | } |
407 | 407 | ||
408 | ERR_clear_error(); | 408 | ERR_clear_error(); |
409 | S3I(ssl)->hs.state = SSL_ST_ACCEPT; | 409 | ctx->hs->state = SSL_ST_ACCEPT; |
410 | 410 | ||
411 | ret = tls13_server_accept(ctx); | 411 | ret = tls13_server_accept(ctx); |
412 | if (ret == TLS13_IO_USE_LEGACY) | 412 | if (ret == TLS13_IO_USE_LEGACY) |
413 | return ssl->method->internal->ssl_accept(ssl); | 413 | return ssl->method->internal->ssl_accept(ssl); |
414 | if (ret == TLS13_IO_SUCCESS) | 414 | if (ret == TLS13_IO_SUCCESS) |
415 | S3I(ssl)->hs.state = SSL_ST_OK; | 415 | ctx->hs->state = SSL_ST_OK; |
416 | 416 | ||
417 | return tls13_legacy_return_code(ssl, ret); | 417 | return tls13_legacy_return_code(ssl, ret); |
418 | } | 418 | } |
@@ -438,7 +438,7 @@ tls13_legacy_connect(SSL *ssl) | |||
438 | } | 438 | } |
439 | ssl->internal->tls13 = ctx; | 439 | ssl->internal->tls13 = ctx; |
440 | ctx->ssl = ssl; | 440 | ctx->ssl = ssl; |
441 | ctx->hs = &S3I(ssl)->hs_tls13; | 441 | ctx->hs = &S3I(ssl)->hs; |
442 | 442 | ||
443 | if (!tls13_client_init(ctx)) { | 443 | if (!tls13_client_init(ctx)) { |
444 | if (ERR_peek_error() == 0) | 444 | if (ERR_peek_error() == 0) |
@@ -448,13 +448,13 @@ tls13_legacy_connect(SSL *ssl) | |||
448 | } | 448 | } |
449 | 449 | ||
450 | ERR_clear_error(); | 450 | ERR_clear_error(); |
451 | S3I(ssl)->hs.state = SSL_ST_CONNECT; | 451 | ctx->hs->state = SSL_ST_CONNECT; |
452 | 452 | ||
453 | ret = tls13_client_connect(ctx); | 453 | ret = tls13_client_connect(ctx); |
454 | if (ret == TLS13_IO_USE_LEGACY) | 454 | if (ret == TLS13_IO_USE_LEGACY) |
455 | return ssl->method->internal->ssl_connect(ssl); | 455 | return ssl->method->internal->ssl_connect(ssl); |
456 | if (ret == TLS13_IO_SUCCESS) | 456 | if (ret == TLS13_IO_SUCCESS) |
457 | S3I(ssl)->hs.state = SSL_ST_OK; | 457 | ctx->hs->state = SSL_ST_OK; |
458 | 458 | ||
459 | return tls13_legacy_return_code(ssl, ret); | 459 | return tls13_legacy_return_code(ssl, ret); |
460 | } | 460 | } |
diff --git a/src/lib/libssl/tls13_lib.c b/src/lib/libssl/tls13_lib.c index 0b3f636b93..9dbb7d6430 100644 --- a/src/lib/libssl/tls13_lib.c +++ b/src/lib/libssl/tls13_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls13_lib.c,v 1.57 2021/03/21 16:56:42 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_lib.c,v 1.58 2021/03/21 18:36:34 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> |
4 | * Copyright (c) 2019 Bob Beck <beck@openbsd.org> | 4 | * Copyright (c) 2019 Bob Beck <beck@openbsd.org> |
@@ -223,7 +223,7 @@ tls13_legacy_ocsp_status_recv_cb(void *arg) | |||
223 | static int | 223 | static int |
224 | tls13_phh_update_local_traffic_secret(struct tls13_ctx *ctx) | 224 | tls13_phh_update_local_traffic_secret(struct tls13_ctx *ctx) |
225 | { | 225 | { |
226 | struct tls13_secrets *secrets = ctx->hs->secrets; | 226 | struct tls13_secrets *secrets = ctx->hs->tls13.secrets; |
227 | 227 | ||
228 | if (ctx->mode == TLS13_HS_CLIENT) | 228 | if (ctx->mode == TLS13_HS_CLIENT) |
229 | return (tls13_update_client_traffic_secret(secrets) && | 229 | return (tls13_update_client_traffic_secret(secrets) && |
@@ -237,7 +237,7 @@ tls13_phh_update_local_traffic_secret(struct tls13_ctx *ctx) | |||
237 | static int | 237 | static int |
238 | tls13_phh_update_peer_traffic_secret(struct tls13_ctx *ctx) | 238 | tls13_phh_update_peer_traffic_secret(struct tls13_ctx *ctx) |
239 | { | 239 | { |
240 | struct tls13_secrets *secrets = ctx->hs->secrets; | 240 | struct tls13_secrets *secrets = ctx->hs->tls13.secrets; |
241 | 241 | ||
242 | if (ctx->mode == TLS13_HS_CLIENT) | 242 | if (ctx->mode == TLS13_HS_CLIENT) |
243 | return (tls13_update_server_traffic_secret(secrets) && | 243 | return (tls13_update_server_traffic_secret(secrets) && |
@@ -503,16 +503,16 @@ tls13_synthetic_handshake_message(struct tls13_ctx *ctx) | |||
503 | int | 503 | int |
504 | tls13_clienthello_hash_init(struct tls13_ctx *ctx) | 504 | tls13_clienthello_hash_init(struct tls13_ctx *ctx) |
505 | { | 505 | { |
506 | if (ctx->hs->clienthello_md_ctx != NULL) | 506 | if (ctx->hs->tls13.clienthello_md_ctx != NULL) |
507 | return 0; | 507 | return 0; |
508 | if ((ctx->hs->clienthello_md_ctx = EVP_MD_CTX_new()) == NULL) | 508 | if ((ctx->hs->tls13.clienthello_md_ctx = EVP_MD_CTX_new()) == NULL) |
509 | return 0; | 509 | return 0; |
510 | if (!EVP_DigestInit_ex(ctx->hs->clienthello_md_ctx, | 510 | if (!EVP_DigestInit_ex(ctx->hs->tls13.clienthello_md_ctx, |
511 | EVP_sha256(), NULL)) | 511 | EVP_sha256(), NULL)) |
512 | return 0; | 512 | return 0; |
513 | 513 | ||
514 | if ((ctx->hs->clienthello_hash == NULL) && | 514 | if ((ctx->hs->tls13.clienthello_hash == NULL) && |
515 | (ctx->hs->clienthello_hash = calloc(1, EVP_MAX_MD_SIZE)) == | 515 | (ctx->hs->tls13.clienthello_hash = calloc(1, EVP_MAX_MD_SIZE)) == |
516 | NULL) | 516 | NULL) |
517 | return 0; | 517 | return 0; |
518 | 518 | ||
@@ -520,7 +520,7 @@ tls13_clienthello_hash_init(struct tls13_ctx *ctx) | |||
520 | } | 520 | } |
521 | 521 | ||
522 | void | 522 | void |
523 | tls13_clienthello_hash_clear(struct ssl_handshake_tls13_st *hs) | 523 | tls13_clienthello_hash_clear(struct ssl_handshake_tls13_st *hs) /* XXX */ |
524 | { | 524 | { |
525 | EVP_MD_CTX_free(hs->clienthello_md_ctx); | 525 | EVP_MD_CTX_free(hs->clienthello_md_ctx); |
526 | hs->clienthello_md_ctx = NULL; | 526 | hs->clienthello_md_ctx = NULL; |
@@ -532,7 +532,7 @@ int | |||
532 | tls13_clienthello_hash_update_bytes(struct tls13_ctx *ctx, void *data, | 532 | tls13_clienthello_hash_update_bytes(struct tls13_ctx *ctx, void *data, |
533 | size_t len) | 533 | size_t len) |
534 | { | 534 | { |
535 | return EVP_DigestUpdate(ctx->hs->clienthello_md_ctx, data, len); | 535 | return EVP_DigestUpdate(ctx->hs->tls13.clienthello_md_ctx, data, len); |
536 | } | 536 | } |
537 | 537 | ||
538 | int | 538 | int |
@@ -545,12 +545,12 @@ tls13_clienthello_hash_update(struct tls13_ctx *ctx, CBS *cbs) | |||
545 | int | 545 | int |
546 | tls13_clienthello_hash_finalize(struct tls13_ctx *ctx) | 546 | tls13_clienthello_hash_finalize(struct tls13_ctx *ctx) |
547 | { | 547 | { |
548 | if (!EVP_DigestFinal_ex(ctx->hs->clienthello_md_ctx, | 548 | if (!EVP_DigestFinal_ex(ctx->hs->tls13.clienthello_md_ctx, |
549 | ctx->hs->clienthello_hash, | 549 | ctx->hs->tls13.clienthello_hash, |
550 | &ctx->hs->clienthello_hash_len)) | 550 | &ctx->hs->tls13.clienthello_hash_len)) |
551 | return 0; | 551 | return 0; |
552 | EVP_MD_CTX_free(ctx->hs->clienthello_md_ctx); | 552 | EVP_MD_CTX_free(ctx->hs->tls13.clienthello_md_ctx); |
553 | ctx->hs->clienthello_md_ctx = NULL; | 553 | ctx->hs->tls13.clienthello_md_ctx = NULL; |
554 | return 1; | 554 | return 1; |
555 | } | 555 | } |
556 | 556 | ||
@@ -560,18 +560,18 @@ tls13_clienthello_hash_validate(struct tls13_ctx *ctx) | |||
560 | unsigned char new_ch_hash[EVP_MAX_MD_SIZE]; | 560 | unsigned char new_ch_hash[EVP_MAX_MD_SIZE]; |
561 | unsigned int new_ch_hash_len; | 561 | unsigned int new_ch_hash_len; |
562 | 562 | ||
563 | if (ctx->hs->clienthello_hash == NULL) | 563 | if (ctx->hs->tls13.clienthello_hash == NULL) |
564 | return 0; | 564 | return 0; |
565 | 565 | ||
566 | if (!EVP_DigestFinal_ex(ctx->hs->clienthello_md_ctx, | 566 | if (!EVP_DigestFinal_ex(ctx->hs->tls13.clienthello_md_ctx, |
567 | new_ch_hash, &new_ch_hash_len)) | 567 | new_ch_hash, &new_ch_hash_len)) |
568 | return 0; | 568 | return 0; |
569 | EVP_MD_CTX_free(ctx->hs->clienthello_md_ctx); | 569 | EVP_MD_CTX_free(ctx->hs->tls13.clienthello_md_ctx); |
570 | ctx->hs->clienthello_md_ctx = NULL; | 570 | ctx->hs->tls13.clienthello_md_ctx = NULL; |
571 | 571 | ||
572 | if (ctx->hs->clienthello_hash_len != new_ch_hash_len) | 572 | if (ctx->hs->tls13.clienthello_hash_len != new_ch_hash_len) |
573 | return 0; | 573 | return 0; |
574 | if (memcmp(ctx->hs->clienthello_hash, new_ch_hash, | 574 | if (memcmp(ctx->hs->tls13.clienthello_hash, new_ch_hash, |
575 | new_ch_hash_len) != 0) | 575 | new_ch_hash_len) != 0) |
576 | return 0; | 576 | return 0; |
577 | 577 | ||
@@ -584,7 +584,7 @@ tls13_exporter(struct tls13_ctx *ctx, const uint8_t *label, size_t label_len, | |||
584 | size_t out_len) | 584 | size_t out_len) |
585 | { | 585 | { |
586 | struct tls13_secret context, export_out, export_secret; | 586 | struct tls13_secret context, export_out, export_secret; |
587 | struct tls13_secrets *secrets = ctx->hs->secrets; | 587 | struct tls13_secrets *secrets = ctx->hs->tls13.secrets; |
588 | EVP_MD_CTX *md_ctx = NULL; | 588 | EVP_MD_CTX *md_ctx = NULL; |
589 | unsigned int md_out_len; | 589 | unsigned int md_out_len; |
590 | int md_len; | 590 | int md_len; |
diff --git a/src/lib/libssl/tls13_server.c b/src/lib/libssl/tls13_server.c index 29c63bcd06..658aef2cfe 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.71 2021/03/10 18:27:02 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_server.c,v 1.72 2021/03/21 18:36:34 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> |
@@ -29,12 +29,12 @@ tls13_server_init(struct tls13_ctx *ctx) | |||
29 | { | 29 | { |
30 | SSL *s = ctx->ssl; | 30 | SSL *s = ctx->ssl; |
31 | 31 | ||
32 | if (!ssl_supported_tls_version_range(s, &S3I(s)->hs.our_min_tls_version, | 32 | if (!ssl_supported_tls_version_range(s, &ctx->hs->our_min_tls_version, |
33 | &S3I(s)->hs.our_max_tls_version)) { | 33 | &ctx->hs->our_max_tls_version)) { |
34 | SSLerror(s, SSL_R_NO_PROTOCOLS_AVAILABLE); | 34 | SSLerror(s, SSL_R_NO_PROTOCOLS_AVAILABLE); |
35 | return 0; | 35 | return 0; |
36 | } | 36 | } |
37 | s->version = S3I(s)->hs.our_max_tls_version; | 37 | s->version = ctx->hs->our_max_tls_version; |
38 | 38 | ||
39 | tls13_record_layer_set_retry_after_phh(ctx->rl, | 39 | tls13_record_layer_set_retry_after_phh(ctx->rl, |
40 | (s->internal->mode & SSL_MODE_AUTO_RETRY) != 0); | 40 | (s->internal->mode & SSL_MODE_AUTO_RETRY) != 0); |
@@ -163,7 +163,7 @@ tls13_client_hello_process(struct tls13_ctx *ctx, CBS *cbs) | |||
163 | goto err; | 163 | goto err; |
164 | return tls13_use_legacy_server(ctx); | 164 | return tls13_use_legacy_server(ctx); |
165 | } | 165 | } |
166 | S3I(s)->hs.negotiated_tls_version = TLS1_3_VERSION; | 166 | ctx->hs->negotiated_tls_version = TLS1_3_VERSION; |
167 | 167 | ||
168 | /* Add decoded values to the current ClientHello hash */ | 168 | /* Add decoded values to the current ClientHello hash */ |
169 | if (!tls13_clienthello_hash_init(ctx)) { | 169 | if (!tls13_clienthello_hash_init(ctx)) { |
@@ -198,7 +198,7 @@ tls13_client_hello_process(struct tls13_ctx *ctx, CBS *cbs) | |||
198 | } | 198 | } |
199 | 199 | ||
200 | /* Finalize first ClientHello hash, or validate against it */ | 200 | /* Finalize first ClientHello hash, or validate against it */ |
201 | if (!ctx->hs->hrr) { | 201 | if (!ctx->hs->tls13.hrr) { |
202 | if (!tls13_clienthello_hash_finalize(ctx)) { | 202 | if (!tls13_clienthello_hash_finalize(ctx)) { |
203 | ctx->alert = TLS13_ALERT_INTERNAL_ERROR; | 203 | ctx->alert = TLS13_ALERT_INTERNAL_ERROR; |
204 | goto err; | 204 | goto err; |
@@ -208,7 +208,7 @@ tls13_client_hello_process(struct tls13_ctx *ctx, CBS *cbs) | |||
208 | ctx->alert = TLS13_ALERT_ILLEGAL_PARAMETER; | 208 | ctx->alert = TLS13_ALERT_ILLEGAL_PARAMETER; |
209 | goto err; | 209 | goto err; |
210 | } | 210 | } |
211 | tls13_clienthello_hash_clear(ctx->hs); | 211 | tls13_clienthello_hash_clear(&ctx->hs->tls13); |
212 | } | 212 | } |
213 | 213 | ||
214 | if (!tls13_client_hello_required_extensions(ctx)) { | 214 | if (!tls13_client_hello_required_extensions(ctx)) { |
@@ -226,13 +226,13 @@ tls13_client_hello_process(struct tls13_ctx *ctx, CBS *cbs) | |||
226 | } | 226 | } |
227 | 227 | ||
228 | /* Store legacy session identifier so we can echo it. */ | 228 | /* Store legacy session identifier so we can echo it. */ |
229 | if (CBS_len(&session_id) > sizeof(ctx->hs->legacy_session_id)) { | 229 | if (CBS_len(&session_id) > sizeof(ctx->hs->tls13.legacy_session_id)) { |
230 | ctx->alert = TLS13_ALERT_ILLEGAL_PARAMETER; | 230 | ctx->alert = TLS13_ALERT_ILLEGAL_PARAMETER; |
231 | goto err; | 231 | goto err; |
232 | } | 232 | } |
233 | if (!CBS_write_bytes(&session_id, ctx->hs->legacy_session_id, | 233 | if (!CBS_write_bytes(&session_id, ctx->hs->tls13.legacy_session_id, |
234 | sizeof(ctx->hs->legacy_session_id), | 234 | sizeof(ctx->hs->tls13.legacy_session_id), |
235 | &ctx->hs->legacy_session_id_len)) { | 235 | &ctx->hs->tls13.legacy_session_id_len)) { |
236 | ctx->alert = TLS13_ALERT_INTERNAL_ERROR; | 236 | ctx->alert = TLS13_ALERT_INTERNAL_ERROR; |
237 | goto err; | 237 | goto err; |
238 | } | 238 | } |
@@ -249,7 +249,7 @@ tls13_client_hello_process(struct tls13_ctx *ctx, CBS *cbs) | |||
249 | ctx->alert = TLS13_ALERT_HANDSHAKE_FAILURE; | 249 | ctx->alert = TLS13_ALERT_HANDSHAKE_FAILURE; |
250 | goto err; | 250 | goto err; |
251 | } | 251 | } |
252 | S3I(s)->hs.new_cipher = cipher; | 252 | ctx->hs->new_cipher = cipher; |
253 | 253 | ||
254 | sk_SSL_CIPHER_free(s->session->ciphers); | 254 | sk_SSL_CIPHER_free(s->session->ciphers); |
255 | s->session->ciphers = ciphers; | 255 | s->session->ciphers = ciphers; |
@@ -293,7 +293,7 @@ tls13_client_hello_recv(struct tls13_ctx *ctx, CBS *cbs) | |||
293 | * has been enabled. This would probably mean using either an | 293 | * has been enabled. This would probably mean using either an |
294 | * INITIAL | WITHOUT_HRR state, or another intermediate state. | 294 | * INITIAL | WITHOUT_HRR state, or another intermediate state. |
295 | */ | 295 | */ |
296 | if (ctx->hs->key_share != NULL) | 296 | if (ctx->hs->tls13.key_share != NULL) |
297 | ctx->handshake_stage.hs_type |= NEGOTIATED | WITHOUT_HRR; | 297 | ctx->handshake_stage.hs_type |= NEGOTIATED | WITHOUT_HRR; |
298 | 298 | ||
299 | /* XXX - check this is the correct point */ | 299 | /* XXX - check this is the correct point */ |
@@ -314,7 +314,7 @@ tls13_server_hello_build(struct tls13_ctx *ctx, CBB *cbb, int hrr) | |||
314 | SSL *s = ctx->ssl; | 314 | SSL *s = ctx->ssl; |
315 | uint16_t cipher; | 315 | uint16_t cipher; |
316 | 316 | ||
317 | cipher = SSL_CIPHER_get_value(S3I(s)->hs.new_cipher); | 317 | cipher = SSL_CIPHER_get_value(ctx->hs->new_cipher); |
318 | server_random = s->s3->server_random; | 318 | server_random = s->s3->server_random; |
319 | 319 | ||
320 | if (hrr) { | 320 | if (hrr) { |
@@ -328,8 +328,8 @@ tls13_server_hello_build(struct tls13_ctx *ctx, CBB *cbb, int hrr) | |||
328 | goto err; | 328 | goto err; |
329 | if (!CBB_add_u8_length_prefixed(cbb, &session_id)) | 329 | if (!CBB_add_u8_length_prefixed(cbb, &session_id)) |
330 | goto err; | 330 | goto err; |
331 | if (!CBB_add_bytes(&session_id, ctx->hs->legacy_session_id, | 331 | if (!CBB_add_bytes(&session_id, ctx->hs->tls13.legacy_session_id, |
332 | ctx->hs->legacy_session_id_len)) | 332 | ctx->hs->tls13.legacy_session_id_len)) |
333 | goto err; | 333 | goto err; |
334 | if (!CBB_add_u16(cbb, cipher)) | 334 | if (!CBB_add_u16(cbb, cipher)) |
335 | goto err; | 335 | goto err; |
@@ -358,20 +358,20 @@ tls13_server_engage_record_protection(struct tls13_ctx *ctx) | |||
358 | SSL *s = ctx->ssl; | 358 | SSL *s = ctx->ssl; |
359 | int ret = 0; | 359 | int ret = 0; |
360 | 360 | ||
361 | if (!tls13_key_share_derive(ctx->hs->key_share, | 361 | if (!tls13_key_share_derive(ctx->hs->tls13.key_share, |
362 | &shared_key, &shared_key_len)) | 362 | &shared_key, &shared_key_len)) |
363 | goto err; | 363 | goto err; |
364 | 364 | ||
365 | s->session->cipher = S3I(s)->hs.new_cipher; | 365 | s->session->cipher = ctx->hs->new_cipher; |
366 | 366 | ||
367 | if ((ctx->aead = tls13_cipher_aead(S3I(s)->hs.new_cipher)) == NULL) | 367 | if ((ctx->aead = tls13_cipher_aead(ctx->hs->new_cipher)) == NULL) |
368 | goto err; | 368 | goto err; |
369 | if ((ctx->hash = tls13_cipher_hash(S3I(s)->hs.new_cipher)) == NULL) | 369 | if ((ctx->hash = tls13_cipher_hash(ctx->hs->new_cipher)) == NULL) |
370 | goto err; | 370 | goto err; |
371 | 371 | ||
372 | if ((secrets = tls13_secrets_create(ctx->hash, 0)) == NULL) | 372 | if ((secrets = tls13_secrets_create(ctx->hash, 0)) == NULL) |
373 | goto err; | 373 | goto err; |
374 | ctx->hs->secrets = secrets; | 374 | ctx->hs->tls13.secrets = secrets; |
375 | 375 | ||
376 | /* XXX - pass in hash. */ | 376 | /* XXX - pass in hash. */ |
377 | if (!tls1_transcript_hash_init(s)) | 377 | if (!tls1_transcript_hash_init(s)) |
@@ -388,7 +388,7 @@ tls13_server_engage_record_protection(struct tls13_ctx *ctx) | |||
388 | goto err; | 388 | goto err; |
389 | 389 | ||
390 | /* Handshake secrets. */ | 390 | /* Handshake secrets. */ |
391 | if (!tls13_derive_handshake_secrets(ctx->hs->secrets, shared_key, | 391 | if (!tls13_derive_handshake_secrets(ctx->hs->tls13.secrets, shared_key, |
392 | shared_key_len, &context)) | 392 | shared_key_len, &context)) |
393 | goto err; | 393 | goto err; |
394 | 394 | ||
@@ -418,16 +418,16 @@ tls13_server_hello_retry_request_send(struct tls13_ctx *ctx, CBB *cbb) | |||
418 | { | 418 | { |
419 | int nid; | 419 | int nid; |
420 | 420 | ||
421 | ctx->hs->hrr = 1; | 421 | ctx->hs->tls13.hrr = 1; |
422 | 422 | ||
423 | if (!tls13_synthetic_handshake_message(ctx)) | 423 | if (!tls13_synthetic_handshake_message(ctx)) |
424 | return 0; | 424 | return 0; |
425 | 425 | ||
426 | if (ctx->hs->key_share != NULL) | 426 | if (ctx->hs->tls13.key_share != NULL) |
427 | return 0; | 427 | return 0; |
428 | if ((nid = tls1_get_shared_curve(ctx->ssl)) == NID_undef) | 428 | if ((nid = tls1_get_shared_curve(ctx->ssl)) == NID_undef) |
429 | return 0; | 429 | return 0; |
430 | if ((ctx->hs->server_group = tls1_ec_nid2curve_id(nid)) == 0) | 430 | if ((ctx->hs->tls13.server_group = tls1_ec_nid2curve_id(nid)) == 0) |
431 | return 0; | 431 | return 0; |
432 | 432 | ||
433 | if (!tls13_server_hello_build(ctx, cbb, 1)) | 433 | if (!tls13_server_hello_build(ctx, cbb, 1)) |
@@ -444,7 +444,7 @@ tls13_server_hello_retry_request_sent(struct tls13_ctx *ctx) | |||
444 | * we MUST send a dummy CCS following our first handshake message. | 444 | * we MUST send a dummy CCS following our first handshake message. |
445 | * See RFC 8446 Appendix D.4. | 445 | * See RFC 8446 Appendix D.4. |
446 | */ | 446 | */ |
447 | if (ctx->hs->legacy_session_id_len > 0) | 447 | if (ctx->hs->tls13.legacy_session_id_len > 0) |
448 | ctx->send_dummy_ccs_after = 1; | 448 | ctx->send_dummy_ccs_after = 1; |
449 | 449 | ||
450 | return 1; | 450 | return 1; |
@@ -462,7 +462,7 @@ tls13_client_hello_retry_recv(struct tls13_ctx *ctx, CBS *cbs) | |||
462 | if (s->method->internal->version < TLS1_3_VERSION) | 462 | if (s->method->internal->version < TLS1_3_VERSION) |
463 | return 0; | 463 | return 0; |
464 | 464 | ||
465 | ctx->hs->hrr = 0; | 465 | ctx->hs->tls13.hrr = 0; |
466 | 466 | ||
467 | return 1; | 467 | return 1; |
468 | } | 468 | } |
@@ -483,14 +483,14 @@ tls13_servername_process(struct tls13_ctx *ctx) | |||
483 | int | 483 | int |
484 | tls13_server_hello_send(struct tls13_ctx *ctx, CBB *cbb) | 484 | tls13_server_hello_send(struct tls13_ctx *ctx, CBB *cbb) |
485 | { | 485 | { |
486 | if (ctx->hs->key_share == NULL) | 486 | if (ctx->hs->tls13.key_share == NULL) |
487 | return 0; | 487 | return 0; |
488 | if (!tls13_key_share_generate(ctx->hs->key_share)) | 488 | if (!tls13_key_share_generate(ctx->hs->tls13.key_share)) |
489 | return 0; | 489 | return 0; |
490 | if (!tls13_servername_process(ctx)) | 490 | if (!tls13_servername_process(ctx)) |
491 | return 0; | 491 | return 0; |
492 | 492 | ||
493 | ctx->hs->server_group = 0; | 493 | ctx->hs->tls13.server_group = 0; |
494 | 494 | ||
495 | if (!tls13_server_hello_build(ctx, cbb, 0)) | 495 | if (!tls13_server_hello_build(ctx, cbb, 0)) |
496 | return 0; | 496 | return 0; |
@@ -507,7 +507,7 @@ tls13_server_hello_sent(struct tls13_ctx *ctx) | |||
507 | * See RFC 8446 Appendix D.4. | 507 | * See RFC 8446 Appendix D.4. |
508 | */ | 508 | */ |
509 | if ((ctx->handshake_stage.hs_type & WITHOUT_HRR) && | 509 | if ((ctx->handshake_stage.hs_type & WITHOUT_HRR) && |
510 | ctx->hs->legacy_session_id_len > 0) | 510 | ctx->hs->tls13.legacy_session_id_len > 0) |
511 | ctx->send_dummy_ccs_after = 1; | 511 | ctx->send_dummy_ccs_after = 1; |
512 | 512 | ||
513 | return tls13_server_engage_record_protection(ctx); | 513 | return tls13_server_engage_record_protection(ctx); |
@@ -633,8 +633,8 @@ tls13_server_certificate_send(struct tls13_ctx *ctx, CBB *cbb) | |||
633 | goto err; | 633 | goto err; |
634 | } | 634 | } |
635 | 635 | ||
636 | ctx->hs->cpk = cpk; | 636 | ctx->hs->tls13.cpk = cpk; |
637 | ctx->hs->sigalg = sigalg; | 637 | ctx->hs->tls13.sigalg = sigalg; |
638 | 638 | ||
639 | if ((chain = cpk->chain) == NULL) | 639 | if ((chain = cpk->chain) == NULL) |
640 | chain = s->ctx->extra_certs; | 640 | chain = s->ctx->extra_certs; |
@@ -705,9 +705,9 @@ tls13_server_certificate_verify_send(struct tls13_ctx *ctx, CBB *cbb) | |||
705 | 705 | ||
706 | memset(&sig_cbb, 0, sizeof(sig_cbb)); | 706 | memset(&sig_cbb, 0, sizeof(sig_cbb)); |
707 | 707 | ||
708 | if ((cpk = ctx->hs->cpk) == NULL) | 708 | if ((cpk = ctx->hs->tls13.cpk) == NULL) |
709 | goto err; | 709 | goto err; |
710 | if ((sigalg = ctx->hs->sigalg) == NULL) | 710 | if ((sigalg = ctx->hs->tls13.sigalg) == NULL) |
711 | goto err; | 711 | goto err; |
712 | pkey = cpk->privatekey; | 712 | pkey = cpk->privatekey; |
713 | 713 | ||
@@ -721,8 +721,8 @@ tls13_server_certificate_verify_send(struct tls13_ctx *ctx, CBB *cbb) | |||
721 | goto err; | 721 | goto err; |
722 | if (!CBB_add_u8(&sig_cbb, 0)) | 722 | if (!CBB_add_u8(&sig_cbb, 0)) |
723 | goto err; | 723 | goto err; |
724 | if (!CBB_add_bytes(&sig_cbb, ctx->hs->transcript_hash, | 724 | if (!CBB_add_bytes(&sig_cbb, ctx->hs->tls13.transcript_hash, |
725 | ctx->hs->transcript_hash_len)) | 725 | ctx->hs->tls13.transcript_hash_len)) |
726 | goto err; | 726 | goto err; |
727 | if (!CBB_finish(&sig_cbb, &sig_content, &sig_content_len)) | 727 | if (!CBB_finish(&sig_cbb, &sig_content, &sig_content_len)) |
728 | goto err; | 728 | goto err; |
@@ -773,7 +773,7 @@ tls13_server_certificate_verify_send(struct tls13_ctx *ctx, CBB *cbb) | |||
773 | int | 773 | int |
774 | tls13_server_finished_send(struct tls13_ctx *ctx, CBB *cbb) | 774 | tls13_server_finished_send(struct tls13_ctx *ctx, CBB *cbb) |
775 | { | 775 | { |
776 | struct tls13_secrets *secrets = ctx->hs->secrets; | 776 | struct tls13_secrets *secrets = ctx->hs->tls13.secrets; |
777 | struct tls13_secret context = { .data = "", .len = 0 }; | 777 | struct tls13_secret context = { .data = "", .len = 0 }; |
778 | struct tls13_secret finished_key = { .data = NULL, .len = 0 } ; | 778 | struct tls13_secret finished_key = { .data = NULL, .len = 0 } ; |
779 | uint8_t transcript_hash[EVP_MAX_MD_SIZE]; | 779 | uint8_t transcript_hash[EVP_MAX_MD_SIZE]; |
@@ -831,14 +831,14 @@ tls13_server_finished_send(struct tls13_ctx *ctx, CBB *cbb) | |||
831 | int | 831 | int |
832 | tls13_server_finished_sent(struct tls13_ctx *ctx) | 832 | tls13_server_finished_sent(struct tls13_ctx *ctx) |
833 | { | 833 | { |
834 | struct tls13_secrets *secrets = ctx->hs->secrets; | 834 | struct tls13_secrets *secrets = ctx->hs->tls13.secrets; |
835 | struct tls13_secret context = { .data = "", .len = 0 }; | 835 | struct tls13_secret context = { .data = "", .len = 0 }; |
836 | 836 | ||
837 | /* | 837 | /* |
838 | * Derive application traffic keys. | 838 | * Derive application traffic keys. |
839 | */ | 839 | */ |
840 | context.data = ctx->hs->transcript_hash; | 840 | context.data = ctx->hs->tls13.transcript_hash; |
841 | context.len = ctx->hs->transcript_hash_len; | 841 | context.len = ctx->hs->tls13.transcript_hash_len; |
842 | 842 | ||
843 | if (!tls13_derive_application_secrets(secrets, &context)) | 843 | if (!tls13_derive_application_secrets(secrets, &context)) |
844 | return 0; | 844 | return 0; |
@@ -984,8 +984,8 @@ tls13_client_certificate_verify_recv(struct tls13_ctx *ctx, CBS *cbs) | |||
984 | goto err; | 984 | goto err; |
985 | if (!CBB_add_u8(&cbb, 0)) | 985 | if (!CBB_add_u8(&cbb, 0)) |
986 | goto err; | 986 | goto err; |
987 | if (!CBB_add_bytes(&cbb, ctx->hs->transcript_hash, | 987 | if (!CBB_add_bytes(&cbb, ctx->hs->tls13.transcript_hash, |
988 | ctx->hs->transcript_hash_len)) | 988 | ctx->hs->tls13.transcript_hash_len)) |
989 | goto err; | 989 | goto err; |
990 | if (!CBB_finish(&cbb, &sig_content, &sig_content_len)) | 990 | if (!CBB_finish(&cbb, &sig_content, &sig_content_len)) |
991 | goto err; | 991 | goto err; |
@@ -1042,7 +1042,7 @@ tls13_client_end_of_early_data_recv(struct tls13_ctx *ctx, CBS *cbs) | |||
1042 | int | 1042 | int |
1043 | tls13_client_finished_recv(struct tls13_ctx *ctx, CBS *cbs) | 1043 | tls13_client_finished_recv(struct tls13_ctx *ctx, CBS *cbs) |
1044 | { | 1044 | { |
1045 | struct tls13_secrets *secrets = ctx->hs->secrets; | 1045 | struct tls13_secrets *secrets = ctx->hs->tls13.secrets; |
1046 | struct tls13_secret context = { .data = "", .len = 0 }; | 1046 | struct tls13_secret context = { .data = "", .len = 0 }; |
1047 | struct tls13_secret finished_key; | 1047 | struct tls13_secret finished_key; |
1048 | uint8_t *verify_data = NULL; | 1048 | uint8_t *verify_data = NULL; |
@@ -1069,8 +1069,8 @@ tls13_client_finished_recv(struct tls13_ctx *ctx, CBS *cbs) | |||
1069 | if (!HMAC_Init_ex(hmac_ctx, finished_key.data, finished_key.len, | 1069 | if (!HMAC_Init_ex(hmac_ctx, finished_key.data, finished_key.len, |
1070 | ctx->hash, NULL)) | 1070 | ctx->hash, NULL)) |
1071 | goto err; | 1071 | goto err; |
1072 | if (!HMAC_Update(hmac_ctx, ctx->hs->transcript_hash, | 1072 | if (!HMAC_Update(hmac_ctx, ctx->hs->tls13.transcript_hash, |
1073 | ctx->hs->transcript_hash_len)) | 1073 | ctx->hs->tls13.transcript_hash_len)) |
1074 | goto err; | 1074 | goto err; |
1075 | verify_data_len = HMAC_size(hmac_ctx); | 1075 | verify_data_len = HMAC_size(hmac_ctx); |
1076 | if ((verify_data = calloc(1, verify_data_len)) == NULL) | 1076 | if ((verify_data = calloc(1, verify_data_len)) == NULL) |