VirtualBox

source: vbox/trunk/src/libs/libtpms-0.9.0/src/tpm2/PropertyCap.c@ 91612

最後變更 在這個檔案從91612是 91612,由 vboxsync 提交於 3 年 前

src/libs: Export libtpms-0.9.0, bugref:10078

檔案大小: 22.1 KB
 
1/********************************************************************************/
2/* */
3/* For accessing the TPM_CAP_TPM_PROPERTY values */
4/* Written by Ken Goldman */
5/* IBM Thomas J. Watson Research Center */
6/* $Id: PropertyCap.c 1519 2019-11-15 20:43:51Z kgoldman $ */
7/* */
8/* Licenses and Notices */
9/* */
10/* 1. Copyright Licenses: */
11/* */
12/* - Trusted Computing Group (TCG) grants to the user of the source code in */
13/* this specification (the "Source Code") a worldwide, irrevocable, */
14/* nonexclusive, royalty free, copyright license to reproduce, create */
15/* derivative works, distribute, display and perform the Source Code and */
16/* derivative works thereof, and to grant others the rights granted herein. */
17/* */
18/* - The TCG grants to the user of the other parts of the specification */
19/* (other than the Source Code) the rights to reproduce, distribute, */
20/* display, and perform the specification solely for the purpose of */
21/* developing products based on such documents. */
22/* */
23/* 2. Source Code Distribution Conditions: */
24/* */
25/* - Redistributions of Source Code must retain the above copyright licenses, */
26/* this list of conditions and the following disclaimers. */
27/* */
28/* - Redistributions in binary form must reproduce the above copyright */
29/* licenses, this list of conditions and the following disclaimers in the */
30/* documentation and/or other materials provided with the distribution. */
31/* */
32/* 3. Disclaimers: */
33/* */
34/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */
35/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */
36/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */
37/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */
38/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */
39/* information on specification licensing rights available through TCG */
40/* membership agreements. */
41/* */
42/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */
43/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */
44/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */
45/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */
46/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */
47/* */
48/* - Without limitation, TCG and its members and licensors disclaim all */
49/* liability, including liability for infringement of any proprietary */
50/* rights, relating to use of information in this specification and to the */
51/* implementation of this specification, and TCG disclaims all liability for */
52/* cost of procurement of substitute goods or services, lost profits, loss */
53/* of use, loss of data or any incidental, consequential, direct, indirect, */
54/* or special damages, whether under contract, tort, warranty or otherwise, */
55/* arising in any way out of use or reliance upon this specification or any */
56/* information herein. */
57/* */
58/* (c) Copyright IBM Corp. and others, 2016 - 2019 */
59/* */
60/********************************************************************************/
61
62/* 9.14 PropertyCap.c */
63/* 9.14.1 Description */
64/* This file contains the functions that are used for accessing the TPM_CAP_TPM_PROPERTY values. */
65/* 9.14.2 Includes */
66#include "Tpm.h"
67
68#define TPM_HAVE_TPM2_DECLARATIONS
69#include "tpm_library_intern.h" // libtpms added
70/* 9.14.3 Functions */
71/* 9.14.3.1 TPMPropertyIsDefined() */
72/* This function accepts a property selection and, if so, sets value to the value of the
73 property. */
74/* All the fixed values are vendor dependent or determined by a platform-specific specification. The
75 values in the table below are examples and should be changed by the vendor. */
76/* Return Values Meaning */
77/* TRUE referenced property exists and value set */
78/* FALSE referenced property does not exist */
79static BOOL
80TPMPropertyIsDefined(
81 TPM_PT property, // IN: property
82 UINT32 *value // OUT: property value
83 )
84{
85 switch(property)
86 {
87 case TPM_PT_FAMILY_INDICATOR:
88 // from the title page of the specification
89 // For this specification, the value is "2.0".
90 *value = TPM_SPEC_FAMILY;
91 break;
92 case TPM_PT_LEVEL:
93 // from the title page of the specification
94 *value = TPM_SPEC_LEVEL;
95 break;
96 case TPM_PT_REVISION:
97 // from the title page of the specification
98 *value = TPM_SPEC_VERSION;
99 break;
100 case TPM_PT_DAY_OF_YEAR:
101 // computed from the date value on the title page of the specification
102 *value = TPM_SPEC_DAY_OF_YEAR;
103 break;
104 case TPM_PT_YEAR:
105 // from the title page of the specification
106 *value = TPM_SPEC_YEAR;
107 break;
108 case TPM_PT_MANUFACTURER:
109 // vendor ID unique to each TPM manufacturer
110 *value = BYTE_ARRAY_TO_UINT32(MANUFACTURER);
111 break;
112 case TPM_PT_VENDOR_STRING_1:
113 // first four characters of the vendor ID string
114 *value = BYTE_ARRAY_TO_UINT32(VENDOR_STRING_1);
115 break;
116 case TPM_PT_VENDOR_STRING_2:
117 // second four characters of the vendor ID string
118#ifdef VENDOR_STRING_2
119 *value = BYTE_ARRAY_TO_UINT32(VENDOR_STRING_2);
120#else
121 *value = 0;
122#endif
123 break;
124 case TPM_PT_VENDOR_STRING_3:
125 // third four characters of the vendor ID string
126#ifdef VENDOR_STRING_3
127 *value = BYTE_ARRAY_TO_UINT32(VENDOR_STRING_3);
128#else
129 *value = 0;
130#endif
131 break;
132 case TPM_PT_VENDOR_STRING_4:
133 // fourth four characters of the vendor ID string
134#ifdef VENDOR_STRING_4
135 *value = BYTE_ARRAY_TO_UINT32(VENDOR_STRING_4);
136#else
137 *value = 0;
138#endif
139 break;
140 case TPM_PT_VENDOR_TPM_TYPE:
141 // vendor-defined value indicating the TPM model
142 *value = 1;
143 break;
144 case TPM_PT_FIRMWARE_VERSION_1:
145 // more significant 32-bits of a vendor-specific value
146 *value = gp.firmwareV1;
147 break;
148 case TPM_PT_FIRMWARE_VERSION_2:
149 // less significant 32-bits of a vendor-specific value
150 *value = gp.firmwareV2;
151 break;
152 case TPM_PT_INPUT_BUFFER:
153 // maximum size of TPM2B_MAX_BUFFER
154 *value = MAX_DIGEST_BUFFER;
155 break;
156 case TPM_PT_HR_TRANSIENT_MIN:
157 // minimum number of transient objects that can be held in TPM
158 // RAM
159 *value = MAX_LOADED_OBJECTS;
160 break;
161 case TPM_PT_HR_PERSISTENT_MIN:
162 // minimum number of persistent objects that can be held in
163 // TPM NV memory
164 // In this implementation, there is no minimum number of
165 // persistent objects.
166 *value = MIN_EVICT_OBJECTS;
167 break;
168 case TPM_PT_HR_LOADED_MIN:
169 // minimum number of authorization sessions that can be held in
170 // TPM RAM
171 *value = MAX_LOADED_SESSIONS;
172 break;
173 case TPM_PT_ACTIVE_SESSIONS_MAX:
174 // number of authorization sessions that may be active at a time
175 *value = MAX_ACTIVE_SESSIONS;
176 break;
177 case TPM_PT_PCR_COUNT:
178 // number of PCR implemented
179 *value = IMPLEMENTATION_PCR;
180 break;
181 case TPM_PT_PCR_SELECT_MIN:
182 // minimum number of bytes in a TPMS_PCR_SELECT.sizeOfSelect
183 *value = PCR_SELECT_MIN;
184 break;
185 case TPM_PT_CONTEXT_GAP_MAX:
186 // maximum allowed difference (unsigned) between the contextID
187 // values of two saved session contexts
188#if 0
189 *value = ((UINT32)1 << (sizeof(CONTEXT_SLOT) * 8)) - 1;
190#endif
191 *value = s_ContextSlotMask; // libtpms added; the mask is either 0xff (old state) or 0xffff
192 break;
193 case TPM_PT_NV_COUNTERS_MAX:
194 // maximum number of NV indexes that are allowed to have the
195 // TPMA_NV_COUNTER attribute SET
196 // In this implementation, there is no limitation on the number
197 // of counters, except for the size of the NV Index memory.
198 *value = 0;
199 break;
200 case TPM_PT_NV_INDEX_MAX:
201 // maximum size of an NV index data area
202 *value = MAX_NV_INDEX_SIZE;
203 break;
204 case TPM_PT_MEMORY:
205 // a TPMA_MEMORY indicating the memory management method for the TPM
206 {
207 union
208 {
209 TPMA_MEMORY att;
210 UINT32 u32;
211 } attributes = { TPMA_ZERO_INITIALIZER() };
212 SET_ATTRIBUTE(attributes.att, TPMA_MEMORY, sharedNV);
213 SET_ATTRIBUTE(attributes.att, TPMA_MEMORY, objectCopiedToRam);
214 // Note: For a LSb0 machine, the bits in a bit field are in the correct
215 // order even if the machine is MSB0. For a MSb0 machine, a TPMA will
216 // be an integer manipulated by masking (USE_BIT_FIELD_STRUCTURES will
217 // NO) so the bits are manipulated correctly.
218 *value = attributes.u32;
219 break;
220 }
221 case TPM_PT_CLOCK_UPDATE:
222 // interval, in seconds, between updates to the copy of
223 // TPMS_TIME_INFO .clock in NV
224 *value = (1 << NV_CLOCK_UPDATE_INTERVAL);
225 break;
226 case TPM_PT_CONTEXT_HASH:
227 // algorithm used for the integrity hash on saved contexts and
228 // for digesting the fuData of TPM2_FirmwareRead()
229 *value = CONTEXT_INTEGRITY_HASH_ALG;
230 break;
231 case TPM_PT_CONTEXT_SYM:
232 // algorithm used for encryption of saved contexts
233 *value = CONTEXT_ENCRYPT_ALG;
234 break;
235 case TPM_PT_CONTEXT_SYM_SIZE:
236 // size of the key used for encryption of saved contexts
237 *value = CONTEXT_ENCRYPT_KEY_BITS;
238 break;
239 case TPM_PT_ORDERLY_COUNT:
240 // maximum difference between the volatile and non-volatile
241 // versions of TPMA_NV_COUNTER that have TPMA_NV_ORDERLY SET
242 *value = MAX_ORDERLY_COUNT;
243 break;
244 case TPM_PT_MAX_COMMAND_SIZE:
245 // maximum value for 'commandSize'
246 *value = MAX_COMMAND_SIZE;
247 break;
248 case TPM_PT_MAX_RESPONSE_SIZE:
249 // maximum value for 'responseSize'
250 *value = MAX_RESPONSE_SIZE;
251 break;
252 case TPM_PT_MAX_DIGEST:
253 // maximum size of a digest that can be produced by the TPM
254 *value = sizeof(TPMU_HA);
255 break;
256 case TPM_PT_MAX_OBJECT_CONTEXT:
257 // Header has 'sequence', 'handle' and 'hierarchy'
258#define SIZE_OF_CONTEXT_HEADER \
259 sizeof(UINT64) + sizeof(TPMI_DH_CONTEXT) + sizeof(TPMI_RH_HIERARCHY)
260#define SIZE_OF_CONTEXT_INTEGRITY (sizeof(UINT16) + CONTEXT_INTEGRITY_HASH_SIZE)
261#define SIZE_OF_FINGERPRINT sizeof(UINT64)
262#define SIZE_OF_CONTEXT_BLOB_OVERHEAD \
263 (sizeof(UINT16) + SIZE_OF_CONTEXT_INTEGRITY + SIZE_OF_FINGERPRINT)
264#define SIZE_OF_CONTEXT_OVERHEAD \
265 (SIZE_OF_CONTEXT_HEADER + SIZE_OF_CONTEXT_BLOB_OVERHEAD)
266#if 0
267 // maximum size of a TPMS_CONTEXT that will be returned by
268 // TPM2_ContextSave for object context
269 *value = 0;
270 // adding sequence, saved handle and hierarchy
271 *value += sizeof(UINT64) + sizeof(TPMI_DH_CONTEXT) +
272 sizeof(TPMI_RH_HIERARCHY);
273 // add size field in TPM2B_CONTEXT
274 *value += sizeof(UINT16);
275 // add integrity hash size
276 *value += sizeof(UINT16) +
277 CryptHashGetDigestSize(CONTEXT_INTEGRITY_HASH_ALG);
278 // Add fingerprint size, which is the same as sequence size
279 *value += sizeof(UINT64);
280 // Add OBJECT structure size
281 *value += sizeof(OBJECT);
282#else
283 // the maximum size of a TPMS_CONTEXT that will be returned by
284 // TPM2_ContextSave for object context
285 *value = SIZE_OF_CONTEXT_OVERHEAD + sizeof(OBJECT);
286#endif
287 break;
288 case TPM_PT_MAX_SESSION_CONTEXT:
289#if 0
290 // the maximum size of a TPMS_CONTEXT that will be returned by
291 // TPM2_ContextSave for object context
292 *value = 0;
293 // adding sequence, saved handle and hierarchy
294 *value += sizeof(UINT64) + sizeof(TPMI_DH_CONTEXT) +
295 sizeof(TPMI_RH_HIERARCHY);
296 // Add size field in TPM2B_CONTEXT
297 *value += sizeof(UINT16);
298 // Add integrity hash size
299 *value += sizeof(UINT16) +
300 CryptHashGetDigestSize(CONTEXT_INTEGRITY_HASH_ALG);
301 // Add fingerprint size, which is the same as sequence size
302 *value += sizeof(UINT64);
303 // Add SESSION structure size
304 *value += sizeof(SESSION);
305#else
306 // the maximum size of a TPMS_CONTEXT that will be returned by
307 // TPM2_ContextSave for object context
308 *value = SIZE_OF_CONTEXT_OVERHEAD + sizeof(SESSION);
309#endif
310 break;
311 case TPM_PT_PS_FAMILY_INDICATOR:
312 // platform specific values for the TPM_PT_PS parameters from
313 // the relevant platform-specific specification
314 // In this reference implementation, all of these values are 0.
315 *value = PLATFORM_FAMILY;
316 break;
317 case TPM_PT_PS_LEVEL:
318 // level of the platform-specific specification
319 *value = PLATFORM_LEVEL;
320 break;
321 case TPM_PT_PS_REVISION:
322 // specification Revision times 100 for the platform-specific
323 // specification
324 *value = PLATFORM_VERSION;
325 break;
326 case TPM_PT_PS_DAY_OF_YEAR:
327 // platform-specific specification day of year using TCG calendar
328 *value = PLATFORM_DAY_OF_YEAR;
329 break;
330 case TPM_PT_PS_YEAR:
331 // platform-specific specification year using the CE
332 *value = PLATFORM_YEAR;
333 break;
334 case TPM_PT_SPLIT_MAX:
335 // number of split signing operations supported by the TPM
336 *value = 0;
337#if ALG_ECC
338 *value = sizeof(gr.commitArray) * 8;
339#endif
340 break;
341 case TPM_PT_TOTAL_COMMANDS:
342 // total number of commands implemented in the TPM
343 // Since the reference implementation does not have any
344 // vendor-defined commands, this will be the same as the
345 // number of library commands.
346 {
347#if COMPRESSED_LISTS
348 (*value) = COMMAND_COUNT;
349#else
350 COMMAND_INDEX commandIndex;
351 *value = 0;
352 // scan all implemented commands
353 for(commandIndex = GetClosestCommandIndex(0);
354 commandIndex != UNIMPLEMENTED_COMMAND_INDEX;
355 commandIndex = GetNextCommandIndex(commandIndex))
356 {
357 (*value)++; // count of all implemented
358 }
359#endif
360 break;
361 }
362 case TPM_PT_LIBRARY_COMMANDS:
363 // number of commands from the TPM library that are implemented
364 {
365#if COMPRESSED_LISTS
366 *value = LIBRARY_COMMAND_ARRAY_SIZE;
367#else
368 COMMAND_INDEX commandIndex;
369 *value = 0;
370 // scan all implemented commands
371 for(commandIndex = GetClosestCommandIndex(0);
372 commandIndex < LIBRARY_COMMAND_ARRAY_SIZE;
373 commandIndex = GetNextCommandIndex(commandIndex))
374 {
375 (*value)++;
376 }
377#endif
378 break;
379 }
380 case TPM_PT_VENDOR_COMMANDS:
381 // number of vendor commands that are implemented
382 *value = VENDOR_COMMAND_ARRAY_SIZE;
383 break;
384 case TPM_PT_NV_BUFFER_MAX:
385 // Maximum data size in an NV write command
386 *value = MAX_NV_BUFFER_SIZE;
387 break;
388 case TPM_PT_MODES:
389#if FIPS_COMPLIANT
390 *value = 1;
391#else
392 *value = 0;
393#endif
394 break;
395 case TPM_PT_MAX_CAP_BUFFER:
396 *value = MAX_CAP_BUFFER;
397 break;
398 // Start of variable commands
399 case TPM_PT_PERMANENT:
400 // TPMA_PERMANENT
401 {
402 union {
403 TPMA_PERMANENT attr;
404 UINT32 u32;
405 } flags = { TPMA_ZERO_INITIALIZER() };
406 if(gp.ownerAuth.t.size != 0)
407 SET_ATTRIBUTE(flags.attr, TPMA_PERMANENT, ownerAuthSet);
408 if(gp.endorsementAuth.t.size != 0)
409 SET_ATTRIBUTE(flags.attr, TPMA_PERMANENT, endorsementAuthSet);
410 if(gp.lockoutAuth.t.size != 0)
411 SET_ATTRIBUTE(flags.attr, TPMA_PERMANENT, lockoutAuthSet);
412 if(gp.disableClear)
413 SET_ATTRIBUTE(flags.attr, TPMA_PERMANENT, disableClear);
414 if(gp.failedTries >= gp.maxTries)
415 SET_ATTRIBUTE(flags.attr, TPMA_PERMANENT, inLockout);
416 // In this implementation, EPS is always generated by TPM
417 SET_ATTRIBUTE(flags.attr, TPMA_PERMANENT, tpmGeneratedEPS);
418 // Note: For a LSb0 machine, the bits in a bit field are in the correct
419 // order even if the machine is MSB0. For a MSb0 machine, a TPMA will
420 // be an integer manipulated by masking (USE_BIT_FIELD_STRUCTURES will
421 // be NO ) so the bits are manipulate correctly.
422 *value = flags.u32;
423 break;
424 }
425 case TPM_PT_STARTUP_CLEAR:
426 // TPMA_STARTUP_CLEAR
427 {
428 union {
429 TPMA_STARTUP_CLEAR attr;
430 UINT32 u32;
431 } flags = { TPMA_ZERO_INITIALIZER() };
432 //
433 if(g_phEnable)
434 SET_ATTRIBUTE(flags.attr, TPMA_STARTUP_CLEAR, phEnable);
435 if(gc.shEnable)
436 SET_ATTRIBUTE(flags.attr, TPMA_STARTUP_CLEAR, shEnable);
437 if(gc.ehEnable)
438 SET_ATTRIBUTE(flags.attr, TPMA_STARTUP_CLEAR, ehEnable);
439 if(gc.phEnableNV)
440 SET_ATTRIBUTE(flags.attr, TPMA_STARTUP_CLEAR, phEnableNV);
441 if(g_prevOrderlyState != SU_NONE_VALUE)
442 SET_ATTRIBUTE(flags.attr, TPMA_STARTUP_CLEAR, orderly);
443 // Note: For a LSb0 machine, the bits in a bit field are in the correct
444 // order even if the machine is MSB0. For a MSb0 machine, a TPMA will
445 // be an integer manipulated by masking (USE_BIT_FIELD_STRUCTURES will
446 // be NO) so the bits are manipulate correctly.
447 *value = flags.u32;
448 break;
449 }
450 case TPM_PT_HR_NV_INDEX:
451 // number of NV indexes currently defined
452 *value = NvCapGetIndexNumber();
453 break;
454 case TPM_PT_HR_LOADED:
455 // number of authorization sessions currently loaded into TPM
456 // RAM
457 *value = SessionCapGetLoadedNumber();
458 break;
459 case TPM_PT_HR_LOADED_AVAIL:
460 // number of additional authorization sessions, of any type,
461 // that could be loaded into TPM RAM
462 *value = SessionCapGetLoadedAvail();
463 break;
464 case TPM_PT_HR_ACTIVE:
465 // number of active authorization sessions currently being
466 // tracked by the TPM
467 *value = SessionCapGetActiveNumber();
468 break;
469 case TPM_PT_HR_ACTIVE_AVAIL:
470 // number of additional authorization sessions, of any type,
471 // that could be created
472 *value = SessionCapGetActiveAvail();
473 break;
474 case TPM_PT_HR_TRANSIENT_AVAIL:
475 // estimate of the number of additional transient objects that
476 // could be loaded into TPM RAM
477 *value = ObjectCapGetTransientAvail();
478 break;
479 case TPM_PT_HR_PERSISTENT:
480 // number of persistent objects currently loaded into TPM
481 // NV memory
482 *value = NvCapGetPersistentNumber();
483 break;
484 case TPM_PT_HR_PERSISTENT_AVAIL:
485 // number of additional persistent objects that could be loaded
486 // into NV memory
487 *value = NvCapGetPersistentAvail();
488 break;
489 case TPM_PT_NV_COUNTERS:
490 // number of defined NV indexes that have NV TPMA_NV_COUNTER
491 // attribute SET
492 *value = NvCapGetCounterNumber();
493 break;
494 case TPM_PT_NV_COUNTERS_AVAIL:
495 // number of additional NV indexes that can be defined with their
496 // TPMA_NV_COUNTER attribute SET
497 *value = NvCapGetCounterAvail();
498 break;
499 case TPM_PT_ALGORITHM_SET:
500 // region code for the TPM
501 *value = gp.algorithmSet;
502 break;
503 case TPM_PT_LOADED_CURVES:
504#if ALG_ECC
505 // number of loaded ECC curves
506 *value = ECC_CURVE_COUNT;
507#else // ALG_ECC
508 *value = 0;
509#endif // ALG_ECC
510 break;
511 case TPM_PT_LOCKOUT_COUNTER:
512 // current value of the lockout counter
513 *value = gp.failedTries;
514 break;
515 case TPM_PT_MAX_AUTH_FAIL:
516 // number of authorization failures before DA lockout is invoked
517 *value = gp.maxTries;
518 break;
519 case TPM_PT_LOCKOUT_INTERVAL:
520 // number of seconds before the value reported by
521 // TPM_PT_LOCKOUT_COUNTER is decremented
522 *value = gp.recoveryTime;
523 break;
524 case TPM_PT_LOCKOUT_RECOVERY:
525 // number of seconds after a lockoutAuth failure before use of
526 // lockoutAuth may be attempted again
527 *value = gp.lockoutRecovery;
528 break;
529 case TPM_PT_NV_WRITE_RECOVERY:
530 // number of milliseconds before the TPM will accept another command
531 // that will modify NV.
532 // This should make a call to the platform code that is doing rate
533 // limiting of NV. Rate limiting is not implemented in the reference
534 // code so no call is made.
535 *value = 0;
536 break;
537 case TPM_PT_AUDIT_COUNTER_0:
538 // high-order 32 bits of the command audit counter
539 *value = (UINT32)(gp.auditCounter >> 32);
540 break;
541 case TPM_PT_AUDIT_COUNTER_1:
542 // low-order 32 bits of the command audit counter
543 *value = (UINT32)(gp.auditCounter);
544 break;
545 default:
546 // property is not defined
547 return FALSE;
548 break;
549 }
550 return TRUE;
551}
552/* 9.14.3.2 TPMCapGetProperties() */
553/* This function is used to get the TPM_PT values. The search of properties will start at property
554 and continue until propertyList has as many values as will fit, or the last property has been
555 reported, or the list has as many values as requested in count. */
556/* Return Values Meaning */
557/* YES more properties are available */
558/* NO no more properties to be reported */
559TPMI_YES_NO
560TPMCapGetProperties(
561 TPM_PT property, // IN: the starting TPM property
562 UINT32 count, // IN: maximum number of returned
563 // properties
564 TPML_TAGGED_TPM_PROPERTY *propertyList // OUT: property list
565 )
566{
567 TPMI_YES_NO more = NO;
568 UINT32 i;
569 UINT32 nextGroup;
570 // initialize output property list
571 propertyList->count = 0;
572 // maximum count of properties we may return is MAX_PCR_PROPERTIES
573 if(count > MAX_TPM_PROPERTIES) count = MAX_TPM_PROPERTIES;
574 // if property is less than PT_FIXED, start from PT_FIXED
575 if(property < PT_FIXED)
576 property = PT_FIXED;
577 // There is only the fixed and variable groups with the variable group coming
578 // last
579 if(property >= (PT_VAR + PT_GROUP))
580 return more;
581 // Don't read past the end of the selected group
582 nextGroup = ((property / PT_GROUP) * PT_GROUP) + PT_GROUP;
583 // Scan through the TPM properties of the requested group.
584 for(i = property; i < nextGroup; i++)
585 {
586 UINT32 value;
587 // if we have hit the end of the group, quit
588 if(i != property && ((i % PT_GROUP) == 0))
589 break;
590 if(TPMPropertyIsDefined((TPM_PT)i, &value))
591 {
592 if(propertyList->count < count)
593 {
594 // If the list is not full, add this property
595 propertyList->tpmProperty[propertyList->count].property =
596 (TPM_PT)i;
597 propertyList->tpmProperty[propertyList->count].value = value;
598 propertyList->count++;
599 }
600 else
601 {
602 // If the return list is full but there are more properties
603 // available, set the indication and exit the loop.
604 more = YES;
605 break;
606 }
607 }
608 }
609 return more;
610}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette