From mboxrd@z Thu Jan 1 00:00:00 1970 From: Przemyslaw Marczak Date: Mon, 03 Mar 2014 15:19:43 +0100 Subject: [U-Boot] [PATCH 2/3] lib: rand: add call to hw_rand() - hardware random number generator In-Reply-To: <201402281802.05442.michael@walle.cc> References: <0de8fbc2fd577e8bae1359e6a0babf17c8ae7018.1393604659.git.p.marczak@samsung.com> <201402281802.05442.michael@walle.cc> Message-ID: <53148F7F.1020409@samsung.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello Michael, Thank you for reply. On 02/28/2014 06:02 PM, Michael Walle wrote: > Am Freitag, 28. Februar 2014, 17:30:54 schrieb Przemyslaw Marczak: >> Changes: >> - lib/rand.c: add call to hw_rand() (depends on CONFIG_RAND_HW_ACCEL) >> - include/common.h: add hw_rand() declaration. >> >> Signed-off-by: Przemyslaw Marczak >> cc: Michael Walle >> cc: Tom Rini >> --- >> include/common.h | 3 +++ >> lib/rand.c | 4 ++++ >> 2 files changed, 7 insertions(+) >> >> diff --git a/include/common.h b/include/common.h >> index 96a45a6..58e2fbc 100644 >> --- a/include/common.h >> +++ b/include/common.h >> @@ -836,6 +836,9 @@ void srand(unsigned int seed); >> unsigned int rand(void); >> unsigned int rand_r(unsigned int *seedp); >> #endif >> +#ifdef CONFIG_RAND_HW_ACCEL >> +unsigned int hw_rand(void); >> +#endif >> >> /* common/console.c */ >> int console_init_f(void); /* Before relocation; uses the serial stuff > */ >> diff --git a/lib/rand.c b/lib/rand.c >> index 5c367e1..f534635 100644 >> --- a/lib/rand.c >> +++ b/lib/rand.c >> @@ -23,7 +23,11 @@ unsigned int rand_r(unsigned int *seedp) >> >> unsigned int rand(void) >> { >> +#ifdef CONFIG_RAND_HW_ACCEL >> + return hw_rand(); >> +#else >> return rand_r(&y); >> +#endif >> } > > shouldn't we put that into rand_r() and ignore the argument? because then both > users of rand() and rand_r() will benefit from the hardware random generator. > Ok, I can change this. > and what does HW_ACCEL mean? is this a real hardware random generator? if this > is the case, wouldn't it make more sense to name it CONFIG_RAND_USE_HW_RNG. > > -michael > HW_ACCEL means hardware accelerated, and it really is. I followed common/hash.c code - there is declared array "hash_algo" and config name for sha hardware acceleration is "CONFIG_SHA_HW_ACCEL", so I think CONFIG_RAND_HW_ACCEL coresponds well to CONFIG_RAND. Thank you -- Przemyslaw Marczak Samsung R&D Institute Poland Samsung Electronics p.marczak at samsung.com