• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stefanberger / libtpms / 2698

pending completion
2698

Pull #353

travis-ci-com

web-flow
Merge a8cae3f5d into d08b929de
Pull Request #353: Travis: Update from bionic to focal and from xenial to bionic

33875 of 43923 relevant lines covered (77.12%)

93992.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.9
/src/tpm2/CommandCodeAttributes.c
1
/********************************************************************************/
2
/*                                                                                */
3
/*                Functions for testing various command properties                */
4
/*                             Written by Ken Goldman                                */
5
/*                       IBM Thomas J. Watson Research Center                        */
6
/*            $Id: CommandCodeAttributes.c 1594 2020-03-26 22:15:48Z 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 - 2020                                */
59
/*                                                                                */
60
/********************************************************************************/
61

62
/* 9.3 CommandCodeAttributes.c */
63
/* 9.3.1 Introduction */
64
/* This file contains the functions for testing various command properties. */
65
/* 9.3.2 Includes and Defines */
66
#include "Tpm.h"
67
#include "CommandCodeAttributes_fp.h"
68
/* Set the default value for CC_VEND if not already set */
69
#ifndef CC_VEND
70
#define     CC_VEND     (TPM_CC)(0x20000000)
71
#endif
72
typedef UINT16          ATTRIBUTE_TYPE;
73
/* The following file is produced from the command tables in part 3 of the specification. It defines
74
   the attributes for each of the commands. */
75
/* NOTE: This file is currently produced by an automated process. Files produced from Part 2 or Part
76
   3 tables through automated processes are not included in the specification so that there is no
77
   ambiguity about the table containing the information being the normative definition. */
78
#define _COMMAND_CODE_ATTRIBUTES_
79
#include    "CommandAttributeData.h"
80
/* 9.3.3 Command Attribute Functions */
81
/* 9.3.3.1 NextImplementedIndex() */
82
/* This function is used when the lists are not compressed. In a compressed list, only the
83
   implemented commands are present. So, a search might find a value but that value may not be
84
   implemented. This function checks to see if the input commandIndex points to an implemented
85
   command and, if not, it searches upwards until it finds one. When the list is compressed, this
86
   function gets defined as a no-op. */
87
/* Return Value        Meaning */
88
/* UNIMPLEMENTED_COMMAND_INDEX        command is not implemented */
89
/* other        index of the command */
90

91
#if !COMPRESSED_LISTS
92
static COMMAND_INDEX
93
NextImplementedIndex(
94
                     COMMAND_INDEX       commandIndex
95
                     )
96
{
97
    for(;commandIndex < COMMAND_COUNT; commandIndex++)
98
        {
99
            if(s_commandAttributes[commandIndex] & IS_IMPLEMENTED)
100
                return commandIndex;
101
        }
102
    return UNIMPLEMENTED_COMMAND_INDEX;
103
}
104
#else
105
#define NextImplementedIndex(x) (x)
106
#endif
107
/* 9.3.3.2 GetClosestCommandIndex() */
108
/* This function returns the command index for the command with a value that is equal to or greater
109
   than the input value */
110
/* Return Value        Meaning */
111
/* UNIMPLEMENTED_COMMAND_INDEX        command is not implemented */
112
/* other        index of the command */
113

114
COMMAND_INDEX
115
GetClosestCommandIndex(
21,087✔
116
                       TPM_CC           commandCode    // IN: the command code to start at
117
                       )
118
{
119
    BOOL                vendor = (commandCode & CC_VEND) != 0;
21,087✔
120
    COMMAND_INDEX       searchIndex = (COMMAND_INDEX)commandCode;
21,087✔
121
    // The commandCode is a UINT32 and the search index is UINT16. We are going to
122
    // search for a match but need to make sure that the commandCode value is not
123
    // out of range. To do this, need to clear the vendor bit of the commandCode
124
    // (if set) and compare the result to the 16-bit searchIndex value. If it is
125
    // out of range, indicate that the command is not implemented
126
    if((commandCode & ~CC_VEND) != searchIndex)
21,087✔
127
        return UNIMPLEMENTED_COMMAND_INDEX;
128
    // if there is at least one vendor command, the last entry in the array will
129
    // have the v bit set. If the input commandCode is larger than the last
130
    // vendor-command, then it is out of range.
131
    if(vendor)
21,067✔
132
        {
133
#if VENDOR_COMMAND_ARRAY_SIZE > 0
134
            COMMAND_INDEX       commandIndex;
135
            COMMAND_INDEX       min;
136
            COMMAND_INDEX       max;
137
            int                 diff;
138
#if LIBRARY_COMMAND_ARRAY_SIZE == COMMAND_COUNT
139
#error "Constants are not consistent."
140
#endif
141
            // Check to see if the value is equal to or below the minimum
142
            // entry.
143
            // Note: Put this check first so that the typical case of only one vendor-
144
            // specific command doesn't waste any more time.
145
            if(GET_ATTRIBUTE(s_ccAttr[LIBRARY_COMMAND_ARRAY_SIZE], TPMA_CC,
146
                             commandIndex) >= searchIndex)
147
                {
148
                    // the vendor array is always assumed to be packed so there is
149
                    // no need to check to see if the command is implemented
150
                    return LIBRARY_COMMAND_ARRAY_SIZE;
151
                }
152
            // See if this is out of range on the top
153
            if(GET_ATTRIBUTE(s_ccAttr[COMMAND_COUNT - 1], TPMA_CC, commandIndex)
154
               < searchIndex)
155
                {
156
                    return UNIMPLEMENTED_COMMAND_INDEX;
157
                }
158
            commandIndex = UNIMPLEMENTED_COMMAND_INDEX; // Needs initialization to keep
159
            // compiler happy
160
            min = LIBRARY_COMMAND_ARRAY_SIZE;       // first vendor command
161
            max = COMMAND_COUNT - 1;                // last vendor command
162
            diff = 1;                               // needs initialization to keep
163
            // compiler happy
164
            while(min <= max)
165
                {
166
                    commandIndex = (min + max + 1) / 2;
167
                    diff = GET_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, commandIndex)
168
                           - searchIndex;
169
                    if(diff == 0)
170
                        return commandIndex;
171
                    if(diff > 0)
172
                        max = commandIndex - 1;
173
                    else
174
                        min = commandIndex + 1;
175
                }
176
            // didn't find and exact match. commandIndex will be pointing at the last
177
            // item tested. If 'diff' is positive, then the last item tested was
178
            // larger index of the command code so it is the smallest value
179
            // larger than the requested value.
180
            if(diff > 0)
181
                return commandIndex;
182
            // if 'diff' is negative, then the value tested was smaller than
183
            // the commandCode index and the next higher value is the correct one.
184
            // Note: this will necessarily be in range because of the earlier check
185
            // that the index was within range.
186
            return commandIndex + 1;
187
#else
188
            // If there are no vendor commands so anything with the vendor bit set is out
189
            // of range
190
            return UNIMPLEMENTED_COMMAND_INDEX;
191
#endif
192
        }
193
    // Get here if the V-Bit was not set in 'commandCode'
194
    if(GET_ATTRIBUTE(s_ccAttr[LIBRARY_COMMAND_ARRAY_SIZE - 1], TPMA_CC,
21,067✔
195
                     commandIndex) < searchIndex)
196
        {
197
            // requested index is out of the range to the top
198
#if VENDOR_COMMAND_ARRAY_SIZE > 0
199
            // If there are vendor commands, then the first vendor command
200
            // is the next value greater than the commandCode.
201
            // NOTE: we got here if the starting index did not have the V bit but we
202
            // reached the end of the array of library commands (non-vendor). Since
203
            // there is at least one vendor command, and vendor commands are always
204
            // in a compressed list that starts after the library list, the next
205
            // index value contains a valid vendor command.
206
            return LIBRARY_COMMAND_ARRAY_SIZE;
207
#else
208
            // if there are no vendor commands, then this is out of range
209
            return UNIMPLEMENTED_COMMAND_INDEX;
210
#endif
211
        }
212
    // If the request is lower than any value in the array, then return
213
    // the lowest value (needs to be an index for an implemented command
214
    if(GET_ATTRIBUTE(s_ccAttr[0], TPMA_CC, commandIndex) >= searchIndex)
21,067✔
215
        {
216
            return NextImplementedIndex(0);
217
        }
218
    else
219
        {
220
#if COMPRESSED_LISTS
221
            COMMAND_INDEX       commandIndex = UNIMPLEMENTED_COMMAND_INDEX;
222
            COMMAND_INDEX       min = 0;
223
            COMMAND_INDEX       max = LIBRARY_COMMAND_ARRAY_SIZE - 1;
224
            int                 diff = 1;
225
#if LIBRARY_COMMAND_ARRAY_SIZE == 0
226
#error  "Something is terribly wrong"
227
#endif
228
            // The s_ccAttr array contains an extra entry at the end (a zero value).
229
            // Don't count this as an array entry. This means that max should start
230
            // out pointing to the last valid entry in the array which is - 2
231
            pAssert(max == (sizeof(s_ccAttr) / sizeof(TPMA_CC)
232
                            - VENDOR_COMMAND_ARRAY_SIZE - 2));
233
            while(min <= max)
109,682✔
234
                {
235
                    commandIndex = (min + max + 1) / 2;
109,682✔
236
                    diff = GET_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC,
109,682✔
237
                                         commandIndex) - searchIndex;
109,682✔
238
                    if(diff == 0)
109,682✔
239
                        return commandIndex;
20,958✔
240
                    if(diff > 0)
88,724✔
241
                        max = commandIndex - 1;
53,908✔
242
                    else
243
                        min = commandIndex + 1;
34,816✔
244
                }
245
            // didn't find and exact match. commandIndex will be pointing at the
246
            // last item tested. If diff is positive, then the last item tested was
247
            // larger index of the command code so it is the smallest value
248
            // larger than the requested value.
249
            if(diff > 0)
×
250
                return commandIndex;
251
            // if diff is negative, then the value tested was smaller than
252
            // the commandCode index and the next higher value is the correct one.
253
            // Note: this will necessarily be in range because of the earlier check
254
            // that the index was within range.
255
            return commandIndex + 1;
×
256
#else
257
            // The list is not compressed so offset into the array by the command
258
            // code value of the first entry in the list. Then go find the first
259
            // implemented command.
260
            return NextImplementedIndex(searchIndex
261
                                        - (COMMAND_INDEX)s_ccAttr[0].commandIndex);
262
#endif
263
        }
264
}
265
/* 9.3.3.3 CommandCodeToComandIndex() */
266
/* This function returns the index in the various attributes arrays of the command. */
267
/* Return Values Meaning */
268
/* UNIMPLEMENTED_COMMAND_INDEX command is not implemented */
269
/* other index of the command */
270
COMMAND_INDEX
271
CommandCodeToCommandIndex(
20,936✔
272
                          TPM_CC           commandCode    // IN: the command code to look up
273
                          )
274
{
275
    // Extract the low 16-bits of the command code to get the starting search index
276
    COMMAND_INDEX       searchIndex = (COMMAND_INDEX)commandCode;
20,936✔
277
    BOOL                vendor = (commandCode & CC_VEND) != 0;
20,936✔
278
    COMMAND_INDEX       commandIndex;
20,936✔
279
#if !COMPRESSED_LISTS
280
    if(!vendor)
281
        {
282
            commandIndex = searchIndex - (COMMAND_INDEX)s_ccAttr[0].commandIndex;
283
            // Check for out of range or unimplemented.
284
            // Note, since a COMMAND_INDEX is unsigned, if searchIndex is smaller than
285
            // the lowest value of command, it will become a 'negative' number making
286
            // it look like a large unsigned number, this will cause it to fail
287
            // the unsigned check below.
288
            if(commandIndex >= LIBRARY_COMMAND_ARRAY_SIZE
289
               || (s_commandAttributes[commandIndex] & IS_IMPLEMENTED) == 0)
290
                return UNIMPLEMENTED_COMMAND_INDEX;
291
            return commandIndex;
292
        }
293
#endif
294
    // Need this code for any vendor code lookup or for compressed lists
295
    commandIndex = GetClosestCommandIndex(commandCode);
20,936✔
296
    // Look at the returned value from get closest. If it isn't the one that was
297
    // requested, then the command is not implemented.
298
    if(commandIndex != UNIMPLEMENTED_COMMAND_INDEX)
20,936✔
299
        {
300
            if((GET_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, commandIndex)
20,932✔
301
                != searchIndex)
302
               || (IS_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, V)) != vendor)
20,932✔
303
                commandIndex = UNIMPLEMENTED_COMMAND_INDEX;
×
304
        }
305
    return commandIndex;
20,936✔
306
}
307
/* 9.3.3.4 GetNextCommandIndex() */
308
/* This function returns the index of the next implemented command. */
309
/* Return Values Meaning */
310
/* UNIMPLEMENTED_COMMAND_INDEX no more implemented commands */
311
/* other the index of the next implemented command */
312
COMMAND_INDEX
313
GetNextCommandIndex(
7,880✔
314
                    COMMAND_INDEX    commandIndex   // IN: the starting index
315
                    )
316
{
317
    while(++commandIndex < COMMAND_COUNT)
7,880✔
318
        {
319
#if !COMPRESSED_LISTS
320
            if(s_commandAttributes[commandIndex] & IS_IMPLEMENTED)
321
#endif
322
                return commandIndex;
323
        }
324
    return UNIMPLEMENTED_COMMAND_INDEX;
94✔
325
}
326
/* 9.3.3.5 GetCommandCode() */
327
/* This function returns the commandCode associated with the command index */
328
TPM_CC
329
GetCommandCode(
57✔
330
               COMMAND_INDEX    commandIndex   // IN: the command index
331
               )
332
{
333
    TPM_CC           commandCode = GET_ATTRIBUTE(s_ccAttr[commandIndex],
57✔
334
                                                 TPMA_CC, commandIndex);
335
    if(IS_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, V))
57✔
336
        commandCode += CC_VEND;
×
337
    return commandCode;
57✔
338
}
339
/* 9.3.3.6 CommandAuthRole() */
340
/* This function returns the authorization role required of a handle. */
341
/* Return Values Meaning */
342
/* AUTH_NONE no authorization is required */
343
/* AUTH_USER user role authorization is required */
344
/* AUTH_ADMIN admin role authorization is required */
345
/* AUTH_DUP duplication role authorization is required */
346
AUTH_ROLE
347
CommandAuthRole(
17,276✔
348
                COMMAND_INDEX    commandIndex,  // IN: command index
349
                UINT32           handleIndex    // IN: handle index (zero based)
350
                )
351
{
352
    if(0 == handleIndex)
17,276✔
353
        {
354
            // Any authorization role set?
355
            COMMAND_ATTRIBUTES  properties = s_commandAttributes[commandIndex];
14,174✔
356
            if(properties & HANDLE_1_USER)
14,174✔
357
                return AUTH_USER;
358
            if(properties & HANDLE_1_ADMIN)
2,271✔
359
                return AUTH_ADMIN;
360
            if(properties & HANDLE_1_DUP)
1,706✔
361
                return AUTH_DUP;
33✔
362
        }
363
    else if(1 == handleIndex)
3,102✔
364
        {
365
            if(s_commandAttributes[commandIndex] & HANDLE_2_USER)
3,030✔
366
                return AUTH_USER;
761✔
367
        }
368
    return AUTH_NONE;
369
}
370
/* 9.3.3.7 EncryptSize() */
371
/* This function returns the size of the decrypt size field. This function returns 0 if encryption
372
   is not allowed */
373
/* Return Values Meaning */
374
/* 0 encryption not allowed */
375
/* 2 size field is two bytes */
376
/* 4 size field is four bytes */
377

378
int
379
EncryptSize(
300✔
380
            COMMAND_INDEX    commandIndex   // IN: command index
381
            )
382
{
383
    return ((s_commandAttributes[commandIndex] & ENCRYPT_2) ? 2 :
300✔
384
            (s_commandAttributes[commandIndex] & ENCRYPT_4) ? 4 : 0);
×
385
}
386

387
/* 9.3.3.8 DecryptSize() */
388
/* This function returns the size of the decrypt size field. This function returns 0 if decryption
389
   is not allowed */
390
/* Return Values Meaning */
391
/* 0 encryption not allowed */
392
/* 2 size field is two bytes */
393
/* 4 size field is four bytes */
394

395
int
396
DecryptSize(
306✔
397
            COMMAND_INDEX    commandIndex   // IN: command index
398
            )
399
{
400
    return ((s_commandAttributes[commandIndex] & DECRYPT_2) ? 2 :
306✔
401
            (s_commandAttributes[commandIndex] & DECRYPT_4) ? 4 : 0);
×
402
}
403

404
/* 9.3.3.9 IsSessionAllowed() */
405
/* This function indicates if the command is allowed to have sessions. */
406
/* This function must not be called if the command is not known to be implemented. */
407
/* Return Values Meaning */
408
/* TRUE session is allowed with this command */
409
/* FALSE session is not allowed with this command */
410

411
BOOL
412
IsSessionAllowed(
20,038✔
413
                 COMMAND_INDEX    commandIndex   // IN: the command to be checked
414
                 )
415
{
416
    return ((s_commandAttributes[commandIndex] & NO_SESSIONS) == 0);
20,038✔
417
}
418

419
/* 9.3.3.10 IsHandleInResponse() */
420
/* This function determines if a command has a handle in the response */
421

422
BOOL
423
IsHandleInResponse(
15,582✔
424
                   COMMAND_INDEX    commandIndex
425
                   )
426
{
427
    return ((s_commandAttributes[commandIndex] & R_HANDLE) != 0);
15,582✔
428
}
429

430
/* 9.3.3.11 IsWriteOperation() */
431
/* Checks to see if an operation will write to an NV Index and is subject to being blocked by
432
   read-lock */
433
BOOL
434
IsWriteOperation(
445✔
435
                 COMMAND_INDEX    commandIndex   // IN: Command to check
436
                 )
437
{
438
#ifdef  WRITE_LOCK
439
    return ((s_commandAttributes[commandIndex] & WRITE_LOCK) != 0);
440
#else
441
    if(!IS_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, V))
445✔
442
        {
443
            switch(GET_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, commandIndex))
445✔
444
                {
445
                  case TPM_CC_NV_Write:
197✔
446
#if CC_NV_Increment
447
                  case TPM_CC_NV_Increment:
448
#endif
449
#if CC_NV_SetBits
450
                  case TPM_CC_NV_SetBits:
451
#endif
452
#if CC_NV_Extend
453
                  case TPM_CC_NV_Extend:
454
#endif
455
#if CC_AC_Send
456
                  case TPM_CC_AC_Send:
457
#endif
458
                    // NV write lock counts as a write operation for authorization purposes.
459
                    // We check to see if the NV is write locked before we do the
460
                    // authorization. If it is locked, we fail the command early.
461
                  case TPM_CC_NV_WriteLock:
462
                    return TRUE;
197✔
463
                  default:
464
                    break;
465
                }
466
        }
467
    return FALSE;
468
#endif
469
}
470
/* 9.3.3.12 IsReadOperation() */
471
/* Checks to see if an operation will write to an NV Index and is subject to being blocked by
472
   write-lock. */
473
BOOL
474
IsReadOperation(
×
475
                COMMAND_INDEX    commandIndex   // IN: Command to check
476
                )
477
{
478
#ifdef  READ_LOCK
479
    return ((s_commandAttributes[commandIndex] & READ_LOCK) != 0);
480
#else
481
    if(!IS_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, V))
×
482
        {
483
            switch(GET_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, commandIndex))
×
484
                {
485
                  case TPM_CC_NV_Read:
×
486
                  case TPM_CC_PolicyNV:
487
                  case TPM_CC_NV_Certify:
488
                    // NV read lock counts as a read operation for authorization purposes.
489
                    // We check to see if the NV is read locked before we do the
490
                    // authorization. If it is locked, we fail the command early.
491
                  case TPM_CC_NV_ReadLock:
492
                    return TRUE;
×
493
                  default:
494
                    break;
495
                }
496
        }
497
    return FALSE;
498
#endif
499
}
500
/* 9.3.3.13 CommandCapGetCCList() */
501
/* This function returns a list of implemented commands and command attributes starting from the
502
   command in commandCode. */
503
/* Return Values Meaning */
504
/* YES more command attributes are available */
505
/* NO no more command attributes are available */
506
TPMI_YES_NO
507
CommandCapGetCCList(
45✔
508
                    TPM_CC           commandCode,   // IN: start command code
509
                    UINT32           count,         // IN: maximum count for number of entries in
510
                    //     'commandList'
511
                    TPML_CCA        *commandList    // OUT: list of TPMA_CC
512
                    )
513
{
514
    TPMI_YES_NO      more = NO;
45✔
515
    COMMAND_INDEX    commandIndex;
45✔
516
    // initialize output handle list count
517
    commandList->count = 0;
45✔
518
    for(commandIndex = GetClosestCommandIndex(commandCode);
45✔
519
        commandIndex != UNIMPLEMENTED_COMMAND_INDEX;
1,269✔
520
        commandIndex = GetNextCommandIndex(commandIndex))
1,224✔
521
        {
522
#if !COMPRESSED_LISTS
523
            // this check isn't needed for compressed lists.
524
            if(!(s_commandAttributes[commandIndex] & IS_IMPLEMENTED))
525
                continue;
526
#endif
527
            if(commandList->count < count)
1,257✔
528
                {
529
                    // If the list is not full, add the attributes for this command.
530
                    commandList->commandAttributes[commandList->count]
1,224✔
531
                        = s_ccAttr[commandIndex];
1,224✔
532
                    commandList->count++;
1,224✔
533
                }
534
            else
535
                {
536
                    // If the list is full but there are more commands to report,
537
                    // indicate this and return.
538
                    more = YES;
539
                    break;
540
                }
541
        }
542
    return more;
45✔
543
}
544
#if 0 /* libtpms added */
545
/* 9.3.3.14 IsVendorCommand() */
546
/* Function indicates if a command index references a vendor command. */
547
/* Return Values Meaning */
548
/* TRUE command is a vendor command */
549
/* FALSE command is not a vendor command */
550

551
BOOL
552
IsVendorCommand(
553
                COMMAND_INDEX    commandIndex   // IN: command index to check
554
                )
555
{
556
    return (IS_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, V));
557
}
558
#endif /* libtpms added */
559

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc