Fix minor compiler issues.
authorTodd Short <tshort@akamai.com>
Thu, 13 Apr 2017 14:20:04 +0000 (10:20 -0400)
committerRich Salz <rsalz@openssl.org>
Wed, 19 Apr 2017 16:51:08 +0000 (12:51 -0400)
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3220)

ssl/record/ssl3_record_tls13.c
ssl/statem/extensions_srvr.c
ssl/statem/statem.c
ssl/tls13_enc.c
test/bad_dtls_test.c

index c6ea511b4d22b314b31ef73d670e55599b4e240d..9e65852f9d4899776e6103df0bddcce656370566 100644 (file)
@@ -21,7 +21,7 @@
  *   -1: if the record's AEAD-authenticator is invalid or, if sending,
  *       an internal error occurred.
  */
-int tls13_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
+int tls13_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int sending)
 {
     EVP_CIPHER_CTX *ctx;
     unsigned char iv[EVP_MAX_IV_LENGTH];
@@ -38,7 +38,7 @@ int tls13_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
         return -1;
     }
 
-    if (send) {
+    if (sending) {
         ctx = s->enc_write_ctx;
         staticiv = s->write_iv;
         seq = RECORD_LAYER_get_write_sequence(&s->rlayer);
@@ -75,7 +75,7 @@ int tls13_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
             taglen = EVP_CCM8_TLS_TAG_LEN;
          else
             taglen = EVP_CCM_TLS_TAG_LEN;
-         if (send && EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, taglen,
+         if (sending && EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, taglen,
                                          NULL) <= 0)
             return -1;
     } else if (alg_enc & SSL_AESGCM) {
@@ -86,7 +86,7 @@ int tls13_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
         return -1;
     }
 
-    if (!send) {
+    if (!sending) {
         /*
          * Take off tag. There must be at least one byte of content type as
          * well as the tag
@@ -118,8 +118,8 @@ int tls13_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
     }
 
     /* TODO(size_t): lenu/lenf should be a size_t but EVP doesn't support it */
-    if (EVP_CipherInit_ex(ctx, NULL, NULL, NULL, iv, send) <= 0
-            || (!send && EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG,
+    if (EVP_CipherInit_ex(ctx, NULL, NULL, NULL, iv, sending) <= 0
+            || (!sending && EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG,
                                              taglen,
                                              rec->data + rec->length) <= 0)
             || EVP_CipherUpdate(ctx, rec->data, &lenu, rec->input,
@@ -128,7 +128,7 @@ int tls13_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
             || (size_t)(lenu + lenf) != rec->length) {
         return -1;
     }
-    if (send) {
+    if (sending) {
         /* Add the tag */
         if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, taglen,
                                 rec->data + rec->length) <= 0)
index da7e8c8aa053132c45904db05e570956ca78776b..7ba1aac8d4a966d4e354fcdd53de3745808faeb1 100644 (file)
@@ -780,7 +780,7 @@ int tls_parse_ctos_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
      * client's due to the network latency). Therefore we add 1000ms to our age
      * calculation to adjust for rounding errors.
      */
-    if (sess->timeout >= agesec
+    if (sess->timeout >= (long)agesec
             && agems / (uint32_t)1000 == agesec
             && ticket_age <= agems + 1000
             && ticket_age + TICKET_AGE_ALLOWANCE >= agems + 1000) {
index 92a0e8f1ec7e6be9a7bc5f1e185047532e3acf04..e63d0ada0b0c1f780208ffedc2e51ba03786c10d 100644 (file)
@@ -172,13 +172,13 @@ int ossl_statem_skip_early_data(SSL *s)
  * Called when we are in SSL_read*(), SSL_write*(), or SSL_accept()
  * /SSL_connect()/SSL_do_handshake(). Used to test whether we are in an early
  * data state and whether we should attempt to move the handshake on if so.
- * |send| is 1 if we are attempting to send data (SSL_write*()), 0 if we are
+ * |sending| is 1 if we are attempting to send data (SSL_write*()), 0 if we are
  * attempting to read data (SSL_read*()), or -1 if we are in SSL_do_handshake()
  * or similar.
  */
-void ossl_statem_check_finish_init(SSL *s, int send)
+void ossl_statem_check_finish_init(SSL *s, int sending)
 {
-    if (send == -1) {
+    if (sending == -1) {
         if (s->statem.hand_state == TLS_ST_PENDING_EARLY_DATA_END
                 || s->statem.hand_state == TLS_ST_EARLY_DATA) {
             ossl_statem_set_in_init(s, 1);
@@ -191,16 +191,16 @@ void ossl_statem_check_finish_init(SSL *s, int send)
             }
         }
     } else if (!s->server) {
-        if ((send && (s->statem.hand_state == TLS_ST_PENDING_EARLY_DATA_END
+        if ((sending && (s->statem.hand_state == TLS_ST_PENDING_EARLY_DATA_END
                       || s->statem.hand_state == TLS_ST_EARLY_DATA)
                   && s->early_data_state != SSL_EARLY_DATA_WRITING)
-                || (!send && s->statem.hand_state == TLS_ST_EARLY_DATA)) {
+                || (!sending && s->statem.hand_state == TLS_ST_EARLY_DATA)) {
             ossl_statem_set_in_init(s, 1);
             /*
              * SSL_write() has been called directly. We don't allow any more
              * writing of early data.
              */
-            if (send && s->early_data_state == SSL_EARLY_DATA_WRITE_RETRY)
+            if (sending && s->early_data_state == SSL_EARLY_DATA_WRITE_RETRY)
                 s->early_data_state = SSL_EARLY_DATA_FINISHED_WRITING;
         }
     } else {
index 2ae45528433857411d8547b9e1b15d6a3f19dd64..9030d1a2924d321f5b766266d6ccc2302316f75d 100644 (file)
@@ -267,7 +267,7 @@ int tls13_setup_key_block(SSL *s)
     return 1;
 }
 
-static int derive_secret_key_and_iv(SSL *s, int send, const EVP_MD *md,
+static int derive_secret_key_and_iv(SSL *s, int sending, const EVP_MD *md,
                                     const EVP_CIPHER *ciph,
                                     const unsigned char *insecret,
                                     const unsigned char *hash,
@@ -312,7 +312,7 @@ static int derive_secret_key_and_iv(SSL *s, int send, const EVP_MD *md,
         goto err;
     }
 
-    if (EVP_CipherInit_ex(ciph_ctx, ciph, NULL, NULL, NULL, send) <= 0
+    if (EVP_CipherInit_ex(ciph_ctx, ciph, NULL, NULL, NULL, sending) <= 0
         || !EVP_CIPHER_CTX_ctrl(ciph_ctx, EVP_CTRL_AEAD_SET_IVLEN, ivlen, NULL)
         || (taglen != 0 && !EVP_CIPHER_CTX_ctrl(ciph_ctx, EVP_CTRL_AEAD_SET_TAG,
                                                 taglen, NULL))
@@ -323,7 +323,7 @@ static int derive_secret_key_and_iv(SSL *s, int send, const EVP_MD *md,
 
 #ifdef OPENSSL_SSL_TRACE_CRYPTO
     if (s->msg_callback) {
-        int wh = send ? TLS1_RT_CRYPTO_WRITE : 0;
+        int wh = sending ? TLS1_RT_CRYPTO_WRITE : 0;
 
         if (ciph->key_len)
             s->msg_callback(2, s->version, wh | TLS1_RT_CRYPTO_KEY,
@@ -557,7 +557,7 @@ int tls13_change_cipher_state(SSL *s, int which)
     return ret;
 }
 
-int tls13_update_key(SSL *s, int send)
+int tls13_update_key(SSL *s, int sending)
 {
     static const unsigned char application_traffic[] =
         "application traffic secret";
@@ -568,12 +568,12 @@ int tls13_update_key(SSL *s, int send)
     EVP_CIPHER_CTX *ciph_ctx;
     int ret = 0;
 
-    if (s->server == send)
+    if (s->server == sending)
         insecret = s->server_app_traffic_secret;
     else
         insecret = s->client_app_traffic_secret;
 
-    if (send) {
+    if (sending) {
         iv = s->write_iv;
         ciph_ctx = s->enc_write_ctx;
         RECORD_LAYER_reset_write_sequence(&s->rlayer);
@@ -583,7 +583,7 @@ int tls13_update_key(SSL *s, int send)
         RECORD_LAYER_reset_read_sequence(&s->rlayer);
     }
 
-    if (!derive_secret_key_and_iv(s, send, ssl_handshake_md(s),
+    if (!derive_secret_key_and_iv(s, sending, ssl_handshake_md(s),
                                   s->s3->tmp.new_sym_enc, insecret, NULL,
                                   application_traffic,
                                   sizeof(application_traffic) - 1, secret, iv,
index 43733e97b16ce325c1967aa7ab692cac972da4f3..0bfbebf7e16795591163c08a21c12d0460df9f63 100644 (file)
@@ -548,8 +548,8 @@ static int test_bad_dtls(void)
 
         if (!TEST_true(send_record(rbio, SSL3_RT_APPLICATION_DATA, tests[i].seq,
                                    &tests[i].seq, sizeof(uint64_t)))) {
-            TEST_error("Failed to send data seq #0x%lx (%d)\n",
-                       tests[i].seq, i);
+            TEST_error("Failed to send data seq #0x%x%08x (%d)\n",
+                       (unsigned int)(tests[i].seq >> 32), (unsigned int)tests[i].seq, i);
             goto end;
         }
 
@@ -558,8 +558,8 @@ static int test_bad_dtls(void)
 
         ret = SSL_read(con, recv_buf, 2 * sizeof(uint64_t));
         if (!TEST_int_eq(ret, (int)sizeof(uint64_t))) {
-            TEST_error("SSL_read failed or wrong size on seq#0x%lx (%d)\n",
-                       tests[i].seq, i);
+            TEST_error("SSL_read failed or wrong size on seq#0x%x%08x (%d)\n",
+                       (unsigned int)(tests[i].seq >> 32), (unsigned int)tests[i].seq, i);
             goto end;
         }
         if (!TEST_true(recv_buf[0] == tests[i].seq))