diff options
Diffstat (limited to 'board/cr50/tpm2/trng.c')
-rw-r--r-- | board/cr50/tpm2/trng.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/board/cr50/tpm2/trng.c b/board/cr50/tpm2/trng.c index ae4312be2c..87519b0e85 100644 --- a/board/cr50/tpm2/trng.c +++ b/board/cr50/tpm2/trng.c @@ -13,6 +13,7 @@ CRYPT_RESULT _cpri__StirRandom(int32_t num, uint8_t *entropy) #ifdef CRYPTO_TEST_SETUP #include "endian.h" #include "extension.h" +#include "fips_rand.h" #include "trng.h" /* * This extension command is similar to TPM2_GetRandom, but made @@ -23,7 +24,8 @@ CRYPT_RESULT _cpri__StirRandom(int32_t num, uint8_t *entropy) * field | size | note * ========================================================================= * text_len | 2 | the number of random bytes to generate, big endian - * type | 1 | 0 = TRNG, other values reserved for extensions + * type | 1 | 0 = TRNG, 1 = FIPS TRNG, 2 = FIPS DRBG + * | | other values reserved for extensions */ static enum vendor_cmd_rc trng_test(enum vendor_cmd_cc code, void *buf, size_t input_size, size_t *response_size) @@ -49,6 +51,15 @@ static enum vendor_cmd_rc trng_test(enum vendor_cmd_cc code, void *buf, case 0: rand_bytes(buf, text_len); break; + case 1: + if (!fips_trng_bytes(buf, text_len)) + return VENDOR_RC_INTERNAL_ERROR; + break; + case 2: + if (!fips_rand_bytes(buf, text_len)) + return VENDOR_RC_INTERNAL_ERROR; + break; + default: return VENDOR_RC_BOGUS_ARGS; } |