summaryrefslogtreecommitdiffstats
path: root/ssl/tls13_enc.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2017-02-23 12:25:21 +0000
committerMatt Caswell <matt@openssl.org>2017-03-02 17:44:15 +0000
commitc117af6765928f3fc61585b01f5d722162914d80 (patch)
tree676c5b33143cfba1e0a1b1b3e5a7a95b194abc67 /ssl/tls13_enc.c
parent576eb3958cbb18484680c0bbe7cbf2dce9af0f1b (diff)
Fix seg fault when sending early_data using CCM ciphersuites
Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2737)
Diffstat (limited to 'ssl/tls13_enc.c')
-rw-r--r--ssl/tls13_enc.c11
1 files 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;