Control sending time with SSL_SEND_{CLIENT,SERVER}RANDOM_MODE
authorNick Mathewson <nickm@torproject.org>
Wed, 9 Oct 2013 14:37:53 +0000 (10:37 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 9 Oct 2013 14:37:53 +0000 (10:37 -0400)
(I'd rather use an option, but it appears that the options field is
full.)

Now, we send the time in the gmt_unix_time field if the appropriate
one of these mode options is set, but randomize the field if the flag
is not set.

ssl/s23_clnt.c
ssl/ssl.h

index 01e492adfbd48c8751554c110e836b2d51a37187..65d2c26ad2844a01a3110489144bd693be854baf 100644 (file)
@@ -273,7 +273,22 @@ static int ssl23_no_ssl2_ciphers(SSL *s)
  * on failure, 1 on success. */
 int ssl_fill_hello_random(SSL *s, int server, unsigned char *result, int len)
        {
-       return RAND_pseudo_bytes(result, len);
+       int send_time = 0;
+       if (len < 4)
+               return 0;
+       if (server)
+               send_time = (s->mode & SSL_MODE_SEND_SERVERHELLO_TIME) != 0;
+       else
+               send_time = (s->mode & SSL_MODE_SEND_CLIENTHELLO_TIME) != 0;
+       if (send_time)
+               {
+               unsigned long Time = time(NULL);
+               unsigned char *p = result;
+               l2n(Time, p);
+               return RAND_pseudo_bytes(p, len-4);
+               }
+       else
+               return RAND_pseudo_bytes(result, len);
        }
 
 static int ssl23_client_hello(SSL *s)
index 593579ed367082609bece19734eb95b8a6763cb9..ae852bf011668c4909e61b4330fec783ccc97d6d 100644 (file)
--- a/ssl/ssl.h
+++ b/ssl/ssl.h
@@ -641,6 +641,12 @@ struct ssl_session_st
  * TLS only.)  "Released" buffers are put onto a free-list in the context
  * or just freed (depending on the context's setting for freelist_max_len). */
 #define SSL_MODE_RELEASE_BUFFERS 0x00000010L
+/* Send the current time in the Random fields of the ClientHello and
+ * ServerHello records for compatibility with hypothetical implementations
+ * that require it.
+ */
+#define SSL_MODE_SEND_CLIENTHELLO_TIME 0x00000020L
+#define SSL_MODE_SEND_SERVERHELLO_TIME 0x00000040L
 
 /* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value,
  * they cannot be used to clear bits. */