1 // SPDX-License-Identifier: BSD-2-Clause 2 /* Copyright (c) 2018, Linaro Limited */ 3 4 #include <compiler.h> 5 #include <crypto/crypto.h> 6 #include <kernel/panic.h> 7 #include <rng_support.h> 8 #include <tee/tee_cryp_utl.h> 9 #include <types_ext.h> 10 11 /* This is a HW RNG, no need for seeding */ 12 TEE_Result crypto_rng_init(const void *data __unused, size_t dlen __unused) 13 { 14 return TEE_SUCCESS; 15 } 16 17 /* This is a HW RNG, no need to add entropy */ 18 void crypto_rng_add_event(enum crypto_rng_src sid __unused, 19 unsigned int *pnum __unused, 20 const void *data __unused, 21 size_t dlen __unused) 22 { 23 } 24 25 TEE_Result crypto_rng_read(void *buf, size_t blen) 26 { 27 if (!buf) 28 return TEE_ERROR_BAD_PARAMETERS; 29 30 return hw_get_random_bytes(buf, blen); 31 } 32