summaryrefslogtreecommitdiff
path: root/src/lib/libssl/ssl_sess.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_sess.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_sess.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/lib/libssl/ssl_sess.c b/src/lib/libssl/ssl_sess.c
index 3ffd7078a5..d76fb8b9c8 100644
--- a/src/lib/libssl/ssl_sess.c
+++ b/src/lib/libssl/ssl_sess.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_sess.c,v 1.41 2014/09/22 14:26:22 jsing Exp $ */ 1/* $OpenBSD: ssl_sess.c,v 1.42 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 *
@@ -136,7 +136,6 @@
136 */ 136 */
137 137
138#include <openssl/lhash.h> 138#include <openssl/lhash.h>
139#include <openssl/rand.h>
140 139
141#ifndef OPENSSL_NO_ENGINE 140#ifndef OPENSSL_NO_ENGINE
142#include <openssl/engine.h> 141#include <openssl/engine.h>
@@ -258,8 +257,7 @@ def_generate_session_id(const SSL *ssl, unsigned char *id, unsigned int *id_len)
258 unsigned int retry = 0; 257 unsigned int retry = 0;
259 258
260 do { 259 do {
261 if (RAND_pseudo_bytes(id, *id_len) <= 0) 260 arc4random_buf(id, *id_len);
262 return 0;
263 } while (SSL_has_matching_session_id(ssl, id, *id_len) && 261 } while (SSL_has_matching_session_id(ssl, id, *id_len) &&
264 (++retry < MAX_SESS_ID_ATTEMPTS)); 262 (++retry < MAX_SESS_ID_ATTEMPTS));
265 263