Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 1 | // This file was extracted from the TCG Published |
| 2 | // Trusted Platform Module Library |
| 3 | // Part 4: Supporting Routines |
| 4 | // Family "2.0" |
| 5 | // Level 00 Revision 01.16 |
| 6 | // October 30, 2014 |
| 7 | |
| 8 | #include "InternalRoutines.h" |
| 9 | // |
| 10 | // |
| 11 | // LocalityGetAttributes() |
| 12 | // |
| 13 | // This function will convert a locality expressed as an integer into TPMA_LOCALITY form. |
| 14 | // The function returns the locality attribute. |
| 15 | // |
| 16 | TPMA_LOCALITY |
| 17 | LocalityGetAttributes( |
| 18 | UINT8 locality // IN: locality value |
| 19 | ) |
| 20 | { |
| 21 | TPMA_LOCALITY locality_attributes; |
| 22 | BYTE *localityAsByte = (BYTE *)&locality_attributes; |
| 23 | MemorySet(&locality_attributes, 0, sizeof(TPMA_LOCALITY)); |
| 24 | switch(locality) |
| 25 | { |
| 26 | case 0: |
Vadim Bendebury | 0baf7f1 | 2015-05-29 18:24:47 -0700 | [diff] [blame] | 27 | locality_attributes.locZero = SET; |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 28 | break; |
| 29 | case 1: |
Vadim Bendebury | 0baf7f1 | 2015-05-29 18:24:47 -0700 | [diff] [blame] | 30 | locality_attributes.locOne = SET; |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 31 | break; |
| 32 | case 2: |
Vadim Bendebury | 0baf7f1 | 2015-05-29 18:24:47 -0700 | [diff] [blame] | 33 | locality_attributes.locTwo = SET; |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 34 | break; |
| 35 | case 3: |
Vadim Bendebury | 0baf7f1 | 2015-05-29 18:24:47 -0700 | [diff] [blame] | 36 | locality_attributes.locThree = SET; |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 37 | break; |
| 38 | case 4: |
Vadim Bendebury | 0baf7f1 | 2015-05-29 18:24:47 -0700 | [diff] [blame] | 39 | locality_attributes.locFour = SET; |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 40 | break; |
| 41 | default: |
nagendra modadugu | 5c18d72 | 2016-04-07 11:22:35 -0700 | [diff] [blame] | 42 | pAssert(locality > 31); |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 43 | *localityAsByte = locality; |
| 44 | break; |
| 45 | } |
| 46 | return locality_attributes; |
| 47 | } |