|
|
@@ -732,24 +732,30 @@ int ssl3_release_read_buffer(SSL *s) |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
/* Fill a ClientRandom or ServerRandom field of length len. Returns 0 |
|
|
|
* on failure, 1 on success. */ |
|
|
|
int ssl_fill_hello_random(SSL *s, int server, unsigned char *result, int 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 = (unsigned long)time(NULL); |
|
|
|
unsigned char *p = result; |
|
|
|
l2n(Time, p); |
|
|
|
return RAND_bytes(p, len-4); |
|
|
|
} |
|
|
|
else |
|
|
|
return RAND_bytes(result, len); |
|
|
|
} |
|
|
|
/* ssl_fill_hello_random fills a client_random or server_random field of length |
|
|
|
* |len|. Returns 0 on failure or 1 on success. */ |
|
|
|
int ssl_fill_hello_random(SSL *s, int server, uint8_t *result, size_t len) { |
|
|
|
int send_time = 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) { |
|
|
|
const uint32_t current_time = time(NULL); |
|
|
|
uint8_t *p = result; |
|
|
|
|
|
|
|
if (len < 4) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
p[0] = current_time >> 24; |
|
|
|
p[1] = current_time >> 16; |
|
|
|
p[2] = current_time >> 8; |
|
|
|
p[3] = current_time; |
|
|
|
return RAND_bytes(p + 4, len - 4); |
|
|
|
} else { |
|
|
|
return RAND_bytes(result, len); |
|
|
|
} |
|
|
|
} |