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 "ReadPublic_fp.h"
10 //
11 //
12 //     Error Returns                     Meaning
13 //
14 //     TPM_RC_SEQUENCE                   can not read the public area of a sequence object
15 //
16 TPM_RC
TPM2_ReadPublic(ReadPublic_In * in,ReadPublic_Out * out)17 TPM2_ReadPublic(
18    ReadPublic_In     *in,                // IN: input parameter list
19    ReadPublic_Out    *out                // OUT: output parameter list
20    )
21 {
22    OBJECT                    *object;
23 
24 // Input Validation
25 
26    // Get loaded object pointer
27    object = ObjectGet(in->objectHandle);
28 
29    // Can not read public area of a sequence object
30    if(ObjectIsSequence(object))
31        return TPM_RC_SEQUENCE;
32 
33 // Command Output
34 
35    // Compute size of public area in canonical form
36    out->outPublic.t.size = TPMT_PUBLIC_Marshal(&object->publicArea, NULL, NULL);
37 
38    // Copy public area to output
39    out->outPublic.t.publicArea = object->publicArea;
40 
41    // Copy name to output
42    out->name.t.size = ObjectGetName(in->objectHandle, &out->name.t.name);
43 
44    // Copy qualified name to output
45    ObjectGetQualifiedName(in->objectHandle, &out->qualifiedName);
46 
47    return TPM_RC_SUCCESS;
48 }
49