diff options
Diffstat (limited to 'board/cr50/tpm2/platform.c')
-rw-r--r-- | board/cr50/tpm2/platform.c | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/board/cr50/tpm2/platform.c b/board/cr50/tpm2/platform.c index afe5c86c74..20b5854625 100644 --- a/board/cr50/tpm2/platform.c +++ b/board/cr50/tpm2/platform.c @@ -8,26 +8,9 @@ #include "trng.h" -UINT16 _cpri__GenerateRandom(INT32 randomSize, - BYTE *buffer) +uint16_t _cpri__GenerateRandom(size_t random_size, + uint8_t *buffer) { - int random_togo = 0; - int buffer_index = 0; - uint32_t random_value; - - /* - * Retrieve random numbers in 4 byte quantities and pack as many bytes - * as needed into 'buffer'. If randomSize is not divisible by 4, the - * remaining random bytes get dropped. - */ - while (buffer_index < randomSize) { - if (!random_togo) { - random_value = rand(); - random_togo = sizeof(random_value); - } - buffer[buffer_index++] = random_value >> - ((random_togo-- - 1) * 8); - } - - return randomSize; + rand_bytes(buffer, random_size); + return random_size; } |