random: remove rand32_timestamp.c
This is a copy of rand32_timer.c that uses z_do_read_cpu_timestamp32() instead of k_cycle_get_32(), with some logic to ensure different values when called in rapid succession missing. Like the other driver, its reported values are not random, it's a testing generator only. This appears to have no advantages over rand32_timer.c, just remove it. In QEMU emulation, the reported TSC values tend to have the lowest five bits zeroed. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
9f0acd44a4
commit
81cfb08f52
4 changed files with 0 additions and 82 deletions
|
@ -47,10 +47,6 @@ An override of the default value can be specified in the SOC or board
|
|||
|
||||
The random number generators available include:
|
||||
|
||||
:option:`CONFIG_X86_TSC_RANDOM_GENERATOR`
|
||||
enables number generator based on timestamp counter of x86 boards,
|
||||
obtained with rdtsc instruction.
|
||||
|
||||
:option:`CONFIG_TIMER_RANDOM_GENERATOR`
|
||||
enables number generator based on system timer clock. This number
|
||||
generator is not random and used for testing only.
|
||||
|
|
|
@ -2,13 +2,11 @@
|
|||
|
||||
if (CONFIG_ENTROPY_DEVICE_RANDOM_GENERATOR OR
|
||||
CONFIG_TIMER_RANDOM_GENERATOR OR
|
||||
CONFIG_X86_TSC_RANDOM_GENERATOR OR
|
||||
CONFIG_XOROSHIRO_RANDOM_GENERATOR)
|
||||
zephyr_library()
|
||||
endif()
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_TIMER_RANDOM_GENERATOR rand32_timer.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_X86_TSC_RANDOM_GENERATOR rand32_timestamp.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_XOROSHIRO_RANDOM_GENERATOR rand32_xoroshiro128.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_CTR_DRBG_CSPRNG_GENERATOR rand32_ctr_drbg.c)
|
||||
|
||||
|
|
|
@ -26,13 +26,6 @@ choice RNG_GENERATOR_CHOICE
|
|||
to support random request then select that. Otherwise, select the
|
||||
XOROSHIRO algorithm
|
||||
|
||||
config X86_TSC_RANDOM_GENERATOR
|
||||
bool "x86 timestamp counter based number generator"
|
||||
depends on TEST_RANDOM_GENERATOR && X86
|
||||
help
|
||||
This options enables number generator based on timestamp counter
|
||||
of x86 boards, obtained with rdtsc instruction.
|
||||
|
||||
config TIMER_RANDOM_GENERATOR
|
||||
bool "System timer clock based number generator"
|
||||
depends on TEST_RANDOM_GENERATOR
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2014 Wind River Systems, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Non-random number generator based on x86 CPU timestamp
|
||||
*
|
||||
* This module provides a non-random implementation of sys_rand32_get(), which
|
||||
* is not meant to be used in a final product as a truly random number
|
||||
* generator. It was provided to allow testing on a platform that does not (yet)
|
||||
* provide a random number generator.
|
||||
*/
|
||||
|
||||
#include <kernel.h>
|
||||
#include <arch/cpu.h>
|
||||
#include <random/rand32.h>
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Get a 32 bit random number
|
||||
*
|
||||
* The non-random number generator returns values that are based off the
|
||||
* CPU's timestamp counter, which means that successive calls will normally
|
||||
* display ever-increasing values.
|
||||
*
|
||||
* @return a 32-bit number
|
||||
*/
|
||||
|
||||
u32_t sys_rand32_get(void)
|
||||
{
|
||||
return z_do_read_cpu_timestamp32();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Fill destination buffer with random numbers
|
||||
*
|
||||
* The non-random number generator returns values that are based off the
|
||||
* target's clock counter, which means that successive calls will return
|
||||
* different values.
|
||||
*
|
||||
* @param dst destination buffer to fill
|
||||
* @param outlen size of destination buffer to fill
|
||||
*
|
||||
* @return N/A
|
||||
*/
|
||||
|
||||
void sys_rand_get(void *dst, size_t outlen)
|
||||
{
|
||||
u32_t len = 0;
|
||||
u32_t blocksize = 4;
|
||||
u32_t ret;
|
||||
u32_t *udst = (u32_t *)dst;
|
||||
|
||||
while (len < outlen) {
|
||||
ret = sys_rand32_get();
|
||||
if ((outlen-len) < sizeof(ret)) {
|
||||
blocksize = len;
|
||||
(void)memcpy(udst, &ret, blocksize);
|
||||
} else {
|
||||
(*udst++) = ret;
|
||||
}
|
||||
len += blocksize;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue