Various review fixes for PSK early_data support
[openssl.git] / ssl / record / ssl3_record_tls13.c
index 0c3fc6b..696cc37 100644 (file)
@@ -58,10 +58,14 @@ int tls13_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int sending)
 
     if (s->early_data_state == SSL_EARLY_DATA_WRITING
             || s->early_data_state == SSL_EARLY_DATA_WRITE_RETRY) {
-        if (s->session != NULL && s->session->ext.max_early_data > 0)
+        if (s->session != NULL && s->session->ext.max_early_data > 0) {
             alg_enc = s->session->cipher->algorithm_enc;
-        else
+        } else {
+            if (!ossl_assert(s->psksession != NULL
+                             && s->psksession->ext.max_early_data > 0))
+                return -1;
             alg_enc = s->psksession->cipher->algorithm_enc;
+        }
     } else {
         /*
          * To get here we must have selected a ciphersuite - otherwise ctx would