From c117af6765928f3fc61585b01f5d722162914d80 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Thu, 23 Feb 2017 12:25:21 +0000 Subject: [PATCH] Fix seg fault when sending early_data using CCM ciphersuites Reviewed-by: Rich Salz (Merged from https://github.com/openssl/openssl/pull/2737) --- ssl/tls13_enc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ssl/tls13_enc.c b/ssl/tls13_enc.c index d42be60c67..db8de1d1ca 100644 --- a/ssl/tls13_enc.c +++ b/ssl/tls13_enc.c @@ -264,9 +264,16 @@ static int derive_secret_key_and_iv(SSL *s, int send, const EVP_MD *md, /* TODO(size_t): convert me */ keylen = EVP_CIPHER_key_length(ciph); if (EVP_CIPHER_mode(ciph) == EVP_CIPH_CCM_MODE) { + uint32_t algenc; + ivlen = EVP_CCM_TLS_IV_LEN; - if (s->s3->tmp.new_cipher->algorithm_enc - & (SSL_AES128CCM8 | SSL_AES256CCM8)) + if (s->s3->tmp.new_cipher == NULL) { + /* We've not selected a cipher yet - we must be doing early data */ + algenc = s->session->cipher->algorithm_enc; + } else { + algenc = s->s3->tmp.new_cipher->algorithm_enc; + } + if (algenc & (SSL_AES128CCM8 | SSL_AES256CCM8)) taglen = EVP_CCM8_TLS_TAG_LEN; else taglen = EVP_CCM_TLS_TAG_LEN; -- 2.25.1