summaryrefslogtreecommitdiffstats
path: root/ssl/s3_lib.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2015-03-31 13:57:46 +0100
committerMatt Caswell <matt@openssl.org>2015-05-16 09:20:38 +0100
commita3680c8f9c33d4190c367572645980ccdb9d5bbf (patch)
tree9f3d8c4400d5fe070f3ef3a306a42d34f10bf65c /ssl/s3_lib.c
parent13c9bb3ecec5f847b4c5295249e039d386e2d10e (diff)
Version negotiation rewrite cleanup
Following the version negotiation rewrite all of the previous code that was dedicated to version negotiation can now be deleted - all six source files of it!! Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Diffstat (limited to 'ssl/s3_lib.c')
-rw-r--r--ssl/s3_lib.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c
index d3265f676e..1a67e4ed2a 100644
--- a/ssl/s3_lib.c
+++ b/ssl/s3_lib.c
@@ -155,6 +155,7 @@
#ifndef OPENSSL_NO_DH
# include <openssl/dh.h>
#endif
+#include <openssl/rand.h>
const char ssl3_version_str[] = "SSLv3" OPENSSL_VERSION_PTEXT;
@@ -4238,3 +4239,26 @@ long ssl_get_algorithm2(SSL *s)
return SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256;
return alg2;
}
+
+/*
+ * 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);
+}