diff options
author | jsing <> | 2017-01-22 09:02:07 +0000 |
---|---|---|
committer | jsing <> | 2017-01-22 09:02:07 +0000 |
commit | fcfe199cc99431d4e250ada852b3989b210b67ca (patch) | |
tree | 74edac7239262d369a6f63b69bea3291a4184000 /src/lib/libssl/s3_srvr.c | |
parent | 0356ccc6b32439d6cef453be9bd3c4786baa75d3 (diff) | |
download | openbsd-fcfe199cc99431d4e250ada852b3989b210b67ca.tar.gz openbsd-fcfe199cc99431d4e250ada852b3989b210b67ca.tar.bz2 openbsd-fcfe199cc99431d4e250ada852b3989b210b67ca.zip |
Move most of the SSL3_STATE fields to internal - the ones that remain are
known to be used by ports.
ok beck@
Diffstat (limited to 'src/lib/libssl/s3_srvr.c')
-rw-r--r-- | src/lib/libssl/s3_srvr.c | 152 |
1 files changed, 76 insertions, 76 deletions
diff --git a/src/lib/libssl/s3_srvr.c b/src/lib/libssl/s3_srvr.c index 7912206785..099537f7ea 100644 --- a/src/lib/libssl/s3_srvr.c +++ b/src/lib/libssl/s3_srvr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s3_srvr.c,v 1.140 2017/01/22 07:16:39 beck Exp $ */ | 1 | /* $OpenBSD: s3_srvr.c,v 1.141 2017/01/22 09:02:07 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -247,7 +247,7 @@ ssl3_accept(SSL *s) | |||
247 | 247 | ||
248 | s->state = SSL3_ST_SR_CLNT_HELLO_A; | 248 | s->state = SSL3_ST_SR_CLNT_HELLO_A; |
249 | s->ctx->stats.sess_accept++; | 249 | s->ctx->stats.sess_accept++; |
250 | } else if (!s->s3->send_connection_binding) { | 250 | } else if (!S3I(s)->send_connection_binding) { |
251 | /* | 251 | /* |
252 | * Server attempting to renegotiate with | 252 | * Server attempting to renegotiate with |
253 | * client that doesn't support secure | 253 | * client that doesn't support secure |
@@ -276,7 +276,7 @@ ssl3_accept(SSL *s) | |||
276 | ret = ssl3_send_hello_request(s); | 276 | ret = ssl3_send_hello_request(s); |
277 | if (ret <= 0) | 277 | if (ret <= 0) |
278 | goto end; | 278 | goto end; |
279 | s->s3->tmp.next_state = SSL3_ST_SW_HELLO_REQ_C; | 279 | S3I(s)->tmp.next_state = SSL3_ST_SW_HELLO_REQ_C; |
280 | s->state = SSL3_ST_SW_FLUSH; | 280 | s->state = SSL3_ST_SW_FLUSH; |
281 | s->init_num = 0; | 281 | s->init_num = 0; |
282 | 282 | ||
@@ -325,7 +325,7 @@ ssl3_accept(SSL *s) | |||
325 | case SSL3_ST_SW_CERT_A: | 325 | case SSL3_ST_SW_CERT_A: |
326 | case SSL3_ST_SW_CERT_B: | 326 | case SSL3_ST_SW_CERT_B: |
327 | /* Check if it is anon DH or anon ECDH. */ | 327 | /* Check if it is anon DH or anon ECDH. */ |
328 | if (!(s->s3->tmp.new_cipher->algorithm_auth & | 328 | if (!(S3I(s)->tmp.new_cipher->algorithm_auth & |
329 | SSL_aNULL)) { | 329 | SSL_aNULL)) { |
330 | ret = ssl3_send_server_certificate(s); | 330 | ret = ssl3_send_server_certificate(s); |
331 | if (ret <= 0) | 331 | if (ret <= 0) |
@@ -343,7 +343,7 @@ ssl3_accept(SSL *s) | |||
343 | 343 | ||
344 | case SSL3_ST_SW_KEY_EXCH_A: | 344 | case SSL3_ST_SW_KEY_EXCH_A: |
345 | case SSL3_ST_SW_KEY_EXCH_B: | 345 | case SSL3_ST_SW_KEY_EXCH_B: |
346 | alg_k = s->s3->tmp.new_cipher->algorithm_mkey; | 346 | alg_k = S3I(s)->tmp.new_cipher->algorithm_mkey; |
347 | 347 | ||
348 | /* | 348 | /* |
349 | * Only send if using a DH key exchange. | 349 | * Only send if using a DH key exchange. |
@@ -386,21 +386,21 @@ ssl3_accept(SSL *s) | |||
386 | if (!(s->verify_mode & SSL_VERIFY_PEER) || | 386 | if (!(s->verify_mode & SSL_VERIFY_PEER) || |
387 | ((s->session->peer != NULL) && | 387 | ((s->session->peer != NULL) && |
388 | (s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) || | 388 | (s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) || |
389 | ((s->s3->tmp.new_cipher->algorithm_auth & | 389 | ((S3I(s)->tmp.new_cipher->algorithm_auth & |
390 | SSL_aNULL) && !(s->verify_mode & | 390 | SSL_aNULL) && !(s->verify_mode & |
391 | SSL_VERIFY_FAIL_IF_NO_PEER_CERT))) { | 391 | SSL_VERIFY_FAIL_IF_NO_PEER_CERT))) { |
392 | /* No cert request */ | 392 | /* No cert request */ |
393 | skip = 1; | 393 | skip = 1; |
394 | s->s3->tmp.cert_request = 0; | 394 | S3I(s)->tmp.cert_request = 0; |
395 | s->state = SSL3_ST_SW_SRVR_DONE_A; | 395 | s->state = SSL3_ST_SW_SRVR_DONE_A; |
396 | if (s->s3->handshake_buffer) { | 396 | if (S3I(s)->handshake_buffer) { |
397 | if (!tls1_digest_cached_records(s)) { | 397 | if (!tls1_digest_cached_records(s)) { |
398 | ret = -1; | 398 | ret = -1; |
399 | goto end; | 399 | goto end; |
400 | } | 400 | } |
401 | } | 401 | } |
402 | } else { | 402 | } else { |
403 | s->s3->tmp.cert_request = 1; | 403 | S3I(s)->tmp.cert_request = 1; |
404 | ret = ssl3_send_certificate_request(s); | 404 | ret = ssl3_send_certificate_request(s); |
405 | if (ret <= 0) | 405 | if (ret <= 0) |
406 | goto end; | 406 | goto end; |
@@ -414,7 +414,7 @@ ssl3_accept(SSL *s) | |||
414 | ret = ssl3_send_server_done(s); | 414 | ret = ssl3_send_server_done(s); |
415 | if (ret <= 0) | 415 | if (ret <= 0) |
416 | goto end; | 416 | goto end; |
417 | s->s3->tmp.next_state = SSL3_ST_SR_CERT_A; | 417 | S3I(s)->tmp.next_state = SSL3_ST_SR_CERT_A; |
418 | s->state = SSL3_ST_SW_FLUSH; | 418 | s->state = SSL3_ST_SW_FLUSH; |
419 | s->init_num = 0; | 419 | s->init_num = 0; |
420 | break; | 420 | break; |
@@ -439,12 +439,12 @@ ssl3_accept(SSL *s) | |||
439 | } | 439 | } |
440 | s->rwstate = SSL_NOTHING; | 440 | s->rwstate = SSL_NOTHING; |
441 | 441 | ||
442 | s->state = s->s3->tmp.next_state; | 442 | s->state = S3I(s)->tmp.next_state; |
443 | break; | 443 | break; |
444 | 444 | ||
445 | case SSL3_ST_SR_CERT_A: | 445 | case SSL3_ST_SR_CERT_A: |
446 | case SSL3_ST_SR_CERT_B: | 446 | case SSL3_ST_SR_CERT_B: |
447 | if (s->s3->tmp.cert_request) { | 447 | if (S3I(s)->tmp.cert_request) { |
448 | ret = ssl3_get_client_certificate(s); | 448 | ret = ssl3_get_client_certificate(s); |
449 | if (ret <= 0) | 449 | if (ret <= 0) |
450 | goto end; | 450 | goto end; |
@@ -458,7 +458,7 @@ ssl3_accept(SSL *s) | |||
458 | ret = ssl3_get_client_key_exchange(s); | 458 | ret = ssl3_get_client_key_exchange(s); |
459 | if (ret <= 0) | 459 | if (ret <= 0) |
460 | goto end; | 460 | goto end; |
461 | alg_k = s->s3->tmp.new_cipher->algorithm_mkey; | 461 | alg_k = S3I(s)->tmp.new_cipher->algorithm_mkey; |
462 | if (ret == 2) { | 462 | if (ret == 2) { |
463 | /* | 463 | /* |
464 | * For the ECDH ciphersuites when | 464 | * For the ECDH ciphersuites when |
@@ -469,7 +469,7 @@ ssl3_accept(SSL *s) | |||
469 | * the client uses its key from the certificate | 469 | * the client uses its key from the certificate |
470 | * for key exchange. | 470 | * for key exchange. |
471 | */ | 471 | */ |
472 | if (s->s3->next_proto_neg_seen) | 472 | if (S3I(s)->next_proto_neg_seen) |
473 | s->state = SSL3_ST_SR_NEXT_PROTO_A; | 473 | s->state = SSL3_ST_SR_NEXT_PROTO_A; |
474 | else | 474 | else |
475 | s->state = SSL3_ST_SR_FINISHED_A; | 475 | s->state = SSL3_ST_SR_FINISHED_A; |
@@ -483,7 +483,7 @@ ssl3_accept(SSL *s) | |||
483 | * For sigalgs freeze the handshake buffer | 483 | * For sigalgs freeze the handshake buffer |
484 | * at this point and digest cached records. | 484 | * at this point and digest cached records. |
485 | */ | 485 | */ |
486 | if (!s->s3->handshake_buffer) { | 486 | if (!S3I(s)->handshake_buffer) { |
487 | SSLerr(SSL_F_SSL3_ACCEPT, | 487 | SSLerr(SSL_F_SSL3_ACCEPT, |
488 | ERR_R_INTERNAL_ERROR); | 488 | ERR_R_INTERNAL_ERROR); |
489 | ret = -1; | 489 | ret = -1; |
@@ -508,7 +508,7 @@ ssl3_accept(SSL *s) | |||
508 | * CertificateVerify should be generalized. | 508 | * CertificateVerify should be generalized. |
509 | * But it is next step | 509 | * But it is next step |
510 | */ | 510 | */ |
511 | if (s->s3->handshake_buffer) { | 511 | if (S3I(s)->handshake_buffer) { |
512 | if (!tls1_digest_cached_records(s)) { | 512 | if (!tls1_digest_cached_records(s)) { |
513 | ret = -1; | 513 | ret = -1; |
514 | goto end; | 514 | goto end; |
@@ -516,15 +516,15 @@ ssl3_accept(SSL *s) | |||
516 | } | 516 | } |
517 | for (dgst_num = 0; dgst_num < SSL_MAX_DIGEST; | 517 | for (dgst_num = 0; dgst_num < SSL_MAX_DIGEST; |
518 | dgst_num++) | 518 | dgst_num++) |
519 | if (s->s3->handshake_dgst[dgst_num]) { | 519 | if (S3I(s)->handshake_dgst[dgst_num]) { |
520 | int dgst_size; | 520 | int dgst_size; |
521 | 521 | ||
522 | s->method->ssl3_enc->cert_verify_mac(s, | 522 | s->method->ssl3_enc->cert_verify_mac(s, |
523 | EVP_MD_CTX_type( | 523 | EVP_MD_CTX_type( |
524 | s->s3->handshake_dgst[dgst_num]), | 524 | S3I(s)->handshake_dgst[dgst_num]), |
525 | &(s->s3->tmp.cert_verify_md[offset])); | 525 | &(S3I(s)->tmp.cert_verify_md[offset])); |
526 | dgst_size = EVP_MD_CTX_size( | 526 | dgst_size = EVP_MD_CTX_size( |
527 | s->s3->handshake_dgst[dgst_num]); | 527 | S3I(s)->handshake_dgst[dgst_num]); |
528 | if (dgst_size < 0) { | 528 | if (dgst_size < 0) { |
529 | ret = -1; | 529 | ret = -1; |
530 | goto end; | 530 | goto end; |
@@ -543,7 +543,7 @@ ssl3_accept(SSL *s) | |||
543 | if (ret <= 0) | 543 | if (ret <= 0) |
544 | goto end; | 544 | goto end; |
545 | 545 | ||
546 | if (s->s3->next_proto_neg_seen) | 546 | if (S3I(s)->next_proto_neg_seen) |
547 | s->state = SSL3_ST_SR_NEXT_PROTO_A; | 547 | s->state = SSL3_ST_SR_NEXT_PROTO_A; |
548 | else | 548 | else |
549 | s->state = SSL3_ST_SR_FINISHED_A; | 549 | s->state = SSL3_ST_SR_FINISHED_A; |
@@ -597,7 +597,7 @@ ssl3_accept(SSL *s) | |||
597 | case SSL3_ST_SW_CHANGE_A: | 597 | case SSL3_ST_SW_CHANGE_A: |
598 | case SSL3_ST_SW_CHANGE_B: | 598 | case SSL3_ST_SW_CHANGE_B: |
599 | 599 | ||
600 | s->session->cipher = s->s3->tmp.new_cipher; | 600 | s->session->cipher = S3I(s)->tmp.new_cipher; |
601 | if (!s->method->ssl3_enc->setup_key_block(s)) { | 601 | if (!s->method->ssl3_enc->setup_key_block(s)) { |
602 | ret = -1; | 602 | ret = -1; |
603 | goto end; | 603 | goto end; |
@@ -629,15 +629,15 @@ ssl3_accept(SSL *s) | |||
629 | goto end; | 629 | goto end; |
630 | s->state = SSL3_ST_SW_FLUSH; | 630 | s->state = SSL3_ST_SW_FLUSH; |
631 | if (s->hit) { | 631 | if (s->hit) { |
632 | if (s->s3->next_proto_neg_seen) { | 632 | if (S3I(s)->next_proto_neg_seen) { |
633 | s->s3->flags |= SSL3_FLAGS_CCS_OK; | 633 | s->s3->flags |= SSL3_FLAGS_CCS_OK; |
634 | s->s3->tmp.next_state = | 634 | S3I(s)->tmp.next_state = |
635 | SSL3_ST_SR_NEXT_PROTO_A; | 635 | SSL3_ST_SR_NEXT_PROTO_A; |
636 | } else | 636 | } else |
637 | s->s3->tmp.next_state = | 637 | S3I(s)->tmp.next_state = |
638 | SSL3_ST_SR_FINISHED_A; | 638 | SSL3_ST_SR_FINISHED_A; |
639 | } else | 639 | } else |
640 | s->s3->tmp.next_state = SSL_ST_OK; | 640 | S3I(s)->tmp.next_state = SSL_ST_OK; |
641 | s->init_num = 0; | 641 | s->init_num = 0; |
642 | break; | 642 | break; |
643 | 643 | ||
@@ -680,7 +680,7 @@ ssl3_accept(SSL *s) | |||
680 | /* break; */ | 680 | /* break; */ |
681 | } | 681 | } |
682 | 682 | ||
683 | if (!s->s3->tmp.reuse_message && !skip) { | 683 | if (!S3I(s)->tmp.reuse_message && !skip) { |
684 | if (s->debug) { | 684 | if (s->debug) { |
685 | if ((ret = BIO_flush(s->wbio)) <= 0) | 685 | if ((ret = BIO_flush(s->wbio)) <= 0) |
686 | goto end; | 686 | goto end; |
@@ -1039,12 +1039,12 @@ ssl3_get_client_hello(SSL *s) | |||
1039 | SSL_R_NO_SHARED_CIPHER); | 1039 | SSL_R_NO_SHARED_CIPHER); |
1040 | goto f_err; | 1040 | goto f_err; |
1041 | } | 1041 | } |
1042 | s->s3->tmp.new_cipher = c; | 1042 | S3I(s)->tmp.new_cipher = c; |
1043 | } else { | 1043 | } else { |
1044 | s->s3->tmp.new_cipher = s->session->cipher; | 1044 | S3I(s)->tmp.new_cipher = s->session->cipher; |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | alg_k = s->s3->tmp.new_cipher->algorithm_mkey; | 1047 | alg_k = S3I(s)->tmp.new_cipher->algorithm_mkey; |
1048 | if (!(SSL_USE_SIGALGS(s) || (alg_k & SSL_kGOST)) || | 1048 | if (!(SSL_USE_SIGALGS(s) || (alg_k & SSL_kGOST)) || |
1049 | !(s->verify_mode & SSL_VERIFY_PEER)) { | 1049 | !(s->verify_mode & SSL_VERIFY_PEER)) { |
1050 | if (!tls1_digest_cached_records(s)) { | 1050 | if (!tls1_digest_cached_records(s)) { |
@@ -1147,7 +1147,7 @@ ssl3_send_server_hello(SSL *s) | |||
1147 | 1147 | ||
1148 | /* Cipher suite. */ | 1148 | /* Cipher suite. */ |
1149 | if (!CBB_add_u16(&cbb, | 1149 | if (!CBB_add_u16(&cbb, |
1150 | ssl3_cipher_get_value(s->s3->tmp.new_cipher))) | 1150 | ssl3_cipher_get_value(S3I(s)->tmp.new_cipher))) |
1151 | goto err; | 1151 | goto err; |
1152 | 1152 | ||
1153 | /* Compression method. */ | 1153 | /* Compression method. */ |
@@ -1210,7 +1210,7 @@ ssl3_send_server_kex_dhe(SSL *s, CBB *cbb) | |||
1210 | 1210 | ||
1211 | if (dhp == NULL && s->cert->dh_tmp_cb != NULL) | 1211 | if (dhp == NULL && s->cert->dh_tmp_cb != NULL) |
1212 | dhp = s->cert->dh_tmp_cb(s, 0, | 1212 | dhp = s->cert->dh_tmp_cb(s, 0, |
1213 | SSL_C_PKEYLENGTH(s->s3->tmp.new_cipher)); | 1213 | SSL_C_PKEYLENGTH(S3I(s)->tmp.new_cipher)); |
1214 | 1214 | ||
1215 | if (dhp == NULL) { | 1215 | if (dhp == NULL) { |
1216 | al = SSL_AD_HANDSHAKE_FAILURE; | 1216 | al = SSL_AD_HANDSHAKE_FAILURE; |
@@ -1219,7 +1219,7 @@ ssl3_send_server_kex_dhe(SSL *s, CBB *cbb) | |||
1219 | goto f_err; | 1219 | goto f_err; |
1220 | } | 1220 | } |
1221 | 1221 | ||
1222 | if (s->s3->tmp.dh != NULL) { | 1222 | if (S3I(s)->tmp.dh != NULL) { |
1223 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, | 1223 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, |
1224 | ERR_R_INTERNAL_ERROR); | 1224 | ERR_R_INTERNAL_ERROR); |
1225 | goto err; | 1225 | goto err; |
@@ -1231,7 +1231,7 @@ ssl3_send_server_kex_dhe(SSL *s, CBB *cbb) | |||
1231 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_DH_LIB); | 1231 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_DH_LIB); |
1232 | goto err; | 1232 | goto err; |
1233 | } | 1233 | } |
1234 | s->s3->tmp.dh = dh; | 1234 | S3I(s)->tmp.dh = dh; |
1235 | if (!DH_generate_key(dh)) { | 1235 | if (!DH_generate_key(dh)) { |
1236 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_DH_LIB); | 1236 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_DH_LIB); |
1237 | goto err; | 1237 | goto err; |
@@ -1288,7 +1288,7 @@ ssl3_send_server_kex_ecdhe_ecp(SSL *s, int nid, CBB *cbb) | |||
1288 | ecdhp = EC_KEY_new_by_curve_name(nid); | 1288 | ecdhp = EC_KEY_new_by_curve_name(nid); |
1289 | } else if (ecdhp == NULL && s->cert->ecdh_tmp_cb != NULL) { | 1289 | } else if (ecdhp == NULL && s->cert->ecdh_tmp_cb != NULL) { |
1290 | ecdhp = s->cert->ecdh_tmp_cb(s, 0, | 1290 | ecdhp = s->cert->ecdh_tmp_cb(s, 0, |
1291 | SSL_C_PKEYLENGTH(s->s3->tmp.new_cipher)); | 1291 | SSL_C_PKEYLENGTH(S3I(s)->tmp.new_cipher)); |
1292 | } | 1292 | } |
1293 | if (ecdhp == NULL) { | 1293 | if (ecdhp == NULL) { |
1294 | al = SSL_AD_HANDSHAKE_FAILURE; | 1294 | al = SSL_AD_HANDSHAKE_FAILURE; |
@@ -1297,7 +1297,7 @@ ssl3_send_server_kex_ecdhe_ecp(SSL *s, int nid, CBB *cbb) | |||
1297 | goto f_err; | 1297 | goto f_err; |
1298 | } | 1298 | } |
1299 | 1299 | ||
1300 | if (s->s3->tmp.ecdh != NULL) { | 1300 | if (S3I(s)->tmp.ecdh != NULL) { |
1301 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, | 1301 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, |
1302 | ERR_R_INTERNAL_ERROR); | 1302 | ERR_R_INTERNAL_ERROR); |
1303 | goto err; | 1303 | goto err; |
@@ -1311,7 +1311,7 @@ ssl3_send_server_kex_ecdhe_ecp(SSL *s, int nid, CBB *cbb) | |||
1311 | ERR_R_ECDH_LIB); | 1311 | ERR_R_ECDH_LIB); |
1312 | goto err; | 1312 | goto err; |
1313 | } | 1313 | } |
1314 | s->s3->tmp.ecdh = ecdh; | 1314 | S3I(s)->tmp.ecdh = ecdh; |
1315 | 1315 | ||
1316 | if ((EC_KEY_get0_public_key(ecdh) == NULL) || | 1316 | if ((EC_KEY_get0_public_key(ecdh) == NULL) || |
1317 | (EC_KEY_get0_private_key(ecdh) == NULL) || | 1317 | (EC_KEY_get0_private_key(ecdh) == NULL) || |
@@ -1413,16 +1413,16 @@ ssl3_send_server_kex_ecdhe_ecx(SSL *s, int nid, CBB *cbb) | |||
1413 | int ret = -1; | 1413 | int ret = -1; |
1414 | 1414 | ||
1415 | /* Generate an X25519 key pair. */ | 1415 | /* Generate an X25519 key pair. */ |
1416 | if (s->s3->tmp.x25519 != NULL) { | 1416 | if (S3I(s)->tmp.x25519 != NULL) { |
1417 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, | 1417 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, |
1418 | ERR_R_INTERNAL_ERROR); | 1418 | ERR_R_INTERNAL_ERROR); |
1419 | goto err; | 1419 | goto err; |
1420 | } | 1420 | } |
1421 | if ((s->s3->tmp.x25519 = malloc(X25519_KEY_LENGTH)) == NULL) | 1421 | if ((S3I(s)->tmp.x25519 = malloc(X25519_KEY_LENGTH)) == NULL) |
1422 | goto err; | 1422 | goto err; |
1423 | if ((public_key = malloc(X25519_KEY_LENGTH)) == NULL) | 1423 | if ((public_key = malloc(X25519_KEY_LENGTH)) == NULL) |
1424 | goto err; | 1424 | goto err; |
1425 | X25519_keypair(public_key, s->s3->tmp.x25519); | 1425 | X25519_keypair(public_key, S3I(s)->tmp.x25519); |
1426 | 1426 | ||
1427 | /* Serialize public key. */ | 1427 | /* Serialize public key. */ |
1428 | if ((curve_id = tls1_ec_nid2curve_id(nid)) == 0) { | 1428 | if ((curve_id = tls1_ec_nid2curve_id(nid)) == 0) { |
@@ -1488,7 +1488,7 @@ ssl3_send_server_key_exchange(SSL *s) | |||
1488 | 1488 | ||
1489 | EVP_MD_CTX_init(&md_ctx); | 1489 | EVP_MD_CTX_init(&md_ctx); |
1490 | if (s->state == SSL3_ST_SW_KEY_EXCH_A) { | 1490 | if (s->state == SSL3_ST_SW_KEY_EXCH_A) { |
1491 | type = s->s3->tmp.new_cipher->algorithm_mkey; | 1491 | type = S3I(s)->tmp.new_cipher->algorithm_mkey; |
1492 | cert = s->cert; | 1492 | cert = s->cert; |
1493 | 1493 | ||
1494 | buf = s->init_buf; | 1494 | buf = s->init_buf; |
@@ -1512,9 +1512,9 @@ ssl3_send_server_key_exchange(SSL *s) | |||
1512 | if (!CBB_finish(&cbb, ¶ms, ¶ms_len)) | 1512 | if (!CBB_finish(&cbb, ¶ms, ¶ms_len)) |
1513 | goto err; | 1513 | goto err; |
1514 | 1514 | ||
1515 | if (!(s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL)) { | 1515 | if (!(S3I(s)->tmp.new_cipher->algorithm_auth & SSL_aNULL)) { |
1516 | if ((pkey = ssl_get_sign_pkey( | 1516 | if ((pkey = ssl_get_sign_pkey( |
1517 | s, s->s3->tmp.new_cipher, &md)) == NULL) { | 1517 | s, S3I(s)->tmp.new_cipher, &md)) == NULL) { |
1518 | al = SSL_AD_DECODE_ERROR; | 1518 | al = SSL_AD_DECODE_ERROR; |
1519 | goto f_err; | 1519 | goto f_err; |
1520 | } | 1520 | } |
@@ -1837,13 +1837,13 @@ ssl3_get_client_kex_dhe(SSL *s, unsigned char *p, long n) | |||
1837 | if (CBS_len(&cbs) != 0) | 1837 | if (CBS_len(&cbs) != 0) |
1838 | goto truncated; | 1838 | goto truncated; |
1839 | 1839 | ||
1840 | if (s->s3->tmp.dh == NULL) { | 1840 | if (S3I(s)->tmp.dh == NULL) { |
1841 | al = SSL_AD_HANDSHAKE_FAILURE; | 1841 | al = SSL_AD_HANDSHAKE_FAILURE; |
1842 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | 1842 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, |
1843 | SSL_R_MISSING_TMP_DH_KEY); | 1843 | SSL_R_MISSING_TMP_DH_KEY); |
1844 | goto f_err; | 1844 | goto f_err; |
1845 | } | 1845 | } |
1846 | dh = s->s3->tmp.dh; | 1846 | dh = S3I(s)->tmp.dh; |
1847 | 1847 | ||
1848 | if ((bn = BN_bin2bn(CBS_data(&dh_Yc), CBS_len(&dh_Yc), NULL)) == NULL) { | 1848 | if ((bn = BN_bin2bn(CBS_data(&dh_Yc), CBS_len(&dh_Yc), NULL)) == NULL) { |
1849 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | 1849 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, |
@@ -1864,8 +1864,8 @@ ssl3_get_client_kex_dhe(SSL *s, unsigned char *p, long n) | |||
1864 | 1864 | ||
1865 | explicit_bzero(p, key_size); | 1865 | explicit_bzero(p, key_size); |
1866 | 1866 | ||
1867 | DH_free(s->s3->tmp.dh); | 1867 | DH_free(S3I(s)->tmp.dh); |
1868 | s->s3->tmp.dh = NULL; | 1868 | S3I(s)->tmp.dh = NULL; |
1869 | 1869 | ||
1870 | BN_clear_free(bn); | 1870 | BN_clear_free(bn); |
1871 | 1871 | ||
@@ -1906,7 +1906,7 @@ ssl3_get_client_kex_ecdhe_ecp(SSL *s, unsigned char *p, long n) | |||
1906 | * Use the ephemeral values we saved when | 1906 | * Use the ephemeral values we saved when |
1907 | * generating the ServerKeyExchange message. | 1907 | * generating the ServerKeyExchange message. |
1908 | */ | 1908 | */ |
1909 | tkey = s->s3->tmp.ecdh; | 1909 | tkey = S3I(s)->tmp.ecdh; |
1910 | 1910 | ||
1911 | group = EC_KEY_get0_group(tkey); | 1911 | group = EC_KEY_get0_group(tkey); |
1912 | priv_key = EC_KEY_get0_private_key(tkey); | 1912 | priv_key = EC_KEY_get0_private_key(tkey); |
@@ -2008,8 +2008,8 @@ ssl3_get_client_kex_ecdhe_ecp(SSL *s, unsigned char *p, long n) | |||
2008 | EC_POINT_free(clnt_ecpoint); | 2008 | EC_POINT_free(clnt_ecpoint); |
2009 | EC_KEY_free(srvr_ecdh); | 2009 | EC_KEY_free(srvr_ecdh); |
2010 | BN_CTX_free(bn_ctx); | 2010 | BN_CTX_free(bn_ctx); |
2011 | EC_KEY_free(s->s3->tmp.ecdh); | 2011 | EC_KEY_free(S3I(s)->tmp.ecdh); |
2012 | s->s3->tmp.ecdh = NULL; | 2012 | S3I(s)->tmp.ecdh = NULL; |
2013 | 2013 | ||
2014 | /* Compute the master secret */ | 2014 | /* Compute the master secret */ |
2015 | s->session->master_key_length = | 2015 | s->session->master_key_length = |
@@ -2047,12 +2047,12 @@ ssl3_get_client_kex_ecdhe_ecx(SSL *s, unsigned char *p, long n) | |||
2047 | 2047 | ||
2048 | if ((shared_key = malloc(X25519_KEY_LENGTH)) == NULL) | 2048 | if ((shared_key = malloc(X25519_KEY_LENGTH)) == NULL) |
2049 | goto err; | 2049 | goto err; |
2050 | if (!X25519(shared_key, s->s3->tmp.x25519, CBS_data(&ecpoint))) | 2050 | if (!X25519(shared_key, S3I(s)->tmp.x25519, CBS_data(&ecpoint))) |
2051 | goto err; | 2051 | goto err; |
2052 | 2052 | ||
2053 | explicit_bzero(s->s3->tmp.x25519, X25519_KEY_LENGTH); | 2053 | explicit_bzero(S3I(s)->tmp.x25519, X25519_KEY_LENGTH); |
2054 | free(s->s3->tmp.x25519); | 2054 | free(S3I(s)->tmp.x25519); |
2055 | s->s3->tmp.x25519 = NULL; | 2055 | S3I(s)->tmp.x25519 = NULL; |
2056 | 2056 | ||
2057 | s->session->master_key_length = | 2057 | s->session->master_key_length = |
2058 | s->method->ssl3_enc->generate_master_secret( | 2058 | s->method->ssl3_enc->generate_master_secret( |
@@ -2071,7 +2071,7 @@ ssl3_get_client_kex_ecdhe_ecx(SSL *s, unsigned char *p, long n) | |||
2071 | static int | 2071 | static int |
2072 | ssl3_get_client_kex_ecdhe(SSL *s, unsigned char *p, long n) | 2072 | ssl3_get_client_kex_ecdhe(SSL *s, unsigned char *p, long n) |
2073 | { | 2073 | { |
2074 | if (s->s3->tmp.x25519 != NULL) | 2074 | if (S3I(s)->tmp.x25519 != NULL) |
2075 | return ssl3_get_client_kex_ecdhe_ecx(s, p, n); | 2075 | return ssl3_get_client_kex_ecdhe_ecx(s, p, n); |
2076 | 2076 | ||
2077 | return ssl3_get_client_kex_ecdhe_ecp(s, p, n); | 2077 | return ssl3_get_client_kex_ecdhe_ecp(s, p, n); |
@@ -2092,7 +2092,7 @@ ssl3_get_client_kex_gost(SSL *s, unsigned char *p, long n) | |||
2092 | int ret = 0; | 2092 | int ret = 0; |
2093 | 2093 | ||
2094 | /* Get our certificate private key*/ | 2094 | /* Get our certificate private key*/ |
2095 | alg_a = s->s3->tmp.new_cipher->algorithm_auth; | 2095 | alg_a = S3I(s)->tmp.new_cipher->algorithm_auth; |
2096 | if (alg_a & SSL_aGOST01) | 2096 | if (alg_a & SSL_aGOST01) |
2097 | pk = s->cert->pkeys[SSL_PKEY_GOST01].privatekey; | 2097 | pk = s->cert->pkeys[SSL_PKEY_GOST01].privatekey; |
2098 | 2098 | ||
@@ -2171,7 +2171,7 @@ ssl3_get_client_key_exchange(SSL *s) | |||
2171 | 2171 | ||
2172 | p = (unsigned char *)s->init_msg; | 2172 | p = (unsigned char *)s->init_msg; |
2173 | 2173 | ||
2174 | alg_k = s->s3->tmp.new_cipher->algorithm_mkey; | 2174 | alg_k = S3I(s)->tmp.new_cipher->algorithm_mkey; |
2175 | 2175 | ||
2176 | if (alg_k & SSL_kRSA) { | 2176 | if (alg_k & SSL_kRSA) { |
2177 | if (ssl3_get_client_kex_rsa(s, p, n) != 1) | 2177 | if (ssl3_get_client_kex_rsa(s, p, n) != 1) |
@@ -2227,8 +2227,8 @@ ssl3_get_cert_verify(SSL *s) | |||
2227 | pkey = NULL; | 2227 | pkey = NULL; |
2228 | } | 2228 | } |
2229 | 2229 | ||
2230 | if (s->s3->tmp.message_type != SSL3_MT_CERTIFICATE_VERIFY) { | 2230 | if (S3I(s)->tmp.message_type != SSL3_MT_CERTIFICATE_VERIFY) { |
2231 | s->s3->tmp.reuse_message = 1; | 2231 | S3I(s)->tmp.reuse_message = 1; |
2232 | if (peer != NULL) { | 2232 | if (peer != NULL) { |
2233 | al = SSL_AD_UNEXPECTED_MESSAGE; | 2233 | al = SSL_AD_UNEXPECTED_MESSAGE; |
2234 | SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, | 2234 | SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, |
@@ -2253,7 +2253,7 @@ ssl3_get_cert_verify(SSL *s) | |||
2253 | goto f_err; | 2253 | goto f_err; |
2254 | } | 2254 | } |
2255 | 2255 | ||
2256 | if (s->s3->change_cipher_spec) { | 2256 | if (S3I(s)->change_cipher_spec) { |
2257 | SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, | 2257 | SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, |
2258 | SSL_R_CCS_RECEIVED_EARLY); | 2258 | SSL_R_CCS_RECEIVED_EARLY); |
2259 | al = SSL_AD_UNEXPECTED_MESSAGE; | 2259 | al = SSL_AD_UNEXPECTED_MESSAGE; |
@@ -2318,7 +2318,7 @@ ssl3_get_cert_verify(SSL *s) | |||
2318 | if (SSL_USE_SIGALGS(s)) { | 2318 | if (SSL_USE_SIGALGS(s)) { |
2319 | long hdatalen = 0; | 2319 | long hdatalen = 0; |
2320 | void *hdata; | 2320 | void *hdata; |
2321 | hdatalen = BIO_get_mem_data(s->s3->handshake_buffer, &hdata); | 2321 | hdatalen = BIO_get_mem_data(S3I(s)->handshake_buffer, &hdata); |
2322 | if (hdatalen <= 0) { | 2322 | if (hdatalen <= 0) { |
2323 | SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, | 2323 | SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, |
2324 | ERR_R_INTERNAL_ERROR); | 2324 | ERR_R_INTERNAL_ERROR); |
@@ -2341,7 +2341,7 @@ ssl3_get_cert_verify(SSL *s) | |||
2341 | } | 2341 | } |
2342 | } else | 2342 | } else |
2343 | if (pkey->type == EVP_PKEY_RSA) { | 2343 | if (pkey->type == EVP_PKEY_RSA) { |
2344 | i = RSA_verify(NID_md5_sha1, s->s3->tmp.cert_verify_md, | 2344 | i = RSA_verify(NID_md5_sha1, S3I(s)->tmp.cert_verify_md, |
2345 | MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, p, i, | 2345 | MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, p, i, |
2346 | pkey->pkey.rsa); | 2346 | pkey->pkey.rsa); |
2347 | if (i < 0) { | 2347 | if (i < 0) { |
@@ -2359,7 +2359,7 @@ ssl3_get_cert_verify(SSL *s) | |||
2359 | } else | 2359 | } else |
2360 | if (pkey->type == EVP_PKEY_DSA) { | 2360 | if (pkey->type == EVP_PKEY_DSA) { |
2361 | j = DSA_verify(pkey->save_type, | 2361 | j = DSA_verify(pkey->save_type, |
2362 | &(s->s3->tmp.cert_verify_md[MD5_DIGEST_LENGTH]), | 2362 | &(S3I(s)->tmp.cert_verify_md[MD5_DIGEST_LENGTH]), |
2363 | SHA_DIGEST_LENGTH, p, i, pkey->pkey.dsa); | 2363 | SHA_DIGEST_LENGTH, p, i, pkey->pkey.dsa); |
2364 | if (j <= 0) { | 2364 | if (j <= 0) { |
2365 | /* bad signature */ | 2365 | /* bad signature */ |
@@ -2371,7 +2371,7 @@ ssl3_get_cert_verify(SSL *s) | |||
2371 | } else | 2371 | } else |
2372 | if (pkey->type == EVP_PKEY_EC) { | 2372 | if (pkey->type == EVP_PKEY_EC) { |
2373 | j = ECDSA_verify(pkey->save_type, | 2373 | j = ECDSA_verify(pkey->save_type, |
2374 | &(s->s3->tmp.cert_verify_md[MD5_DIGEST_LENGTH]), | 2374 | &(S3I(s)->tmp.cert_verify_md[MD5_DIGEST_LENGTH]), |
2375 | SHA_DIGEST_LENGTH, p, i, pkey->pkey.ec); | 2375 | SHA_DIGEST_LENGTH, p, i, pkey->pkey.ec); |
2376 | if (j <= 0) { | 2376 | if (j <= 0) { |
2377 | /* bad signature */ | 2377 | /* bad signature */ |
@@ -2391,7 +2391,7 @@ ssl3_get_cert_verify(SSL *s) | |||
2391 | int nid; | 2391 | int nid; |
2392 | EVP_PKEY_CTX *pctx; | 2392 | EVP_PKEY_CTX *pctx; |
2393 | 2393 | ||
2394 | hdatalen = BIO_get_mem_data(s->s3->handshake_buffer, &hdata); | 2394 | hdatalen = BIO_get_mem_data(S3I(s)->handshake_buffer, &hdata); |
2395 | if (hdatalen <= 0) { | 2395 | if (hdatalen <= 0) { |
2396 | SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, | 2396 | SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, |
2397 | ERR_R_INTERNAL_ERROR); | 2397 | ERR_R_INTERNAL_ERROR); |
@@ -2456,9 +2456,9 @@ f_err: | |||
2456 | ssl3_send_alert(s, SSL3_AL_FATAL, al); | 2456 | ssl3_send_alert(s, SSL3_AL_FATAL, al); |
2457 | } | 2457 | } |
2458 | end: | 2458 | end: |
2459 | if (s->s3->handshake_buffer) { | 2459 | if (S3I(s)->handshake_buffer) { |
2460 | BIO_free(s->s3->handshake_buffer); | 2460 | BIO_free(S3I(s)->handshake_buffer); |
2461 | s->s3->handshake_buffer = NULL; | 2461 | S3I(s)->handshake_buffer = NULL; |
2462 | s->s3->flags &= ~TLS1_FLAGS_KEEP_HANDSHAKE; | 2462 | s->s3->flags &= ~TLS1_FLAGS_KEEP_HANDSHAKE; |
2463 | } | 2463 | } |
2464 | EVP_MD_CTX_cleanup(&mctx); | 2464 | EVP_MD_CTX_cleanup(&mctx); |
@@ -2482,7 +2482,7 @@ ssl3_get_client_certificate(SSL *s) | |||
2482 | if (!ok) | 2482 | if (!ok) |
2483 | return ((int)n); | 2483 | return ((int)n); |
2484 | 2484 | ||
2485 | if (s->s3->tmp.message_type == SSL3_MT_CLIENT_KEY_EXCHANGE) { | 2485 | if (S3I(s)->tmp.message_type == SSL3_MT_CLIENT_KEY_EXCHANGE) { |
2486 | if ((s->verify_mode & SSL_VERIFY_PEER) && | 2486 | if ((s->verify_mode & SSL_VERIFY_PEER) && |
2487 | (s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) { | 2487 | (s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) { |
2488 | SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, | 2488 | SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, |
@@ -2494,18 +2494,18 @@ ssl3_get_client_certificate(SSL *s) | |||
2494 | * If tls asked for a client cert, | 2494 | * If tls asked for a client cert, |
2495 | * the client must return a 0 list. | 2495 | * the client must return a 0 list. |
2496 | */ | 2496 | */ |
2497 | if (s->s3->tmp.cert_request) { | 2497 | if (S3I(s)->tmp.cert_request) { |
2498 | SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, | 2498 | SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, |
2499 | SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST | 2499 | SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST |
2500 | ); | 2500 | ); |
2501 | al = SSL_AD_UNEXPECTED_MESSAGE; | 2501 | al = SSL_AD_UNEXPECTED_MESSAGE; |
2502 | goto f_err; | 2502 | goto f_err; |
2503 | } | 2503 | } |
2504 | s->s3->tmp.reuse_message = 1; | 2504 | S3I(s)->tmp.reuse_message = 1; |
2505 | return (1); | 2505 | return (1); |
2506 | } | 2506 | } |
2507 | 2507 | ||
2508 | if (s->s3->tmp.message_type != SSL3_MT_CERTIFICATE) { | 2508 | if (S3I(s)->tmp.message_type != SSL3_MT_CERTIFICATE) { |
2509 | al = SSL_AD_UNEXPECTED_MESSAGE; | 2509 | al = SSL_AD_UNEXPECTED_MESSAGE; |
2510 | SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, | 2510 | SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, |
2511 | SSL_R_WRONG_MESSAGE_TYPE); | 2511 | SSL_R_WRONG_MESSAGE_TYPE); |
@@ -2571,7 +2571,7 @@ ssl3_get_client_certificate(SSL *s) | |||
2571 | goto f_err; | 2571 | goto f_err; |
2572 | } | 2572 | } |
2573 | /* No client certificate so digest cached records */ | 2573 | /* No client certificate so digest cached records */ |
2574 | if (s->s3->handshake_buffer && !tls1_digest_cached_records(s)) { | 2574 | if (S3I(s)->handshake_buffer && !tls1_digest_cached_records(s)) { |
2575 | al = SSL_AD_INTERNAL_ERROR; | 2575 | al = SSL_AD_INTERNAL_ERROR; |
2576 | goto f_err; | 2576 | goto f_err; |
2577 | } | 2577 | } |
@@ -2860,7 +2860,7 @@ ssl3_get_next_proto(SSL *s) | |||
2860 | * Clients cannot send a NextProtocol message if we didn't see the | 2860 | * Clients cannot send a NextProtocol message if we didn't see the |
2861 | * extension in their ClientHello | 2861 | * extension in their ClientHello |
2862 | */ | 2862 | */ |
2863 | if (!s->s3->next_proto_neg_seen) { | 2863 | if (!S3I(s)->next_proto_neg_seen) { |
2864 | SSLerr(SSL_F_SSL3_GET_NEXT_PROTO, | 2864 | SSLerr(SSL_F_SSL3_GET_NEXT_PROTO, |
2865 | SSL_R_GOT_NEXT_PROTO_WITHOUT_EXTENSION); | 2865 | SSL_R_GOT_NEXT_PROTO_WITHOUT_EXTENSION); |
2866 | return (-1); | 2866 | return (-1); |
@@ -2874,10 +2874,10 @@ ssl3_get_next_proto(SSL *s) | |||
2874 | 2874 | ||
2875 | /* | 2875 | /* |
2876 | * s->state doesn't reflect whether ChangeCipherSpec has been received | 2876 | * s->state doesn't reflect whether ChangeCipherSpec has been received |
2877 | * in this handshake, but s->s3->change_cipher_spec does (will be reset | 2877 | * in this handshake, but S3I(s)->change_cipher_spec does (will be reset |
2878 | * by ssl3_get_finished). | 2878 | * by ssl3_get_finished). |
2879 | */ | 2879 | */ |
2880 | if (!s->s3->change_cipher_spec) { | 2880 | if (!S3I(s)->change_cipher_spec) { |
2881 | SSLerr(SSL_F_SSL3_GET_NEXT_PROTO, | 2881 | SSLerr(SSL_F_SSL3_GET_NEXT_PROTO, |
2882 | SSL_R_GOT_NEXT_PROTO_BEFORE_A_CCS); | 2882 | SSL_R_GOT_NEXT_PROTO_BEFORE_A_CCS); |
2883 | return (-1); | 2883 | return (-1); |