Ignore:
Timestamp:
Aug 7, 2014, 8:25:37 PM (11 years ago)
Author:
dmik
Message:

openssl: Merge version 1.0.0n from vendor to trunk.

Location:
openssl/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • openssl/trunk

  • TabularUnified openssl/trunk/ssl/s3_srvr.c

    r150 r808  
    259259
    260260                        s->init_num=0;
     261                        s->s3->flags &= ~SSL3_FLAGS_SGC_RESTART_DONE;
    261262
    262263                        if (s->state != SSL_ST_RENEGOTIATE)
     
    578579                case SSL3_ST_SR_CERT_VRFY_B:
    579580
     581                        s->s3->flags |= SSL3_FLAGS_CCS_OK;
    580582                        /* we should decide if we expected this one */
    581583                        ret=ssl3_get_cert_verify(s);
     
    588590                case SSL3_ST_SR_FINISHED_A:
    589591                case SSL3_ST_SR_FINISHED_B:
     592                        s->s3->flags |= SSL3_FLAGS_CCS_OK;
    590593                        ret=ssl3_get_finished(s,SSL3_ST_SR_FINISHED_A,
    591594                                SSL3_ST_SR_FINISHED_B);
     
    768771        if (s->s3->tmp.message_type == SSL3_MT_CLIENT_HELLO)
    769772                {
     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                        }
    770780                /* 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.) */
    774782#ifndef OPENSSL_NO_DH
    775783                if (s->s3->tmp.dh != NULL)
     
    779787                        }
    780788#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;
    781797                return 2;
    782798                }
     
    9861002                                }
    9871003                        }
     1004/* Disabled because it can be used in a ciphersuite downgrade
     1005 * attack: CVE-2010-4180.
     1006 */
     1007#if 0
    9881008                if (j == 0 && (s->options & SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG) && (sk_SSL_CIPHER_num(ciphers) == 1))
    9891009                        {
     
    10001020                                }
    10011021                        }
     1022#endif
    10021023                if (j == 0)
    10031024                        {
     
    10451066                        }
    10461067                }
    1047                 if (ssl_check_clienthello_tlsext(s) <= 0) {
     1068                if (ssl_check_clienthello_tlsext_early(s) <= 0) {
    10481069                        SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_CLIENTHELLO_TLSEXT);
    10491070                        goto err;
     
    12511272
    12521273        if (!ssl3_digest_cached_records(s))
     1274                {
     1275                al = SSL_AD_INTERNAL_ERROR;
    12531276                goto f_err;
     1277                }
    12541278       
    12551279        /* we now have the following setup.
     
    12631287         * s->tmp.new_cipher    - the new cipher to use.
    12641288         */
     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
    12651301
    12661302        if (ret < 0) ret=1;
     
    14871523                        if (s->s3->tmp.dh != NULL)
    14881524                                {
    1489                                 DH_free(dh);
    14901525                                SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);
    14911526                                goto err;
     
    15481583                        if (s->s3->tmp.ecdh != NULL)
    15491584                                {
    1550                                 EC_KEY_free(s->s3->tmp.ecdh);
    15511585                                SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);
    15521586                                goto err;
     
    15591593                                goto err;
    15601594                                }
    1561                         if (!EC_KEY_up_ref(ecdhp))
     1595                        if ((ecdh = EC_KEY_dup(ecdhp)) == NULL)
    15621596                                {
    15631597                                SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,ERR_R_ECDH_LIB);
    15641598                                goto err;
    15651599                                }
    1566                         ecdh = ecdhp;
    15671600
    15681601                        s->s3->tmp.ecdh=ecdh;
     
    17271760                            encodedlen);
    17281761                        OPENSSL_free(encodedPoint);
     1762                        encodedPoint = NULL;
    17291763                        p += encodedlen;
    17301764                        }
     
    19131947                s->init_off=0;
    19141948#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                        }
    19151954                p=(unsigned char *)s->init_buf->data + s->init_num;
    19161955
     
    21232162                        {
    21242163                        SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,ERR_R_DH_LIB);
     2164                        BN_clear_free(pub);
    21252165                        goto err;
    21262166                        }
     
    24362476                        i = *p;
    24372477                        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                                }
    24382484                        if (EC_POINT_oct2point(group,
    24392485                            clnt_ecpoint, p, i, bn_ctx) == 0)
     
    25802626                        int ret = 0;
    25812627                        EVP_PKEY_CTX *pkey_ctx;
    2582                         EVP_PKEY *client_pub_pkey = NULL;
     2628                        EVP_PKEY *client_pub_pkey = NULL, *pk = NULL;
    25832629                        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;
    25852634
    25862635                        /* 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);
    25882643                        EVP_PKEY_decrypt_init(pkey_ctx);
    25892644                        /* If client certificate is present and is of the same type, maybe
     
    25982653                                }
    25992654                        /* 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)
    26012658                                {
    26022659                                SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_DECRYPTION_FAILED);
    26032660                                goto gerr;
    26042661                                }
    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;
    26202664                        if (EVP_PKEY_decrypt(pkey_ctx,premaster_secret,&outlen,start,inlen) <=0)
    26212665
     
    26782722                SSL3_ST_SR_CERT_VRFY_B,
    26792723                -1,
    2680                 514, /* 514? */
     2724                SSL3_RT_MAX_PLAIN_LENGTH,
    26812725                &ok);
    26822726
     
    26982742                {
    26992743                s->s3->tmp.reuse_message=1;
    2700                 if ((peer != NULL) && (type | EVP_PKT_SIGN))
     2744                if ((peer != NULL) && (type & EVP_PKT_SIGN))
    27012745                        {
    27022746                        al=SSL_AD_UNEXPECTED_MESSAGE;
Note: See TracChangeset for help on using the changeset viewer.