diff mbox

[10/10] Remove os_random() as it makes use of a weak PRNG, having previously refactored all its callers to use os_get_random(…) instead

Message ID CAGnO3dr31=TZLhQzHoG4QOOs3C6yiJD8F6YLZHaX4Ek7qKKB0Q@mail.gmail.com
State Deferred
Headers show

Commit Message

Nick Lowe Feb. 14, 2016, 7:43 p.m. UTC
Remove os_random() as it makes use of a weak PRNG, having previously
refactored all its callers to use os_get_random(…) instead. We should
avoid using this outright unless there is a compelling performance
justification to retain it. Such a justification does not exist for
the hostapd/wpa_supplicant. When marginal, insignificant performance
gains are equated against the benefit of removing a function that can
be subtly dangerous, we should err on the side of caution.

Signed-off-by: Nick Lowe <nick.lowe@lugatech.com>
---
 src/utils/os.h          | 6 ------
 src/utils/os_internal.c | 6 ------
 src/utils/os_none.c     | 6 ------
 src/utils/os_unix.c     | 6 ------
 src/utils/os_win32.c    | 7 -------
 5 files changed, 31 deletions(-)
diff mbox

Patch

From 2acbbed9c111e4bd4272419fe31c2bdccdab0851 Mon Sep 17 00:00:00 2001
From: Nick Lowe <nick.lowe@lugatech.com>
Date: Tue, 9 Feb 2016 16:18:39 +0000
Subject: [PATCH 10/10] Remove os_random() as it makes use of a weak
PRNG, having previously refactored all its callers to use
os_get_random(…) instead. We should avoid using this outright unless
there is a compelling performance justification to retain it. Such a
justification does not exist for the hostapd/wpa_supplicant. When
marginal, insignificant performance gains are equated against the
benefit of removing a function that can be subtly dangerous, we should
err on the side of caution.

Signed-off-by: Nick Lowe <nick.lowe@lugatech.com>
---
 src/utils/os.h          | 6 ------
 src/utils/os_internal.c | 6 ------
 src/utils/os_none.c     | 6 ------
 src/utils/os_unix.c     | 6 ------
 src/utils/os_win32.c    | 7 -------
 5 files changed, 31 deletions(-)

diff --git a/src/utils/os.h b/src/utils/os.h
index 9e496fb..08c97e0 100644
--- a/src/utils/os.h
+++ b/src/utils/os.h
@@ -165,12 +165,6 @@  void os_daemonize_terminate(const char *pid_file);
 int os_get_random(unsigned char *buf, size_t len);
 
 /**
- * os_random - Get pseudo random value (not necessarily very strong)
- * Returns: Pseudo random value
- */
-unsigned long os_random(void);
-
-/**
  * os_rel2abs_path - Get an absolute path for a file
  * @rel_path: Relative path to a file
  * Returns: Absolute path for the file or %NULL on failure
diff --git a/src/utils/os_internal.c b/src/utils/os_internal.c
index ed6eb3c..06b4e7f 100644
--- a/src/utils/os_internal.c
+++ b/src/utils/os_internal.c
@@ -139,12 +139,6 @@  int os_get_random(unsigned char *buf, size_t len)
 }
 
 
-unsigned long os_random(void)
-{
-	return random();
-}
-
-
 char * os_rel2abs_path(const char *rel_path)
 {
 	char *buf = NULL, *cwd, *ret;
diff --git a/src/utils/os_none.c b/src/utils/os_none.c
index 0c3214d..523292f 100644
--- a/src/utils/os_none.c
+++ b/src/utils/os_none.c
@@ -61,12 +61,6 @@  int os_get_random(unsigned char *buf, size_t len)
 }
 
 
-unsigned long os_random(void)
-{
-	return 0;
-}
-
-
 char * os_rel2abs_path(const char *rel_path)
 {
 	return NULL; /* strdup(rel_path) can be used here */
diff --git a/src/utils/os_unix.c b/src/utils/os_unix.c
index 8f8dc5b..3ae5f8f 100644
--- a/src/utils/os_unix.c
+++ b/src/utils/os_unix.c
@@ -266,12 +266,6 @@  int os_get_random(unsigned char *buf, size_t len)
 }
 
 
-unsigned long os_random(void)
-{
-	return random();
-}
-
-
 char * os_rel2abs_path(const char *rel_path)
 {
 	char *buf = NULL, *cwd, *ret;
diff --git a/src/utils/os_win32.c b/src/utils/os_win32.c
index dea27b9..6adcaf0 100644
--- a/src/utils/os_win32.c
+++ b/src/utils/os_win32.c
@@ -144,13 +144,6 @@  int os_get_random(unsigned char *buf, size_t len)
 	return ret ? 0 : -1;
 }
 
-
-unsigned long os_random(void)
-{
-	return rand();
-}
-
-
 char * os_rel2abs_path(const char *rel_path)
 {
 	return _strdup(rel_path);
-- 
2.5.0