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 <rng_support.h> 7 #include <tee/tee_cryp_utl.h> 8 #include <types_ext.h> 9 10 TEE_Result __weak crypto_rng_init(const void *data __unused, 11 size_t dlen __unused) 12 { 13 return TEE_SUCCESS; 14 } 15 16 void __weak crypto_rng_add_event(enum crypto_rng_src sid __unused, 17 unsigned int *pnum __unused, 18 const void *data __unused, 19 size_t dlen __unused) 20 { 21 } 22 23 TEE_Result __weak crypto_rng_read(void *buf, size_t blen) 24 { 25 uint8_t *b = buf; 26 size_t n; 27 28 if (!b) 29 return TEE_ERROR_BAD_PARAMETERS; 30 31 for (n = 0; n < blen; n++) 32 b[n] = hw_get_random_byte(); 33 34 return TEE_SUCCESS; 35 } 36 37