diff options
author | Jens Wiklander <jens.wiklander@linaro.org> | 2018-06-14 11:12:01 +0200 |
---|---|---|
committer | Jérôme Forissier <jerome.forissier@linaro.org> | 2018-06-18 10:01:13 +0200 |
commit | ea6cd9133a2627a0973855fa4c94bb02079e967e (patch) | |
tree | cf8357a915ad41ef2cc084e176f36ba2d4879fd7 | |
parent | 249c24a353272a94c17898d3dfc0aaf8b2eda032 (diff) |
Remove get_rng_array()
Removes get_rng_array() in favor of crypto_rng_read() which always uses
the configured RNG implementation to draw random.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
-rw-r--r-- | core/crypto/rng_hw.c | 12 | ||||
-rw-r--r-- | core/include/tee/tee_cryp_utl.h | 4 | ||||
-rw-r--r-- | core/tee/tee_cryp_utl.c | 17 |
3 files changed, 11 insertions, 22 deletions
diff --git a/core/crypto/rng_hw.c b/core/crypto/rng_hw.c index 577eacaa..714736ef 100644 --- a/core/crypto/rng_hw.c +++ b/core/crypto/rng_hw.c @@ -3,6 +3,7 @@ #include <compiler.h> #include <crypto/crypto.h> +#include <rng_support.h> #include <tee/tee_cryp_utl.h> #include <types_ext.h> @@ -21,6 +22,15 @@ void __weak crypto_rng_add_event(enum crypto_rng_src sid __unused, TEE_Result __weak crypto_rng_read(void *buf, size_t blen) { - return get_rng_array(buf, blen); + uint8_t *b = buf; + size_t n; + + if (!b) + return TEE_ERROR_BAD_PARAMETERS; + + for (n = 0; n < blen; n++) + b[n] = hw_get_random_byte(); + + return TEE_SUCCESS; } diff --git a/core/include/tee/tee_cryp_utl.h b/core/include/tee/tee_cryp_utl.h index 5ad15e6f..28358233 100644 --- a/core/include/tee/tee_cryp_utl.h +++ b/core/include/tee/tee_cryp_utl.h @@ -9,10 +9,6 @@ #include <tee_api_types.h> #include <crypto/crypto.h> -#if !defined(CFG_WITH_SOFTWARE_PRNG) -TEE_Result get_rng_array(void *buffer, int len); -#endif - TEE_Result tee_hash_get_digest_size(uint32_t algo, size_t *size); TEE_Result tee_hash_createdigest(uint32_t algo, const uint8_t *data, size_t datalen, uint8_t *digest, diff --git a/core/tee/tee_cryp_utl.c b/core/tee/tee_cryp_utl.c index a7dfe342..aeaea6cb 100644 --- a/core/tee/tee_cryp_utl.c +++ b/core/tee/tee_cryp_utl.c @@ -15,23 +15,6 @@ #include <trace.h> #include <utee_defines.h> -#if !defined(CFG_WITH_SOFTWARE_PRNG) -TEE_Result get_rng_array(void *buffer, int len) -{ - char *buf_char = buffer; - int i; - - - if (buf_char == NULL) - return TEE_ERROR_BAD_PARAMETERS; - - for (i = 0; i < len; i++) - buf_char[i] = hw_get_random_byte(); - - return TEE_SUCCESS; -} -#endif - TEE_Result tee_hash_get_digest_size(uint32_t algo, size_t *size) { switch (algo) { |