Parcourir la source

qcacld-3.0: Replace cds_rand_get_bytes()

The functionality provided by cds_rand_get_bytes() replicates
functionality provided by qdf_get_random_bytes(), so use
qdf_get_random_bytes().

Change-Id: I0b855556c9a9861c7067dfadaf0b8a4cdaf8709e
CRs-Fixed: 2366960
Jeff Johnson il y a 6 ans
Parent
commit
51a8052b29

+ 0 - 16
core/cds/inc/cds_utils.h

@@ -105,22 +105,6 @@ QDF_STATUS cds_crypto_init(uint32_t *phCryptProv);
 
 QDF_STATUS cds_crypto_deinit(uint32_t hCryptProv);
 
-/**
- * cds_rand_get_bytes
-
- * FUNCTION:
- * Returns cryptographically secure pseudo-random bytes.
- *
- *
- * @param pbBuf - the caller allocated location where the bytes should be copied
- * @param numBytes the number of bytes that should be generated and
- * copied
- *
- * @return QDF_STATUS_SUCCSS if the operation succeeds
- */
-QDF_STATUS cds_rand_get_bytes(uint32_t handle, uint8_t *pbBuf,
-			      uint32_t numBytes);
-
 uint32_t cds_chan_to_freq(uint8_t chan);
 uint8_t cds_freq_to_chan(uint32_t freq);
 enum cds_band_type cds_chan_to_band(uint32_t chan);

+ 0 - 43
core/cds/src/cds_utils.c

@@ -223,49 +223,6 @@ QDF_STATUS cds_crypto_deinit(uint32_t hCryptProv)
 	return uResult;
 }
 
-/*--------------------------------------------------------------------------
-
-   \brief cds_rand_get_bytes() - Generates random byte
-
-   The cds_rand_get_bytes() function generate random bytes.
-
-   Buffer should be allocated before calling cds_rand_get_bytes().
-
-   Attempting to initialize an already initialized lock results in
-   a failure.
-
-   \param lock - pointer to the opaque lock object to initialize
-
-   \return QDF_STATUS_SUCCESS - Successfully generated random memory.
-
-   QDF_STATUS_E_FAULT  - pbBuf is an invalid pointer.
-
-   QDF_STATUS_E_FAILURE - default return value if it fails due to
-   unknown reasons
-
-  ***QDF_STATUS_E_RESOURCES - System resources (other than memory)
-  are unavailable
-   \sa
-
-    ( *** return value not considered yet )
-   --------------------------------------------------------------------------*/
-QDF_STATUS
-cds_rand_get_bytes(uint32_t cryptHandle, uint8_t *pbBuf, uint32_t numBytes)
-{
-	QDF_STATUS uResult = QDF_STATUS_E_FAILURE;
-
-	/* check for invalid pointer */
-	if (NULL == pbBuf) {
-		uResult = QDF_STATUS_E_FAULT;
-		return uResult;
-	}
-
-	get_random_bytes(pbBuf, numBytes);
-	/* "Random sequence generated." */
-	uResult = QDF_STATUS_SUCCESS;
-	return uResult;
-}
-
 #ifdef WLAN_FEATURE_11W
 uint8_t cds_get_mmie_size(void)
 {

+ 1 - 1
core/hdd/src/wlan_hdd_main.c

@@ -10461,7 +10461,7 @@ static int hdd_initialize_mac_address(struct hdd_context *hdd_ctx)
 		struct qdf_mac_addr mac_addr;
 
 		hdd_err("MAC failure from device serial no.");
-		cds_rand_get_bytes(0, (uint8_t *)(&mac_addr), sizeof(mac_addr));
+		qdf_get_random_bytes(&mac_addr, sizeof(mac_addr));
 		/*
 		 * Reset multicast bit (bit-0) and set
 		 * locally-administered bit

+ 3 - 3
core/hdd/src/wlan_hdd_nan_datapath.c

@@ -39,6 +39,7 @@
 #include "nan_public_structs.h"
 #include "cfg_nan_api.h"
 #include "wlan_mlme_ucfg_api.h"
+#include "qdf_util.h"
 
 /**
  * hdd_nan_datapath_target_config() - Configure NAN datapath features
@@ -252,7 +253,7 @@ static int hdd_get_random_nan_mac_addr(struct hdd_context *hdd_ctx,
 			hdd_debug("NDI already exists, deriving next mac");
 			qdf_mem_copy(mac_addr, &adapter->mac_addr,
 				     sizeof(*mac_addr));
-			cds_rand_get_bytes(0, &pos, sizeof(pos));
+			qdf_get_random_bytes(&pos, sizeof(pos));
 			/* skipping byte 0, 5 leaves 8*4=32 positions */
 			pos = pos % 32;
 			bit_pos = pos % 8;
@@ -261,8 +262,7 @@ static int hdd_get_random_nan_mac_addr(struct hdd_context *hdd_ctx,
 			/* flip the required bit */
 			mac_addr->bytes[byte_pos + 1] ^= mask;
 		} else {
-			cds_rand_get_bytes(0, (uint8_t *)mac_addr,
-					   sizeof(*mac_addr));
+			qdf_get_random_bytes(mac_addr, sizeof(*mac_addr));
 			/*
 			 * Reset multicast bit (bit-0) and set
 			 * locally-administered bit

+ 3 - 2
core/mac/src/pe/lim/lim_process_fils.c

@@ -25,6 +25,7 @@
 #include <lim_session.h>
 #include <cds_ieee80211_defines.h>
 #include <qdf_crypto.h>
+#include "qdf_util.h"
 
 #ifdef WLAN_FEATURE_FILS_SK
 
@@ -1007,7 +1008,7 @@ void lim_add_fils_data_to_auth_frame(struct pe_session *session,
 	*body = SIR_FILS_NONCE_EXT_EID;
 	body++;
 	/* Add data */
-	cds_rand_get_bytes(0, fils_info->fils_nonce, SIR_FILS_NONCE_LENGTH);
+	qdf_get_random_bytes(fils_info->fils_nonce, SIR_FILS_NONCE_LENGTH);
 	qdf_mem_copy(body, fils_info->fils_nonce, SIR_FILS_NONCE_LENGTH);
 	body = body + SIR_FILS_NONCE_LENGTH;
 	/* Dump data */
@@ -1025,7 +1026,7 @@ void lim_add_fils_data_to_auth_frame(struct pe_session *session,
 	*body = SIR_FILS_SESSION_EXT_EID;
 	body++;
 	/* Add data */
-	cds_rand_get_bytes(0, fils_info->fils_session, SIR_FILS_SESSION_LENGTH);
+	qdf_get_random_bytes(fils_info->fils_session, SIR_FILS_SESSION_LENGTH);
 	qdf_mem_copy(body, fils_info->fils_session, SIR_FILS_SESSION_LENGTH);
 	body = body + SIR_FILS_SESSION_LENGTH;
 	/* dump data */

+ 2 - 1
core/mac/src/pe/lim/lim_utils.c

@@ -65,6 +65,7 @@
 #include "cfg_ucfg_api.h"
 #include "lim_ft.h"
 #include "wlan_mlme_main.h"
+#include "qdf_util.h"
 
 #define ASCII_SPACE_CHARACTER 0x20
 
@@ -7006,7 +7007,7 @@ void lim_decide_he_op(struct mac_context *mac_ctx, tpAddBssParams add_bss,
 	if (he_ops_from_ie->bss_color) {
 		he_ops->bss_color = he_ops_from_ie->bss_color;
 	} else {
-		cds_rand_get_bytes(0, &color, 1);
+		qdf_get_random_bytes(&color, sizeof(color));
 		/* make sure color is within 1-63*/
 		he_ops->bss_color = (color % WNI_CFG_HE_OPS_BSS_COLOR_MAX) + 1;
 	}