EVP_CIPHER_CTX_set_keylen should not succeed if a bad keylen is passed
[openssl.git] / ssl / d1_msg.c
index a8253b940417ec0c4e252409ea5db604199ac2ce..96741efd7cea787f68edebbf14ba81a0ebb9db31 100644 (file)
@@ -1,35 +1,23 @@
 /*
  * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved.
  *
- * Licensed under the OpenSSL license (the "License").  You may not use
+ * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
  * in the file LICENSE in the source distribution or at
  * https://www.openssl.org/source/license.html
  */
 
-#define USE_SOCKETS
-#include "ssl_locl.h"
+#include "ssl_local.h"
 
 int dtls1_write_app_data_bytes(SSL *s, int type, const void *buf_, size_t len,
                                size_t *written)
 {
     int i;
 
-#ifndef OPENSSL_NO_SCTP
-    /*
-     * Check if we have to continue an interrupted handshake for reading
-     * belated app data with SCTP.
-     */
-    if ((SSL_in_init(s) && !ossl_statem_get_in_handshake(s)) ||
-        (BIO_dgram_is_sctp(SSL_get_wbio(s)) &&
-         ossl_statem_in_sctp_read_sock(s)))
-#else
-    if (SSL_in_init(s) && !ossl_statem_get_in_handshake(s))
-#endif
-    {
+    if (SSL_in_init(s) && !ossl_statem_get_in_handshake(s)) {
         i = s->handshake_func(s);
         if (i < 0)
-            return (i);
+            return i;
         if (i == 0) {
             SSLerr(SSL_F_DTLS1_WRITE_APP_DATA_BYTES,
                    SSL_R_SSL_HANDSHAKE_FAILURE);
@@ -53,22 +41,21 @@ int dtls1_dispatch_alert(SSL *s)
     unsigned char *ptr = &buf[0];
     size_t written;
 
-    s->s3->alert_dispatch = 0;
+    s->s3.alert_dispatch = 0;
 
     memset(buf, 0, sizeof(buf));
-    *ptr++ = s->s3->send_alert[0];
-    *ptr++ = s->s3->send_alert[1];
+    *ptr++ = s->s3.send_alert[0];
+    *ptr++ = s->s3.send_alert[1];
 
     i = do_dtls1_write(s, SSL3_RT_ALERT, &buf[0], sizeof(buf), 0, &written);
     if (i <= 0) {
-        s->s3->alert_dispatch = 1;
+        s->s3.alert_dispatch = 1;
         /* fprintf( stderr, "not done with alert\n" ); */
     } else {
-        if (s->s3->send_alert[0] == SSL3_AL_FATAL)
-            (void)BIO_flush(s->wbio);
+        (void)BIO_flush(s->wbio);
 
         if (s->msg_callback)
-            s->msg_callback(1, s->version, SSL3_RT_ALERT, s->s3->send_alert,
+            s->msg_callback(1, s->version, SSL3_RT_ALERT, s->s3.send_alert,
                             2, s, s->msg_callback_arg);
 
         if (s->info_callback != NULL)
@@ -77,7 +64,7 @@ int dtls1_dispatch_alert(SSL *s)
             cb = s->ctx->info_callback;
 
         if (cb != NULL) {
-            j = (s->s3->send_alert[0] << 8) | s->s3->send_alert[1];
+            j = (s->s3.send_alert[0] << 8) | s->s3.send_alert[1];
             cb(s, SSL_CB_WRITE_ALERT, j);
         }
     }