Line | Count | Source (jump to first uncovered line) |
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 "Attest_spt_fp.h" |
10 | | #include "Certify_fp.h" |
11 | | // |
12 | | // |
13 | | // Error Returns Meaning |
14 | | // |
15 | | // TPM_RC_KEY key referenced by signHandle is not a signing key |
16 | | // TPM_RC_SCHEME inScheme is not compatible with signHandle |
17 | | // TPM_RC_VALUE digest generated for inScheme is greater or has larger size than the |
18 | | // modulus of signHandle, or the buffer for the result in signature is too |
19 | | // small (for an RSA key); invalid commit status (for an ECC key with a |
20 | | // split scheme). |
21 | | // |
22 | | TPM_RC |
23 | | TPM2_Certify( |
24 | | Certify_In *in, // IN: input parameter list |
25 | | Certify_Out *out // OUT: output parameter list |
26 | | ) |
27 | 0 | { |
28 | 0 | TPM_RC result; |
29 | 0 | TPMS_ATTEST certifyInfo; |
30 | | |
31 | | // Command Output |
32 | | |
33 | | // Filling in attest information |
34 | | // Common fields |
35 | 0 | result = FillInAttestInfo(in->signHandle, |
36 | 0 | &in->inScheme, |
37 | 0 | &in->qualifyingData, |
38 | 0 | &certifyInfo); |
39 | 0 | if(result != TPM_RC_SUCCESS) |
40 | 0 | { |
41 | 0 | if(result == TPM_RC_KEY) |
42 | 0 | return TPM_RC_KEY + RC_Certify_signHandle; |
43 | 0 | else |
44 | 0 | return RcSafeAddToResult(result, RC_Certify_inScheme); |
45 | 0 | } |
46 | | // Certify specific fields |
47 | | // Attestation type |
48 | 0 | certifyInfo.type = TPM_ST_ATTEST_CERTIFY; |
49 | | // Certified object name |
50 | 0 | certifyInfo.attested.certify.name.t.size = |
51 | 0 | ObjectGetName(in->objectHandle, |
52 | 0 | &certifyInfo.attested.certify.name.t.name); |
53 | | // Certified object qualified name |
54 | 0 | ObjectGetQualifiedName(in->objectHandle, |
55 | 0 | &certifyInfo.attested.certify.qualifiedName); |
56 | | |
57 | | // Sign attestation structure. A NULL signature will be returned if |
58 | | // signHandle is TPM_RH_NULL. A TPM_RC_NV_UNAVAILABLE, TPM_RC_NV_RATE, |
59 | | // TPM_RC_VALUE, TPM_RC_SCHEME or TPM_RC_ATTRIBUTES error may be returned |
60 | | // by SignAttestInfo() |
61 | 0 | result = SignAttestInfo(in->signHandle, |
62 | 0 | &in->inScheme, |
63 | 0 | &certifyInfo, |
64 | 0 | &in->qualifyingData, |
65 | 0 | &out->certifyInfo, |
66 | 0 | &out->signature); |
67 | | |
68 | | // TPM_RC_ATTRIBUTES cannot be returned here as FillInAttestInfo would already |
69 | | // have returned TPM_RC_KEY |
70 | 0 | pAssert(result != TPM_RC_ATTRIBUTES); |
71 | |
|
72 | 0 | if(result != TPM_RC_SUCCESS) |
73 | 0 | return result; |
74 | | |
75 | | // orderly state should be cleared because of the reporting of clock info |
76 | | // if signing happens |
77 | 0 | if(in->signHandle != TPM_RH_NULL) |
78 | 0 | g_clearOrderly = TRUE; |
79 | |
|
80 | 0 | return TPM_RC_SUCCESS; |
81 | 0 | } |