Coverage Report

Created: 2025-10-28 06:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/tpm2/GetRandom.c
Line
Count
Source
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
0
{
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
0
   if(in->bytesRequested > sizeof(TPMU_HA))
21
0
       out->randomBytes.t.size = sizeof(TPMU_HA);
22
0
   else
23
0
       out->randomBytes.t.size = in->bytesRequested;
24
25
0
   CryptGenerateRandom(out->randomBytes.t.size, out->randomBytes.t.buffer);
26
27
0
   return TPM_RC_SUCCESS;
28
0
}