From owner-svn-src-all@FreeBSD.ORG Tue Jan 7 19:02:10 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 06EC6D08; Tue, 7 Jan 2014 19:02:10 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id DB0D41469; Tue, 7 Jan 2014 19:02:09 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s07J297A047654; Tue, 7 Jan 2014 19:02:09 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s07J283m047643; Tue, 7 Jan 2014 19:02:08 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201401071902.s07J283m047643@svn.freebsd.org> From: Xin LI Date: Tue, 7 Jan 2014 19:02:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r260399 - vendor-crypto/openssl/dist/ssl X-SVN-Group: vendor-crypto MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jan 2014 19:02:10 -0000 Author: delphij Date: Tue Jan 7 19:02:08 2014 New Revision: 260399 URL: http://svnweb.freebsd.org/changeset/base/260399 Log: Import vendor fixes: 197e0ea Fix for TLS record tampering bug. (CVE-2013-4353). 3462896 For DTLS we might need to retransmit messages from the previous session so keep a copy of write context in DTLS retransmission buffers instead of replacing it after sending CCS. (CVE-2013-6450). ca98926 When deciding whether to use TLS 1.2 PRF and record hash algorithms use the version number in the corresponding SSL_METHOD structure instead of the SSL structure. The SSL structure version is sometimes inaccurate. Note: OpenSSL 1.0.2 and later effectively do this already. (CVE-2013-6449). Modified: vendor-crypto/openssl/dist/ssl/d1_both.c vendor-crypto/openssl/dist/ssl/s3_both.c vendor-crypto/openssl/dist/ssl/s3_lib.c vendor-crypto/openssl/dist/ssl/ssl_locl.h vendor-crypto/openssl/dist/ssl/t1_enc.c Modified: vendor-crypto/openssl/dist/ssl/d1_both.c ============================================================================== --- vendor-crypto/openssl/dist/ssl/d1_both.c Tue Jan 7 19:00:40 2014 (r260398) +++ vendor-crypto/openssl/dist/ssl/d1_both.c Tue Jan 7 19:02:08 2014 (r260399) @@ -214,6 +214,12 @@ dtls1_hm_fragment_new(unsigned long frag static void dtls1_hm_fragment_free(hm_fragment *frag) { + + if (frag->msg_header.is_ccs) + { + EVP_CIPHER_CTX_free(frag->msg_header.saved_retransmit_state.enc_write_ctx); + EVP_MD_CTX_destroy(frag->msg_header.saved_retransmit_state.write_hash); + } if (frag->fragment) OPENSSL_free(frag->fragment); if (frag->reassembly) OPENSSL_free(frag->reassembly); OPENSSL_free(frag); Modified: vendor-crypto/openssl/dist/ssl/s3_both.c ============================================================================== --- vendor-crypto/openssl/dist/ssl/s3_both.c Tue Jan 7 19:00:40 2014 (r260398) +++ vendor-crypto/openssl/dist/ssl/s3_both.c Tue Jan 7 19:02:08 2014 (r260399) @@ -208,7 +208,11 @@ static void ssl3_take_mac(SSL *s) { const char *sender; int slen; - + /* If no new cipher setup return immediately: other functions will + * set the appropriate error. + */ + if (s->s3->tmp.new_cipher == NULL) + return; if (s->state & SSL_ST_CONNECT) { sender=s->method->ssl3_enc->server_finished_label; Modified: vendor-crypto/openssl/dist/ssl/s3_lib.c ============================================================================== --- vendor-crypto/openssl/dist/ssl/s3_lib.c Tue Jan 7 19:00:40 2014 (r260398) +++ vendor-crypto/openssl/dist/ssl/s3_lib.c Tue Jan 7 19:02:08 2014 (r260399) @@ -4274,7 +4274,7 @@ need to go to SSL_ST_ACCEPT. long ssl_get_algorithm2(SSL *s) { long alg2 = s->s3->tmp.new_cipher->algorithm2; - if (TLS1_get_version(s) >= TLS1_2_VERSION && + if (s->method->version == TLS1_2_VERSION && alg2 == (SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF)) return SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256; return alg2; Modified: vendor-crypto/openssl/dist/ssl/ssl_locl.h ============================================================================== --- vendor-crypto/openssl/dist/ssl/ssl_locl.h Tue Jan 7 19:00:40 2014 (r260398) +++ vendor-crypto/openssl/dist/ssl/ssl_locl.h Tue Jan 7 19:02:08 2014 (r260399) @@ -621,6 +621,8 @@ extern SSL3_ENC_METHOD TLSv1_enc_data; extern SSL3_ENC_METHOD SSLv3_enc_data; extern SSL3_ENC_METHOD DTLSv1_enc_data; +#define SSL_IS_DTLS(s) (s->method->version == DTLS1_VERSION) + #define IMPLEMENT_tls_meth_func(version, func_name, s_accept, s_connect, \ s_get_meth) \ const SSL_METHOD *func_name(void) \ Modified: vendor-crypto/openssl/dist/ssl/t1_enc.c ============================================================================== --- vendor-crypto/openssl/dist/ssl/t1_enc.c Tue Jan 7 19:00:40 2014 (r260398) +++ vendor-crypto/openssl/dist/ssl/t1_enc.c Tue Jan 7 19:02:08 2014 (r260399) @@ -414,15 +414,20 @@ int tls1_change_cipher_state(SSL *s, int 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) + if (s->enc_write_ctx != NULL && !SSL_IS_DTLS(s)) reuse_dd = 1; - else if ((s->enc_write_ctx=OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL) + else if ((s->enc_write_ctx=EVP_CIPHER_CTX_new()) == NULL) goto err; - else - /* make sure it's intialized in case we exit later with an error */ - EVP_CIPHER_CTX_init(s->enc_write_ctx); dd= s->enc_write_ctx; - mac_ctx = ssl_replace_hash(&s->write_hash,NULL); + if (SSL_IS_DTLS(s)) + { + mac_ctx = EVP_MD_CTX_create(); + if (!mac_ctx) + goto err; + s->write_hash = mac_ctx; + } + else + mac_ctx = ssl_replace_hash(&s->write_hash,NULL); #ifndef OPENSSL_NO_COMP if (s->compress != NULL) {