Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 1 | // This file was extracted from the TCG Published |
| 2 | // Trusted Platform Module Library |
| 3 | // Part 3: Commands |
| 4 | // Family "2.0" |
| 5 | // Level 00 Revision 01.16 |
| 6 | // October 30, 2014 |
| 7 | |
| 8 | #include "InternalRoutines.h" |
| 9 | #include "GetRandom_fp.h" |
| 10 | TPM_RC |
| 11 | TPM2_GetRandom( |
| 12 | GetRandom_In *in, // IN: input parameter list |
| 13 | GetRandom_Out *out // OUT: output parameter list |
| 14 | ) |
| 15 | { |
| 16 | // Command Output |
| 17 | |
| 18 | // if the requested bytes exceed the output buffer size, generates the |
| 19 | // maximum bytes that the output buffer allows |
| 20 | if(in->bytesRequested > sizeof(TPMU_HA)) |
| 21 | out->randomBytes.t.size = sizeof(TPMU_HA); |
| 22 | else |
| 23 | out->randomBytes.t.size = in->bytesRequested; |
| 24 | |
| 25 | CryptGenerateRandom(out->randomBytes.t.size, out->randomBytes.t.buffer); |
| 26 | |
| 27 | return TPM_RC_SUCCESS; |
| 28 | } |