mirror of
https://github.com/openssl/openssl.git
synced 2024-11-23 18:13:39 +08:00
Convert the state machine code to use SSLfatal()
Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4778)
This commit is contained in:
parent
4752c5deb2
commit
f63a17d66d
@ -965,9 +965,13 @@ SSL_F_ADD_CLIENT_KEY_SHARE_EXT:438:*
|
||||
SSL_F_ADD_KEY_SHARE:512:add_key_share
|
||||
SSL_F_BYTES_TO_CIPHER_LIST:519:bytes_to_cipher_list
|
||||
SSL_F_CHECK_SUITEB_CIPHER_LIST:331:check_suiteb_cipher_list
|
||||
SSL_F_CONSTRUCT_CA_NAMES:552:construct_ca_names
|
||||
SSL_F_CONSTRUCT_KEY_EXCHANGE_TBS:553:construct_key_exchange_tbs
|
||||
SSL_F_CREATE_SYNTHETIC_MESSAGE_HASH:539:create_synthetic_message_hash
|
||||
SSL_F_CT_MOVE_SCTS:345:ct_move_scts
|
||||
SSL_F_CT_STRICT:349:ct_strict
|
||||
SSL_F_CUSTOM_EXT_ADD:554:custom_ext_add
|
||||
SSL_F_CUSTOM_EXT_PARSE:555:custom_ext_parse
|
||||
SSL_F_D2I_SSL_SESSION:103:d2i_SSL_SESSION
|
||||
SSL_F_DANE_CTX_ENABLE:347:dane_ctx_enable
|
||||
SSL_F_DANE_MTYPE_SET:393:dane_mtype_set
|
||||
@ -993,11 +997,15 @@ SSL_F_DTLS_CONSTRUCT_HELLO_VERIFY_REQUEST:385:\
|
||||
SSL_F_DTLS_GET_REASSEMBLED_MESSAGE:370:dtls_get_reassembled_message
|
||||
SSL_F_DTLS_PROCESS_HELLO_VERIFY:386:dtls_process_hello_verify
|
||||
SSL_F_EARLY_DATA_COUNT_OK:532:early_data_count_ok
|
||||
SSL_F_FINAL_EARLY_DATA:556:final_early_data
|
||||
SSL_F_FINAL_EC_PT_FORMATS:485:final_ec_pt_formats
|
||||
SSL_F_FINAL_EMS:486:final_ems
|
||||
SSL_F_FINAL_KEY_SHARE:503:final_key_share
|
||||
SSL_F_FINAL_MAXFRAGMENTLEN:557:final_maxfragmentlen
|
||||
SSL_F_FINAL_RENEGOTIATE:483:final_renegotiate
|
||||
SSL_F_FINAL_SERVER_NAME:558:final_server_name
|
||||
SSL_F_FINAL_SIG_ALGS:497:final_sig_algs
|
||||
SSL_F_GET_CERT_VERIFY_TBS_DATA:588:get_cert_verify_tbs_data
|
||||
SSL_F_NSS_KEYLOG_INT:500:nss_keylog_int
|
||||
SSL_F_OPENSSL_INIT_SSL:342:OPENSSL_init_ssl
|
||||
SSL_F_OSSL_STATEM_CLIENT13_READ_TRANSITION:436:*
|
||||
@ -1010,6 +1018,7 @@ SSL_F_PARSE_CA_NAMES:541:parse_ca_names
|
||||
SSL_F_PROCESS_KEY_SHARE_EXT:439:*
|
||||
SSL_F_READ_STATE_MACHINE:352:read_state_machine
|
||||
SSL_F_SET_CLIENT_CIPHERSUITE:540:set_client_ciphersuite
|
||||
SSL_F_SRP_GENERATE_SERVER_MASTER_SECRET:589:srp_generate_server_master_secret
|
||||
SSL_F_SSL3_CHANGE_CIPHER_STATE:129:ssl3_change_cipher_state
|
||||
SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM:130:ssl3_check_cert_and_algorithm
|
||||
SSL_F_SSL3_CTRL:213:ssl3_ctrl
|
||||
@ -1017,6 +1026,7 @@ SSL_F_SSL3_CTX_CTRL:133:ssl3_ctx_ctrl
|
||||
SSL_F_SSL3_DIGEST_CACHED_RECORDS:293:ssl3_digest_cached_records
|
||||
SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC:292:ssl3_do_change_cipher_spec
|
||||
SSL_F_SSL3_FINAL_FINISH_MAC:285:ssl3_final_finish_mac
|
||||
SSL_F_SSL3_FINISH_MAC:587:ssl3_finish_mac
|
||||
SSL_F_SSL3_GENERATE_KEY_BLOCK:238:ssl3_generate_key_block
|
||||
SSL_F_SSL3_GENERATE_MASTER_SECRET:388:ssl3_generate_master_secret
|
||||
SSL_F_SSL3_GET_RECORD:143:ssl3_get_record
|
||||
@ -1087,15 +1097,18 @@ SSL_F_SSL_CTX_USE_SERVERINFO_EX:543:SSL_CTX_use_serverinfo_ex
|
||||
SSL_F_SSL_CTX_USE_SERVERINFO_FILE:337:SSL_CTX_use_serverinfo_file
|
||||
SSL_F_SSL_DANE_DUP:403:ssl_dane_dup
|
||||
SSL_F_SSL_DANE_ENABLE:395:SSL_dane_enable
|
||||
SSL_F_SSL_DERIVE:590:ssl_derive
|
||||
SSL_F_SSL_DO_CONFIG:391:ssl_do_config
|
||||
SSL_F_SSL_DO_HANDSHAKE:180:SSL_do_handshake
|
||||
SSL_F_SSL_DUP_CA_LIST:408:SSL_dup_CA_list
|
||||
SSL_F_SSL_ENABLE_CT:402:SSL_enable_ct
|
||||
SSL_F_SSL_GENERATE_PKEY_GROUP:559:ssl_generate_pkey_group
|
||||
SSL_F_SSL_GENERATE_SESSION_ID:547:ssl_generate_session_id
|
||||
SSL_F_SSL_GET_NEW_SESSION:181:ssl_get_new_session
|
||||
SSL_F_SSL_GET_PREV_SESSION:217:ssl_get_prev_session
|
||||
SSL_F_SSL_GET_SERVER_CERT_INDEX:322:*
|
||||
SSL_F_SSL_GET_SIGN_PKEY:183:*
|
||||
SSL_F_SSL_HANDSHAKE_HASH:560:ssl_handshake_hash
|
||||
SSL_F_SSL_INIT_WBIO_BUFFER:184:ssl_init_wbio_buffer
|
||||
SSL_F_SSL_KEY_UPDATE:515:SSL_key_update
|
||||
SSL_F_SSL_LOAD_CLIENT_CA_FILE:185:SSL_load_client_CA_file
|
||||
@ -1103,6 +1116,7 @@ SSL_F_SSL_LOG_MASTER_SECRET:498:*
|
||||
SSL_F_SSL_LOG_RSA_CLIENT_KEY_EXCHANGE:499:ssl_log_rsa_client_key_exchange
|
||||
SSL_F_SSL_MODULE_INIT:392:ssl_module_init
|
||||
SSL_F_SSL_NEW:186:SSL_new
|
||||
SSL_F_SSL_NEXT_PROTO_VALIDATE:565:ssl_next_proto_validate
|
||||
SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT:300:*
|
||||
SSL_F_SSL_PARSE_CLIENTHELLO_TLSEXT:302:*
|
||||
SSL_F_SSL_PARSE_CLIENTHELLO_USE_SRTP_EXT:310:*
|
||||
@ -1163,6 +1177,8 @@ SSL_F_STATE_MACHINE:353:state_machine
|
||||
SSL_F_TLS12_CHECK_PEER_SIGALG:333:tls12_check_peer_sigalg
|
||||
SSL_F_TLS12_COPY_SIGALGS:533:tls12_copy_sigalgs
|
||||
SSL_F_TLS13_CHANGE_CIPHER_STATE:440:tls13_change_cipher_state
|
||||
SSL_F_TLS13_GENERATE_SECRET:591:tls13_generate_secret
|
||||
SSL_F_TLS13_HKDF_EXPAND:561:tls13_hkdf_expand
|
||||
SSL_F_TLS13_SETUP_KEY_BLOCK:441:tls13_setup_key_block
|
||||
SSL_F_TLS1_CHANGE_CIPHER_STATE:209:tls1_change_cipher_state
|
||||
SSL_F_TLS1_CHECK_DUPLICATE_EXTENSIONS:341:*
|
||||
@ -1258,17 +1274,40 @@ SSL_F_TLS_EARLY_POST_PROCESS_CLIENT_HELLO:521:\
|
||||
tls_early_post_process_client_hello
|
||||
SSL_F_TLS_GET_MESSAGE_BODY:351:tls_get_message_body
|
||||
SSL_F_TLS_GET_MESSAGE_HEADER:387:tls_get_message_header
|
||||
SSL_F_TLS_HANDLE_ALPN:562:tls_handle_alpn
|
||||
SSL_F_TLS_HANDLE_STATUS_REQUEST:563:tls_handle_status_request
|
||||
SSL_F_TLS_PARSE_CERTIFICATE_AUTHORITIES:566:tls_parse_certificate_authorities
|
||||
SSL_F_TLS_PARSE_CLIENTHELLO_TLSEXT:449:*
|
||||
SSL_F_TLS_PARSE_CTOS_ALPN:567:tls_parse_ctos_alpn
|
||||
SSL_F_TLS_PARSE_CTOS_EARLY_DATA:568:tls_parse_ctos_early_data
|
||||
SSL_F_TLS_PARSE_CTOS_EC_PT_FORMATS:569:tls_parse_ctos_ec_pt_formats
|
||||
SSL_F_TLS_PARSE_CTOS_EMS:570:tls_parse_ctos_ems
|
||||
SSL_F_TLS_PARSE_CTOS_KEY_SHARE:463:tls_parse_ctos_key_share
|
||||
SSL_F_TLS_PARSE_CTOS_MAXFRAGMENTLEN:571:tls_parse_ctos_maxfragmentlen
|
||||
SSL_F_TLS_PARSE_CTOS_PSK:505:tls_parse_ctos_psk
|
||||
SSL_F_TLS_PARSE_CTOS_PSK_KEX_MODES:572:tls_parse_ctos_psk_kex_modes
|
||||
SSL_F_TLS_PARSE_CTOS_RENEGOTIATE:464:tls_parse_ctos_renegotiate
|
||||
SSL_F_TLS_PARSE_CTOS_SERVER_NAME:573:tls_parse_ctos_server_name
|
||||
SSL_F_TLS_PARSE_CTOS_SESSION_TICKET:574:tls_parse_ctos_session_ticket
|
||||
SSL_F_TLS_PARSE_CTOS_SIG_ALGS:575:tls_parse_ctos_sig_algs
|
||||
SSL_F_TLS_PARSE_CTOS_SRP:576:tls_parse_ctos_srp
|
||||
SSL_F_TLS_PARSE_CTOS_STATUS_REQUEST:577:tls_parse_ctos_status_request
|
||||
SSL_F_TLS_PARSE_CTOS_SUPPORTED_GROUPS:578:tls_parse_ctos_supported_groups
|
||||
SSL_F_TLS_PARSE_CTOS_USE_SRTP:465:tls_parse_ctos_use_srtp
|
||||
SSL_F_TLS_PARSE_STOC_ALPN:579:tls_parse_stoc_alpn
|
||||
SSL_F_TLS_PARSE_STOC_COOKIE:534:tls_parse_stoc_cookie
|
||||
SSL_F_TLS_PARSE_STOC_EARLY_DATA:538:tls_parse_stoc_early_data
|
||||
SSL_F_TLS_PARSE_STOC_EARLY_DATA_INFO:528:*
|
||||
SSL_F_TLS_PARSE_STOC_EC_PT_FORMATS:580:tls_parse_stoc_ec_pt_formats
|
||||
SSL_F_TLS_PARSE_STOC_KEY_SHARE:445:tls_parse_stoc_key_share
|
||||
SSL_F_TLS_PARSE_STOC_MAXFRAGMENTLEN:581:tls_parse_stoc_maxfragmentlen
|
||||
SSL_F_TLS_PARSE_STOC_NPN:582:tls_parse_stoc_npn
|
||||
SSL_F_TLS_PARSE_STOC_PSK:502:tls_parse_stoc_psk
|
||||
SSL_F_TLS_PARSE_STOC_RENEGOTIATE:448:tls_parse_stoc_renegotiate
|
||||
SSL_F_TLS_PARSE_STOC_SCT:564:tls_parse_stoc_sct
|
||||
SSL_F_TLS_PARSE_STOC_SERVER_NAME:583:tls_parse_stoc_server_name
|
||||
SSL_F_TLS_PARSE_STOC_SESSION_TICKET:584:tls_parse_stoc_session_ticket
|
||||
SSL_F_TLS_PARSE_STOC_STATUS_REQUEST:585:tls_parse_stoc_status_request
|
||||
SSL_F_TLS_PARSE_STOC_USE_SRTP:446:tls_parse_stoc_use_srtp
|
||||
SSL_F_TLS_POST_PROCESS_CLIENT_HELLO:378:tls_post_process_client_hello
|
||||
SSL_F_TLS_POST_PROCESS_CLIENT_KEY_EXCHANGE:384:\
|
||||
@ -1309,6 +1348,7 @@ SSL_F_TLS_PSK_DO_BINDER:506:tls_psk_do_binder
|
||||
SSL_F_TLS_SCAN_CLIENTHELLO_TLSEXT:450:*
|
||||
SSL_F_TLS_SETUP_HANDSHAKE:508:tls_setup_handshake
|
||||
SSL_F_USE_CERTIFICATE_CHAIN_FILE:220:use_certificate_chain_file
|
||||
SSL_F_WRITE_STATE_MACHINE:586:write_state_machine
|
||||
TS_F_DEF_SERIAL_CB:110:def_serial_cb
|
||||
TS_F_DEF_TIME_CB:111:def_time_cb
|
||||
TS_F_ESS_ADD_SIGNING_CERT:112:ess_add_signing_cert
|
||||
@ -2286,14 +2326,17 @@ SSL_R_BAD_DATA_RETURNED_BY_CALLBACK:106:bad data returned by callback
|
||||
SSL_R_BAD_DECOMPRESSION:107:bad decompression
|
||||
SSL_R_BAD_DH_VALUE:102:bad dh value
|
||||
SSL_R_BAD_DIGEST_LENGTH:111:bad digest length
|
||||
SSL_R_BAD_EARLY_DATA:233:bad early data
|
||||
SSL_R_BAD_ECC_CERT:304:bad ecc cert
|
||||
SSL_R_BAD_ECPOINT:306:bad ecpoint
|
||||
SSL_R_BAD_EXTENSION:110:bad extension
|
||||
SSL_R_BAD_HANDSHAKE_LENGTH:332:bad handshake length
|
||||
SSL_R_BAD_HANDSHAKE_STATE:236:bad handshake state
|
||||
SSL_R_BAD_HELLO_REQUEST:105:bad hello request
|
||||
SSL_R_BAD_KEY_SHARE:108:bad key share
|
||||
SSL_R_BAD_KEY_UPDATE:122:bad key update
|
||||
SSL_R_BAD_LENGTH:271:bad length
|
||||
SSL_R_BAD_PACKET:240:bad packet
|
||||
SSL_R_BAD_PACKET_LENGTH:115:bad packet length
|
||||
SSL_R_BAD_PROTOCOL_VERSION_NUMBER:116:bad protocol version number
|
||||
SSL_R_BAD_PSK:219:bad psk
|
||||
@ -2311,6 +2354,7 @@ SSL_R_BAD_WRITE_RETRY:127:bad write retry
|
||||
SSL_R_BIO_NOT_SET:128:bio not set
|
||||
SSL_R_BLOCK_CIPHER_PAD_IS_WRONG:129:block cipher pad is wrong
|
||||
SSL_R_BN_LIB:130:bn lib
|
||||
SSL_R_CALLBACK_FAILED:234:callback failed
|
||||
SSL_R_CANNOT_CHANGE_CIPHER:109:cannot change cipher
|
||||
SSL_R_CA_DN_LENGTH_MISMATCH:131:ca dn length mismatch
|
||||
SSL_R_CA_KEY_TOO_SMALL:397:ca key too small
|
||||
@ -2380,6 +2424,7 @@ SSL_R_INCONSISTENT_EARLY_DATA_ALPN:222:inconsistent early data alpn
|
||||
SSL_R_INCONSISTENT_EARLY_DATA_SNI:231:inconsistent early data sni
|
||||
SSL_R_INCONSISTENT_EXTMS:104:inconsistent extms
|
||||
SSL_R_INVALID_ALERT:205:invalid alert
|
||||
SSL_R_INVALID_CERTIFICATE_OR_ALG:238:invalid certificate or alg
|
||||
SSL_R_INVALID_COMMAND:280:invalid command
|
||||
SSL_R_INVALID_COMPRESSION_ALGORITHM:341:invalid compression algorithm
|
||||
SSL_R_INVALID_CONFIGURATION_NAME:113:invalid configuration name
|
||||
@ -2409,6 +2454,7 @@ SSL_R_MISSING_SUPPORTED_GROUPS_EXTENSION:209:missing supported groups extension
|
||||
SSL_R_MISSING_TMP_DH_KEY:171:missing tmp dh key
|
||||
SSL_R_MISSING_TMP_ECDH_KEY:311:missing tmp ecdh key
|
||||
SSL_R_NOT_ON_RECORD_BOUNDARY:182:not on record boundary
|
||||
SSL_R_NO_APPLICATION_PROTOCOL:235:no application protocol
|
||||
SSL_R_NO_CERTIFICATES_RETURNED:176:no certificates returned
|
||||
SSL_R_NO_CERTIFICATE_ASSIGNED:177:no certificate assigned
|
||||
SSL_R_NO_CERTIFICATE_SET:179:no certificate set
|
||||
@ -2439,6 +2485,7 @@ SSL_R_NULL_SSL_METHOD_PASSED:196:null ssl method passed
|
||||
SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED:197:old session cipher not returned
|
||||
SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED:344:\
|
||||
old session compression algorithm not returned
|
||||
SSL_R_OVERFLOW_ERROR:237:overflow error
|
||||
SSL_R_PACKET_LENGTH_TOO_LONG:198:packet length too long
|
||||
SSL_R_PARSE_TLSEXT:227:parse tlsext
|
||||
SSL_R_PATH_TOO_LONG:270:path too long
|
||||
|
@ -26,9 +26,13 @@ int ERR_load_SSL_strings(void);
|
||||
# define SSL_F_ADD_KEY_SHARE 512
|
||||
# define SSL_F_BYTES_TO_CIPHER_LIST 519
|
||||
# define SSL_F_CHECK_SUITEB_CIPHER_LIST 331
|
||||
# define SSL_F_CONSTRUCT_CA_NAMES 552
|
||||
# define SSL_F_CONSTRUCT_KEY_EXCHANGE_TBS 553
|
||||
# define SSL_F_CREATE_SYNTHETIC_MESSAGE_HASH 539
|
||||
# define SSL_F_CT_MOVE_SCTS 345
|
||||
# define SSL_F_CT_STRICT 349
|
||||
# define SSL_F_CUSTOM_EXT_ADD 554
|
||||
# define SSL_F_CUSTOM_EXT_PARSE 555
|
||||
# define SSL_F_D2I_SSL_SESSION 103
|
||||
# define SSL_F_DANE_CTX_ENABLE 347
|
||||
# define SSL_F_DANE_MTYPE_SET 393
|
||||
@ -53,11 +57,15 @@ int ERR_load_SSL_strings(void);
|
||||
# define SSL_F_DTLS_GET_REASSEMBLED_MESSAGE 370
|
||||
# define SSL_F_DTLS_PROCESS_HELLO_VERIFY 386
|
||||
# define SSL_F_EARLY_DATA_COUNT_OK 532
|
||||
# define SSL_F_FINAL_EARLY_DATA 556
|
||||
# define SSL_F_FINAL_EC_PT_FORMATS 485
|
||||
# define SSL_F_FINAL_EMS 486
|
||||
# define SSL_F_FINAL_KEY_SHARE 503
|
||||
# define SSL_F_FINAL_MAXFRAGMENTLEN 557
|
||||
# define SSL_F_FINAL_RENEGOTIATE 483
|
||||
# define SSL_F_FINAL_SERVER_NAME 558
|
||||
# define SSL_F_FINAL_SIG_ALGS 497
|
||||
# define SSL_F_GET_CERT_VERIFY_TBS_DATA 588
|
||||
# define SSL_F_NSS_KEYLOG_INT 500
|
||||
# define SSL_F_OPENSSL_INIT_SSL 342
|
||||
# define SSL_F_OSSL_STATEM_CLIENT13_READ_TRANSITION 436
|
||||
@ -70,6 +78,7 @@ int ERR_load_SSL_strings(void);
|
||||
# define SSL_F_PROCESS_KEY_SHARE_EXT 439
|
||||
# define SSL_F_READ_STATE_MACHINE 352
|
||||
# define SSL_F_SET_CLIENT_CIPHERSUITE 540
|
||||
# define SSL_F_SRP_GENERATE_SERVER_MASTER_SECRET 589
|
||||
# define SSL_F_SSL3_CHANGE_CIPHER_STATE 129
|
||||
# define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 130
|
||||
# define SSL_F_SSL3_CTRL 213
|
||||
@ -77,6 +86,7 @@ int ERR_load_SSL_strings(void);
|
||||
# define SSL_F_SSL3_DIGEST_CACHED_RECORDS 293
|
||||
# define SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC 292
|
||||
# define SSL_F_SSL3_FINAL_FINISH_MAC 285
|
||||
# define SSL_F_SSL3_FINISH_MAC 587
|
||||
# define SSL_F_SSL3_GENERATE_KEY_BLOCK 238
|
||||
# define SSL_F_SSL3_GENERATE_MASTER_SECRET 388
|
||||
# define SSL_F_SSL3_GET_RECORD 143
|
||||
@ -145,15 +155,18 @@ int ERR_load_SSL_strings(void);
|
||||
# define SSL_F_SSL_CTX_USE_SERVERINFO_FILE 337
|
||||
# define SSL_F_SSL_DANE_DUP 403
|
||||
# define SSL_F_SSL_DANE_ENABLE 395
|
||||
# define SSL_F_SSL_DERIVE 590
|
||||
# define SSL_F_SSL_DO_CONFIG 391
|
||||
# define SSL_F_SSL_DO_HANDSHAKE 180
|
||||
# define SSL_F_SSL_DUP_CA_LIST 408
|
||||
# define SSL_F_SSL_ENABLE_CT 402
|
||||
# define SSL_F_SSL_GENERATE_PKEY_GROUP 559
|
||||
# define SSL_F_SSL_GENERATE_SESSION_ID 547
|
||||
# define SSL_F_SSL_GET_NEW_SESSION 181
|
||||
# define SSL_F_SSL_GET_PREV_SESSION 217
|
||||
# define SSL_F_SSL_GET_SERVER_CERT_INDEX 322
|
||||
# define SSL_F_SSL_GET_SIGN_PKEY 183
|
||||
# define SSL_F_SSL_HANDSHAKE_HASH 560
|
||||
# define SSL_F_SSL_INIT_WBIO_BUFFER 184
|
||||
# define SSL_F_SSL_KEY_UPDATE 515
|
||||
# define SSL_F_SSL_LOAD_CLIENT_CA_FILE 185
|
||||
@ -161,6 +174,7 @@ int ERR_load_SSL_strings(void);
|
||||
# define SSL_F_SSL_LOG_RSA_CLIENT_KEY_EXCHANGE 499
|
||||
# define SSL_F_SSL_MODULE_INIT 392
|
||||
# define SSL_F_SSL_NEW 186
|
||||
# define SSL_F_SSL_NEXT_PROTO_VALIDATE 565
|
||||
# define SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT 300
|
||||
# define SSL_F_SSL_PARSE_CLIENTHELLO_TLSEXT 302
|
||||
# define SSL_F_SSL_PARSE_CLIENTHELLO_USE_SRTP_EXT 310
|
||||
@ -221,6 +235,8 @@ int ERR_load_SSL_strings(void);
|
||||
# define SSL_F_TLS12_CHECK_PEER_SIGALG 333
|
||||
# define SSL_F_TLS12_COPY_SIGALGS 533
|
||||
# define SSL_F_TLS13_CHANGE_CIPHER_STATE 440
|
||||
# define SSL_F_TLS13_GENERATE_SECRET 591
|
||||
# define SSL_F_TLS13_HKDF_EXPAND 561
|
||||
# define SSL_F_TLS13_SETUP_KEY_BLOCK 441
|
||||
# define SSL_F_TLS1_CHANGE_CIPHER_STATE 209
|
||||
# define SSL_F_TLS1_CHECK_DUPLICATE_EXTENSIONS 341
|
||||
@ -311,17 +327,40 @@ int ERR_load_SSL_strings(void);
|
||||
# define SSL_F_TLS_EARLY_POST_PROCESS_CLIENT_HELLO 521
|
||||
# define SSL_F_TLS_GET_MESSAGE_BODY 351
|
||||
# define SSL_F_TLS_GET_MESSAGE_HEADER 387
|
||||
# define SSL_F_TLS_HANDLE_ALPN 562
|
||||
# define SSL_F_TLS_HANDLE_STATUS_REQUEST 563
|
||||
# define SSL_F_TLS_PARSE_CERTIFICATE_AUTHORITIES 566
|
||||
# define SSL_F_TLS_PARSE_CLIENTHELLO_TLSEXT 449
|
||||
# define SSL_F_TLS_PARSE_CTOS_ALPN 567
|
||||
# define SSL_F_TLS_PARSE_CTOS_EARLY_DATA 568
|
||||
# define SSL_F_TLS_PARSE_CTOS_EC_PT_FORMATS 569
|
||||
# define SSL_F_TLS_PARSE_CTOS_EMS 570
|
||||
# define SSL_F_TLS_PARSE_CTOS_KEY_SHARE 463
|
||||
# define SSL_F_TLS_PARSE_CTOS_MAXFRAGMENTLEN 571
|
||||
# define SSL_F_TLS_PARSE_CTOS_PSK 505
|
||||
# define SSL_F_TLS_PARSE_CTOS_PSK_KEX_MODES 572
|
||||
# define SSL_F_TLS_PARSE_CTOS_RENEGOTIATE 464
|
||||
# define SSL_F_TLS_PARSE_CTOS_SERVER_NAME 573
|
||||
# define SSL_F_TLS_PARSE_CTOS_SESSION_TICKET 574
|
||||
# define SSL_F_TLS_PARSE_CTOS_SIG_ALGS 575
|
||||
# define SSL_F_TLS_PARSE_CTOS_SRP 576
|
||||
# define SSL_F_TLS_PARSE_CTOS_STATUS_REQUEST 577
|
||||
# define SSL_F_TLS_PARSE_CTOS_SUPPORTED_GROUPS 578
|
||||
# define SSL_F_TLS_PARSE_CTOS_USE_SRTP 465
|
||||
# define SSL_F_TLS_PARSE_STOC_ALPN 579
|
||||
# define SSL_F_TLS_PARSE_STOC_COOKIE 534
|
||||
# define SSL_F_TLS_PARSE_STOC_EARLY_DATA 538
|
||||
# define SSL_F_TLS_PARSE_STOC_EARLY_DATA_INFO 528
|
||||
# define SSL_F_TLS_PARSE_STOC_EC_PT_FORMATS 580
|
||||
# define SSL_F_TLS_PARSE_STOC_KEY_SHARE 445
|
||||
# define SSL_F_TLS_PARSE_STOC_MAXFRAGMENTLEN 581
|
||||
# define SSL_F_TLS_PARSE_STOC_NPN 582
|
||||
# define SSL_F_TLS_PARSE_STOC_PSK 502
|
||||
# define SSL_F_TLS_PARSE_STOC_RENEGOTIATE 448
|
||||
# define SSL_F_TLS_PARSE_STOC_SCT 564
|
||||
# define SSL_F_TLS_PARSE_STOC_SERVER_NAME 583
|
||||
# define SSL_F_TLS_PARSE_STOC_SESSION_TICKET 584
|
||||
# define SSL_F_TLS_PARSE_STOC_STATUS_REQUEST 585
|
||||
# define SSL_F_TLS_PARSE_STOC_USE_SRTP 446
|
||||
# define SSL_F_TLS_POST_PROCESS_CLIENT_HELLO 378
|
||||
# define SSL_F_TLS_POST_PROCESS_CLIENT_KEY_EXCHANGE 384
|
||||
@ -361,6 +400,7 @@ int ERR_load_SSL_strings(void);
|
||||
# define SSL_F_TLS_SCAN_CLIENTHELLO_TLSEXT 450
|
||||
# define SSL_F_TLS_SETUP_HANDSHAKE 508
|
||||
# define SSL_F_USE_CERTIFICATE_CHAIN_FILE 220
|
||||
# define SSL_F_WRITE_STATE_MACHINE 586
|
||||
|
||||
/*
|
||||
* SSL reason codes.
|
||||
@ -376,14 +416,17 @@ int ERR_load_SSL_strings(void);
|
||||
# define SSL_R_BAD_DECOMPRESSION 107
|
||||
# define SSL_R_BAD_DH_VALUE 102
|
||||
# define SSL_R_BAD_DIGEST_LENGTH 111
|
||||
# define SSL_R_BAD_EARLY_DATA 233
|
||||
# define SSL_R_BAD_ECC_CERT 304
|
||||
# define SSL_R_BAD_ECPOINT 306
|
||||
# define SSL_R_BAD_EXTENSION 110
|
||||
# define SSL_R_BAD_HANDSHAKE_LENGTH 332
|
||||
# define SSL_R_BAD_HANDSHAKE_STATE 236
|
||||
# define SSL_R_BAD_HELLO_REQUEST 105
|
||||
# define SSL_R_BAD_KEY_SHARE 108
|
||||
# define SSL_R_BAD_KEY_UPDATE 122
|
||||
# define SSL_R_BAD_LENGTH 271
|
||||
# define SSL_R_BAD_PACKET 240
|
||||
# define SSL_R_BAD_PACKET_LENGTH 115
|
||||
# define SSL_R_BAD_PROTOCOL_VERSION_NUMBER 116
|
||||
# define SSL_R_BAD_PSK 219
|
||||
@ -401,6 +444,7 @@ int ERR_load_SSL_strings(void);
|
||||
# define SSL_R_BIO_NOT_SET 128
|
||||
# define SSL_R_BLOCK_CIPHER_PAD_IS_WRONG 129
|
||||
# define SSL_R_BN_LIB 130
|
||||
# define SSL_R_CALLBACK_FAILED 234
|
||||
# define SSL_R_CANNOT_CHANGE_CIPHER 109
|
||||
# define SSL_R_CA_DN_LENGTH_MISMATCH 131
|
||||
# define SSL_R_CA_KEY_TOO_SMALL 397
|
||||
@ -467,6 +511,7 @@ int ERR_load_SSL_strings(void);
|
||||
# define SSL_R_INCONSISTENT_EARLY_DATA_SNI 231
|
||||
# define SSL_R_INCONSISTENT_EXTMS 104
|
||||
# define SSL_R_INVALID_ALERT 205
|
||||
# define SSL_R_INVALID_CERTIFICATE_OR_ALG 238
|
||||
# define SSL_R_INVALID_COMMAND 280
|
||||
# define SSL_R_INVALID_COMPRESSION_ALGORITHM 341
|
||||
# define SSL_R_INVALID_CONFIGURATION_NAME 113
|
||||
@ -496,6 +541,7 @@ int ERR_load_SSL_strings(void);
|
||||
# define SSL_R_MISSING_TMP_DH_KEY 171
|
||||
# define SSL_R_MISSING_TMP_ECDH_KEY 311
|
||||
# define SSL_R_NOT_ON_RECORD_BOUNDARY 182
|
||||
# define SSL_R_NO_APPLICATION_PROTOCOL 235
|
||||
# define SSL_R_NO_CERTIFICATES_RETURNED 176
|
||||
# define SSL_R_NO_CERTIFICATE_ASSIGNED 177
|
||||
# define SSL_R_NO_CERTIFICATE_SET 179
|
||||
@ -524,6 +570,7 @@ int ERR_load_SSL_strings(void);
|
||||
# define SSL_R_NULL_SSL_METHOD_PASSED 196
|
||||
# define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED 197
|
||||
# define SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED 344
|
||||
# define SSL_R_OVERFLOW_ERROR 237
|
||||
# define SSL_R_PACKET_LENGTH_TOO_LONG 198
|
||||
# define SSL_R_PARSE_TLSEXT 227
|
||||
# define SSL_R_PATH_TOO_LONG 270
|
||||
|
@ -116,7 +116,9 @@ int ssl3_setup_write_buffer(SSL *s, size_t numwpipes, size_t len)
|
||||
p = OPENSSL_malloc(len);
|
||||
if (p == NULL) {
|
||||
s->rlayer.numwpipes = currpipe;
|
||||
goto err;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_SSL3_SETUP_WRITE_BUFFER, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
memset(thiswb, 0, sizeof(SSL3_BUFFER));
|
||||
thiswb->buf = p;
|
||||
@ -125,18 +127,16 @@ int ssl3_setup_write_buffer(SSL *s, size_t numwpipes, size_t len)
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
err:
|
||||
SSLerr(SSL_F_SSL3_SETUP_WRITE_BUFFER, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ssl3_setup_buffers(SSL *s)
|
||||
{
|
||||
if (!ssl3_setup_read_buffer(s))
|
||||
return 0;
|
||||
if (!ssl3_setup_write_buffer(s, 1, 0))
|
||||
if (!ssl3_setup_write_buffer(s, 1, 0)) {
|
||||
/* SSLfatal() already called */
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
120
ssl/s3_enc.c
120
ssl/s3_enc.c
@ -96,8 +96,9 @@ int ssl3_change_cipher_state(SSL *s, int which)
|
||||
m = s->s3->tmp.new_hash;
|
||||
/* m == NULL will lead to a crash later */
|
||||
if (!ossl_assert(m != NULL)) {
|
||||
SSLerr(SSL_F_SSL3_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
|
||||
goto err2;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_CHANGE_CIPHER_STATE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
#ifndef OPENSSL_NO_COMP
|
||||
if (s->s3->tmp.new_compression == NULL)
|
||||
@ -107,20 +108,24 @@ int ssl3_change_cipher_state(SSL *s, int which)
|
||||
#endif
|
||||
|
||||
if (which & SSL3_CC_READ) {
|
||||
if (s->enc_read_ctx != NULL)
|
||||
if (s->enc_read_ctx != NULL) {
|
||||
reuse_dd = 1;
|
||||
else if ((s->enc_read_ctx = EVP_CIPHER_CTX_new()) == NULL)
|
||||
} else if ((s->enc_read_ctx = EVP_CIPHER_CTX_new()) == NULL) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_CHANGE_CIPHER_STATE,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
else
|
||||
} else {
|
||||
/*
|
||||
* make sure it's initialised in case we exit later with an error
|
||||
*/
|
||||
EVP_CIPHER_CTX_reset(s->enc_read_ctx);
|
||||
}
|
||||
dd = s->enc_read_ctx;
|
||||
|
||||
if (ssl_replace_hash(&s->read_hash, m) == NULL) {
|
||||
SSLerr(SSL_F_SSL3_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
|
||||
goto err2;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_CHANGE_CIPHER_STATE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
#ifndef OPENSSL_NO_COMP
|
||||
/* COMPRESS */
|
||||
@ -129,28 +134,33 @@ int ssl3_change_cipher_state(SSL *s, int which)
|
||||
if (comp != NULL) {
|
||||
s->expand = COMP_CTX_new(comp);
|
||||
if (s->expand == NULL) {
|
||||
SSLerr(SSL_F_SSL3_CHANGE_CIPHER_STATE,
|
||||
SSL_R_COMPRESSION_LIBRARY_ERROR);
|
||||
goto err2;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_SSL3_CHANGE_CIPHER_STATE,
|
||||
SSL_R_COMPRESSION_LIBRARY_ERROR);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
RECORD_LAYER_reset_read_sequence(&s->rlayer);
|
||||
mac_secret = &(s->s3->read_mac_secret[0]);
|
||||
} else {
|
||||
if (s->enc_write_ctx != NULL)
|
||||
if (s->enc_write_ctx != NULL) {
|
||||
reuse_dd = 1;
|
||||
else if ((s->enc_write_ctx = EVP_CIPHER_CTX_new()) == NULL)
|
||||
} else if ((s->enc_write_ctx = EVP_CIPHER_CTX_new()) == NULL) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_CHANGE_CIPHER_STATE,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
else
|
||||
} else {
|
||||
/*
|
||||
* make sure it's initialised in case we exit later with an error
|
||||
*/
|
||||
EVP_CIPHER_CTX_reset(s->enc_write_ctx);
|
||||
}
|
||||
dd = s->enc_write_ctx;
|
||||
if (ssl_replace_hash(&s->write_hash, m) == NULL) {
|
||||
SSLerr(SSL_F_SSL3_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
|
||||
goto err2;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_CHANGE_CIPHER_STATE,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
#ifndef OPENSSL_NO_COMP
|
||||
/* COMPRESS */
|
||||
@ -159,9 +169,10 @@ int ssl3_change_cipher_state(SSL *s, int which)
|
||||
if (comp != NULL) {
|
||||
s->compress = COMP_CTX_new(comp);
|
||||
if (s->compress == NULL) {
|
||||
SSLerr(SSL_F_SSL3_CHANGE_CIPHER_STATE,
|
||||
SSL_R_COMPRESSION_LIBRARY_ERROR);
|
||||
goto err2;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_SSL3_CHANGE_CIPHER_STATE,
|
||||
SSL_R_COMPRESSION_LIBRARY_ERROR);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -174,8 +185,11 @@ int ssl3_change_cipher_state(SSL *s, int which)
|
||||
|
||||
p = s->s3->tmp.key_block;
|
||||
mdi = EVP_MD_size(m);
|
||||
if (mdi < 0)
|
||||
goto err2;
|
||||
if (mdi < 0) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_CHANGE_CIPHER_STATE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
i = mdi;
|
||||
cl = EVP_CIPHER_key_length(c);
|
||||
j = cl;
|
||||
@ -199,21 +213,23 @@ int ssl3_change_cipher_state(SSL *s, int which)
|
||||
}
|
||||
|
||||
if (n > s->s3->tmp.key_block_length) {
|
||||
SSLerr(SSL_F_SSL3_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
|
||||
goto err2;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_CHANGE_CIPHER_STATE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
memcpy(mac_secret, ms, i);
|
||||
|
||||
if (!EVP_CipherInit_ex(dd, c, NULL, key, iv, (which & SSL3_CC_WRITE)))
|
||||
goto err2;
|
||||
if (!EVP_CipherInit_ex(dd, c, NULL, key, iv, (which & SSL3_CC_WRITE))) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_CHANGE_CIPHER_STATE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
OPENSSL_cleanse(exp_key, sizeof(exp_key));
|
||||
OPENSSL_cleanse(exp_iv, sizeof(exp_iv));
|
||||
return 1;
|
||||
err:
|
||||
SSLerr(SSL_F_SSL3_CHANGE_CIPHER_STATE, ERR_R_MALLOC_FAILURE);
|
||||
err2:
|
||||
OPENSSL_cleanse(exp_key, sizeof(exp_key));
|
||||
OPENSSL_cleanse(exp_iv, sizeof(exp_iv));
|
||||
return 0;
|
||||
@ -232,7 +248,8 @@ int ssl3_setup_key_block(SSL *s)
|
||||
return 1;
|
||||
|
||||
if (!ssl_cipher_get_evp(s->session, &c, &hash, NULL, NULL, &comp, 0)) {
|
||||
SSLerr(SSL_F_SSL3_SETUP_KEY_BLOCK, SSL_R_CIPHER_OR_HASH_UNAVAILABLE);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_SETUP_KEY_BLOCK,
|
||||
SSL_R_CIPHER_OR_HASH_UNAVAILABLE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -253,8 +270,11 @@ int ssl3_setup_key_block(SSL *s)
|
||||
|
||||
ssl3_cleanup_key_block(s);
|
||||
|
||||
if ((p = OPENSSL_malloc(num)) == NULL)
|
||||
goto err;
|
||||
if ((p = OPENSSL_malloc(num)) == NULL) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_SETUP_KEY_BLOCK,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
s->s3->tmp.key_block_length = num;
|
||||
s->s3->tmp.key_block = p;
|
||||
@ -280,10 +300,6 @@ int ssl3_setup_key_block(SSL *s)
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
err:
|
||||
SSLerr(SSL_F_SSL3_SETUP_KEY_BLOCK, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ssl3_cleanup_key_block(SSL *s)
|
||||
@ -323,16 +339,30 @@ void ssl3_free_digest_list(SSL *s)
|
||||
|
||||
int ssl3_finish_mac(SSL *s, const unsigned char *buf, size_t len)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (s->s3->handshake_dgst == NULL) {
|
||||
int ret;
|
||||
/* Note: this writes to a memory BIO so a failure is a fatal error */
|
||||
if (len > INT_MAX)
|
||||
if (len > INT_MAX) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_FINISH_MAC,
|
||||
SSL_R_OVERFLOW_ERROR);
|
||||
return 0;
|
||||
}
|
||||
ret = BIO_write(s->s3->handshake_buffer, (void *)buf, (int)len);
|
||||
return ret > 0 && ret == (int)len;
|
||||
if (ret <= 0 || ret != (int)len) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_FINISH_MAC,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
return EVP_DigestUpdate(s->s3->handshake_dgst, buf, len);
|
||||
ret = EVP_DigestUpdate(s->s3->handshake_dgst, buf, len);
|
||||
if (!ret) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_FINISH_MAC,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ssl3_digest_cached_records(SSL *s, int keep)
|
||||
@ -344,21 +374,23 @@ int ssl3_digest_cached_records(SSL *s, int keep)
|
||||
if (s->s3->handshake_dgst == NULL) {
|
||||
hdatalen = BIO_get_mem_data(s->s3->handshake_buffer, &hdata);
|
||||
if (hdatalen <= 0) {
|
||||
SSLerr(SSL_F_SSL3_DIGEST_CACHED_RECORDS,
|
||||
SSL_R_BAD_HANDSHAKE_LENGTH);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_DIGEST_CACHED_RECORDS,
|
||||
SSL_R_BAD_HANDSHAKE_LENGTH);
|
||||
return 0;
|
||||
}
|
||||
|
||||
s->s3->handshake_dgst = EVP_MD_CTX_new();
|
||||
if (s->s3->handshake_dgst == NULL) {
|
||||
SSLerr(SSL_F_SSL3_DIGEST_CACHED_RECORDS, ERR_R_MALLOC_FAILURE);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_DIGEST_CACHED_RECORDS,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
md = ssl_handshake_md(s);
|
||||
if (md == NULL || !EVP_DigestInit_ex(s->s3->handshake_dgst, md, NULL)
|
||||
|| !EVP_DigestUpdate(s->s3->handshake_dgst, hdata, hdatalen)) {
|
||||
SSLerr(SSL_F_SSL3_DIGEST_CACHED_RECORDS, ERR_R_INTERNAL_ERROR);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_DIGEST_CACHED_RECORDS,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -435,7 +467,8 @@ int ssl3_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p,
|
||||
size_t ret_secret_size = 0;
|
||||
|
||||
if (ctx == NULL) {
|
||||
SSLerr(SSL_F_SSL3_GENERATE_MASTER_SECRET, ERR_R_MALLOC_FAILURE);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_GENERATE_MASTER_SECRET,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; i < 3; i++) {
|
||||
@ -453,7 +486,8 @@ int ssl3_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p,
|
||||
|| EVP_DigestUpdate(ctx, p, len) <= 0
|
||||
|| EVP_DigestUpdate(ctx, buf, n) <= 0
|
||||
|| EVP_DigestFinal_ex(ctx, out, &n) <= 0) {
|
||||
SSLerr(SSL_F_SSL3_GENERATE_MASTER_SECRET, ERR_R_INTERNAL_ERROR);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_SSL3_GENERATE_MASTER_SECRET, ERR_R_INTERNAL_ERROR);
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
|
50
ssl/s3_lib.c
50
ssl/s3_lib.c
@ -4590,8 +4590,10 @@ int ssl_generate_master_secret(SSL *s, unsigned char *pms, size_t pmslen,
|
||||
s->s3->tmp.psk = NULL;
|
||||
if (!s->method->ssl3_enc->generate_master_secret(s,
|
||||
s->session->master_key,pskpms, pskpmslen,
|
||||
&s->session->master_key_length))
|
||||
&s->session->master_key_length)) {
|
||||
/* SSLfatal() already called */
|
||||
goto err;
|
||||
}
|
||||
OPENSSL_clear_free(pskpms, pskpmslen);
|
||||
#else
|
||||
/* Should never happen */
|
||||
@ -4600,8 +4602,10 @@ int ssl_generate_master_secret(SSL *s, unsigned char *pms, size_t pmslen,
|
||||
} else {
|
||||
if (!s->method->ssl3_enc->generate_master_secret(s,
|
||||
s->session->master_key, pms, pmslen,
|
||||
&s->session->master_key_length))
|
||||
&s->session->master_key_length)) {
|
||||
/* SSLfatal() already called */
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
@ -4641,28 +4645,42 @@ EVP_PKEY *ssl_generate_pkey(EVP_PKEY *pm)
|
||||
}
|
||||
#ifndef OPENSSL_NO_EC
|
||||
/* Generate a private key from a group ID */
|
||||
EVP_PKEY *ssl_generate_pkey_group(uint16_t id)
|
||||
EVP_PKEY *ssl_generate_pkey_group(SSL *s, uint16_t id)
|
||||
{
|
||||
EVP_PKEY_CTX *pctx = NULL;
|
||||
EVP_PKEY *pkey = NULL;
|
||||
const TLS_GROUP_INFO *ginf = tls1_group_id_lookup(id);
|
||||
uint16_t gtype;
|
||||
|
||||
if (ginf == NULL)
|
||||
if (ginf == NULL) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GENERATE_PKEY_GROUP,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
gtype = ginf->flags & TLS_CURVE_TYPE;
|
||||
if (gtype == TLS_CURVE_CUSTOM)
|
||||
pctx = EVP_PKEY_CTX_new_id(ginf->nid, NULL);
|
||||
else
|
||||
pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL);
|
||||
if (pctx == NULL)
|
||||
if (pctx == NULL) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GENERATE_PKEY_GROUP,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
if (EVP_PKEY_keygen_init(pctx) <= 0)
|
||||
}
|
||||
if (EVP_PKEY_keygen_init(pctx) <= 0) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GENERATE_PKEY_GROUP,
|
||||
ERR_R_EVP_LIB);
|
||||
goto err;
|
||||
}
|
||||
if (gtype != TLS_CURVE_CUSTOM
|
||||
&& EVP_PKEY_CTX_set_ec_paramgen_curve_nid(pctx, ginf->nid) <= 0)
|
||||
&& EVP_PKEY_CTX_set_ec_paramgen_curve_nid(pctx, ginf->nid) <= 0) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GENERATE_PKEY_GROUP,
|
||||
ERR_R_EVP_LIB);
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_keygen(pctx, &pkey) <= 0) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GENERATE_PKEY_GROUP,
|
||||
ERR_R_EVP_LIB);
|
||||
EVP_PKEY_free(pkey);
|
||||
pkey = NULL;
|
||||
}
|
||||
@ -4718,25 +4736,37 @@ int ssl_derive(SSL *s, EVP_PKEY *privkey, EVP_PKEY *pubkey, int gensecret)
|
||||
size_t pmslen = 0;
|
||||
EVP_PKEY_CTX *pctx;
|
||||
|
||||
if (privkey == NULL || pubkey == NULL)
|
||||
if (privkey == NULL || pubkey == NULL) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_DERIVE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
pctx = EVP_PKEY_CTX_new(privkey, NULL);
|
||||
|
||||
if (EVP_PKEY_derive_init(pctx) <= 0
|
||||
|| EVP_PKEY_derive_set_peer(pctx, pubkey) <= 0
|
||||
|| EVP_PKEY_derive(pctx, NULL, &pmslen) <= 0) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_DERIVE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
pms = OPENSSL_malloc(pmslen);
|
||||
if (pms == NULL)
|
||||
if (pms == NULL) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_DERIVE,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (EVP_PKEY_derive(pctx, pms, &pmslen) <= 0)
|
||||
if (EVP_PKEY_derive(pctx, pms, &pmslen) <= 0) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_DERIVE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (gensecret) {
|
||||
/* SSLfatal() called as appropriate in the below functions */
|
||||
if (SSL_IS_TLS13(s)) {
|
||||
/*
|
||||
* If we are resuming then we already generated the early secret
|
||||
|
@ -20,10 +20,15 @@ static const ERR_STRING_DATA SSL_str_functs[] = {
|
||||
"bytes_to_cipher_list"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_CHECK_SUITEB_CIPHER_LIST, 0),
|
||||
"check_suiteb_cipher_list"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_CONSTRUCT_CA_NAMES, 0), "construct_ca_names"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_CONSTRUCT_KEY_EXCHANGE_TBS, 0),
|
||||
"construct_key_exchange_tbs"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_CREATE_SYNTHETIC_MESSAGE_HASH, 0),
|
||||
"create_synthetic_message_hash"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_CT_MOVE_SCTS, 0), "ct_move_scts"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_CT_STRICT, 0), "ct_strict"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_CUSTOM_EXT_ADD, 0), "custom_ext_add"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_CUSTOM_EXT_PARSE, 0), "custom_ext_parse"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_D2I_SSL_SESSION, 0), "d2i_SSL_SESSION"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_DANE_CTX_ENABLE, 0), "dane_ctx_enable"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_DANE_MTYPE_SET, 0), "dane_mtype_set"},
|
||||
@ -61,12 +66,18 @@ static const ERR_STRING_DATA SSL_str_functs[] = {
|
||||
"dtls_process_hello_verify"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_EARLY_DATA_COUNT_OK, 0),
|
||||
"early_data_count_ok"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_FINAL_EARLY_DATA, 0), "final_early_data"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_FINAL_EC_PT_FORMATS, 0),
|
||||
"final_ec_pt_formats"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_FINAL_EMS, 0), "final_ems"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_FINAL_KEY_SHARE, 0), "final_key_share"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_FINAL_MAXFRAGMENTLEN, 0),
|
||||
"final_maxfragmentlen"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_FINAL_RENEGOTIATE, 0), "final_renegotiate"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_FINAL_SERVER_NAME, 0), "final_server_name"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_FINAL_SIG_ALGS, 0), "final_sig_algs"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_GET_CERT_VERIFY_TBS_DATA, 0),
|
||||
"get_cert_verify_tbs_data"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_NSS_KEYLOG_INT, 0), "nss_keylog_int"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_OPENSSL_INIT_SSL, 0), "OPENSSL_init_ssl"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_OSSL_STATEM_CLIENT13_READ_TRANSITION, 0), ""},
|
||||
@ -82,6 +93,8 @@ static const ERR_STRING_DATA SSL_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_READ_STATE_MACHINE, 0), "read_state_machine"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SET_CLIENT_CIPHERSUITE, 0),
|
||||
"set_client_ciphersuite"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SRP_GENERATE_SERVER_MASTER_SECRET, 0),
|
||||
"srp_generate_server_master_secret"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL3_CHANGE_CIPHER_STATE, 0),
|
||||
"ssl3_change_cipher_state"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, 0),
|
||||
@ -94,6 +107,7 @@ static const ERR_STRING_DATA SSL_str_functs[] = {
|
||||
"ssl3_do_change_cipher_spec"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL3_FINAL_FINISH_MAC, 0),
|
||||
"ssl3_final_finish_mac"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL3_FINISH_MAC, 0), "ssl3_finish_mac"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL3_GENERATE_KEY_BLOCK, 0),
|
||||
"ssl3_generate_key_block"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL3_GENERATE_MASTER_SECRET, 0),
|
||||
@ -206,10 +220,13 @@ static const ERR_STRING_DATA SSL_str_functs[] = {
|
||||
"SSL_CTX_use_serverinfo_file"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_DANE_DUP, 0), "ssl_dane_dup"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_DANE_ENABLE, 0), "SSL_dane_enable"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_DERIVE, 0), "ssl_derive"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_DO_CONFIG, 0), "ssl_do_config"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_DO_HANDSHAKE, 0), "SSL_do_handshake"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_DUP_CA_LIST, 0), "SSL_dup_CA_list"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_ENABLE_CT, 0), "SSL_enable_ct"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_GENERATE_PKEY_GROUP, 0),
|
||||
"ssl_generate_pkey_group"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_GENERATE_SESSION_ID, 0),
|
||||
"ssl_generate_session_id"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_GET_NEW_SESSION, 0),
|
||||
@ -218,6 +235,7 @@ static const ERR_STRING_DATA SSL_str_functs[] = {
|
||||
"ssl_get_prev_session"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_GET_SERVER_CERT_INDEX, 0), ""},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_GET_SIGN_PKEY, 0), ""},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_HANDSHAKE_HASH, 0), "ssl_handshake_hash"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_INIT_WBIO_BUFFER, 0),
|
||||
"ssl_init_wbio_buffer"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_KEY_UPDATE, 0), "SSL_key_update"},
|
||||
@ -228,6 +246,8 @@ static const ERR_STRING_DATA SSL_str_functs[] = {
|
||||
"ssl_log_rsa_client_key_exchange"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_MODULE_INIT, 0), "ssl_module_init"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_NEW, 0), "SSL_new"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_NEXT_PROTO_VALIDATE, 0),
|
||||
"ssl_next_proto_validate"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT, 0), ""},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_PARSE_CLIENTHELLO_TLSEXT, 0), ""},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_PARSE_CLIENTHELLO_USE_SRTP_EXT, 0), ""},
|
||||
@ -315,6 +335,9 @@ static const ERR_STRING_DATA SSL_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS12_COPY_SIGALGS, 0), "tls12_copy_sigalgs"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS13_CHANGE_CIPHER_STATE, 0),
|
||||
"tls13_change_cipher_state"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS13_GENERATE_SECRET, 0),
|
||||
"tls13_generate_secret"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS13_HKDF_EXPAND, 0), "tls13_hkdf_expand"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS13_SETUP_KEY_BLOCK, 0),
|
||||
"tls13_setup_key_block"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS1_CHANGE_CIPHER_STATE, 0),
|
||||
@ -478,24 +501,65 @@ static const ERR_STRING_DATA SSL_str_functs[] = {
|
||||
"tls_get_message_body"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_GET_MESSAGE_HEADER, 0),
|
||||
"tls_get_message_header"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_HANDLE_ALPN, 0), "tls_handle_alpn"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_HANDLE_STATUS_REQUEST, 0),
|
||||
"tls_handle_status_request"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_CERTIFICATE_AUTHORITIES, 0),
|
||||
"tls_parse_certificate_authorities"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_CLIENTHELLO_TLSEXT, 0), ""},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_CTOS_ALPN, 0),
|
||||
"tls_parse_ctos_alpn"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_CTOS_EARLY_DATA, 0),
|
||||
"tls_parse_ctos_early_data"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_CTOS_EC_PT_FORMATS, 0),
|
||||
"tls_parse_ctos_ec_pt_formats"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_CTOS_EMS, 0), "tls_parse_ctos_ems"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_CTOS_KEY_SHARE, 0),
|
||||
"tls_parse_ctos_key_share"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_CTOS_MAXFRAGMENTLEN, 0),
|
||||
"tls_parse_ctos_maxfragmentlen"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_CTOS_PSK, 0), "tls_parse_ctos_psk"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_CTOS_PSK_KEX_MODES, 0),
|
||||
"tls_parse_ctos_psk_kex_modes"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_CTOS_RENEGOTIATE, 0),
|
||||
"tls_parse_ctos_renegotiate"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_CTOS_SERVER_NAME, 0),
|
||||
"tls_parse_ctos_server_name"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_CTOS_SESSION_TICKET, 0),
|
||||
"tls_parse_ctos_session_ticket"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_CTOS_SIG_ALGS, 0),
|
||||
"tls_parse_ctos_sig_algs"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_CTOS_SRP, 0), "tls_parse_ctos_srp"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_CTOS_STATUS_REQUEST, 0),
|
||||
"tls_parse_ctos_status_request"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_CTOS_SUPPORTED_GROUPS, 0),
|
||||
"tls_parse_ctos_supported_groups"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_CTOS_USE_SRTP, 0),
|
||||
"tls_parse_ctos_use_srtp"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_STOC_ALPN, 0),
|
||||
"tls_parse_stoc_alpn"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_STOC_COOKIE, 0),
|
||||
"tls_parse_stoc_cookie"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_STOC_EARLY_DATA, 0),
|
||||
"tls_parse_stoc_early_data"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_STOC_EARLY_DATA_INFO, 0), ""},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_STOC_EC_PT_FORMATS, 0),
|
||||
"tls_parse_stoc_ec_pt_formats"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_STOC_KEY_SHARE, 0),
|
||||
"tls_parse_stoc_key_share"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_STOC_MAXFRAGMENTLEN, 0),
|
||||
"tls_parse_stoc_maxfragmentlen"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_STOC_NPN, 0), "tls_parse_stoc_npn"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_STOC_PSK, 0), "tls_parse_stoc_psk"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_STOC_RENEGOTIATE, 0),
|
||||
"tls_parse_stoc_renegotiate"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_STOC_SCT, 0), "tls_parse_stoc_sct"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_STOC_SERVER_NAME, 0),
|
||||
"tls_parse_stoc_server_name"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_STOC_SESSION_TICKET, 0),
|
||||
"tls_parse_stoc_session_ticket"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_STOC_STATUS_REQUEST, 0),
|
||||
"tls_parse_stoc_status_request"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_PARSE_STOC_USE_SRTP, 0),
|
||||
"tls_parse_stoc_use_srtp"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_TLS_POST_PROCESS_CLIENT_HELLO, 0),
|
||||
@ -571,6 +635,8 @@ static const ERR_STRING_DATA SSL_str_functs[] = {
|
||||
"tls_setup_handshake"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_USE_CERTIFICATE_CHAIN_FILE, 0),
|
||||
"use_certificate_chain_file"},
|
||||
{ERR_PACK(ERR_LIB_SSL, SSL_F_WRITE_STATE_MACHINE, 0),
|
||||
"write_state_machine"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
@ -592,15 +658,19 @@ static const ERR_STRING_DATA SSL_str_reasons[] = {
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_DECOMPRESSION), "bad decompression"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_DH_VALUE), "bad dh value"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_DIGEST_LENGTH), "bad digest length"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_EARLY_DATA), "bad early data"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_ECC_CERT), "bad ecc cert"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_ECPOINT), "bad ecpoint"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_EXTENSION), "bad extension"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_HANDSHAKE_LENGTH),
|
||||
"bad handshake length"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_HANDSHAKE_STATE),
|
||||
"bad handshake state"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_HELLO_REQUEST), "bad hello request"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_KEY_SHARE), "bad key share"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_KEY_UPDATE), "bad key update"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_LENGTH), "bad length"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_PACKET), "bad packet"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_PACKET_LENGTH), "bad packet length"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_PROTOCOL_VERSION_NUMBER),
|
||||
"bad protocol version number"},
|
||||
@ -621,6 +691,7 @@ static const ERR_STRING_DATA SSL_str_reasons[] = {
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BLOCK_CIPHER_PAD_IS_WRONG),
|
||||
"block cipher pad is wrong"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BN_LIB), "bn lib"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_CALLBACK_FAILED), "callback failed"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_CANNOT_CHANGE_CIPHER),
|
||||
"cannot change cipher"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_CA_DN_LENGTH_MISMATCH),
|
||||
@ -740,6 +811,8 @@ static const ERR_STRING_DATA SSL_str_reasons[] = {
|
||||
"inconsistent early data sni"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_INCONSISTENT_EXTMS), "inconsistent extms"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_INVALID_ALERT), "invalid alert"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_INVALID_CERTIFICATE_OR_ALG),
|
||||
"invalid certificate or alg"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_INVALID_COMMAND), "invalid command"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_INVALID_COMPRESSION_ALGORITHM),
|
||||
"invalid compression algorithm"},
|
||||
@ -792,6 +865,8 @@ static const ERR_STRING_DATA SSL_str_reasons[] = {
|
||||
"missing tmp ecdh key"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_NOT_ON_RECORD_BOUNDARY),
|
||||
"not on record boundary"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_NO_APPLICATION_PROTOCOL),
|
||||
"no application protocol"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_NO_CERTIFICATES_RETURNED),
|
||||
"no certificates returned"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_NO_CERTIFICATE_ASSIGNED),
|
||||
@ -838,6 +913,7 @@ static const ERR_STRING_DATA SSL_str_reasons[] = {
|
||||
"old session cipher not returned"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED),
|
||||
"old session compression algorithm not returned"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_OVERFLOW_ERROR), "overflow error"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_PACKET_LENGTH_TOO_LONG),
|
||||
"packet length too long"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_PARSE_TLSEXT), "parse tlsext"},
|
||||
|
@ -4201,16 +4201,22 @@ int ssl_handshake_hash(SSL *s, unsigned char *out, size_t outlen,
|
||||
int hashleni = EVP_MD_CTX_size(hdgst);
|
||||
int ret = 0;
|
||||
|
||||
if (hashleni < 0 || (size_t)hashleni > outlen)
|
||||
if (hashleni < 0 || (size_t)hashleni > outlen) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_HANDSHAKE_HASH,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ctx = EVP_MD_CTX_new();
|
||||
if (ctx == NULL)
|
||||
goto err;
|
||||
|
||||
if (!EVP_MD_CTX_copy_ex(ctx, hdgst)
|
||||
|| EVP_DigestFinal_ex(ctx, out, NULL) <= 0)
|
||||
|| EVP_DigestFinal_ex(ctx, out, NULL) <= 0) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_HANDSHAKE_HASH,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
*hashlen = hashleni;
|
||||
|
||||
@ -4630,7 +4636,8 @@ int ssl_validate_ct(SSL *s)
|
||||
|
||||
ctx = CT_POLICY_EVAL_CTX_new();
|
||||
if (ctx == NULL) {
|
||||
SSLerr(SSL_F_SSL_VALIDATE_CT, ERR_R_MALLOC_FAILURE);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_VALIDATE_CT,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@ -4658,13 +4665,17 @@ int ssl_validate_ct(SSL *s)
|
||||
* ought to correspond to an inability to carry out its duties.
|
||||
*/
|
||||
if (SCT_LIST_validate(scts, ctx) < 0) {
|
||||
SSLerr(SSL_F_SSL_VALIDATE_CT, SSL_R_SCT_VERIFICATION_FAILED);
|
||||
SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_SSL_VALIDATE_CT,
|
||||
SSL_R_SCT_VERIFICATION_FAILED);
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = s->ct_validation_callback(ctx, scts, s->ct_validation_callback_arg);
|
||||
if (ret < 0)
|
||||
ret = 0; /* This function returns 0 on failure */
|
||||
if (!ret)
|
||||
SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_SSL_VALIDATE_CT,
|
||||
SSL_R_CALLBACK_FAILED);
|
||||
|
||||
end:
|
||||
CT_POLICY_EVAL_CTX_free(ctx);
|
||||
@ -4899,7 +4910,8 @@ static int nss_keylog_int(const char *prefix,
|
||||
prefix_len = strlen(prefix);
|
||||
out_len = prefix_len + (2*parameter_1_len) + (2*parameter_2_len) + 3;
|
||||
if ((out = cursor = OPENSSL_malloc(out_len)) == NULL) {
|
||||
SSLerr(SSL_F_NSS_KEYLOG_INT, ERR_R_MALLOC_FAILURE);
|
||||
SSLfatal(ssl, SSL_AD_INTERNAL_ERROR, SSL_F_NSS_KEYLOG_INT,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -4932,7 +4944,8 @@ int ssl_log_rsa_client_key_exchange(SSL *ssl,
|
||||
size_t premaster_len)
|
||||
{
|
||||
if (encrypted_premaster_len < 8) {
|
||||
SSLerr(SSL_F_SSL_LOG_RSA_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);
|
||||
SSLfatal(ssl, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_SSL_LOG_RSA_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -4960,23 +4973,21 @@ int ssl_log_secret(SSL *ssl,
|
||||
|
||||
#define SSLV2_CIPHER_LEN 3
|
||||
|
||||
int ssl_cache_cipherlist(SSL *s, PACKET *cipher_suites, int sslv2format,
|
||||
int *al)
|
||||
int ssl_cache_cipherlist(SSL *s, PACKET *cipher_suites, int sslv2format)
|
||||
{
|
||||
int n;
|
||||
|
||||
n = sslv2format ? SSLV2_CIPHER_LEN : TLS_CIPHER_LEN;
|
||||
|
||||
if (PACKET_remaining(cipher_suites) == 0) {
|
||||
SSLerr(SSL_F_SSL_CACHE_CIPHERLIST, SSL_R_NO_CIPHERS_SPECIFIED);
|
||||
*al = SSL_AD_ILLEGAL_PARAMETER;
|
||||
SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_SSL_CACHE_CIPHERLIST,
|
||||
SSL_R_NO_CIPHERS_SPECIFIED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (PACKET_remaining(cipher_suites) % n != 0) {
|
||||
SSLerr(SSL_F_SSL_CACHE_CIPHERLIST,
|
||||
SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_SSL_CACHE_CIPHERLIST,
|
||||
SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST);
|
||||
*al = SSL_AD_DECODE_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -5000,8 +5011,9 @@ int ssl_cache_cipherlist(SSL *s, PACKET *cipher_suites, int sslv2format,
|
||||
raw = OPENSSL_malloc(numciphers * TLS_CIPHER_LEN);
|
||||
s->s3->tmp.ciphers_raw = raw;
|
||||
if (raw == NULL) {
|
||||
*al = SSL_AD_INTERNAL_ERROR;
|
||||
goto err;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_CACHE_CIPHERLIST,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
for (s->s3->tmp.ciphers_rawlen = 0;
|
||||
PACKET_remaining(&sslv2ciphers) > 0;
|
||||
@ -5012,41 +5024,40 @@ int ssl_cache_cipherlist(SSL *s, PACKET *cipher_suites, int sslv2format,
|
||||
TLS_CIPHER_LEN))
|
||||
|| (leadbyte != 0
|
||||
&& !PACKET_forward(&sslv2ciphers, TLS_CIPHER_LEN))) {
|
||||
*al = SSL_AD_DECODE_ERROR;
|
||||
SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_SSL_CACHE_CIPHERLIST,
|
||||
SSL_R_BAD_PACKET);
|
||||
OPENSSL_free(s->s3->tmp.ciphers_raw);
|
||||
s->s3->tmp.ciphers_raw = NULL;
|
||||
s->s3->tmp.ciphers_rawlen = 0;
|
||||
goto err;
|
||||
return 0;
|
||||
}
|
||||
if (leadbyte == 0)
|
||||
s->s3->tmp.ciphers_rawlen += TLS_CIPHER_LEN;
|
||||
}
|
||||
} else if (!PACKET_memdup(cipher_suites, &s->s3->tmp.ciphers_raw,
|
||||
&s->s3->tmp.ciphers_rawlen)) {
|
||||
*al = SSL_AD_INTERNAL_ERROR;
|
||||
goto err;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_CACHE_CIPHERLIST,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
err:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SSL_bytes_to_cipher_list(SSL *s, const unsigned char *bytes, size_t len,
|
||||
int isv2format, STACK_OF(SSL_CIPHER) **sk,
|
||||
STACK_OF(SSL_CIPHER) **scsvs)
|
||||
{
|
||||
int alert;
|
||||
PACKET pkt;
|
||||
|
||||
if (!PACKET_buf_init(&pkt, bytes, len))
|
||||
return 0;
|
||||
return bytes_to_cipher_list(s, &pkt, sk, scsvs, isv2format, &alert);
|
||||
return bytes_to_cipher_list(s, &pkt, sk, scsvs, isv2format, 0);
|
||||
}
|
||||
|
||||
int bytes_to_cipher_list(SSL *s, PACKET *cipher_suites,
|
||||
STACK_OF(SSL_CIPHER) **skp,
|
||||
STACK_OF(SSL_CIPHER) **scsvs_out,
|
||||
int sslv2format, int *al)
|
||||
int sslv2format, int fatal)
|
||||
{
|
||||
const SSL_CIPHER *c;
|
||||
STACK_OF(SSL_CIPHER) *sk = NULL;
|
||||
@ -5058,23 +5069,32 @@ int bytes_to_cipher_list(SSL *s, PACKET *cipher_suites,
|
||||
n = sslv2format ? SSLV2_CIPHER_LEN : TLS_CIPHER_LEN;
|
||||
|
||||
if (PACKET_remaining(cipher_suites) == 0) {
|
||||
SSLerr(SSL_F_BYTES_TO_CIPHER_LIST, SSL_R_NO_CIPHERS_SPECIFIED);
|
||||
*al = SSL_AD_ILLEGAL_PARAMETER;
|
||||
if (fatal)
|
||||
SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_BYTES_TO_CIPHER_LIST,
|
||||
SSL_R_NO_CIPHERS_SPECIFIED);
|
||||
else
|
||||
SSLerr(SSL_F_BYTES_TO_CIPHER_LIST, SSL_R_NO_CIPHERS_SPECIFIED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (PACKET_remaining(cipher_suites) % n != 0) {
|
||||
SSLerr(SSL_F_BYTES_TO_CIPHER_LIST,
|
||||
SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST);
|
||||
*al = SSL_AD_DECODE_ERROR;
|
||||
if (fatal)
|
||||
SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_BYTES_TO_CIPHER_LIST,
|
||||
SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST);
|
||||
else
|
||||
SSLerr(SSL_F_BYTES_TO_CIPHER_LIST,
|
||||
SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST);
|
||||
return 0;
|
||||
}
|
||||
|
||||
sk = sk_SSL_CIPHER_new_null();
|
||||
scsvs = sk_SSL_CIPHER_new_null();
|
||||
if (sk == NULL || scsvs == NULL) {
|
||||
SSLerr(SSL_F_BYTES_TO_CIPHER_LIST, ERR_R_MALLOC_FAILURE);
|
||||
*al = SSL_AD_INTERNAL_ERROR;
|
||||
if (fatal)
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_BYTES_TO_CIPHER_LIST,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
else
|
||||
SSLerr(SSL_F_BYTES_TO_CIPHER_LIST, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -5092,15 +5112,21 @@ int bytes_to_cipher_list(SSL *s, PACKET *cipher_suites,
|
||||
if (c != NULL) {
|
||||
if ((c->valid && !sk_SSL_CIPHER_push(sk, c)) ||
|
||||
(!c->valid && !sk_SSL_CIPHER_push(scsvs, c))) {
|
||||
SSLerr(SSL_F_BYTES_TO_CIPHER_LIST, ERR_R_MALLOC_FAILURE);
|
||||
*al = SSL_AD_INTERNAL_ERROR;
|
||||
if (fatal)
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_BYTES_TO_CIPHER_LIST, ERR_R_MALLOC_FAILURE);
|
||||
else
|
||||
SSLerr(SSL_F_BYTES_TO_CIPHER_LIST, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (PACKET_remaining(cipher_suites) > 0) {
|
||||
*al = SSL_AD_DECODE_ERROR;
|
||||
SSLerr(SSL_F_BYTES_TO_CIPHER_LIST, SSL_R_BAD_LENGTH);
|
||||
if (fatal)
|
||||
SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_BYTES_TO_CIPHER_LIST,
|
||||
SSL_R_BAD_LENGTH);
|
||||
else
|
||||
SSLerr(SSL_F_BYTES_TO_CIPHER_LIST, SSL_R_BAD_LENGTH);
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -2132,7 +2132,7 @@ void ssl_cert_clear_certs(CERT *c);
|
||||
void ssl_cert_free(CERT *c);
|
||||
__owur int ssl_generate_session_id(SSL *s, SSL_SESSION *ss);
|
||||
__owur int ssl_get_new_session(SSL *s, int session);
|
||||
__owur int ssl_get_prev_session(SSL *s, CLIENTHELLO_MSG *hello, int *al);
|
||||
__owur int ssl_get_prev_session(SSL *s, CLIENTHELLO_MSG *hello);
|
||||
__owur SSL_SESSION *ssl_session_dup(SSL_SESSION *src, int ticket);
|
||||
__owur int ssl_cipher_id_cmp(const SSL_CIPHER *a, const SSL_CIPHER *b);
|
||||
DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(SSL_CIPHER, SSL_CIPHER, ssl_cipher_id);
|
||||
@ -2144,12 +2144,11 @@ __owur STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *meth,
|
||||
**sorted,
|
||||
const char *rule_str,
|
||||
CERT *c);
|
||||
__owur int ssl_cache_cipherlist(SSL *s, PACKET *cipher_suites,
|
||||
int sslv2format, int *al);
|
||||
__owur int ssl_cache_cipherlist(SSL *s, PACKET *cipher_suites, int sslv2format);
|
||||
__owur int bytes_to_cipher_list(SSL *s, PACKET *cipher_suites,
|
||||
STACK_OF(SSL_CIPHER) **skp,
|
||||
STACK_OF(SSL_CIPHER) **scsvs, int sslv2format,
|
||||
int *al);
|
||||
int fatal);
|
||||
void ssl_update_cache(SSL *s, int mode);
|
||||
__owur int ssl_cipher_get_evp(const SSL_SESSION *s, const EVP_CIPHER **enc,
|
||||
const EVP_MD **md, int *mac_pkey_type,
|
||||
@ -2231,7 +2230,7 @@ __owur size_t ssl3_final_finish_mac(SSL *s, const char *sender, size_t slen,
|
||||
__owur int ssl3_finish_mac(SSL *s, const unsigned char *buf, size_t len);
|
||||
void ssl3_free_digest_list(SSL *s);
|
||||
__owur unsigned long ssl3_output_cert_chain(SSL *s, WPACKET *pkt,
|
||||
CERT_PKEY *cpk, int *al);
|
||||
CERT_PKEY *cpk);
|
||||
__owur const SSL_CIPHER *ssl3_choose_cipher(SSL *ssl,
|
||||
STACK_OF(SSL_CIPHER) *clnt,
|
||||
STACK_OF(SSL_CIPHER) *srvr);
|
||||
@ -2386,7 +2385,7 @@ __owur int tls1_set_groups_list(uint16_t **pext, size_t *pextlen,
|
||||
void tls1_get_formatlist(SSL *s, const unsigned char **pformats,
|
||||
size_t *num_formats);
|
||||
__owur int tls1_check_ec_tmp_key(SSL *s, unsigned long id);
|
||||
__owur EVP_PKEY *ssl_generate_pkey_group(uint16_t id);
|
||||
__owur EVP_PKEY *ssl_generate_pkey_group(SSL *s, uint16_t id);
|
||||
__owur EVP_PKEY *ssl_generate_param_group(uint16_t id);
|
||||
# endif /* OPENSSL_NO_EC */
|
||||
|
||||
@ -2444,7 +2443,7 @@ __owur int ssl_security_cert(SSL *s, SSL_CTX *ctx, X509 *x, int vfy, int is_ee);
|
||||
__owur int ssl_security_cert_chain(SSL *s, STACK_OF(X509) *sk, X509 *ex,
|
||||
int vfy);
|
||||
|
||||
int tls_choose_sigalg(SSL *s, int *al);
|
||||
int tls_choose_sigalg(SSL *s, int fatalerrs);
|
||||
|
||||
__owur EVP_MD_CTX *ssl_replace_hash(EVP_MD_CTX **hash, const EVP_MD *md);
|
||||
void ssl_clear_hash_ctx(EVP_MD_CTX **hash);
|
||||
@ -2520,9 +2519,9 @@ void custom_ext_init(custom_ext_methods *meths);
|
||||
|
||||
__owur int custom_ext_parse(SSL *s, unsigned int context, unsigned int ext_type,
|
||||
const unsigned char *ext_data, size_t ext_size,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
__owur int custom_ext_add(SSL *s, int context, WPACKET *pkt, X509 *x,
|
||||
size_t chainidx, int maxversion, int *al);
|
||||
size_t chainidx, int maxversion);
|
||||
|
||||
__owur int custom_exts_copy(custom_ext_methods *dst,
|
||||
const custom_ext_methods *src);
|
||||
|
@ -322,7 +322,8 @@ int ssl_generate_session_id(SSL *s, SSL_SESSION *ss)
|
||||
ss->session_id_length = SSL3_SSL_SESSION_ID_LENGTH;
|
||||
break;
|
||||
default:
|
||||
SSLerr(SSL_F_SSL_GENERATE_SESSION_ID, SSL_R_UNSUPPORTED_SSL_VERSION);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GENERATE_SESSION_ID,
|
||||
SSL_R_UNSUPPORTED_SSL_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -360,8 +361,8 @@ int ssl_generate_session_id(SSL *s, SSL_SESSION *ss)
|
||||
tmp = (int)ss->session_id_length;
|
||||
if (!cb(s, ss->session_id, &tmp)) {
|
||||
/* The callback failed */
|
||||
SSLerr(SSL_F_SSL_GENERATE_SESSION_ID,
|
||||
SSL_R_SSL_SESSION_ID_CALLBACK_FAILED);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GENERATE_SESSION_ID,
|
||||
SSL_R_SSL_SESSION_ID_CALLBACK_FAILED);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
@ -370,15 +371,16 @@ int ssl_generate_session_id(SSL *s, SSL_SESSION *ss)
|
||||
*/
|
||||
if (tmp == 0 || tmp > ss->session_id_length) {
|
||||
/* The callback set an illegal length */
|
||||
SSLerr(SSL_F_SSL_GENERATE_SESSION_ID,
|
||||
SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GENERATE_SESSION_ID,
|
||||
SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH);
|
||||
return 0;
|
||||
}
|
||||
ss->session_id_length = tmp;
|
||||
/* Finally, check for a conflict */
|
||||
if (SSL_has_matching_session_id(s, ss->session_id,
|
||||
(unsigned int)ss->session_id_length)) {
|
||||
SSLerr(SSL_F_SSL_GENERATE_SESSION_ID, SSL_R_SSL_SESSION_ID_CONFLICT);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GENERATE_SESSION_ID,
|
||||
SSL_R_SSL_SESSION_ID_CONFLICT);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -391,8 +393,11 @@ int ssl_get_new_session(SSL *s, int session)
|
||||
|
||||
SSL_SESSION *ss = NULL;
|
||||
|
||||
if ((ss = SSL_SESSION_new()) == NULL)
|
||||
if ((ss = SSL_SESSION_new()) == NULL) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GET_NEW_SESSION,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If the context has a default timeout, use it */
|
||||
if (s->session_ctx->session_timeout == 0)
|
||||
@ -405,6 +410,7 @@ int ssl_get_new_session(SSL *s, int session)
|
||||
|
||||
if (session) {
|
||||
if (!ssl_generate_session_id(s, ss)) {
|
||||
/* SSLfatal() already called */
|
||||
SSL_SESSION_free(ss);
|
||||
return 0;
|
||||
}
|
||||
@ -412,7 +418,8 @@ int ssl_get_new_session(SSL *s, int session)
|
||||
if (s->ext.hostname) {
|
||||
ss->ext.hostname = OPENSSL_strdup(s->ext.hostname);
|
||||
if (ss->ext.hostname == NULL) {
|
||||
SSLerr(SSL_F_SSL_GET_NEW_SESSION, ERR_R_INTERNAL_ERROR);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GET_NEW_SESSION,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
SSL_SESSION_free(ss);
|
||||
return 0;
|
||||
}
|
||||
@ -422,7 +429,8 @@ int ssl_get_new_session(SSL *s, int session)
|
||||
}
|
||||
|
||||
if (s->sid_ctx_length > sizeof ss->sid_ctx) {
|
||||
SSLerr(SSL_F_SSL_GET_NEW_SESSION, ERR_R_INTERNAL_ERROR);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GET_NEW_SESSION,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
SSL_SESSION_free(ss);
|
||||
return 0;
|
||||
}
|
||||
@ -456,7 +464,7 @@ int ssl_get_new_session(SSL *s, int session)
|
||||
* - Both for new and resumed sessions, s->ext.ticket_expected is set to 1
|
||||
* if the server should issue a new session ticket (to 0 otherwise).
|
||||
*/
|
||||
int ssl_get_prev_session(SSL *s, CLIENTHELLO_MSG *hello, int *al)
|
||||
int ssl_get_prev_session(SSL *s, CLIENTHELLO_MSG *hello)
|
||||
{
|
||||
/* This is used only by servers. */
|
||||
|
||||
@ -468,9 +476,9 @@ int ssl_get_prev_session(SSL *s, CLIENTHELLO_MSG *hello, int *al)
|
||||
if (SSL_IS_TLS13(s)) {
|
||||
if (!tls_parse_extension(s, TLSEXT_IDX_psk_kex_modes,
|
||||
SSL_EXT_CLIENT_HELLO, hello->pre_proc_exts,
|
||||
NULL, 0, al)
|
||||
NULL, 0)
|
||||
|| !tls_parse_extension(s, TLSEXT_IDX_psk, SSL_EXT_CLIENT_HELLO,
|
||||
hello->pre_proc_exts, NULL, 0, al))
|
||||
hello->pre_proc_exts, NULL, 0))
|
||||
return -1;
|
||||
|
||||
ret = s->session;
|
||||
@ -481,6 +489,8 @@ int ssl_get_prev_session(SSL *s, CLIENTHELLO_MSG *hello, int *al)
|
||||
case TICKET_FATAL_ERR_MALLOC:
|
||||
case TICKET_FATAL_ERR_OTHER:
|
||||
fatal = 1;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GET_PREV_SESSION,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
case TICKET_NONE:
|
||||
case TICKET_EMPTY:
|
||||
@ -584,8 +594,8 @@ int ssl_get_prev_session(SSL *s, CLIENTHELLO_MSG *hello, int *al)
|
||||
* noticing).
|
||||
*/
|
||||
|
||||
SSLerr(SSL_F_SSL_GET_PREV_SESSION,
|
||||
SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GET_PREV_SESSION,
|
||||
SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED);
|
||||
fatal = 1;
|
||||
goto err;
|
||||
}
|
||||
@ -604,8 +614,8 @@ int ssl_get_prev_session(SSL *s, CLIENTHELLO_MSG *hello, int *al)
|
||||
if (ret->flags & SSL_SESS_FLAG_EXTMS) {
|
||||
/* If old session includes extms, but new does not: abort handshake */
|
||||
if (!(s->s3->flags & TLS1_FLAGS_RECEIVED_EXTMS)) {
|
||||
SSLerr(SSL_F_SSL_GET_PREV_SESSION, SSL_R_INCONSISTENT_EXTMS);
|
||||
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_ILLEGAL_PARAMETER);
|
||||
SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_SSL_GET_PREV_SESSION,
|
||||
SSL_R_INCONSISTENT_EXTMS);
|
||||
fatal = 1;
|
||||
goto err;
|
||||
}
|
||||
@ -640,10 +650,8 @@ int ssl_get_prev_session(SSL *s, CLIENTHELLO_MSG *hello, int *al)
|
||||
s->ext.ticket_expected = 1;
|
||||
}
|
||||
}
|
||||
if (fatal) {
|
||||
*al = SSL_AD_INTERNAL_ERROR;
|
||||
if (fatal)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -12,14 +12,11 @@
|
||||
#include "../ssl_locl.h"
|
||||
#include "statem_locl.h"
|
||||
|
||||
static int final_renegotiate(SSL *s, unsigned int context, int sent,
|
||||
int *al);
|
||||
static int final_renegotiate(SSL *s, unsigned int context, int sent);
|
||||
static int init_server_name(SSL *s, unsigned int context);
|
||||
static int final_server_name(SSL *s, unsigned int context, int sent,
|
||||
int *al);
|
||||
static int final_server_name(SSL *s, unsigned int context, int sent);
|
||||
#ifndef OPENSSL_NO_EC
|
||||
static int final_ec_pt_formats(SSL *s, unsigned int context, int sent,
|
||||
int *al);
|
||||
static int final_ec_pt_formats(SSL *s, unsigned int context, int sent);
|
||||
#endif
|
||||
static int init_session_ticket(SSL *s, unsigned int context);
|
||||
#ifndef OPENSSL_NO_OCSP
|
||||
@ -29,33 +26,32 @@ static int init_status_request(SSL *s, unsigned int context);
|
||||
static int init_npn(SSL *s, unsigned int context);
|
||||
#endif
|
||||
static int init_alpn(SSL *s, unsigned int context);
|
||||
static int final_alpn(SSL *s, unsigned int context, int sent, int *al);
|
||||
static int final_alpn(SSL *s, unsigned int context, int sent);
|
||||
static int init_sig_algs(SSL *s, unsigned int context);
|
||||
static int init_certificate_authorities(SSL *s, unsigned int context);
|
||||
static EXT_RETURN tls_construct_certificate_authorities(SSL *s, WPACKET *pkt,
|
||||
unsigned int context,
|
||||
X509 *x,
|
||||
size_t chainidx,
|
||||
int *al);
|
||||
size_t chainidx);
|
||||
static int tls_parse_certificate_authorities(SSL *s, PACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
#ifndef OPENSSL_NO_SRP
|
||||
static int init_srp(SSL *s, unsigned int context);
|
||||
#endif
|
||||
static int init_etm(SSL *s, unsigned int context);
|
||||
static int init_ems(SSL *s, unsigned int context);
|
||||
static int final_ems(SSL *s, unsigned int context, int sent, int *al);
|
||||
static int final_ems(SSL *s, unsigned int context, int sent);
|
||||
static int init_psk_kex_modes(SSL *s, unsigned int context);
|
||||
#ifndef OPENSSL_NO_EC
|
||||
static int final_key_share(SSL *s, unsigned int context, int sent, int *al);
|
||||
static int final_key_share(SSL *s, unsigned int context, int sent);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SRTP
|
||||
static int init_srtp(SSL *s, unsigned int context);
|
||||
#endif
|
||||
static int final_sig_algs(SSL *s, unsigned int context, int sent, int *al);
|
||||
static int final_early_data(SSL *s, unsigned int context, int sent, int *al);
|
||||
static int final_maxfragmentlen(SSL *s, unsigned int context, int sent, int *al);
|
||||
static int final_sig_algs(SSL *s, unsigned int context, int sent);
|
||||
static int final_early_data(SSL *s, unsigned int context, int sent);
|
||||
static int final_maxfragmentlen(SSL *s, unsigned int context, int sent);
|
||||
|
||||
/* Structure to define a built-in extension */
|
||||
typedef struct extensions_definition_st {
|
||||
@ -73,22 +69,22 @@ typedef struct extensions_definition_st {
|
||||
int (*init)(SSL *s, unsigned int context);
|
||||
/* Parse extension sent from client to server */
|
||||
int (*parse_ctos)(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
/* Parse extension send from server to client */
|
||||
int (*parse_stoc)(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
/* Construct extension sent from server to client */
|
||||
EXT_RETURN (*construct_stoc)(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
/* Construct extension sent from client to server */
|
||||
EXT_RETURN (*construct_ctos)(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
/*
|
||||
* Finalise extension after parsing. Always called where an extensions was
|
||||
* initialised even if the extension was not present. |sent| is set to 1 if
|
||||
* the extension was seen, or 0 otherwise.
|
||||
*/
|
||||
int (*final)(SSL *s, unsigned int context, int sent, int *al);
|
||||
int (*final)(SSL *s, unsigned int context, int sent);
|
||||
} EXTENSION_DEFINITION;
|
||||
|
||||
/*
|
||||
@ -458,8 +454,7 @@ int extension_is_relevant(SSL *s, unsigned int extctx, unsigned int thisctx)
|
||||
* extensions that we know about. We ignore others.
|
||||
*/
|
||||
int tls_collect_extensions(SSL *s, PACKET *packet, unsigned int context,
|
||||
RAW_EXTENSION **res, int *al, size_t *len,
|
||||
int init)
|
||||
RAW_EXTENSION **res, size_t *len, int init)
|
||||
{
|
||||
PACKET extensions = *packet;
|
||||
size_t i = 0;
|
||||
@ -480,8 +475,8 @@ int tls_collect_extensions(SSL *s, PACKET *packet, unsigned int context,
|
||||
num_exts = OSSL_NELEM(ext_defs) + (exts != NULL ? exts->meths_count : 0);
|
||||
raw_extensions = OPENSSL_zalloc(num_exts * sizeof(*raw_extensions));
|
||||
if (raw_extensions == NULL) {
|
||||
*al = SSL_AD_INTERNAL_ERROR;
|
||||
SSLerr(SSL_F_TLS_COLLECT_EXTENSIONS, ERR_R_MALLOC_FAILURE);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_COLLECT_EXTENSIONS,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -493,8 +488,8 @@ int tls_collect_extensions(SSL *s, PACKET *packet, unsigned int context,
|
||||
|
||||
if (!PACKET_get_net_2(&extensions, &type) ||
|
||||
!PACKET_get_length_prefixed_2(&extensions, &extension)) {
|
||||
SSLerr(SSL_F_TLS_COLLECT_EXTENSIONS, SSL_R_BAD_EXTENSION);
|
||||
*al = SSL_AD_DECODE_ERROR;
|
||||
SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_TLS_COLLECT_EXTENSIONS,
|
||||
SSL_R_BAD_EXTENSION);
|
||||
goto err;
|
||||
}
|
||||
/*
|
||||
@ -507,8 +502,8 @@ int tls_collect_extensions(SSL *s, PACKET *packet, unsigned int context,
|
||||
|| (type == TLSEXT_TYPE_psk
|
||||
&& (context & SSL_EXT_CLIENT_HELLO) != 0
|
||||
&& PACKET_remaining(&extensions) != 0)) {
|
||||
SSLerr(SSL_F_TLS_COLLECT_EXTENSIONS, SSL_R_BAD_EXTENSION);
|
||||
*al = SSL_AD_ILLEGAL_PARAMETER;
|
||||
SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_TLS_COLLECT_EXTENSIONS,
|
||||
SSL_R_BAD_EXTENSION);
|
||||
goto err;
|
||||
}
|
||||
idx = thisex - raw_extensions;
|
||||
@ -534,8 +529,8 @@ int tls_collect_extensions(SSL *s, PACKET *packet, unsigned int context,
|
||||
&& type != TLSEXT_TYPE_renegotiate
|
||||
&& type != TLSEXT_TYPE_signed_certificate_timestamp
|
||||
&& (s->ext.extflags[idx] & SSL_EXT_FLAG_SENT) == 0) {
|
||||
SSLerr(SSL_F_TLS_COLLECT_EXTENSIONS, SSL_R_UNSOLICITED_EXTENSION);
|
||||
*al = SSL_AD_UNSUPPORTED_EXTENSION;
|
||||
SSLfatal(s, SSL_AD_UNSUPPORTED_EXTENSION,
|
||||
SSL_F_TLS_COLLECT_EXTENSIONS, SSL_R_UNSOLICITED_EXTENSION);
|
||||
goto err;
|
||||
}
|
||||
if (thisex != NULL) {
|
||||
@ -561,7 +556,7 @@ int tls_collect_extensions(SSL *s, PACKET *packet, unsigned int context,
|
||||
if (thisexd->init != NULL && (thisexd->context & context) != 0
|
||||
&& extension_is_relevant(s, thisexd->context, context)
|
||||
&& !thisexd->init(s, context)) {
|
||||
*al = SSL_AD_INTERNAL_ERROR;
|
||||
/* SSLfatal() already called */
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
@ -589,11 +584,11 @@ int tls_collect_extensions(SSL *s, PACKET *packet, unsigned int context,
|
||||
* this counted as success.
|
||||
*/
|
||||
int tls_parse_extension(SSL *s, TLSEXT_INDEX idx, int context,
|
||||
RAW_EXTENSION *exts, X509 *x, size_t chainidx, int *al)
|
||||
RAW_EXTENSION *exts, X509 *x, size_t chainidx)
|
||||
{
|
||||
RAW_EXTENSION *currext = &exts[idx];
|
||||
int (*parser)(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al) = NULL;
|
||||
size_t chainidx) = NULL;
|
||||
|
||||
/* Skip if the extension is not present */
|
||||
if (!currext->present)
|
||||
@ -616,7 +611,7 @@ int tls_parse_extension(SSL *s, TLSEXT_INDEX idx, int context,
|
||||
parser = s->server ? extdef->parse_ctos : extdef->parse_stoc;
|
||||
|
||||
if (parser != NULL)
|
||||
return parser(s, &currext->data, context, x, chainidx, al);
|
||||
return parser(s, &currext->data, context, x, chainidx);
|
||||
|
||||
/*
|
||||
* If the parser is NULL we fall through to the custom extension
|
||||
@ -625,13 +620,10 @@ int tls_parse_extension(SSL *s, TLSEXT_INDEX idx, int context,
|
||||
}
|
||||
|
||||
/* Parse custom extensions */
|
||||
if (custom_ext_parse(s, context, currext->type,
|
||||
PACKET_data(&currext->data),
|
||||
PACKET_remaining(&currext->data),
|
||||
x, chainidx, al) <= 0)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
return custom_ext_parse(s, context, currext->type,
|
||||
PACKET_data(&currext->data),
|
||||
PACKET_remaining(&currext->data),
|
||||
x, chainidx);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -643,7 +635,7 @@ int tls_parse_extension(SSL *s, TLSEXT_INDEX idx, int context,
|
||||
* failure, |*al| is populated with a suitable alert code.
|
||||
*/
|
||||
int tls_parse_all_extensions(SSL *s, int context, RAW_EXTENSION *exts, X509 *x,
|
||||
size_t chainidx, int *al, int fin)
|
||||
size_t chainidx, int fin)
|
||||
{
|
||||
size_t i, numexts = OSSL_NELEM(ext_defs);
|
||||
const EXTENSION_DEFINITION *thisexd;
|
||||
@ -653,8 +645,10 @@ int tls_parse_all_extensions(SSL *s, int context, RAW_EXTENSION *exts, X509 *x,
|
||||
|
||||
/* Parse each extension in turn */
|
||||
for (i = 0; i < numexts; i++) {
|
||||
if (!tls_parse_extension(s, i, context, exts, x, chainidx, al))
|
||||
if (!tls_parse_extension(s, i, context, exts, x, chainidx)) {
|
||||
/* SSLfatal() already called */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (fin) {
|
||||
@ -665,8 +659,10 @@ int tls_parse_all_extensions(SSL *s, int context, RAW_EXTENSION *exts, X509 *x,
|
||||
for (i = 0, thisexd = ext_defs; i < OSSL_NELEM(ext_defs);
|
||||
i++, thisexd++) {
|
||||
if (thisexd->final != NULL && (thisexd->context & context) != 0
|
||||
&& !thisexd->final(s, context, exts[i].present, al))
|
||||
&& !thisexd->final(s, context, exts[i].present)) {
|
||||
/* SSLfatal() already called */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -702,23 +698,16 @@ int should_add_extension(SSL *s, unsigned int extctx, unsigned int thisctx,
|
||||
* them to |pkt|. If this is an extension for a Certificate in a Certificate
|
||||
* message, then |x| will be set to the Certificate we are handling, and
|
||||
* |chainidx| will indicate the position in the chainidx we are processing (with
|
||||
* 0 being the first in the chain). Returns 1 on success or 0 on failure. If a
|
||||
* failure occurs then |al| is populated with a suitable alert code. On a
|
||||
* 0 being the first in the chain). Returns 1 on success or 0 on failure. On a
|
||||
* failure construction stops at the first extension to fail to construct.
|
||||
*/
|
||||
int tls_construct_extensions(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al)
|
||||
X509 *x, size_t chainidx)
|
||||
{
|
||||
size_t i;
|
||||
int min_version, max_version = 0, reason, tmpal;
|
||||
int min_version, max_version = 0, reason;
|
||||
const EXTENSION_DEFINITION *thisexd;
|
||||
|
||||
/*
|
||||
* Normally if something goes wrong during construction it's an internal
|
||||
* error. We can always override this later.
|
||||
*/
|
||||
tmpal = SSL_AD_INTERNAL_ERROR;
|
||||
|
||||
if (!WPACKET_start_sub_packet_u16(pkt)
|
||||
/*
|
||||
* If extensions are of zero length then we don't even add the
|
||||
@ -729,15 +718,17 @@ int tls_construct_extensions(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
(SSL_EXT_CLIENT_HELLO | SSL_EXT_TLS1_2_SERVER_HELLO)) != 0
|
||||
&& !WPACKET_set_flags(pkt,
|
||||
WPACKET_FLAGS_ABANDON_ON_ZERO_LENGTH))) {
|
||||
SSLerr(SSL_F_TLS_CONSTRUCT_EXTENSIONS, ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_EXTENSIONS,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((context & SSL_EXT_CLIENT_HELLO) != 0) {
|
||||
reason = ssl_get_min_max_version(s, &min_version, &max_version);
|
||||
if (reason != 0) {
|
||||
SSLerr(SSL_F_TLS_CONSTRUCT_EXTENSIONS, reason);
|
||||
goto err;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_EXTENSIONS,
|
||||
reason);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -746,14 +737,14 @@ int tls_construct_extensions(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
/* On the server side with initialise during ClientHello parsing */
|
||||
custom_ext_init(&s->cert->custext);
|
||||
}
|
||||
if (!custom_ext_add(s, context, pkt, x, chainidx, max_version, &tmpal)) {
|
||||
SSLerr(SSL_F_TLS_CONSTRUCT_EXTENSIONS, ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
if (!custom_ext_add(s, context, pkt, x, chainidx, max_version)) {
|
||||
/* SSLfatal() already called */
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0, thisexd = ext_defs; i < OSSL_NELEM(ext_defs); i++, thisexd++) {
|
||||
EXT_RETURN (*construct)(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
EXT_RETURN ret;
|
||||
|
||||
/* Skip if not relevant for our context */
|
||||
@ -766,9 +757,11 @@ int tls_construct_extensions(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
if (construct == NULL)
|
||||
continue;
|
||||
|
||||
ret = construct(s, pkt, context, x, chainidx, &tmpal);
|
||||
if (ret == EXT_RETURN_FAIL)
|
||||
goto err;
|
||||
ret = construct(s, pkt, context, x, chainidx);
|
||||
if (ret == EXT_RETURN_FAIL) {
|
||||
/* SSLfatal() already called */
|
||||
return 0;
|
||||
}
|
||||
if (ret == EXT_RETURN_SENT
|
||||
&& (context & (SSL_EXT_CLIENT_HELLO
|
||||
| SSL_EXT_TLS1_3_CERTIFICATE_REQUEST
|
||||
@ -777,15 +770,12 @@ int tls_construct_extensions(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
}
|
||||
|
||||
if (!WPACKET_close(pkt)) {
|
||||
SSLerr(SSL_F_TLS_CONSTRUCT_EXTENSIONS, ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_EXTENSIONS,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
err:
|
||||
*al = tmpal;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -796,8 +786,7 @@ int tls_construct_extensions(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
* of a failure then |*al| is populated with a suitable error code.
|
||||
*/
|
||||
|
||||
static int final_renegotiate(SSL *s, unsigned int context, int sent,
|
||||
int *al)
|
||||
static int final_renegotiate(SSL *s, unsigned int context, int sent)
|
||||
{
|
||||
if (!s->server) {
|
||||
/*
|
||||
@ -807,9 +796,8 @@ static int final_renegotiate(SSL *s, unsigned int context, int sent,
|
||||
if (!(s->options & SSL_OP_LEGACY_SERVER_CONNECT)
|
||||
&& !(s->options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)
|
||||
&& !sent) {
|
||||
*al = SSL_AD_HANDSHAKE_FAILURE;
|
||||
SSLerr(SSL_F_FINAL_RENEGOTIATE,
|
||||
SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED);
|
||||
SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_FINAL_RENEGOTIATE,
|
||||
SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -820,9 +808,8 @@ static int final_renegotiate(SSL *s, unsigned int context, int sent,
|
||||
if (s->renegotiate
|
||||
&& !(s->options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)
|
||||
&& !sent) {
|
||||
*al = SSL_AD_HANDSHAKE_FAILURE;
|
||||
SSLerr(SSL_F_FINAL_RENEGOTIATE,
|
||||
SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED);
|
||||
SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_FINAL_RENEGOTIATE,
|
||||
SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -838,8 +825,7 @@ static int init_server_name(SSL *s, unsigned int context)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int final_server_name(SSL *s, unsigned int context, int sent,
|
||||
int *al)
|
||||
static int final_server_name(SSL *s, unsigned int context, int sent)
|
||||
{
|
||||
int ret = SSL_TLSEXT_ERR_NOACK, discard;
|
||||
int altmp = SSL_AD_UNRECOGNIZED_NAME;
|
||||
@ -890,23 +876,25 @@ static int final_server_name(SSL *s, unsigned int context, int sent,
|
||||
ss->ext.tick_age_add = 0;
|
||||
ss->ext.tick_identity = 0;
|
||||
if (!ssl_generate_session_id(s, ss)) {
|
||||
ret = SSL_TLSEXT_ERR_ALERT_FATAL;
|
||||
altmp = SSL_AD_INTERNAL_ERROR;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_FINAL_SERVER_NAME,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
ret = SSL_TLSEXT_ERR_ALERT_FATAL;
|
||||
altmp = SSL_AD_INTERNAL_ERROR;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_FINAL_SERVER_NAME,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (ret) {
|
||||
case SSL_TLSEXT_ERR_ALERT_FATAL:
|
||||
*al = altmp;
|
||||
SSLfatal(s, altmp, SSL_F_FINAL_SERVER_NAME, SSL_R_CALLBACK_FAILED);
|
||||
return 0;
|
||||
|
||||
case SSL_TLSEXT_ERR_ALERT_WARNING:
|
||||
*al = altmp;
|
||||
ssl3_send_alert(s, SSL3_AL_WARNING, altmp);
|
||||
return 1;
|
||||
|
||||
case SSL_TLSEXT_ERR_NOACK:
|
||||
@ -919,8 +907,7 @@ static int final_server_name(SSL *s, unsigned int context, int sent,
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_EC
|
||||
static int final_ec_pt_formats(SSL *s, unsigned int context, int sent,
|
||||
int *al)
|
||||
static int final_ec_pt_formats(SSL *s, unsigned int context, int sent)
|
||||
{
|
||||
unsigned long alg_k, alg_a;
|
||||
|
||||
@ -949,8 +936,8 @@ static int final_ec_pt_formats(SSL *s, unsigned int context, int sent,
|
||||
break;
|
||||
}
|
||||
if (i == s->session->ext.ecpointformats_len) {
|
||||
SSLerr(SSL_F_FINAL_EC_PT_FORMATS,
|
||||
SSL_R_TLS_INVALID_ECPOINTFORMAT_LIST);
|
||||
SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_FINAL_EC_PT_FORMATS,
|
||||
SSL_R_TLS_INVALID_ECPOINTFORMAT_LIST);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1008,7 +995,7 @@ static int init_alpn(SSL *s, unsigned int context)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int final_alpn(SSL *s, unsigned int context, int sent, int *al)
|
||||
static int final_alpn(SSL *s, unsigned int context, int sent)
|
||||
{
|
||||
if (!s->server && !sent && s->session->ext.alpn_selected != NULL)
|
||||
s->ext.early_data_ok = 0;
|
||||
@ -1022,8 +1009,10 @@ static int final_alpn(SSL *s, unsigned int context, int sent, int *al)
|
||||
* we also have to do this before we decide whether to accept early_data.
|
||||
* In TLSv1.3 we've already negotiated our cipher so we do this call now.
|
||||
* For < TLSv1.3 we defer it until after cipher negotiation.
|
||||
*
|
||||
* On failure SSLfatal() already called.
|
||||
*/
|
||||
return tls_handle_alpn(s, al);
|
||||
return tls_handle_alpn(s);
|
||||
}
|
||||
|
||||
static int init_sig_algs(SSL *s, unsigned int context)
|
||||
@ -1060,7 +1049,7 @@ static int init_ems(SSL *s, unsigned int context)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int final_ems(SSL *s, unsigned int context, int sent, int *al)
|
||||
static int final_ems(SSL *s, unsigned int context, int sent)
|
||||
{
|
||||
if (!s->server && s->hit) {
|
||||
/*
|
||||
@ -1069,8 +1058,8 @@ static int final_ems(SSL *s, unsigned int context, int sent, int *al)
|
||||
*/
|
||||
if (!(s->s3->flags & TLS1_FLAGS_RECEIVED_EXTMS) !=
|
||||
!(s->session->flags & SSL_SESS_FLAG_EXTMS)) {
|
||||
*al = SSL_AD_HANDSHAKE_FAILURE;
|
||||
SSLerr(SSL_F_FINAL_EMS, SSL_R_INCONSISTENT_EXTMS);
|
||||
SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_FINAL_EMS,
|
||||
SSL_R_INCONSISTENT_EXTMS);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1088,8 +1077,7 @@ static int init_certificate_authorities(SSL *s, unsigned int context)
|
||||
static EXT_RETURN tls_construct_certificate_authorities(SSL *s, WPACKET *pkt,
|
||||
unsigned int context,
|
||||
X509 *x,
|
||||
size_t chainidx,
|
||||
int *al)
|
||||
size_t chainidx)
|
||||
{
|
||||
const STACK_OF(X509_NAME) *ca_sk = SSL_get0_CA_list(s);
|
||||
|
||||
@ -1097,25 +1085,37 @@ static EXT_RETURN tls_construct_certificate_authorities(SSL *s, WPACKET *pkt,
|
||||
return EXT_RETURN_NOT_SENT;
|
||||
|
||||
if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_certificate_authorities)
|
||||
|| !WPACKET_start_sub_packet_u16(pkt)
|
||||
|| !construct_ca_names(s, pkt)
|
||||
|| !WPACKET_close(pkt)) {
|
||||
SSLerr(SSL_F_TLS_CONSTRUCT_CERTIFICATE_AUTHORITIES,
|
||||
|| !WPACKET_start_sub_packet_u16(pkt)) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_TLS_CONSTRUCT_CERTIFICATE_AUTHORITIES,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return EXT_RETURN_FAIL;
|
||||
}
|
||||
|
||||
if (!construct_ca_names(s, pkt)) {
|
||||
/* SSLfatal() already called */
|
||||
return EXT_RETURN_FAIL;
|
||||
}
|
||||
|
||||
if (!WPACKET_close(pkt)) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_TLS_CONSTRUCT_CERTIFICATE_AUTHORITIES,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return EXT_RETURN_FAIL;
|
||||
}
|
||||
|
||||
return EXT_RETURN_SENT;
|
||||
}
|
||||
|
||||
static int tls_parse_certificate_authorities(SSL *s, PACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al)
|
||||
size_t chainidx)
|
||||
{
|
||||
if (!parse_ca_names(s, pkt, al))
|
||||
if (!parse_ca_names(s, pkt))
|
||||
return 0;
|
||||
if (PACKET_remaining(pkt) != 0) {
|
||||
*al = SSL_AD_DECODE_ERROR;
|
||||
SSLfatal(s, SSL_AD_DECODE_ERROR,
|
||||
SSL_F_TLS_PARSE_CERTIFICATE_AUTHORITIES, SSL_R_BAD_EXTENSION);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@ -1131,11 +1131,11 @@ static int init_srtp(SSL *s, unsigned int context)
|
||||
}
|
||||
#endif
|
||||
|
||||
static int final_sig_algs(SSL *s, unsigned int context, int sent, int *al)
|
||||
static int final_sig_algs(SSL *s, unsigned int context, int sent)
|
||||
{
|
||||
if (!sent && SSL_IS_TLS13(s) && !s->hit) {
|
||||
*al = TLS13_AD_MISSING_EXTENSION;
|
||||
SSLerr(SSL_F_FINAL_SIG_ALGS, SSL_R_MISSING_SIGALGS_EXTENSION);
|
||||
SSLfatal(s, TLS13_AD_MISSING_EXTENSION, SSL_F_FINAL_SIG_ALGS,
|
||||
SSL_R_MISSING_SIGALGS_EXTENSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1143,7 +1143,7 @@ static int final_sig_algs(SSL *s, unsigned int context, int sent, int *al)
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_EC
|
||||
static int final_key_share(SSL *s, unsigned int context, int sent, int *al)
|
||||
static int final_key_share(SSL *s, unsigned int context, int sent)
|
||||
{
|
||||
if (!SSL_IS_TLS13(s))
|
||||
return 1;
|
||||
@ -1168,8 +1168,8 @@ static int final_key_share(SSL *s, unsigned int context, int sent, int *al)
|
||||
&& (!s->hit
|
||||
|| (s->ext.psk_kex_mode & TLSEXT_KEX_MODE_FLAG_KE) == 0)) {
|
||||
/* Nothing left we can do - just fail */
|
||||
*al = SSL_AD_MISSING_EXTENSION;
|
||||
SSLerr(SSL_F_FINAL_KEY_SHARE, SSL_R_NO_SUITABLE_KEY_SHARE);
|
||||
SSLfatal(s, SSL_AD_MISSING_EXTENSION, SSL_F_FINAL_KEY_SHARE,
|
||||
SSL_R_NO_SUITABLE_KEY_SHARE);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
@ -1230,11 +1230,9 @@ static int final_key_share(SSL *s, unsigned int context, int sent, int *al)
|
||||
if (!s->hit
|
||||
|| (s->ext.psk_kex_mode & TLSEXT_KEX_MODE_FLAG_KE) == 0) {
|
||||
/* Nothing left we can do - just fail */
|
||||
if (!sent)
|
||||
*al = SSL_AD_MISSING_EXTENSION;
|
||||
else
|
||||
*al = SSL_AD_HANDSHAKE_FAILURE;
|
||||
SSLerr(SSL_F_FINAL_KEY_SHARE, SSL_R_NO_SUITABLE_KEY_SHARE);
|
||||
SSLfatal(s,
|
||||
sent ? SSL_AD_HANDSHAKE_FAILURE : SSL_AD_MISSING_EXTENSION,
|
||||
SSL_F_FINAL_KEY_SHARE, SSL_R_NO_SUITABLE_KEY_SHARE);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1249,8 +1247,8 @@ static int final_key_share(SSL *s, unsigned int context, int sent, int *al)
|
||||
* processing).
|
||||
*/
|
||||
if (!sent && !s->server && !tls13_generate_handshake_secret(s, NULL, 0)) {
|
||||
*al = SSL_AD_INTERNAL_ERROR;
|
||||
SSLerr(SSL_F_FINAL_KEY_SHARE, ERR_R_INTERNAL_ERROR);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_FINAL_KEY_SHARE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1442,7 +1440,7 @@ int tls_psk_do_binder(SSL *s, const EVP_MD *md, const unsigned char *msgstart,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int final_early_data(SSL *s, unsigned int context, int sent, int *al)
|
||||
static int final_early_data(SSL *s, unsigned int context, int sent)
|
||||
{
|
||||
if (!sent)
|
||||
return 1;
|
||||
@ -1456,7 +1454,8 @@ static int final_early_data(SSL *s, unsigned int context, int sent, int *al)
|
||||
* later realised that it shouldn't have done (e.g. inconsistent
|
||||
* ALPN)
|
||||
*/
|
||||
*al = SSL_AD_ILLEGAL_PARAMETER;
|
||||
SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_FINAL_EARLY_DATA,
|
||||
SSL_R_BAD_EARLY_DATA);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1475,7 +1474,7 @@ static int final_early_data(SSL *s, unsigned int context, int sent, int *al)
|
||||
|
||||
if (!tls13_change_cipher_state(s,
|
||||
SSL3_CC_EARLY | SSL3_CHANGE_CIPHER_SERVER_READ)) {
|
||||
*al = SSL_AD_INTERNAL_ERROR;
|
||||
/* SSLfatal() already called */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1483,24 +1482,27 @@ static int final_early_data(SSL *s, unsigned int context, int sent, int *al)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int final_maxfragmentlen(SSL *ssl, unsigned int context, int sent, int *al)
|
||||
static int final_maxfragmentlen(SSL *s, unsigned int context, int sent)
|
||||
{
|
||||
/*
|
||||
* Session resumption on server-side with MFL extension active
|
||||
* BUT MFL extension packet was not resent (i.e. sent == 0)
|
||||
*/
|
||||
if (ssl->server && ssl->hit && USE_MAX_FRAGMENT_LENGTH_EXT(ssl->session)
|
||||
if (s->server && s->hit && USE_MAX_FRAGMENT_LENGTH_EXT(s->session)
|
||||
&& !sent ) {
|
||||
*al = SSL_AD_MISSING_EXTENSION;
|
||||
SSLfatal(s, SSL_AD_MISSING_EXTENSION, SSL_F_FINAL_MAXFRAGMENTLEN,
|
||||
SSL_R_BAD_EXTENSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Current SSL buffer is lower than requested MFL */
|
||||
if (ssl->session && USE_MAX_FRAGMENT_LENGTH_EXT(ssl->session)
|
||||
&& ssl->max_send_fragment < GET_MAX_FRAGMENT_LENGTH(ssl->session))
|
||||
if (s->session && USE_MAX_FRAGMENT_LENGTH_EXT(s->session)
|
||||
&& s->max_send_fragment < GET_MAX_FRAGMENT_LENGTH(s->session))
|
||||
/* trigger a larger buffer reallocation */
|
||||
if (!ssl3_setup_buffers(ssl))
|
||||
if (!ssl3_setup_buffers(s)) {
|
||||
/* SSLfatal() already called */
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -112,8 +112,9 @@ void custom_ext_init(custom_ext_methods *exts)
|
||||
/* Pass received custom extension data to the application for parsing. */
|
||||
int custom_ext_parse(SSL *s, unsigned int context, unsigned int ext_type,
|
||||
const unsigned char *ext_data, size_t ext_size, X509 *x,
|
||||
size_t chainidx, int *al)
|
||||
size_t chainidx)
|
||||
{
|
||||
int al;
|
||||
custom_ext_methods *exts = &s->cert->custext;
|
||||
custom_ext_method *meth;
|
||||
ENDPOINT role = ENDPOINT_BOTH;
|
||||
@ -138,7 +139,8 @@ int custom_ext_parse(SSL *s, unsigned int context, unsigned int ext_type,
|
||||
* extensions not sent in ClientHello.
|
||||
*/
|
||||
if ((meth->ext_flags & SSL_EXT_FLAG_SENT) == 0) {
|
||||
*al = TLS1_AD_UNSUPPORTED_EXTENSION;
|
||||
SSLfatal(s, TLS1_AD_UNSUPPORTED_EXTENSION, SSL_F_CUSTOM_EXT_PARSE,
|
||||
SSL_R_BAD_EXTENSION);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -155,8 +157,13 @@ int custom_ext_parse(SSL *s, unsigned int context, unsigned int ext_type,
|
||||
if (!meth->parse_cb)
|
||||
return 1;
|
||||
|
||||
return meth->parse_cb(s, ext_type, context, ext_data, ext_size, x, chainidx,
|
||||
al, meth->parse_arg);
|
||||
if (meth->parse_cb(s, ext_type, context, ext_data, ext_size, x, chainidx,
|
||||
&al, meth->parse_arg) <= 0) {
|
||||
SSLfatal(s, al, SSL_F_CUSTOM_EXT_PARSE, SSL_R_BAD_EXTENSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -164,11 +171,12 @@ int custom_ext_parse(SSL *s, unsigned int context, unsigned int ext_type,
|
||||
* buffer.
|
||||
*/
|
||||
int custom_ext_add(SSL *s, int context, WPACKET *pkt, X509 *x, size_t chainidx,
|
||||
int maxversion, int *al)
|
||||
int maxversion)
|
||||
{
|
||||
custom_ext_methods *exts = &s->cert->custext;
|
||||
custom_ext_method *meth;
|
||||
size_t i;
|
||||
int al;
|
||||
|
||||
for (i = 0; i < exts->meths_count; i++) {
|
||||
const unsigned char *out = NULL;
|
||||
@ -197,11 +205,13 @@ int custom_ext_add(SSL *s, int context, WPACKET *pkt, X509 *x, size_t chainidx,
|
||||
|
||||
if (meth->add_cb != NULL) {
|
||||
int cb_retval = meth->add_cb(s, meth->ext_type, context, &out,
|
||||
&outlen, x, chainidx, al,
|
||||
&outlen, x, chainidx, &al,
|
||||
meth->add_arg);
|
||||
|
||||
if (cb_retval < 0)
|
||||
if (cb_retval < 0) {
|
||||
SSLfatal(s, al, SSL_F_CUSTOM_EXT_ADD, SSL_R_CALLBACK_FAILED);
|
||||
return 0; /* error */
|
||||
}
|
||||
if (cb_retval == 0)
|
||||
continue; /* skip this extension */
|
||||
}
|
||||
@ -210,7 +220,8 @@ int custom_ext_add(SSL *s, int context, WPACKET *pkt, X509 *x, size_t chainidx,
|
||||
|| !WPACKET_start_sub_packet_u16(pkt)
|
||||
|| (outlen > 0 && !WPACKET_memcpy(pkt, out, outlen))
|
||||
|| !WPACKET_close(pkt)) {
|
||||
*al = SSL_AD_INTERNAL_ERROR;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_CUSTOM_EXT_ADD,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
if ((context & SSL_EXT_CLIENT_HELLO) != 0) {
|
||||
@ -218,7 +229,8 @@ int custom_ext_add(SSL *s, int context, WPACKET *pkt, X509 *x, size_t chainidx,
|
||||
* We can't send duplicates: code logic should prevent this.
|
||||
*/
|
||||
if (!ossl_assert((meth->ext_flags & SSL_EXT_FLAG_SENT) == 0)) {
|
||||
*al = SSL_AD_INTERNAL_ERROR;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_CUSTOM_EXT_ADD,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -120,14 +120,8 @@ void ossl_statem_fatal(SSL *s, int al, int func, int reason, const char *file,
|
||||
s->statem.in_init = 1;
|
||||
s->statem.state = MSG_FLOW_ERROR;
|
||||
ERR_put_error(ERR_LIB_SSL, func, reason, file, line);
|
||||
if (s->statem.hand_state != TLS_ST_BEFORE
|
||||
&& s->statem.hand_state != TLS_ST_CW_CLNT_HELLO) {
|
||||
/*
|
||||
* We only send an alert if we've got as far as actually sending or
|
||||
* receiving a message.
|
||||
*/
|
||||
if (al != SSL_AD_NO_ALERT)
|
||||
ssl3_send_alert(s, SSL3_AL_FATAL, al);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -557,13 +551,12 @@ static SUB_STATE_RETURN read_state_machine(SSL *s)
|
||||
* to that state if so
|
||||
*/
|
||||
if (!transition(s, mt)) {
|
||||
ossl_statem_set_error(s);
|
||||
return SUB_STATE_ERROR;
|
||||
}
|
||||
|
||||
if (s->s3->tmp.message_size > max_message_size(s)) {
|
||||
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_ILLEGAL_PARAMETER);
|
||||
SSLerr(SSL_F_READ_STATE_MACHINE, SSL_R_EXCESSIVE_MESSAGE_SIZE);
|
||||
SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_READ_STATE_MACHINE,
|
||||
SSL_R_EXCESSIVE_MESSAGE_SIZE);
|
||||
return SUB_STATE_ERROR;
|
||||
}
|
||||
|
||||
@ -572,8 +565,8 @@ static SUB_STATE_RETURN read_state_machine(SSL *s)
|
||||
&& s->s3->tmp.message_size > 0
|
||||
&& !grow_init_buf(s, s->s3->tmp.message_size
|
||||
+ SSL3_HM_HEADER_LENGTH)) {
|
||||
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
|
||||
SSLerr(SSL_F_READ_STATE_MACHINE, ERR_R_BUF_LIB);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_READ_STATE_MACHINE,
|
||||
ERR_R_BUF_LIB);
|
||||
return SUB_STATE_ERROR;
|
||||
}
|
||||
|
||||
@ -592,8 +585,8 @@ static SUB_STATE_RETURN read_state_machine(SSL *s)
|
||||
|
||||
s->first_packet = 0;
|
||||
if (!PACKET_buf_init(&pkt, s->init_msg, len)) {
|
||||
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
|
||||
SSLerr(SSL_F_READ_STATE_MACHINE, ERR_R_INTERNAL_ERROR);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_READ_STATE_MACHINE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return SUB_STATE_ERROR;
|
||||
}
|
||||
ret = process_message(s, &pkt);
|
||||
@ -645,9 +638,8 @@ static SUB_STATE_RETURN read_state_machine(SSL *s)
|
||||
|
||||
default:
|
||||
/* Shouldn't happen */
|
||||
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
|
||||
SSLerr(SSL_F_READ_STATE_MACHINE, ERR_R_INTERNAL_ERROR);
|
||||
ossl_statem_set_error(s);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_READ_STATE_MACHINE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return SUB_STATE_ERROR;
|
||||
}
|
||||
}
|
||||
@ -782,7 +774,7 @@ static SUB_STATE_RETURN write_state_machine(SSL *s)
|
||||
return SUB_STATE_END_HANDSHAKE;
|
||||
}
|
||||
if (!get_construct_message_f(s, &pkt, &confunc, &mt)) {
|
||||
ossl_statem_set_error(s);
|
||||
/* SSLfatal() already called */
|
||||
return SUB_STATE_ERROR;
|
||||
}
|
||||
if (mt == SSL3_MT_DUMMY) {
|
||||
@ -792,12 +784,22 @@ static SUB_STATE_RETURN write_state_machine(SSL *s)
|
||||
break;
|
||||
}
|
||||
if (!WPACKET_init(&pkt, s->init_buf)
|
||||
|| !ssl_set_handshake_header(s, &pkt, mt)
|
||||
|| (confunc != NULL && !confunc(s, &pkt))
|
||||
|| !ssl_close_construct_packet(s, &pkt, mt)
|
||||
|| !ssl_set_handshake_header(s, &pkt, mt)) {
|
||||
WPACKET_cleanup(&pkt);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_WRITE_STATE_MACHINE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return SUB_STATE_ERROR;
|
||||
}
|
||||
if (confunc != NULL && !confunc(s, &pkt)) {
|
||||
WPACKET_cleanup(&pkt);
|
||||
/* SSLfatal() already called */
|
||||
return SUB_STATE_ERROR;
|
||||
}
|
||||
if (!ssl_close_construct_packet(s, &pkt, mt)
|
||||
|| !WPACKET_finish(&pkt)) {
|
||||
WPACKET_cleanup(&pkt);
|
||||
ossl_statem_set_error(s);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_WRITE_STATE_MACHINE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return SUB_STATE_ERROR;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -70,8 +70,10 @@ int tls_close_construct_packet(SSL *s, WPACKET *pkt, int htype)
|
||||
|
||||
int tls_setup_handshake(SSL *s)
|
||||
{
|
||||
if (!ssl3_init_finished_mac(s))
|
||||
if (!ssl3_init_finished_mac(s)) {
|
||||
/* SSLfatal() already called */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Reset any extension flags */
|
||||
memset(s->ext.extflags, 0, sizeof(s->ext.extflags));
|
||||
@ -194,6 +196,7 @@ static int get_cert_verify_tbs_data(SSL *s, unsigned char *tls13tbs,
|
||||
hashlen = s->cert_verify_hash_len;
|
||||
} else if (!ssl_handshake_hash(s, tls13tbs + TLS13_TBS_PREAMBLE_SIZE,
|
||||
EVP_MAX_MD_SIZE, &hashlen)) {
|
||||
/* SSLfatal() already called */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -203,8 +206,11 @@ static int get_cert_verify_tbs_data(SSL *s, unsigned char *tls13tbs,
|
||||
size_t retlen;
|
||||
|
||||
retlen = BIO_get_mem_data(s->s3->handshake_buffer, hdata);
|
||||
if (retlen <= 0)
|
||||
if (retlen <= 0) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_GET_CERT_VERIFY_TBS_DATA,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
*hdatalen = retlen;
|
||||
}
|
||||
|
||||
@ -242,7 +248,7 @@ int tls_construct_cert_verify(SSL *s, WPACKET *pkt)
|
||||
|
||||
/* Get the data to be signed */
|
||||
if (!get_cert_verify_tbs_data(s, tls13tbs, &hdata, &hdatalen)) {
|
||||
SSLerr(SSL_F_TLS_CONSTRUCT_CERT_VERIFY, ERR_R_INTERNAL_ERROR);
|
||||
/* SSLfatal() already called */
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -322,7 +328,6 @@ MSG_PROCESS_RETURN tls_process_cert_verify(SSL *s, PACKET *pkt)
|
||||
#ifndef OPENSSL_NO_GOST
|
||||
unsigned char *gost_data = NULL;
|
||||
#endif
|
||||
int al = SSL_AD_INTERNAL_ERROR;
|
||||
MSG_PROCESS_RETURN ret = MSG_PROCESS_ERROR;
|
||||
int j;
|
||||
unsigned int len;
|
||||
@ -335,49 +340,50 @@ MSG_PROCESS_RETURN tls_process_cert_verify(SSL *s, PACKET *pkt)
|
||||
EVP_PKEY_CTX *pctx = NULL;
|
||||
|
||||
if (mctx == NULL) {
|
||||
SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, ERR_R_MALLOC_FAILURE);
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
peer = s->session->peer;
|
||||
pkey = X509_get0_pubkey(peer);
|
||||
if (pkey == NULL)
|
||||
goto f_err;
|
||||
if (pkey == NULL) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (ssl_cert_lookup_by_pkey(pkey, NULL) == NULL) {
|
||||
SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY,
|
||||
SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE);
|
||||
al = SSL_AD_ILLEGAL_PARAMETER;
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_TLS_PROCESS_CERT_VERIFY,
|
||||
SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (SSL_USE_SIGALGS(s)) {
|
||||
int rv;
|
||||
unsigned int sigalg;
|
||||
|
||||
if (!PACKET_get_net_2(pkt, &sigalg)) {
|
||||
al = SSL_AD_DECODE_ERROR;
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,
|
||||
SSL_R_BAD_PACKET);
|
||||
goto err;
|
||||
}
|
||||
rv = tls12_check_peer_sigalg(s, sigalg, pkey);
|
||||
if (rv == -1) {
|
||||
goto f_err;
|
||||
} else if (rv == 0) {
|
||||
al = SSL_AD_DECODE_ERROR;
|
||||
goto f_err;
|
||||
if (tls12_check_peer_sigalg(s, sigalg, pkey) <= 0) {
|
||||
/* SSLfatal() already called */
|
||||
goto err;
|
||||
}
|
||||
#ifdef SSL_DEBUG
|
||||
fprintf(stderr, "USING TLSv1.2 HASH %s\n", EVP_MD_name(md));
|
||||
#endif
|
||||
} else if (!tls1_set_peer_legacy_sigalg(s, pkey)) {
|
||||
al = SSL_AD_INTERNAL_ERROR;
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!tls1_lookup_md(s->s3->tmp.peer_sigalg, &md)) {
|
||||
SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, ERR_R_INTERNAL_ERROR);
|
||||
al = SSL_AD_INTERNAL_ERROR;
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Check for broken implementations of GOST ciphersuites */
|
||||
@ -396,35 +402,36 @@ MSG_PROCESS_RETURN tls_process_cert_verify(SSL *s, PACKET *pkt)
|
||||
} else
|
||||
#endif
|
||||
if (!PACKET_get_net_2(pkt, &len)) {
|
||||
SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, SSL_R_LENGTH_MISMATCH);
|
||||
al = SSL_AD_DECODE_ERROR;
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,
|
||||
SSL_R_LENGTH_MISMATCH);
|
||||
goto err;
|
||||
}
|
||||
|
||||
j = EVP_PKEY_size(pkey);
|
||||
if (((int)len > j) || ((int)PACKET_remaining(pkt) > j)
|
||||
|| (PACKET_remaining(pkt) == 0)) {
|
||||
SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, SSL_R_WRONG_SIGNATURE_SIZE);
|
||||
al = SSL_AD_DECODE_ERROR;
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,
|
||||
SSL_R_WRONG_SIGNATURE_SIZE);
|
||||
goto err;
|
||||
}
|
||||
if (!PACKET_get_bytes(pkt, &data, len)) {
|
||||
SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, SSL_R_LENGTH_MISMATCH);
|
||||
al = SSL_AD_DECODE_ERROR;
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,
|
||||
SSL_R_LENGTH_MISMATCH);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!get_cert_verify_tbs_data(s, tls13tbs, &hdata, &hdatalen)) {
|
||||
SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, ERR_R_INTERNAL_ERROR);
|
||||
goto f_err;
|
||||
/* SSLfatal() already called */
|
||||
goto err;
|
||||
}
|
||||
|
||||
#ifdef SSL_DEBUG
|
||||
fprintf(stderr, "Using client verify alg %s\n", EVP_MD_name(md));
|
||||
#endif
|
||||
if (EVP_DigestVerifyInit(mctx, &pctx, md, NULL, pkey) <= 0) {
|
||||
SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, ERR_R_EVP_LIB);
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,
|
||||
ERR_R_EVP_LIB);
|
||||
goto err;
|
||||
}
|
||||
#ifndef OPENSSL_NO_GOST
|
||||
{
|
||||
@ -433,8 +440,9 @@ MSG_PROCESS_RETURN tls_process_cert_verify(SSL *s, PACKET *pkt)
|
||||
|| pktype == NID_id_GostR3410_2012_256
|
||||
|| pktype == NID_id_GostR3410_2012_512) {
|
||||
if ((gost_data = OPENSSL_malloc(len)) == NULL) {
|
||||
SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, ERR_R_MALLOC_FAILURE);
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_TLS_PROCESS_CERT_VERIFY, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
BUF_reverse(gost_data, data, len);
|
||||
data = gost_data;
|
||||
@ -446,8 +454,9 @@ MSG_PROCESS_RETURN tls_process_cert_verify(SSL *s, PACKET *pkt)
|
||||
if (EVP_PKEY_CTX_set_rsa_padding(pctx, RSA_PKCS1_PSS_PADDING) <= 0
|
||||
|| EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx,
|
||||
RSA_PSS_SALTLEN_DIGEST) <= 0) {
|
||||
SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, ERR_R_EVP_LIB);
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,
|
||||
ERR_R_EVP_LIB);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (s->version == SSL3_VERSION) {
|
||||
@ -455,29 +464,26 @@ MSG_PROCESS_RETURN tls_process_cert_verify(SSL *s, PACKET *pkt)
|
||||
|| !EVP_MD_CTX_ctrl(mctx, EVP_CTRL_SSL3_MASTER_SECRET,
|
||||
(int)s->session->master_key_length,
|
||||
s->session->master_key)) {
|
||||
SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, ERR_R_EVP_LIB);
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,
|
||||
ERR_R_EVP_LIB);
|
||||
goto err;
|
||||
}
|
||||
if (EVP_DigestVerifyFinal(mctx, data, len) <= 0) {
|
||||
al = SSL_AD_DECRYPT_ERROR;
|
||||
SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, SSL_R_BAD_SIGNATURE);
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_DECRYPT_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,
|
||||
SSL_R_BAD_SIGNATURE);
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
j = EVP_DigestVerify(mctx, data, len, hdata, hdatalen);
|
||||
if (j <= 0) {
|
||||
al = SSL_AD_DECRYPT_ERROR;
|
||||
SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, SSL_R_BAD_SIGNATURE);
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_DECRYPT_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,
|
||||
SSL_R_BAD_SIGNATURE);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
ret = MSG_PROCESS_CONTINUE_READING;
|
||||
if (0) {
|
||||
f_err:
|
||||
ssl3_send_alert(s, SSL3_AL_FATAL, al);
|
||||
ossl_statem_set_error(s);
|
||||
}
|
||||
err:
|
||||
BIO_free(s->s3->handshake_buffer);
|
||||
s->s3->handshake_buffer = NULL;
|
||||
EVP_MD_CTX_free(mctx);
|
||||
@ -589,14 +595,13 @@ int tls_construct_key_update(SSL *s, WPACKET *pkt)
|
||||
|
||||
MSG_PROCESS_RETURN tls_process_key_update(SSL *s, PACKET *pkt)
|
||||
{
|
||||
int al;
|
||||
unsigned int updatetype;
|
||||
|
||||
s->key_update_count++;
|
||||
if (s->key_update_count > MAX_KEY_UPDATE_MESSAGES) {
|
||||
al = SSL_AD_ILLEGAL_PARAMETER;
|
||||
SSLerr(SSL_F_TLS_PROCESS_KEY_UPDATE, SSL_R_TOO_MANY_KEY_UPDATES);
|
||||
goto err;
|
||||
SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_TLS_PROCESS_KEY_UPDATE,
|
||||
SSL_R_TOO_MANY_KEY_UPDATES);
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -604,16 +609,16 @@ MSG_PROCESS_RETURN tls_process_key_update(SSL *s, PACKET *pkt)
|
||||
* be on a record boundary.
|
||||
*/
|
||||
if (RECORD_LAYER_processed_read_pending(&s->rlayer)) {
|
||||
al = SSL_AD_UNEXPECTED_MESSAGE;
|
||||
SSLerr(SSL_F_TLS_PROCESS_KEY_UPDATE, SSL_R_NOT_ON_RECORD_BOUNDARY);
|
||||
goto err;
|
||||
SSLfatal(s, SSL_AD_UNEXPECTED_MESSAGE, SSL_F_TLS_PROCESS_KEY_UPDATE,
|
||||
SSL_R_NOT_ON_RECORD_BOUNDARY);
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
|
||||
if (!PACKET_get_1(pkt, &updatetype)
|
||||
|| PACKET_remaining(pkt) != 0) {
|
||||
al = SSL_AD_DECODE_ERROR;
|
||||
SSLerr(SSL_F_TLS_PROCESS_KEY_UPDATE, SSL_R_BAD_KEY_UPDATE);
|
||||
goto err;
|
||||
SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_TLS_PROCESS_KEY_UPDATE,
|
||||
SSL_R_BAD_KEY_UPDATE);
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -622,9 +627,9 @@ MSG_PROCESS_RETURN tls_process_key_update(SSL *s, PACKET *pkt)
|
||||
*/
|
||||
if (updatetype != SSL_KEY_UPDATE_NOT_REQUESTED
|
||||
&& updatetype != SSL_KEY_UPDATE_REQUESTED) {
|
||||
al = SSL_AD_ILLEGAL_PARAMETER;
|
||||
SSLerr(SSL_F_TLS_PROCESS_KEY_UPDATE, SSL_R_BAD_KEY_UPDATE);
|
||||
goto err;
|
||||
SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_TLS_PROCESS_KEY_UPDATE,
|
||||
SSL_R_BAD_KEY_UPDATE);
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -636,16 +641,11 @@ MSG_PROCESS_RETURN tls_process_key_update(SSL *s, PACKET *pkt)
|
||||
s->key_update = SSL_KEY_UPDATE_NOT_REQUESTED;
|
||||
|
||||
if (!tls13_update_key(s, 0)) {
|
||||
al = SSL_AD_INTERNAL_ERROR;
|
||||
SSLerr(SSL_F_TLS_PROCESS_KEY_UPDATE, ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
/* SSLfatal() already called */
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
|
||||
return MSG_PROCESS_FINISHED_READING;
|
||||
err:
|
||||
ssl3_send_alert(s, SSL3_AL_FATAL, al);
|
||||
ossl_statem_set_error(s);
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
@ -680,7 +680,6 @@ static void ssl3_take_mac(SSL *s)
|
||||
|
||||
MSG_PROCESS_RETURN tls_process_change_cipher_spec(SSL *s, PACKET *pkt)
|
||||
{
|
||||
int al;
|
||||
size_t remain;
|
||||
|
||||
remain = PACKET_remaining(pkt);
|
||||
@ -694,32 +693,32 @@ MSG_PROCESS_RETURN tls_process_change_cipher_spec(SSL *s, PACKET *pkt)
|
||||
&& remain != DTLS1_CCS_HEADER_LENGTH + 1)
|
||||
|| (s->version != DTLS1_BAD_VER
|
||||
&& remain != DTLS1_CCS_HEADER_LENGTH - 1)) {
|
||||
al = SSL_AD_DECODE_ERROR;
|
||||
SSLerr(SSL_F_TLS_PROCESS_CHANGE_CIPHER_SPEC,
|
||||
SSL_R_BAD_CHANGE_CIPHER_SPEC);
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_DECODE_ERROR,
|
||||
SSL_F_TLS_PROCESS_CHANGE_CIPHER_SPEC,
|
||||
SSL_R_BAD_CHANGE_CIPHER_SPEC);
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
} else {
|
||||
if (remain != 0) {
|
||||
al = SSL_AD_DECODE_ERROR;
|
||||
SSLerr(SSL_F_TLS_PROCESS_CHANGE_CIPHER_SPEC,
|
||||
SSL_R_BAD_CHANGE_CIPHER_SPEC);
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_DECODE_ERROR,
|
||||
SSL_F_TLS_PROCESS_CHANGE_CIPHER_SPEC,
|
||||
SSL_R_BAD_CHANGE_CIPHER_SPEC);
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check we have a cipher to change to */
|
||||
if (s->s3->tmp.new_cipher == NULL) {
|
||||
al = SSL_AD_UNEXPECTED_MESSAGE;
|
||||
SSLerr(SSL_F_TLS_PROCESS_CHANGE_CIPHER_SPEC, SSL_R_CCS_RECEIVED_EARLY);
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_UNEXPECTED_MESSAGE,
|
||||
SSL_F_TLS_PROCESS_CHANGE_CIPHER_SPEC, SSL_R_CCS_RECEIVED_EARLY);
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
|
||||
s->s3->change_cipher_spec = 1;
|
||||
if (!ssl3_do_change_cipher_spec(s)) {
|
||||
al = SSL_AD_INTERNAL_ERROR;
|
||||
SSLerr(SSL_F_TLS_PROCESS_CHANGE_CIPHER_SPEC, ERR_R_INTERNAL_ERROR);
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CHANGE_CIPHER_SPEC,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
|
||||
if (SSL_IS_DTLS(s)) {
|
||||
@ -739,15 +738,10 @@ MSG_PROCESS_RETURN tls_process_change_cipher_spec(SSL *s, PACKET *pkt)
|
||||
}
|
||||
|
||||
return MSG_PROCESS_CONTINUE_READING;
|
||||
f_err:
|
||||
ssl3_send_alert(s, SSL3_AL_FATAL, al);
|
||||
ossl_statem_set_error(s);
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
|
||||
MSG_PROCESS_RETURN tls_process_finished(SSL *s, PACKET *pkt)
|
||||
{
|
||||
int al = SSL_AD_INTERNAL_ERROR;
|
||||
size_t md_len;
|
||||
|
||||
|
||||
@ -760,41 +754,41 @@ MSG_PROCESS_RETURN tls_process_finished(SSL *s, PACKET *pkt)
|
||||
* message must be on a record boundary.
|
||||
*/
|
||||
if (SSL_IS_TLS13(s) && RECORD_LAYER_processed_read_pending(&s->rlayer)) {
|
||||
al = SSL_AD_UNEXPECTED_MESSAGE;
|
||||
SSLerr(SSL_F_TLS_PROCESS_FINISHED, SSL_R_NOT_ON_RECORD_BOUNDARY);
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_UNEXPECTED_MESSAGE, SSL_F_TLS_PROCESS_FINISHED,
|
||||
SSL_R_NOT_ON_RECORD_BOUNDARY);
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
|
||||
/* If this occurs, we have missed a message */
|
||||
if (!SSL_IS_TLS13(s) && !s->s3->change_cipher_spec) {
|
||||
al = SSL_AD_UNEXPECTED_MESSAGE;
|
||||
SSLerr(SSL_F_TLS_PROCESS_FINISHED, SSL_R_GOT_A_FIN_BEFORE_A_CCS);
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_UNEXPECTED_MESSAGE, SSL_F_TLS_PROCESS_FINISHED,
|
||||
SSL_R_GOT_A_FIN_BEFORE_A_CCS);
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
s->s3->change_cipher_spec = 0;
|
||||
|
||||
md_len = s->s3->tmp.peer_finish_md_len;
|
||||
|
||||
if (md_len != PACKET_remaining(pkt)) {
|
||||
al = SSL_AD_DECODE_ERROR;
|
||||
SSLerr(SSL_F_TLS_PROCESS_FINISHED, SSL_R_BAD_DIGEST_LENGTH);
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_TLS_PROCESS_FINISHED,
|
||||
SSL_R_BAD_DIGEST_LENGTH);
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
|
||||
if (CRYPTO_memcmp(PACKET_data(pkt), s->s3->tmp.peer_finish_md,
|
||||
md_len) != 0) {
|
||||
al = SSL_AD_DECRYPT_ERROR;
|
||||
SSLerr(SSL_F_TLS_PROCESS_FINISHED, SSL_R_DIGEST_CHECK_FAILED);
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_DECRYPT_ERROR, SSL_F_TLS_PROCESS_FINISHED,
|
||||
SSL_R_DIGEST_CHECK_FAILED);
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy the finished so we can use it for renegotiation checks
|
||||
*/
|
||||
if (!ossl_assert(md_len <= EVP_MAX_MD_SIZE)) {
|
||||
al = SSL_AD_INTERNAL_ERROR;
|
||||
SSLerr(SSL_F_TLS_PROCESS_FINISHED, ERR_R_INTERNAL_ERROR);
|
||||
goto f_err;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_FINISHED,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
if (s->server) {
|
||||
memcpy(s->s3->previous_client_finished, s->s3->tmp.peer_finish_md,
|
||||
@ -814,31 +808,29 @@ MSG_PROCESS_RETURN tls_process_finished(SSL *s, PACKET *pkt)
|
||||
if (s->server) {
|
||||
if (!s->method->ssl3_enc->change_cipher_state(s,
|
||||
SSL3_CC_APPLICATION | SSL3_CHANGE_CIPHER_SERVER_READ)) {
|
||||
SSLerr(SSL_F_TLS_PROCESS_FINISHED, SSL_R_CANNOT_CHANGE_CIPHER);
|
||||
goto f_err;
|
||||
/* SSLfatal() already called */
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
} else {
|
||||
if (!s->method->ssl3_enc->generate_master_secret(s,
|
||||
s->master_secret, s->handshake_secret, 0,
|
||||
&s->session->master_key_length)) {
|
||||
SSLerr(SSL_F_TLS_PROCESS_FINISHED, SSL_R_CANNOT_CHANGE_CIPHER);
|
||||
goto f_err;
|
||||
/* SSLfatal() already called */
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
if (!s->method->ssl3_enc->change_cipher_state(s,
|
||||
SSL3_CC_APPLICATION | SSL3_CHANGE_CIPHER_CLIENT_READ)) {
|
||||
SSLerr(SSL_F_TLS_PROCESS_FINISHED, SSL_R_CANNOT_CHANGE_CIPHER);
|
||||
goto f_err;
|
||||
/* SSLfatal() already called */
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
if (!tls_process_initial_server_flight(s)) {
|
||||
/* SSLfatal() already called */
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
if (!tls_process_initial_server_flight(s, &al))
|
||||
goto f_err;
|
||||
}
|
||||
}
|
||||
|
||||
return MSG_PROCESS_FINISHED_READING;
|
||||
f_err:
|
||||
ssl3_send_alert(s, SSL3_AL_FATAL, al);
|
||||
ossl_statem_set_error(s);
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
|
||||
int tls_construct_change_cipher_spec(SSL *s, WPACKET *pkt)
|
||||
@ -853,42 +845,42 @@ int tls_construct_change_cipher_spec(SSL *s, WPACKET *pkt)
|
||||
}
|
||||
|
||||
/* Add a certificate to the WPACKET */
|
||||
static int ssl_add_cert_to_wpacket(SSL *s, WPACKET *pkt, X509 *x, int chain,
|
||||
int *al)
|
||||
static int ssl_add_cert_to_wpacket(SSL *s, WPACKET *pkt, X509 *x, int chain)
|
||||
{
|
||||
int len;
|
||||
unsigned char *outbytes;
|
||||
|
||||
len = i2d_X509(x, NULL);
|
||||
if (len < 0) {
|
||||
SSLerr(SSL_F_SSL_ADD_CERT_TO_WPACKET, ERR_R_BUF_LIB);
|
||||
*al = SSL_AD_INTERNAL_ERROR;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_ADD_CERT_TO_WPACKET,
|
||||
ERR_R_BUF_LIB);
|
||||
return 0;
|
||||
}
|
||||
if (!WPACKET_sub_allocate_bytes_u24(pkt, len, &outbytes)
|
||||
|| i2d_X509(x, &outbytes) != len) {
|
||||
SSLerr(SSL_F_SSL_ADD_CERT_TO_WPACKET, ERR_R_INTERNAL_ERROR);
|
||||
*al = SSL_AD_INTERNAL_ERROR;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_ADD_CERT_TO_WPACKET,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (SSL_IS_TLS13(s)
|
||||
&& !tls_construct_extensions(s, pkt, SSL_EXT_TLS1_3_CERTIFICATE, x,
|
||||
chain, al))
|
||||
chain)) {
|
||||
/* SSLfatal() already called */
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Add certificate chain to provided WPACKET */
|
||||
static int ssl_add_cert_chain(SSL *s, WPACKET *pkt, CERT_PKEY *cpk, int *al)
|
||||
static int ssl_add_cert_chain(SSL *s, WPACKET *pkt, CERT_PKEY *cpk)
|
||||
{
|
||||
int i, chain_count;
|
||||
X509 *x;
|
||||
STACK_OF(X509) *extra_certs;
|
||||
STACK_OF(X509) *chain = NULL;
|
||||
X509_STORE *chain_store;
|
||||
int tmpal = SSL_AD_INTERNAL_ERROR;
|
||||
|
||||
if (cpk == NULL || cpk->x509 == NULL)
|
||||
return 1;
|
||||
@ -914,13 +906,15 @@ static int ssl_add_cert_chain(SSL *s, WPACKET *pkt, CERT_PKEY *cpk, int *al)
|
||||
X509_STORE_CTX *xs_ctx = X509_STORE_CTX_new();
|
||||
|
||||
if (xs_ctx == NULL) {
|
||||
SSLerr(SSL_F_SSL_ADD_CERT_CHAIN, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_ADD_CERT_CHAIN,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
if (!X509_STORE_CTX_init(xs_ctx, chain_store, x, NULL)) {
|
||||
X509_STORE_CTX_free(xs_ctx);
|
||||
SSLerr(SSL_F_SSL_ADD_CERT_CHAIN, ERR_R_X509_LIB);
|
||||
goto err;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_ADD_CERT_CHAIN,
|
||||
ERR_R_X509_LIB);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* It is valid for the chain not to be complete (because normally we
|
||||
@ -941,52 +935,58 @@ static int ssl_add_cert_chain(SSL *s, WPACKET *pkt, CERT_PKEY *cpk, int *al)
|
||||
SSLerr(SSL_F_SSL_ADD_CERT_CHAIN, SSL_R_CA_MD_TOO_WEAK);
|
||||
#endif
|
||||
X509_STORE_CTX_free(xs_ctx);
|
||||
SSLerr(SSL_F_SSL_ADD_CERT_CHAIN, i);
|
||||
goto err;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_ADD_CERT_CHAIN, i);
|
||||
return 0;
|
||||
}
|
||||
chain_count = sk_X509_num(chain);
|
||||
for (i = 0; i < chain_count; i++) {
|
||||
x = sk_X509_value(chain, i);
|
||||
|
||||
if (!ssl_add_cert_to_wpacket(s, pkt, x, i, &tmpal)) {
|
||||
if (!ssl_add_cert_to_wpacket(s, pkt, x, i)) {
|
||||
/* SSLfatal() already called */
|
||||
X509_STORE_CTX_free(xs_ctx);
|
||||
goto err;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
X509_STORE_CTX_free(xs_ctx);
|
||||
} else {
|
||||
i = ssl_security_cert_chain(s, extra_certs, x, 0);
|
||||
if (i != 1) {
|
||||
SSLerr(SSL_F_SSL_ADD_CERT_CHAIN, i);
|
||||
goto err;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_ADD_CERT_CHAIN, i);
|
||||
return 0;
|
||||
}
|
||||
if (!ssl_add_cert_to_wpacket(s, pkt, x, 0)) {
|
||||
/* SSLfatal() already called */
|
||||
return 0;
|
||||
}
|
||||
if (!ssl_add_cert_to_wpacket(s, pkt, x, 0, &tmpal))
|
||||
goto err;
|
||||
for (i = 0; i < sk_X509_num(extra_certs); i++) {
|
||||
x = sk_X509_value(extra_certs, i);
|
||||
if (!ssl_add_cert_to_wpacket(s, pkt, x, i + 1, &tmpal))
|
||||
goto err;
|
||||
if (!ssl_add_cert_to_wpacket(s, pkt, x, i + 1)) {
|
||||
/* SSLfatal() already called */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
||||
err:
|
||||
*al = tmpal;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long ssl3_output_cert_chain(SSL *s, WPACKET *pkt, CERT_PKEY *cpk,
|
||||
int *al)
|
||||
unsigned long ssl3_output_cert_chain(SSL *s, WPACKET *pkt, CERT_PKEY *cpk)
|
||||
{
|
||||
int tmpal = SSL_AD_INTERNAL_ERROR;
|
||||
|
||||
if (!WPACKET_start_sub_packet_u24(pkt)
|
||||
|| !ssl_add_cert_chain(s, pkt, cpk, &tmpal)
|
||||
|| !WPACKET_close(pkt)) {
|
||||
SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN, ERR_R_INTERNAL_ERROR);
|
||||
*al = tmpal;
|
||||
if (!WPACKET_start_sub_packet_u24(pkt)) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_OUTPUT_CERT_CHAIN,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!ssl_add_cert_chain(s, pkt, cpk))
|
||||
return 0;
|
||||
|
||||
if (!WPACKET_close(pkt)) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_OUTPUT_CERT_CHAIN,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -2009,20 +2009,22 @@ int create_synthetic_message_hash(SSL *s)
|
||||
/* Get the hash of the initial ClientHello */
|
||||
if (!ssl3_digest_cached_records(s, 0)
|
||||
|| !ssl_handshake_hash(s, hashval, sizeof(hashval), &hashlen)) {
|
||||
SSLerr(SSL_F_CREATE_SYNTHETIC_MESSAGE_HASH, ERR_R_INTERNAL_ERROR);
|
||||
/* SSLfatal() already called */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Reinitialise the transcript hash */
|
||||
if (!ssl3_init_finished_mac(s))
|
||||
if (!ssl3_init_finished_mac(s)) {
|
||||
/* SSLfatal() already called */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Inject the synthetic message_hash message */
|
||||
msghdr[0] = SSL3_MT_MESSAGE_HASH;
|
||||
msghdr[SSL3_HM_HEADER_LENGTH - 1] = (unsigned char)hashlen;
|
||||
if (!ssl3_finish_mac(s, msghdr, SSL3_HM_HEADER_LENGTH)
|
||||
|| !ssl3_finish_mac(s, hashval, hashlen)) {
|
||||
SSLerr(SSL_F_CREATE_SYNTHETIC_MESSAGE_HASH, ERR_R_INTERNAL_ERROR);
|
||||
/* SSLfatal() already called */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2034,21 +2036,22 @@ static int ca_dn_cmp(const X509_NAME *const *a, const X509_NAME *const *b)
|
||||
return X509_NAME_cmp(*a, *b);
|
||||
}
|
||||
|
||||
int parse_ca_names(SSL *s, PACKET *pkt, int *al)
|
||||
int parse_ca_names(SSL *s, PACKET *pkt)
|
||||
{
|
||||
STACK_OF(X509_NAME) *ca_sk = sk_X509_NAME_new(ca_dn_cmp);
|
||||
X509_NAME *xn = NULL;
|
||||
PACKET cadns;
|
||||
|
||||
if (ca_sk == NULL) {
|
||||
SSLerr(SSL_F_PARSE_CA_NAMES, ERR_R_MALLOC_FAILURE);
|
||||
goto decerr;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_PARSE_CA_NAMES,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
/* get the CA RDNs */
|
||||
if (!PACKET_get_length_prefixed_2(pkt, &cadns)) {
|
||||
*al = SSL_AD_DECODE_ERROR;
|
||||
SSLerr(SSL_F_PARSE_CA_NAMES, SSL_R_LENGTH_MISMATCH);
|
||||
goto decerr;
|
||||
SSLfatal(s, SSL_AD_DECODE_ERROR,SSL_F_PARSE_CA_NAMES,
|
||||
SSL_R_LENGTH_MISMATCH);
|
||||
goto err;
|
||||
}
|
||||
|
||||
while (PACKET_remaining(&cadns)) {
|
||||
@ -2057,23 +2060,26 @@ int parse_ca_names(SSL *s, PACKET *pkt, int *al)
|
||||
|
||||
if (!PACKET_get_net_2(&cadns, &name_len)
|
||||
|| !PACKET_get_bytes(&cadns, &namebytes, name_len)) {
|
||||
SSLerr(SSL_F_PARSE_CA_NAMES, SSL_R_LENGTH_MISMATCH);
|
||||
goto decerr;
|
||||
SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_PARSE_CA_NAMES,
|
||||
SSL_R_LENGTH_MISMATCH);
|
||||
goto err;
|
||||
}
|
||||
|
||||
namestart = namebytes;
|
||||
if ((xn = d2i_X509_NAME(NULL, &namebytes, name_len)) == NULL) {
|
||||
SSLerr(SSL_F_PARSE_CA_NAMES, ERR_R_ASN1_LIB);
|
||||
goto decerr;
|
||||
SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_PARSE_CA_NAMES,
|
||||
ERR_R_ASN1_LIB);
|
||||
goto err;
|
||||
}
|
||||
if (namebytes != (namestart + name_len)) {
|
||||
SSLerr(SSL_F_PARSE_CA_NAMES, SSL_R_CA_DN_LENGTH_MISMATCH);
|
||||
goto decerr;
|
||||
SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_PARSE_CA_NAMES,
|
||||
SSL_R_CA_DN_LENGTH_MISMATCH);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!sk_X509_NAME_push(ca_sk, xn)) {
|
||||
SSLerr(SSL_F_PARSE_CA_NAMES, ERR_R_MALLOC_FAILURE);
|
||||
*al = SSL_AD_INTERNAL_ERROR;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_PARSE_CA_NAMES,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
xn = NULL;
|
||||
@ -2084,8 +2090,6 @@ int parse_ca_names(SSL *s, PACKET *pkt, int *al)
|
||||
|
||||
return 1;
|
||||
|
||||
decerr:
|
||||
*al = SSL_AD_DECODE_ERROR;
|
||||
err:
|
||||
sk_X509_NAME_pop_free(ca_sk, X509_NAME_free);
|
||||
X509_NAME_free(xn);
|
||||
@ -2097,8 +2101,11 @@ int construct_ca_names(SSL *s, WPACKET *pkt)
|
||||
const STACK_OF(X509_NAME) *ca_sk = SSL_get0_CA_list(s);
|
||||
|
||||
/* Start sub-packet for client CA list */
|
||||
if (!WPACKET_start_sub_packet_u16(pkt))
|
||||
if (!WPACKET_start_sub_packet_u16(pkt)) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_CONSTRUCT_CA_NAMES,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ca_sk != NULL) {
|
||||
int i;
|
||||
@ -2113,26 +2120,34 @@ int construct_ca_names(SSL *s, WPACKET *pkt)
|
||||
|| !WPACKET_sub_allocate_bytes_u16(pkt, namelen,
|
||||
&namebytes)
|
||||
|| i2d_X509_NAME(name, &namebytes) != namelen) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_CONSTRUCT_CA_NAMES,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!WPACKET_close(pkt))
|
||||
if (!WPACKET_close(pkt)) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_CONSTRUCT_CA_NAMES,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Create a buffer containing data to be signed for server key exchange */
|
||||
size_t construct_key_exchange_tbs(const SSL *s, unsigned char **ptbs,
|
||||
size_t construct_key_exchange_tbs(SSL *s, unsigned char **ptbs,
|
||||
const void *param, size_t paramlen)
|
||||
{
|
||||
size_t tbslen = 2 * SSL3_RANDOM_SIZE + paramlen;
|
||||
unsigned char *tbs = OPENSSL_malloc(tbslen);
|
||||
|
||||
if (tbs == NULL)
|
||||
if (tbs == NULL) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_CONSTRUCT_KEY_EXCHANGE_TBS,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
memcpy(tbs, s->s3->client_random, SSL3_RANDOM_SIZE);
|
||||
memcpy(tbs + SSL3_RANDOM_SIZE, s->s3->server_random, SSL3_RANDOM_SIZE);
|
||||
|
||||
|
@ -58,9 +58,9 @@ typedef int (*confunc_f) (SSL *s, WPACKET *pkt);
|
||||
int check_in_list(SSL *s, uint16_t group_id, const uint16_t *groups,
|
||||
size_t num_groups, int checkallow);
|
||||
int create_synthetic_message_hash(SSL *s);
|
||||
int parse_ca_names(SSL *s, PACKET *pkt, int *al);
|
||||
int parse_ca_names(SSL *s, PACKET *pkt);
|
||||
int construct_ca_names(SSL *s, WPACKET *pkt);
|
||||
size_t construct_key_exchange_tbs(const SSL *s, unsigned char **ptbs,
|
||||
size_t construct_key_exchange_tbs(SSL *s, unsigned char **ptbs,
|
||||
const void *param, size_t paramlen);
|
||||
|
||||
/*
|
||||
@ -95,7 +95,7 @@ __owur int tls_get_message_body(SSL *s, size_t *len);
|
||||
__owur int dtls_get_message(SSL *s, int *mt, size_t *len);
|
||||
|
||||
/* Message construction and processing functions */
|
||||
__owur int tls_process_initial_server_flight(SSL *s, int *al);
|
||||
__owur int tls_process_initial_server_flight(SSL *s);
|
||||
__owur MSG_PROCESS_RETURN tls_process_change_cipher_spec(SSL *s, PACKET *pkt);
|
||||
__owur MSG_PROCESS_RETURN tls_process_finished(SSL *s, PACKET *pkt);
|
||||
__owur int tls_construct_change_cipher_spec(SSL *s, WPACKET *pkt);
|
||||
@ -112,7 +112,7 @@ __owur int tls_construct_client_hello(SSL *s, WPACKET *pkt);
|
||||
__owur MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt);
|
||||
__owur MSG_PROCESS_RETURN tls_process_certificate_request(SSL *s, PACKET *pkt);
|
||||
__owur MSG_PROCESS_RETURN tls_process_new_session_ticket(SSL *s, PACKET *pkt);
|
||||
__owur int tls_process_cert_status_body(SSL *s, PACKET *pkt, int *al);
|
||||
__owur int tls_process_cert_status_body(SSL *s, PACKET *pkt);
|
||||
__owur MSG_PROCESS_RETURN tls_process_cert_status(SSL *s, PACKET *pkt);
|
||||
__owur MSG_PROCESS_RETURN tls_process_server_done(SSL *s, PACKET *pkt);
|
||||
__owur int tls_construct_cert_verify(SSL *s, WPACKET *pkt);
|
||||
@ -164,17 +164,15 @@ typedef enum ext_return_en {
|
||||
__owur int extension_is_relevant(SSL *s, unsigned int extctx,
|
||||
unsigned int thisctx);
|
||||
__owur int tls_collect_extensions(SSL *s, PACKET *packet, unsigned int context,
|
||||
RAW_EXTENSION **res, int *al, size_t *len,
|
||||
int init);
|
||||
RAW_EXTENSION **res, size_t *len, int init);
|
||||
__owur int tls_parse_extension(SSL *s, TLSEXT_INDEX idx, int context,
|
||||
RAW_EXTENSION *exts, X509 *x, size_t chainidx,
|
||||
int *al);
|
||||
RAW_EXTENSION *exts, X509 *x, size_t chainidx);
|
||||
__owur int tls_parse_all_extensions(SSL *s, int context, RAW_EXTENSION *exts,
|
||||
X509 *x, size_t chainidx, int *al, int fin);
|
||||
X509 *x, size_t chainidx, int fin);
|
||||
__owur int should_add_extension(SSL *s, unsigned int extctx,
|
||||
unsigned int thisctx, int max_version);
|
||||
__owur int tls_construct_extensions(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
|
||||
__owur int tls_psk_do_binder(SSL *s, const EVP_MD *md,
|
||||
const unsigned char *msgstart,
|
||||
@ -184,98 +182,98 @@ __owur int tls_psk_do_binder(SSL *s, const EVP_MD *md,
|
||||
|
||||
/* Server Extension processing */
|
||||
int tls_parse_ctos_renegotiate(SSL *s, PACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
int tls_parse_ctos_server_name(SSL *s, PACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
int tls_parse_ctos_maxfragmentlen(SSL *s, PACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
#ifndef OPENSSL_NO_SRP
|
||||
int tls_parse_ctos_srp(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
#endif
|
||||
int tls_parse_ctos_early_data(SSL *s, PACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
#ifndef OPENSSL_NO_EC
|
||||
int tls_parse_ctos_ec_pt_formats(SSL *s, PACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
int tls_parse_ctos_supported_groups(SSL *s, PACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidxl);
|
||||
#endif
|
||||
int tls_parse_ctos_session_ticket(SSL *s, PACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
int tls_parse_ctos_sig_algs(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
#ifndef OPENSSL_NO_OCSP
|
||||
int tls_parse_ctos_status_request(SSL *s, PACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
int tls_parse_ctos_npn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
#endif
|
||||
int tls_parse_ctos_alpn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
#ifndef OPENSSL_NO_SRTP
|
||||
int tls_parse_ctos_use_srtp(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
#endif
|
||||
int tls_parse_ctos_etm(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
int tls_parse_ctos_key_share(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
int tls_parse_ctos_ems(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
int tls_parse_ctos_psk_kex_modes(SSL *s, PACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
int tls_parse_ctos_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
|
||||
EXT_RETURN tls_construct_stoc_renegotiate(SSL *s, WPACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
EXT_RETURN tls_construct_stoc_server_name(SSL *s, WPACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
EXT_RETURN tls_construct_stoc_early_data(SSL *s, WPACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
EXT_RETURN tls_construct_stoc_maxfragmentlen(SSL *s, WPACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
#ifndef OPENSSL_NO_EC
|
||||
EXT_RETURN tls_construct_stoc_ec_pt_formats(SSL *s, WPACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
#endif
|
||||
EXT_RETURN tls_construct_stoc_supported_groups(SSL *s, WPACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
EXT_RETURN tls_construct_stoc_session_ticket(SSL *s, WPACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
#ifndef OPENSSL_NO_OCSP
|
||||
EXT_RETURN tls_construct_stoc_status_request(SSL *s, WPACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
EXT_RETURN tls_construct_stoc_next_proto_neg(SSL *s, WPACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
#endif
|
||||
EXT_RETURN tls_construct_stoc_alpn(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
#ifndef OPENSSL_NO_SRTP
|
||||
EXT_RETURN tls_construct_stoc_use_srtp(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
#endif
|
||||
EXT_RETURN tls_construct_stoc_etm(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
EXT_RETURN tls_construct_stoc_ems(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
EXT_RETURN tls_construct_stoc_key_share(SSL *s, WPACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
/*
|
||||
* Not in public headers as this is not an official extension. Only used when
|
||||
* SSL_OP_CRYPTOPRO_TLSEXT_BUG is set.
|
||||
@ -283,118 +281,118 @@ EXT_RETURN tls_construct_stoc_key_share(SSL *s, WPACKET *pkt,
|
||||
#define TLSEXT_TYPE_cryptopro_bug 0xfde8
|
||||
EXT_RETURN tls_construct_stoc_cryptopro_bug(SSL *s, WPACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
EXT_RETURN tls_construct_stoc_psk(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
|
||||
/* Client Extension processing */
|
||||
EXT_RETURN tls_construct_ctos_renegotiate(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
EXT_RETURN tls_construct_ctos_server_name(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
EXT_RETURN tls_construct_ctos_maxfragmentlen(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
#ifndef OPENSSL_NO_SRP
|
||||
EXT_RETURN tls_construct_ctos_srp(SSL *s, WPACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
EXT_RETURN tls_construct_ctos_ec_pt_formats(SSL *s, WPACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
EXT_RETURN tls_construct_ctos_supported_groups(SSL *s, WPACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
#endif
|
||||
EXT_RETURN tls_construct_ctos_early_data(SSL *s, WPACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
EXT_RETURN tls_construct_ctos_session_ticket(SSL *s, WPACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
EXT_RETURN tls_construct_ctos_sig_algs(SSL *s, WPACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
#ifndef OPENSSL_NO_OCSP
|
||||
EXT_RETURN tls_construct_ctos_status_request(SSL *s, WPACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
EXT_RETURN tls_construct_ctos_npn(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
#endif
|
||||
EXT_RETURN tls_construct_ctos_alpn(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
#ifndef OPENSSL_NO_SRTP
|
||||
EXT_RETURN tls_construct_ctos_use_srtp(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
#endif
|
||||
EXT_RETURN tls_construct_ctos_etm(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
#ifndef OPENSSL_NO_CT
|
||||
EXT_RETURN tls_construct_ctos_sct(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
#endif
|
||||
EXT_RETURN tls_construct_ctos_ems(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
EXT_RETURN tls_construct_ctos_supported_versions(SSL *s, WPACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
EXT_RETURN tls_construct_ctos_key_share(SSL *s, WPACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
EXT_RETURN tls_construct_ctos_psk_kex_modes(SSL *s, WPACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
EXT_RETURN tls_construct_ctos_cookie(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
EXT_RETURN tls_construct_ctos_padding(SSL *s, WPACKET *pkt,
|
||||
unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
EXT_RETURN tls_construct_ctos_psk(SSL *s, WPACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
int tls_parse_stoc_renegotiate(SSL *s, PACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
int tls_parse_stoc_server_name(SSL *s, PACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
int tls_parse_stoc_early_data(SSL *s, PACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
int tls_parse_stoc_maxfragmentlen(SSL *s, PACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
#ifndef OPENSSL_NO_EC
|
||||
int tls_parse_stoc_ec_pt_formats(SSL *s, PACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
#endif
|
||||
int tls_parse_stoc_session_ticket(SSL *s, PACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
#ifndef OPENSSL_NO_OCSP
|
||||
int tls_parse_stoc_status_request(SSL *s, PACKET *pkt, unsigned int context,
|
||||
X509 *x, size_t chainidx, int *al);
|
||||
X509 *x, size_t chainidx);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CT
|
||||
int tls_parse_stoc_sct(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
int tls_parse_stoc_npn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
#endif
|
||||
int tls_parse_stoc_alpn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
#ifndef OPENSSL_NO_SRTP
|
||||
int tls_parse_stoc_use_srtp(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
#endif
|
||||
int tls_parse_stoc_etm(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
int tls_parse_stoc_ems(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
int tls_parse_stoc_key_share(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
int tls_parse_stoc_cookie(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
int tls_parse_stoc_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx, int *al);
|
||||
size_t chainidx);
|
||||
|
||||
int tls_handle_alpn(SSL *s, int *al);
|
||||
int tls_handle_alpn(SSL *s);
|
||||
|
File diff suppressed because it is too large
Load Diff
87
ssl/t1_enc.c
87
ssl/t1_enc.c
@ -113,15 +113,18 @@ int tls1_change_cipher_state(SSL *s, int which)
|
||||
else
|
||||
s->mac_flags &= ~SSL_MAC_FLAG_READ_MAC_STREAM;
|
||||
|
||||
if (s->enc_read_ctx != NULL)
|
||||
if (s->enc_read_ctx != NULL) {
|
||||
reuse_dd = 1;
|
||||
else if ((s->enc_read_ctx = EVP_CIPHER_CTX_new()) == NULL)
|
||||
} else if ((s->enc_read_ctx = EVP_CIPHER_CTX_new()) == NULL) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_CHANGE_CIPHER_STATE,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
else
|
||||
} else {
|
||||
/*
|
||||
* make sure it's initialised in case we exit later with an error
|
||||
*/
|
||||
EVP_CIPHER_CTX_reset(s->enc_read_ctx);
|
||||
}
|
||||
dd = s->enc_read_ctx;
|
||||
mac_ctx = ssl_replace_hash(&s->read_hash, NULL);
|
||||
if (mac_ctx == NULL)
|
||||
@ -132,9 +135,10 @@ int tls1_change_cipher_state(SSL *s, int which)
|
||||
if (comp != NULL) {
|
||||
s->expand = COMP_CTX_new(comp->method);
|
||||
if (s->expand == NULL) {
|
||||
SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE,
|
||||
SSL_R_COMPRESSION_LIBRARY_ERROR);
|
||||
goto err2;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_TLS1_CHANGE_CIPHER_STATE,
|
||||
SSL_R_COMPRESSION_LIBRARY_ERROR);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -155,20 +159,31 @@ int tls1_change_cipher_state(SSL *s, int which)
|
||||
s->mac_flags |= SSL_MAC_FLAG_WRITE_MAC_STREAM;
|
||||
else
|
||||
s->mac_flags &= ~SSL_MAC_FLAG_WRITE_MAC_STREAM;
|
||||
if (s->enc_write_ctx != NULL && !SSL_IS_DTLS(s))
|
||||
if (s->enc_write_ctx != NULL && !SSL_IS_DTLS(s)) {
|
||||
reuse_dd = 1;
|
||||
else if ((s->enc_write_ctx = EVP_CIPHER_CTX_new()) == NULL)
|
||||
} else if ((s->enc_write_ctx = EVP_CIPHER_CTX_new()) == NULL) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_CHANGE_CIPHER_STATE,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
dd = s->enc_write_ctx;
|
||||
if (SSL_IS_DTLS(s)) {
|
||||
mac_ctx = EVP_MD_CTX_new();
|
||||
if (mac_ctx == NULL)
|
||||
if (mac_ctx == NULL) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_TLS1_CHANGE_CIPHER_STATE,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
s->write_hash = mac_ctx;
|
||||
} else {
|
||||
mac_ctx = ssl_replace_hash(&s->write_hash, NULL);
|
||||
if (mac_ctx == NULL)
|
||||
if (mac_ctx == NULL) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_TLS1_CHANGE_CIPHER_STATE,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
#ifndef OPENSSL_NO_COMP
|
||||
COMP_CTX_free(s->compress);
|
||||
@ -176,9 +191,10 @@ int tls1_change_cipher_state(SSL *s, int which)
|
||||
if (comp != NULL) {
|
||||
s->compress = COMP_CTX_new(comp->method);
|
||||
if (s->compress == NULL) {
|
||||
SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE,
|
||||
SSL_R_COMPRESSION_LIBRARY_ERROR);
|
||||
goto err2;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_TLS1_CHANGE_CIPHER_STATE,
|
||||
SSL_R_COMPRESSION_LIBRARY_ERROR);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -227,8 +243,9 @@ int tls1_change_cipher_state(SSL *s, int which)
|
||||
}
|
||||
|
||||
if (n > s->s3->tmp.key_block_length) {
|
||||
SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
|
||||
goto err2;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_CHANGE_CIPHER_STATE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
memcpy(mac_secret, ms, i);
|
||||
@ -240,8 +257,9 @@ int tls1_change_cipher_state(SSL *s, int which)
|
||||
if (mac_key == NULL
|
||||
|| EVP_DigestSignInit(mac_ctx, NULL, m, NULL, mac_key) <= 0) {
|
||||
EVP_PKEY_free(mac_key);
|
||||
SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
|
||||
goto err2;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_CHANGE_CIPHER_STATE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
EVP_PKEY_free(mac_key);
|
||||
}
|
||||
@ -258,8 +276,9 @@ int tls1_change_cipher_state(SSL *s, int which)
|
||||
if (!EVP_CipherInit_ex(dd, c, NULL, key, NULL, (which & SSL3_CC_WRITE))
|
||||
|| !EVP_CIPHER_CTX_ctrl(dd, EVP_CTRL_GCM_SET_IV_FIXED, (int)k,
|
||||
iv)) {
|
||||
SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
|
||||
goto err2;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_CHANGE_CIPHER_STATE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
} else if (EVP_CIPHER_mode(c) == EVP_CIPH_CCM_MODE) {
|
||||
int taglen;
|
||||
@ -273,21 +292,24 @@ int tls1_change_cipher_state(SSL *s, int which)
|
||||
|| !EVP_CIPHER_CTX_ctrl(dd, EVP_CTRL_AEAD_SET_TAG, taglen, NULL)
|
||||
|| !EVP_CIPHER_CTX_ctrl(dd, EVP_CTRL_CCM_SET_IV_FIXED, (int)k, iv)
|
||||
|| !EVP_CipherInit_ex(dd, NULL, NULL, key, NULL, -1)) {
|
||||
SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
|
||||
goto err2;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_CHANGE_CIPHER_STATE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
if (!EVP_CipherInit_ex(dd, c, NULL, key, iv, (which & SSL3_CC_WRITE))) {
|
||||
SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
|
||||
goto err2;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_CHANGE_CIPHER_STATE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
/* Needed for "composite" AEADs, such as RC4-HMAC-MD5 */
|
||||
if ((EVP_CIPHER_flags(c) & EVP_CIPH_FLAG_AEAD_CIPHER) && *mac_secret_size
|
||||
&& !EVP_CIPHER_CTX_ctrl(dd, EVP_CTRL_AEAD_SET_MAC_KEY,
|
||||
(int)*mac_secret_size, mac_secret)) {
|
||||
SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
|
||||
goto err2;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_CHANGE_CIPHER_STATE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
#ifdef SSL_DEBUG
|
||||
@ -312,8 +334,6 @@ int tls1_change_cipher_state(SSL *s, int which)
|
||||
OPENSSL_cleanse(iv2, sizeof(iv2));
|
||||
return 1;
|
||||
err:
|
||||
SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE, ERR_R_MALLOC_FAILURE);
|
||||
err2:
|
||||
OPENSSL_cleanse(tmp1, sizeof(tmp1));
|
||||
OPENSSL_cleanse(tmp2, sizeof(tmp1));
|
||||
OPENSSL_cleanse(iv1, sizeof(iv1));
|
||||
@ -336,7 +356,8 @@ int tls1_setup_key_block(SSL *s)
|
||||
|
||||
if (!ssl_cipher_get_evp(s->session, &c, &hash, &mac_type, &mac_secret_size,
|
||||
&comp, s->ext.use_etm)) {
|
||||
SSLerr(SSL_F_TLS1_SETUP_KEY_BLOCK, SSL_R_CIPHER_OR_HASH_UNAVAILABLE);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_SETUP_KEY_BLOCK,
|
||||
SSL_R_CIPHER_OR_HASH_UNAVAILABLE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -350,7 +371,8 @@ int tls1_setup_key_block(SSL *s)
|
||||
ssl3_cleanup_key_block(s);
|
||||
|
||||
if ((p = OPENSSL_malloc(num)) == NULL) {
|
||||
SSLerr(SSL_F_TLS1_SETUP_KEY_BLOCK, ERR_R_MALLOC_FAILURE);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_SETUP_KEY_BLOCK,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -446,10 +468,11 @@ int tls1_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p,
|
||||
* affect client auth because we're freezing the buffer at the same
|
||||
* point (after client key exchange and before certificate verify)
|
||||
*/
|
||||
if (!ssl3_digest_cached_records(s, 1))
|
||||
return 0;
|
||||
if (!ssl_handshake_hash(s, hash, sizeof(hash), &hashlen))
|
||||
if (!ssl3_digest_cached_records(s, 1)
|
||||
|| !ssl_handshake_hash(s, hash, sizeof(hash), &hashlen)) {
|
||||
/* SSLfatal() already called */
|
||||
return 0;
|
||||
}
|
||||
#ifdef SSL_DEBUG
|
||||
fprintf(stderr, "Handshake hashes:\n");
|
||||
BIO_dump_fp(stderr, (char *)hash, hashlen);
|
||||
|
89
ssl/t1_lib.c
89
ssl/t1_lib.c
@ -894,7 +894,8 @@ int tls12_check_peer_sigalg(SSL *s, uint16_t sig, EVP_PKEY *pkey)
|
||||
if (SSL_IS_TLS13(s)) {
|
||||
/* Disallow DSA for TLS 1.3 */
|
||||
if (pkeyid == EVP_PKEY_DSA) {
|
||||
SSLerr(SSL_F_TLS12_CHECK_PEER_SIGALG, SSL_R_WRONG_SIGNATURE_TYPE);
|
||||
SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_TLS12_CHECK_PEER_SIGALG,
|
||||
SSL_R_WRONG_SIGNATURE_TYPE);
|
||||
return 0;
|
||||
}
|
||||
/* Only allow PSS for TLS 1.3 */
|
||||
@ -910,7 +911,8 @@ int tls12_check_peer_sigalg(SSL *s, uint16_t sig, EVP_PKEY *pkey)
|
||||
|| (SSL_IS_TLS13(s) && (lu->hash == NID_sha1 || lu->hash == NID_sha224))
|
||||
|| (pkeyid != lu->sig
|
||||
&& (lu->sig != EVP_PKEY_RSA_PSS || pkeyid != EVP_PKEY_RSA))) {
|
||||
SSLerr(SSL_F_TLS12_CHECK_PEER_SIGALG, SSL_R_WRONG_SIGNATURE_TYPE);
|
||||
SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_TLS12_CHECK_PEER_SIGALG,
|
||||
SSL_R_WRONG_SIGNATURE_TYPE);
|
||||
return 0;
|
||||
}
|
||||
#ifndef OPENSSL_NO_EC
|
||||
@ -918,8 +920,9 @@ int tls12_check_peer_sigalg(SSL *s, uint16_t sig, EVP_PKEY *pkey)
|
||||
|
||||
/* Check point compression is permitted */
|
||||
if (!tls1_check_pkey_comp(s, pkey)) {
|
||||
SSLerr(SSL_F_TLS12_CHECK_PEER_SIGALG,
|
||||
SSL_R_ILLEGAL_POINT_COMPRESSION);
|
||||
SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER,
|
||||
SSL_F_TLS12_CHECK_PEER_SIGALG,
|
||||
SSL_R_ILLEGAL_POINT_COMPRESSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -929,27 +932,32 @@ int tls12_check_peer_sigalg(SSL *s, uint16_t sig, EVP_PKEY *pkey)
|
||||
int curve = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec));
|
||||
|
||||
if (lu->curve != NID_undef && curve != lu->curve) {
|
||||
SSLerr(SSL_F_TLS12_CHECK_PEER_SIGALG, SSL_R_WRONG_CURVE);
|
||||
SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER,
|
||||
SSL_F_TLS12_CHECK_PEER_SIGALG, SSL_R_WRONG_CURVE);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (!SSL_IS_TLS13(s)) {
|
||||
/* Check curve matches extensions */
|
||||
if (!tls1_check_group_id(s, tls1_get_group_id(pkey))) {
|
||||
SSLerr(SSL_F_TLS12_CHECK_PEER_SIGALG, SSL_R_WRONG_CURVE);
|
||||
SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER,
|
||||
SSL_F_TLS12_CHECK_PEER_SIGALG, SSL_R_WRONG_CURVE);
|
||||
return 0;
|
||||
}
|
||||
if (tls1_suiteb(s)) {
|
||||
/* Check sigalg matches a permissible Suite B value */
|
||||
if (sig != TLSEXT_SIGALG_ecdsa_secp256r1_sha256
|
||||
&& sig != TLSEXT_SIGALG_ecdsa_secp384r1_sha384) {
|
||||
SSLerr(SSL_F_TLS12_CHECK_PEER_SIGALG,
|
||||
SSL_R_WRONG_SIGNATURE_TYPE);
|
||||
SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE,
|
||||
SSL_F_TLS12_CHECK_PEER_SIGALG,
|
||||
SSL_R_WRONG_SIGNATURE_TYPE);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (tls1_suiteb(s)) {
|
||||
SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_TLS12_CHECK_PEER_SIGALG,
|
||||
SSL_R_WRONG_SIGNATURE_TYPE);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@ -963,12 +971,14 @@ int tls12_check_peer_sigalg(SSL *s, uint16_t sig, EVP_PKEY *pkey)
|
||||
/* Allow fallback to SHA1 if not strict mode */
|
||||
if (i == sent_sigslen && (lu->hash != NID_sha1
|
||||
|| s->cert->cert_flags & SSL_CERT_FLAGS_CHECK_TLS_STRICT)) {
|
||||
SSLerr(SSL_F_TLS12_CHECK_PEER_SIGALG, SSL_R_WRONG_SIGNATURE_TYPE);
|
||||
SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_TLS12_CHECK_PEER_SIGALG,
|
||||
SSL_R_WRONG_SIGNATURE_TYPE);
|
||||
return 0;
|
||||
}
|
||||
if (!tls1_lookup_md(lu, &md)) {
|
||||
SSLerr(SSL_F_TLS12_CHECK_PEER_SIGALG, SSL_R_UNKNOWN_DIGEST);
|
||||
return 0;
|
||||
SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_TLS12_CHECK_PEER_SIGALG,
|
||||
SSL_R_UNKNOWN_DIGEST);
|
||||
return 0;
|
||||
}
|
||||
if (md != NULL) {
|
||||
/*
|
||||
@ -980,7 +990,8 @@ int tls12_check_peer_sigalg(SSL *s, uint16_t sig, EVP_PKEY *pkey)
|
||||
if (!ssl_security(s, SSL_SECOP_SIGALG_CHECK,
|
||||
EVP_MD_size(md) * 4, EVP_MD_type(md),
|
||||
(void *)sigalgstr)) {
|
||||
SSLerr(SSL_F_TLS12_CHECK_PEER_SIGALG, SSL_R_WRONG_SIGNATURE_TYPE);
|
||||
SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_TLS12_CHECK_PEER_SIGALG,
|
||||
SSL_R_WRONG_SIGNATURE_TYPE);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1074,7 +1085,6 @@ int tls_use_ticket(SSL *s)
|
||||
|
||||
int tls1_set_server_sigalgs(SSL *s)
|
||||
{
|
||||
int al;
|
||||
size_t i;
|
||||
|
||||
/* Clear any shared signature algorithms */
|
||||
@ -1110,17 +1120,16 @@ int tls1_set_server_sigalgs(SSL *s)
|
||||
}
|
||||
|
||||
if (!tls1_process_sigalgs(s)) {
|
||||
SSLerr(SSL_F_TLS1_SET_SERVER_SIGALGS, ERR_R_MALLOC_FAILURE);
|
||||
al = SSL_AD_INTERNAL_ERROR;
|
||||
goto err;
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_TLS1_SET_SERVER_SIGALGS, ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
if (s->cert->shared_sigalgs != NULL)
|
||||
return 1;
|
||||
|
||||
/* Fatal error if no shared signature algorithms */
|
||||
SSLerr(SSL_F_TLS1_SET_SERVER_SIGALGS, SSL_R_NO_SHARED_SIGNATURE_ALGORITHMS);
|
||||
al = SSL_AD_HANDSHAKE_FAILURE;
|
||||
err:
|
||||
ssl3_send_alert(s, SSL3_AL_FATAL, al);
|
||||
SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_TLS1_SET_SERVER_SIGALGS,
|
||||
SSL_R_NO_SHARED_SIGNATURE_ALGORITHMS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2240,14 +2249,14 @@ static int tls12_get_cert_sigalg_idx(const SSL *s, const SIGALG_LOOKUP *lu)
|
||||
* Choose an appropriate signature algorithm based on available certificates
|
||||
* Sets chosen certificate and signature algorithm.
|
||||
*
|
||||
* For servers if we fail to find a required certificate it is a fatal error
|
||||
* and an appropriate error code is set and the TLS alert set in *al.
|
||||
* For servers if we fail to find a required certificate it is a fatal error,
|
||||
* an appropriate error code is set and a TLS alert is sent.
|
||||
*
|
||||
* For clients al is set to NULL. If a certificate is not suitable it is not
|
||||
* For clients fatalerrs is set to 0. If a certificate is not suitable it is not
|
||||
* a fatal error: we will either try another certificate or not present one
|
||||
* to the server. In this case no error is set.
|
||||
*/
|
||||
int tls_choose_sigalg(SSL *s, int *al)
|
||||
int tls_choose_sigalg(SSL *s, int fatalerrs)
|
||||
{
|
||||
const SIGALG_LOOKUP *lu = NULL;
|
||||
int sig_idx = -1;
|
||||
@ -2298,11 +2307,10 @@ int tls_choose_sigalg(SSL *s, int *al)
|
||||
break;
|
||||
}
|
||||
if (i == s->cert->shared_sigalgslen) {
|
||||
if (al == NULL)
|
||||
if (!fatalerrs)
|
||||
return 1;
|
||||
*al = SSL_AD_HANDSHAKE_FAILURE;
|
||||
SSLerr(SSL_F_TLS_CHOOSE_SIGALG,
|
||||
SSL_R_NO_SUITABLE_SIGNATURE_ALGORITHM);
|
||||
SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_TLS_CHOOSE_SIGALG,
|
||||
SSL_R_NO_SUITABLE_SIGNATURE_ALGORITHM);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
@ -2354,10 +2362,10 @@ int tls_choose_sigalg(SSL *s, int *al)
|
||||
break;
|
||||
}
|
||||
if (i == s->cert->shared_sigalgslen) {
|
||||
if (al == NULL)
|
||||
if (!fatalerrs)
|
||||
return 1;
|
||||
*al = SSL_AD_INTERNAL_ERROR;
|
||||
SSLerr(SSL_F_TLS_CHOOSE_SIGALG, ERR_R_INTERNAL_ERROR);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CHOOSE_SIGALG,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
@ -2368,10 +2376,10 @@ int tls_choose_sigalg(SSL *s, int *al)
|
||||
size_t sent_sigslen, i;
|
||||
|
||||
if ((lu = tls1_get_legacy_sigalg(s, -1)) == NULL) {
|
||||
if (al == NULL)
|
||||
if (!fatalerrs)
|
||||
return 1;
|
||||
*al = SSL_AD_INTERNAL_ERROR;
|
||||
SSLerr(SSL_F_TLS_CHOOSE_SIGALG, ERR_R_INTERNAL_ERROR);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CHOOSE_SIGALG,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2382,19 +2390,20 @@ int tls_choose_sigalg(SSL *s, int *al)
|
||||
break;
|
||||
}
|
||||
if (i == sent_sigslen) {
|
||||
if (al == NULL)
|
||||
if (!fatalerrs)
|
||||
return 1;
|
||||
SSLerr(SSL_F_TLS_CHOOSE_SIGALG, SSL_R_WRONG_SIGNATURE_TYPE);
|
||||
*al = SSL_AD_ILLEGAL_PARAMETER;
|
||||
SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER,
|
||||
SSL_F_TLS_CHOOSE_SIGALG,
|
||||
SSL_R_WRONG_SIGNATURE_TYPE);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((lu = tls1_get_legacy_sigalg(s, -1)) == NULL) {
|
||||
if (al == NULL)
|
||||
if (!fatalerrs)
|
||||
return 1;
|
||||
*al = SSL_AD_INTERNAL_ERROR;
|
||||
SSLerr(SSL_F_TLS_CHOOSE_SIGALG, ERR_R_INTERNAL_ERROR);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CHOOSE_SIGALG,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,8 @@ int tls13_hkdf_expand(SSL *s, const EVP_MD *md, const unsigned char *secret,
|
||||
|| !WPACKET_finish(&pkt)) {
|
||||
EVP_PKEY_CTX_free(pctx);
|
||||
WPACKET_cleanup(&pkt);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS13_HKDF_EXPAND,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -72,6 +74,10 @@ int tls13_hkdf_expand(SSL *s, const EVP_MD *md, const unsigned char *secret,
|
||||
|
||||
EVP_PKEY_CTX_free(pctx);
|
||||
|
||||
if (ret != 0)
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS13_HKDF_EXPAND,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
|
||||
return ret == 0;
|
||||
}
|
||||
|
||||
@ -128,8 +134,11 @@ int tls13_generate_secret(SSL *s, const EVP_MD *md,
|
||||
static const char derived_secret_label[] = "derived";
|
||||
unsigned char preextractsec[EVP_MAX_MD_SIZE];
|
||||
|
||||
if (pctx == NULL)
|
||||
if (pctx == NULL) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS13_GENERATE_SECRET,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
mdlen = EVP_MD_size(md);
|
||||
|
||||
@ -148,6 +157,8 @@ int tls13_generate_secret(SSL *s, const EVP_MD *md,
|
||||
if (mctx == NULL
|
||||
|| EVP_DigestInit_ex(mctx, md, NULL) <= 0
|
||||
|| EVP_DigestFinal_ex(mctx, hash, NULL) <= 0) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS13_GENERATE_SECRET,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
EVP_MD_CTX_free(mctx);
|
||||
EVP_PKEY_CTX_free(pctx);
|
||||
return 0;
|
||||
@ -159,6 +170,7 @@ int tls13_generate_secret(SSL *s, const EVP_MD *md,
|
||||
(unsigned char *)derived_secret_label,
|
||||
sizeof(derived_secret_label) - 1, hash, mdlen,
|
||||
preextractsec, mdlen)) {
|
||||
/* SSLfatal() already called */
|
||||
EVP_PKEY_CTX_free(pctx);
|
||||
return 0;
|
||||
}
|
||||
@ -177,6 +189,10 @@ int tls13_generate_secret(SSL *s, const EVP_MD *md,
|
||||
|| EVP_PKEY_derive(pctx, outsecret, &mdlen)
|
||||
<= 0;
|
||||
|
||||
if (ret != 0)
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS13_GENERATE_SECRET,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
|
||||
EVP_PKEY_CTX_free(pctx);
|
||||
if (prevsecret == preextractsec)
|
||||
OPENSSL_cleanse(preextractsec, mdlen);
|
||||
@ -191,6 +207,7 @@ int tls13_generate_secret(SSL *s, const EVP_MD *md,
|
||||
int tls13_generate_handshake_secret(SSL *s, const unsigned char *insecret,
|
||||
size_t insecretlen)
|
||||
{
|
||||
/* Calls SSLfatal() if required */
|
||||
return tls13_generate_secret(s, ssl_handshake_md(s), s->early_secret,
|
||||
insecret, insecretlen,
|
||||
(unsigned char *)&s->handshake_secret);
|
||||
@ -208,6 +225,7 @@ int tls13_generate_master_secret(SSL *s, unsigned char *out,
|
||||
const EVP_MD *md = ssl_handshake_md(s);
|
||||
|
||||
*secret_size = EVP_MD_size(md);
|
||||
/* Calls SSLfatal() if required */
|
||||
return tls13_generate_secret(s, md, prev, NULL, 0, out);
|
||||
}
|
||||
|
||||
@ -261,7 +279,8 @@ int tls13_setup_key_block(SSL *s)
|
||||
s->session->cipher = s->s3->tmp.new_cipher;
|
||||
if (!ssl_cipher_get_evp
|
||||
(s->session, &c, &hash, &mac_type, NULL, NULL, 0)) {
|
||||
SSLerr(SSL_F_TLS13_SETUP_KEY_BLOCK, SSL_R_CIPHER_OR_HASH_UNAVAILABLE);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS13_SETUP_KEY_BLOCK,
|
||||
SSL_R_CIPHER_OR_HASH_UNAVAILABLE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -285,7 +304,7 @@ static int derive_secret_key_and_iv(SSL *s, int sending, const EVP_MD *md,
|
||||
|
||||
if (!tls13_hkdf_expand(s, md, insecret, label, labellen, hash, hashlen,
|
||||
secret, hashlen)) {
|
||||
SSLerr(SSL_F_DERIVE_SECRET_KEY_AND_IV, ERR_R_INTERNAL_ERROR);
|
||||
/* SSLfatal() already called */
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -312,7 +331,7 @@ static int derive_secret_key_and_iv(SSL *s, int sending, const EVP_MD *md,
|
||||
|
||||
if (!tls13_derive_key(s, md, secret, key, keylen)
|
||||
|| !tls13_derive_iv(s, md, secret, iv, ivlen)) {
|
||||
SSLerr(SSL_F_DERIVE_SECRET_KEY_AND_IV, ERR_R_INTERNAL_ERROR);
|
||||
/* SSLfatal() already called */
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -321,7 +340,8 @@ static int derive_secret_key_and_iv(SSL *s, int sending, const EVP_MD *md,
|
||||
|| (taglen != 0 && !EVP_CIPHER_CTX_ctrl(ciph_ctx, EVP_CTRL_AEAD_SET_TAG,
|
||||
taglen, NULL))
|
||||
|| EVP_CipherInit_ex(ciph_ctx, NULL, NULL, key, NULL, -1) <= 0) {
|
||||
SSLerr(SSL_F_DERIVE_SECRET_KEY_AND_IV, ERR_R_EVP_LIB);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_DERIVE_SECRET_KEY_AND_IV,
|
||||
ERR_R_EVP_LIB);
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -361,7 +381,8 @@ int tls13_change_cipher_state(SSL *s, int which)
|
||||
} else {
|
||||
s->enc_read_ctx = EVP_CIPHER_CTX_new();
|
||||
if (s->enc_read_ctx == NULL) {
|
||||
SSLerr(SSL_F_TLS13_CHANGE_CIPHER_STATE, ERR_R_MALLOC_FAILURE);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_TLS13_CHANGE_CIPHER_STATE, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
@ -375,7 +396,8 @@ int tls13_change_cipher_state(SSL *s, int which)
|
||||
} else {
|
||||
s->enc_write_ctx = EVP_CIPHER_CTX_new();
|
||||
if (s->enc_write_ctx == NULL) {
|
||||
SSLerr(SSL_F_TLS13_CHANGE_CIPHER_STATE, ERR_R_MALLOC_FAILURE);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_TLS13_CHANGE_CIPHER_STATE, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
@ -401,8 +423,9 @@ int tls13_change_cipher_state(SSL *s, int which)
|
||||
|
||||
handlen = BIO_get_mem_data(s->s3->handshake_buffer, &hdata);
|
||||
if (handlen <= 0) {
|
||||
SSLerr(SSL_F_TLS13_CHANGE_CIPHER_STATE,
|
||||
SSL_R_BAD_HANDSHAKE_LENGTH);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_TLS13_CHANGE_CIPHER_STATE,
|
||||
SSL_R_BAD_HANDSHAKE_LENGTH);
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -417,14 +440,16 @@ int tls13_change_cipher_state(SSL *s, int which)
|
||||
if (!ossl_assert(s->psksession != NULL
|
||||
&& s->max_early_data ==
|
||||
s->psksession->ext.max_early_data)) {
|
||||
SSLerr(SSL_F_TLS13_CHANGE_CIPHER_STATE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_TLS13_CHANGE_CIPHER_STATE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
sslcipher = SSL_SESSION_get0_cipher(s->psksession);
|
||||
}
|
||||
if (sslcipher == NULL) {
|
||||
SSLerr(SSL_F_TLS13_CHANGE_CIPHER_STATE, SSL_R_BAD_PSK);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_TLS13_CHANGE_CIPHER_STATE, SSL_R_BAD_PSK);
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -435,7 +460,8 @@ int tls13_change_cipher_state(SSL *s, int which)
|
||||
*/
|
||||
mdctx = EVP_MD_CTX_new();
|
||||
if (mdctx == NULL) {
|
||||
SSLerr(SSL_F_TLS13_CHANGE_CIPHER_STATE, ERR_R_MALLOC_FAILURE);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_TLS13_CHANGE_CIPHER_STATE, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
cipher = EVP_get_cipherbynid(SSL_CIPHER_get_cipher_nid(sslcipher));
|
||||
@ -443,7 +469,8 @@ int tls13_change_cipher_state(SSL *s, int which)
|
||||
if (md == NULL || !EVP_DigestInit_ex(mdctx, md, NULL)
|
||||
|| !EVP_DigestUpdate(mdctx, hdata, handlen)
|
||||
|| !EVP_DigestFinal_ex(mdctx, hashval, &hashlenui)) {
|
||||
SSLerr(SSL_F_TLS13_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_TLS13_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
|
||||
EVP_MD_CTX_free(mdctx);
|
||||
goto err;
|
||||
}
|
||||
@ -501,7 +528,7 @@ int tls13_change_cipher_state(SSL *s, int which)
|
||||
cipher = s->s3->tmp.new_sym_enc;
|
||||
if (!ssl3_digest_cached_records(s, 1)
|
||||
|| !ssl_handshake_hash(s, hashval, sizeof(hashval), &hashlen)) {
|
||||
SSLerr(SSL_F_TLS13_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
|
||||
/* SSLfatal() already called */;
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
@ -526,7 +553,7 @@ int tls13_change_cipher_state(SSL *s, int which)
|
||||
sizeof(resumption_master_secret) - 1,
|
||||
hashval, hashlen, s->session->master_key,
|
||||
hashlen)) {
|
||||
SSLerr(SSL_F_TLS13_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
|
||||
/* SSLfatal() already called */
|
||||
goto err;
|
||||
}
|
||||
s->session->master_key_length = hashlen;
|
||||
@ -537,7 +564,7 @@ int tls13_change_cipher_state(SSL *s, int which)
|
||||
sizeof(exporter_master_secret) - 1,
|
||||
hash, hashlen, s->exporter_master_secret,
|
||||
hashlen)) {
|
||||
SSLerr(SSL_F_TLS13_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
|
||||
/* SSLfatal() already called */
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
@ -545,6 +572,7 @@ int tls13_change_cipher_state(SSL *s, int which)
|
||||
if (!derive_secret_key_and_iv(s, which & SSL3_CC_WRITE, md, cipher,
|
||||
insecret, hash, label, labellen, secret, iv,
|
||||
ciph_ctx)) {
|
||||
/* SSLfatal() already called */
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -554,14 +582,14 @@ int tls13_change_cipher_state(SSL *s, int which)
|
||||
memcpy(s->client_app_traffic_secret, secret, hashlen);
|
||||
|
||||
if (!ssl_log_secret(s, log_label, secret, hashlen)) {
|
||||
SSLerr(SSL_F_TLS13_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
|
||||
/* SSLfatal() already called */
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (finsecret != NULL
|
||||
&& !tls13_derive_finishedkey(s, ssl_handshake_md(s), secret,
|
||||
finsecret, finsecretlen)) {
|
||||
SSLerr(SSL_F_TLS13_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR);
|
||||
/* SSLfatal() already called */
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -600,8 +628,10 @@ int tls13_update_key(SSL *s, int sending)
|
||||
s->s3->tmp.new_sym_enc, insecret, NULL,
|
||||
application_traffic,
|
||||
sizeof(application_traffic) - 1, secret, iv,
|
||||
ciph_ctx))
|
||||
ciph_ctx)) {
|
||||
/* SSLfatal() already called */
|
||||
goto err;
|
||||
}
|
||||
|
||||
memcpy(insecret, secret, hashlen);
|
||||
|
||||
|
@ -257,9 +257,13 @@ int srp_generate_server_master_secret(SSL *s)
|
||||
goto err;
|
||||
|
||||
tmp_len = BN_num_bytes(K);
|
||||
if ((tmp = OPENSSL_malloc(tmp_len)) == NULL)
|
||||
if ((tmp = OPENSSL_malloc(tmp_len)) == NULL) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||
SSL_F_SRP_GENERATE_SERVER_MASTER_SECRET, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
BN_bn2bin(K, tmp);
|
||||
/* Calls SSLfatal() as required */
|
||||
ret = ssl_generate_master_secret(s, tmp, tmp_len, 1);
|
||||
err:
|
||||
BN_clear_free(K);
|
||||
|
@ -207,6 +207,11 @@ const EVP_MD *ssl_md(int idx)
|
||||
return EVP_sha256();
|
||||
}
|
||||
|
||||
void ossl_statem_fatal(SSL *s, int al, int func, int reason, const char *file,
|
||||
int line)
|
||||
{
|
||||
}
|
||||
|
||||
/* End of mocked out code */
|
||||
|
||||
static int test_secret(SSL *s, unsigned char *prk,
|
||||
|
Loading…
Reference in New Issue
Block a user