ssl/s3_cbc.c: uint64_t portability fix.
authorAndy Polyakov <appro@openssl.org>
Fri, 1 Feb 2013 08:55:43 +0000 (09:55 +0100)
committerAndy Polyakov <appro@openssl.org>
Fri, 1 Feb 2013 09:31:23 +0000 (10:31 +0100)
Break dependency on uint64_t. It's possible to declare bits as
unsigned int, because TLS packets are limited in size and 32-bit
value can't overflow.

ssl/s3_cbc.c

index 58da5012705ca2fb785388b8531dc9a998e9c1e1..694bf374d24a4c052054dcd117f5bf5a727c67a5 100644 (file)
@@ -53,8 +53,6 @@
  *
  */
 
-#include <stdint.h>
-
 #include "ssl_locl.h"
 
 #include <openssl/md5.h>
@@ -424,7 +422,7 @@ void ssl3_cbc_digest_record(
        unsigned sslv3_pad_length = 40, header_length, variance_blocks,
                 len, max_mac_bytes, num_blocks,
                 num_starting_blocks, k, mac_end_offset, c, index_a, index_b;
-       uint64_t bits;
+       unsigned int bits;      /* at most 18 bits */
        unsigned char length_bytes[MAX_HASH_BIT_COUNT_BYTES];
        /* hmac_pad is the masked HMAC key. */
        unsigned char hmac_pad[MAX_HASH_BLOCK_SIZE];
@@ -584,14 +582,11 @@ void ssl3_cbc_digest_record(
                md_transform(md_state, hmac_pad);
                }
 
-       j = 0;
-       if (md_length_size == 16)
-               {
-               memset(length_bytes, 0, 8);
-               j = 8;
-               }
-       for (i = 0; i < 8; i++)
-               length_bytes[i+j] = bits >> (8*(7-i));
+       memset(length_bytes,0,md_length_size-4);
+       length_bytes[md_length_size-4] = (unsigned char)(bits>>24);
+       length_bytes[md_length_size-3] = (unsigned char)(bits>>16);
+       length_bytes[md_length_size-2] = (unsigned char)(bits>>8);
+       length_bytes[md_length_size-1] = (unsigned char)bits;
 
        if (k > 0)
                {