Skip to content

Commit 3462896

Browse files
committed
Fix DTLS retransmission from previous session.
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.
1 parent a6c62f0 commit 3462896

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

CHANGES

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
Changes between 1.0.1e and 1.0.1f [xx XXX xxxx]
66

7+
*) Keep original DTLS digest and encryption contexts in retransmission
8+
structures so we can use the previous session parameters if they need
9+
to be resent. (CVE-2013-6450)
10+
[Steve Henson]
11+
712
*) Add option SSL_OP_SAFARI_ECDHE_ECDSA_BUG (part of SSL_OP_ALL) which
813
avoids preferring ECDHE-ECDSA ciphers when the client appears to be
914
Safari on OS X. Safari on OS X 10.8..10.8.3 advertises support for

ssl/d1_both.c

+6
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ dtls1_hm_fragment_new(unsigned long frag_len, int reassembly)
214214
static void
215215
dtls1_hm_fragment_free(hm_fragment *frag)
216216
{
217+
218+
if (frag->msg_header.is_ccs)
219+
{
220+
EVP_CIPHER_CTX_free(frag->msg_header.saved_retransmit_state.enc_write_ctx);
221+
EVP_MD_CTX_destroy(frag->msg_header.saved_retransmit_state.write_hash);
222+
}
217223
if (frag->fragment) OPENSSL_free(frag->fragment);
218224
if (frag->reassembly) OPENSSL_free(frag->reassembly);
219225
OPENSSL_free(frag);

ssl/ssl_locl.h

+2
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,8 @@ extern SSL3_ENC_METHOD TLSv1_enc_data;
621621
extern SSL3_ENC_METHOD SSLv3_enc_data;
622622
extern SSL3_ENC_METHOD DTLSv1_enc_data;
623623

624+
#define SSL_IS_DTLS(s) (s->method->version == DTLS1_VERSION)
625+
624626
#define IMPLEMENT_tls_meth_func(version, func_name, s_accept, s_connect, \
625627
s_get_meth) \
626628
const SSL_METHOD *func_name(void) \

ssl/t1_enc.c

+11-6
Original file line numberDiff line numberDiff line change
@@ -414,15 +414,20 @@ int tls1_change_cipher_state(SSL *s, int which)
414414
s->mac_flags |= SSL_MAC_FLAG_WRITE_MAC_STREAM;
415415
else
416416
s->mac_flags &= ~SSL_MAC_FLAG_WRITE_MAC_STREAM;
417-
if (s->enc_write_ctx != NULL)
417+
if (s->enc_write_ctx != NULL && !SSL_IS_DTLS(s))
418418
reuse_dd = 1;
419-
else if ((s->enc_write_ctx=OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL)
419+
else if ((s->enc_write_ctx=EVP_CIPHER_CTX_new()) == NULL)
420420
goto err;
421-
else
422-
/* make sure it's intialized in case we exit later with an error */
423-
EVP_CIPHER_CTX_init(s->enc_write_ctx);
424421
dd= s->enc_write_ctx;
425-
mac_ctx = ssl_replace_hash(&s->write_hash,NULL);
422+
if (SSL_IS_DTLS(s))
423+
{
424+
mac_ctx = EVP_MD_CTX_create();
425+
if (!mac_ctx)
426+
goto err;
427+
s->write_hash = mac_ctx;
428+
}
429+
else
430+
mac_ctx = ssl_replace_hash(&s->write_hash,NULL);
426431
#ifndef OPENSSL_NO_COMP
427432
if (s->compress != NULL)
428433
{

0 commit comments

Comments
 (0)