summaryrefslogtreecommitdiff
path: root/src/lib/libssl/ssl_lib.c
diff options
context:
space:
mode:
authorjsing <>2014-10-18 16:13:16 +0000
committerjsing <>2014-10-18 16:13:16 +0000
commitc7ab256a26b40c83b42c202488c01636a208c01c (patch)
tree0ec0407532b236ff11b9134f214f8db715d84e63 /src/lib/libssl/ssl_lib.c
parentdd127b6b5a62ebd88f0cbb2e6d7d749d20363a16 (diff)
downloadopenbsd-c7ab256a26b40c83b42c202488c01636a208c01c.tar.gz
openbsd-c7ab256a26b40c83b42c202488c01636a208c01c.tar.bz2
openbsd-c7ab256a26b40c83b42c202488c01636a208c01c.zip
Use arc4random_buf() instead of RAND_bytes() or RAND_pseudo_bytes().
arc4random provides high quality pseudo-random numbers, hence there is no need to differentiate between "strong" and "pseudo". Furthermore, the arc4random_buf() function is guaranteed to succeed, which avoids the need to check for and handle failure, simplifying the code. It is worth noting that a number of the replaced RAND_bytes() and RAND_pseudo_bytes() calls were missing return value checks and these functions can fail for a number of reasons (at least in OpenSSL - thankfully they were converted to wrappers around arc4random_buf() some time ago in LibreSSL). ok beck@ deraadt@ miod@
Diffstat (limited to '')
-rw-r--r--src/lib/libssl/ssl_lib.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c
index d3108f2663..3fa8f5039f 100644
--- a/src/lib/libssl/ssl_lib.c
+++ b/src/lib/libssl/ssl_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_lib.c,v 1.86 2014/10/15 17:39:34 jsing Exp $ */ 1/* $OpenBSD: ssl_lib.c,v 1.87 2014/10/18 16:13:16 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -145,7 +145,6 @@
145#include <openssl/objects.h> 145#include <openssl/objects.h>
146#include <openssl/lhash.h> 146#include <openssl/lhash.h>
147#include <openssl/x509v3.h> 147#include <openssl/x509v3.h>
148#include <openssl/rand.h>
149#include <openssl/ocsp.h> 148#include <openssl/ocsp.h>
150#include <openssl/dh.h> 149#include <openssl/dh.h>
151#ifndef OPENSSL_NO_ENGINE 150#ifndef OPENSSL_NO_ENGINE
@@ -1786,11 +1785,11 @@ SSL_CTX_new(const SSL_METHOD *meth)
1786 1785
1787 ret->tlsext_servername_callback = 0; 1786 ret->tlsext_servername_callback = 0;
1788 ret->tlsext_servername_arg = NULL; 1787 ret->tlsext_servername_arg = NULL;
1788
1789 /* Setup RFC4507 ticket keys */ 1789 /* Setup RFC4507 ticket keys */
1790 if ((RAND_pseudo_bytes(ret->tlsext_tick_key_name, 16) <= 0) 1790 arc4random_buf(ret->tlsext_tick_key_name, 16);
1791 || (RAND_bytes(ret->tlsext_tick_hmac_key, 16) <= 0) 1791 arc4random_buf(ret->tlsext_tick_hmac_key, 16);
1792 || (RAND_bytes(ret->tlsext_tick_aes_key, 16) <= 0)) 1792 arc4random_buf(ret->tlsext_tick_aes_key, 16);
1793 ret->options |= SSL_OP_NO_TICKET;
1794 1793
1795 ret->tlsext_status_cb = 0; 1794 ret->tlsext_status_cb = 0;
1796 ret->tlsext_status_arg = NULL; 1795 ret->tlsext_status_arg = NULL;