Changeset 808 for openssl/trunk/ssl/s3_srvr.c
- Timestamp:
- Aug 7, 2014, 8:25:37 PM (11 years ago)
- Location:
- openssl/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
openssl/trunk ¶
- Property svn:mergeinfo changed
/openssl/vendor/1.0.0-current (added) merged: 799-800,804 /openssl/vendor/1.0.0n (added) merged: 807
- Property svn:mergeinfo changed
-
TabularUnified openssl/trunk/ssl/s3_srvr.c ¶
r150 r808 259 259 260 260 s->init_num=0; 261 s->s3->flags &= ~SSL3_FLAGS_SGC_RESTART_DONE; 261 262 262 263 if (s->state != SSL_ST_RENEGOTIATE) … … 578 579 case SSL3_ST_SR_CERT_VRFY_B: 579 580 581 s->s3->flags |= SSL3_FLAGS_CCS_OK; 580 582 /* we should decide if we expected this one */ 581 583 ret=ssl3_get_cert_verify(s); … … 588 590 case SSL3_ST_SR_FINISHED_A: 589 591 case SSL3_ST_SR_FINISHED_B: 592 s->s3->flags |= SSL3_FLAGS_CCS_OK; 590 593 ret=ssl3_get_finished(s,SSL3_ST_SR_FINISHED_A, 591 594 SSL3_ST_SR_FINISHED_B); … … 768 771 if (s->s3->tmp.message_type == SSL3_MT_CLIENT_HELLO) 769 772 { 773 /* We only allow the client to restart the handshake once per 774 * negotiation. */ 775 if (s->s3->flags & SSL3_FLAGS_SGC_RESTART_DONE) 776 { 777 SSLerr(SSL_F_SSL3_CHECK_CLIENT_HELLO, SSL_R_MULTIPLE_SGC_RESTARTS); 778 return -1; 779 } 770 780 /* Throw away what we have done so far in the current handshake, 771 * which will now be aborted. (A full SSL_clear would be too much.) 772 * I hope that tmp.dh is the only thing that may need to be cleared 773 * when a handshake is not completed ... */ 781 * which will now be aborted. (A full SSL_clear would be too much.) */ 774 782 #ifndef OPENSSL_NO_DH 775 783 if (s->s3->tmp.dh != NULL) … … 779 787 } 780 788 #endif 789 #ifndef OPENSSL_NO_ECDH 790 if (s->s3->tmp.ecdh != NULL) 791 { 792 EC_KEY_free(s->s3->tmp.ecdh); 793 s->s3->tmp.ecdh = NULL; 794 } 795 #endif 796 s->s3->flags |= SSL3_FLAGS_SGC_RESTART_DONE; 781 797 return 2; 782 798 } … … 986 1002 } 987 1003 } 1004 /* Disabled because it can be used in a ciphersuite downgrade 1005 * attack: CVE-2010-4180. 1006 */ 1007 #if 0 988 1008 if (j == 0 && (s->options & SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG) && (sk_SSL_CIPHER_num(ciphers) == 1)) 989 1009 { … … 1000 1020 } 1001 1021 } 1022 #endif 1002 1023 if (j == 0) 1003 1024 { … … 1045 1066 } 1046 1067 } 1047 if (ssl_check_clienthello_tlsext (s) <= 0) {1068 if (ssl_check_clienthello_tlsext_early(s) <= 0) { 1048 1069 SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_CLIENTHELLO_TLSEXT); 1049 1070 goto err; … … 1251 1272 1252 1273 if (!ssl3_digest_cached_records(s)) 1274 { 1275 al = SSL_AD_INTERNAL_ERROR; 1253 1276 goto f_err; 1277 } 1254 1278 1255 1279 /* we now have the following setup. … … 1263 1287 * s->tmp.new_cipher - the new cipher to use. 1264 1288 */ 1289 1290 #ifndef OPENSSL_NO_TLSEXT 1291 /* Handles TLS extensions that we couldn't check earlier */ 1292 if (s->version >= SSL3_VERSION) 1293 { 1294 if (ssl_check_clienthello_tlsext_late(s) <= 0) 1295 { 1296 SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT); 1297 goto err; 1298 } 1299 } 1300 #endif 1265 1301 1266 1302 if (ret < 0) ret=1; … … 1487 1523 if (s->s3->tmp.dh != NULL) 1488 1524 { 1489 DH_free(dh);1490 1525 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); 1491 1526 goto err; … … 1548 1583 if (s->s3->tmp.ecdh != NULL) 1549 1584 { 1550 EC_KEY_free(s->s3->tmp.ecdh);1551 1585 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); 1552 1586 goto err; … … 1559 1593 goto err; 1560 1594 } 1561 if ( !EC_KEY_up_ref(ecdhp))1595 if ((ecdh = EC_KEY_dup(ecdhp)) == NULL) 1562 1596 { 1563 1597 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,ERR_R_ECDH_LIB); 1564 1598 goto err; 1565 1599 } 1566 ecdh = ecdhp;1567 1600 1568 1601 s->s3->tmp.ecdh=ecdh; … … 1727 1760 encodedlen); 1728 1761 OPENSSL_free(encodedPoint); 1762 encodedPoint = NULL; 1729 1763 p += encodedlen; 1730 1764 } … … 1913 1947 s->init_off=0; 1914 1948 #ifdef NETSCAPE_HANG_BUG 1949 if (!BUF_MEM_grow_clean(buf, s->init_num + 4)) 1950 { 1951 SSLerr(SSL_F_SSL3_SEND_CERTIFICATE_REQUEST,ERR_R_BUF_LIB); 1952 goto err; 1953 } 1915 1954 p=(unsigned char *)s->init_buf->data + s->init_num; 1916 1955 … … 2123 2162 { 2124 2163 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,ERR_R_DH_LIB); 2164 BN_clear_free(pub); 2125 2165 goto err; 2126 2166 } … … 2436 2476 i = *p; 2437 2477 p += 1; 2478 if (n != 1 + i) 2479 { 2480 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, 2481 ERR_R_EC_LIB); 2482 goto err; 2483 } 2438 2484 if (EC_POINT_oct2point(group, 2439 2485 clnt_ecpoint, p, i, bn_ctx) == 0) … … 2580 2626 int ret = 0; 2581 2627 EVP_PKEY_CTX *pkey_ctx; 2582 EVP_PKEY *client_pub_pkey = NULL ;2628 EVP_PKEY *client_pub_pkey = NULL, *pk = NULL; 2583 2629 unsigned char premaster_secret[32], *start; 2584 size_t outlen=32, inlen; 2630 size_t outlen=32, inlen; 2631 unsigned long alg_a; 2632 int Ttag, Tclass; 2633 long Tlen; 2585 2634 2586 2635 /* Get our certificate private key*/ 2587 pkey_ctx = EVP_PKEY_CTX_new(s->cert->key->privatekey,NULL); 2636 alg_a = s->s3->tmp.new_cipher->algorithm_auth; 2637 if (alg_a & SSL_aGOST94) 2638 pk = s->cert->pkeys[SSL_PKEY_GOST94].privatekey; 2639 else if (alg_a & SSL_aGOST01) 2640 pk = s->cert->pkeys[SSL_PKEY_GOST01].privatekey; 2641 2642 pkey_ctx = EVP_PKEY_CTX_new(pk,NULL); 2588 2643 EVP_PKEY_decrypt_init(pkey_ctx); 2589 2644 /* If client certificate is present and is of the same type, maybe … … 2598 2653 } 2599 2654 /* Decrypt session key */ 2600 if ((*p!=( V_ASN1_SEQUENCE| V_ASN1_CONSTRUCTED))) 2655 if (ASN1_get_object((const unsigned char **)&p, &Tlen, &Ttag, &Tclass, n) != V_ASN1_CONSTRUCTED || 2656 Ttag != V_ASN1_SEQUENCE || 2657 Tclass != V_ASN1_UNIVERSAL) 2601 2658 { 2602 2659 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_DECRYPTION_FAILED); 2603 2660 goto gerr; 2604 2661 } 2605 if (p[1] == 0x81) 2606 { 2607 start = p+3; 2608 inlen = p[2]; 2609 } 2610 else if (p[1] < 0x80) 2611 { 2612 start = p+2; 2613 inlen = p[1]; 2614 } 2615 else 2616 { 2617 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_DECRYPTION_FAILED); 2618 goto gerr; 2619 } 2662 start = p; 2663 inlen = Tlen; 2620 2664 if (EVP_PKEY_decrypt(pkey_ctx,premaster_secret,&outlen,start,inlen) <=0) 2621 2665 … … 2678 2722 SSL3_ST_SR_CERT_VRFY_B, 2679 2723 -1, 2680 514, /* 514? */2724 SSL3_RT_MAX_PLAIN_LENGTH, 2681 2725 &ok); 2682 2726 … … 2698 2742 { 2699 2743 s->s3->tmp.reuse_message=1; 2700 if ((peer != NULL) && (type |EVP_PKT_SIGN))2744 if ((peer != NULL) && (type & EVP_PKT_SIGN)) 2701 2745 { 2702 2746 al=SSL_AD_UNEXPECTED_MESSAGE;
Note:
See TracChangeset
for help on using the changeset viewer.