|
30 | 30 |
|
31 | 31 | /* For some struct to buffer conversions */ |
32 | 32 | #include <wolftpm/tpm2_packet.h> |
33 | | - |
| 33 | +#include <hal/tpm_io.h> /* for default IO callback */ |
34 | 34 |
|
35 | 35 | /* Local Functions */ |
36 | 36 | static int wolfTPM2_GetCapabilities_NoDev(WOLFTPM2_CAPS* cap); |
@@ -182,7 +182,7 @@ WOLFTPM2_DEV* wolfTPM2_New(void) |
182 | 182 | WOLFTPM2_DEV *dev = (WOLFTPM2_DEV*)XMALLOC( |
183 | 183 | sizeof(WOLFTPM2_DEV), NULL, DYNAMIC_TYPE_TMP_BUFFER); |
184 | 184 | if (dev != NULL) { |
185 | | - if (wolfTPM2_Init(dev, NULL, NULL) != TPM_RC_SUCCESS) { |
| 185 | + if (wolfTPM2_Init(dev, TPM2_IoCb, NULL) != TPM_RC_SUCCESS) { |
186 | 186 | XFREE(dev, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
187 | 187 | dev = NULL; |
188 | 188 | } |
@@ -797,20 +797,27 @@ static int wolfTPM2_GetCapabilities_NoDev(WOLFTPM2_CAPS* cap) |
797 | 797 | #if defined(WOLFTPM_SLB9672) || defined(WOLFTPM_SLB9673) |
798 | 798 | /* Get vendor specific information */ |
799 | 799 | if (rc == 0) { |
800 | | - rc = tpm2_ifx_cap_vendor_get(cap, TPM_PT_VENDOR_FIX_FU_OPERATION_MODE, |
| 800 | + int rc_ifx; |
| 801 | + rc_ifx = tpm2_ifx_cap_vendor_get(cap, TPM_PT_VENDOR_FIX_FU_OPERATION_MODE, |
801 | 802 | &cap->opMode, sizeof(cap->opMode)); |
802 | | - } |
803 | | - if (rc == 0) { |
804 | | - rc = tpm2_ifx_cap_vendor_get(cap, TPM_PT_VENDOR_FIX_FU_KEYGROUP_ID, |
805 | | - (uint8_t*)&cap->keyGroupId, sizeof(cap->keyGroupId)); |
806 | | - } |
807 | | - if (rc == 0) { |
808 | | - rc = tpm2_ifx_cap_vendor_get(cap, TPM_PT_VENDOR_FIX_FU_COUNTER, |
809 | | - (uint8_t*)&cap->fwCounter, sizeof(cap->fwCounter)); |
810 | | - } |
811 | | - if (rc == 0) { |
812 | | - rc = tpm2_ifx_cap_vendor_get(cap, TPM_PT_VENDOR_FIX_FU_COUNTER_SAME, |
813 | | - (uint8_t*)&cap->fwCounterSame, sizeof(cap->fwCounterSame)); |
| 803 | + if (rc_ifx == 0) { |
| 804 | + rc_ifx = tpm2_ifx_cap_vendor_get(cap, TPM_PT_VENDOR_FIX_FU_KEYGROUP_ID, |
| 805 | + (uint8_t*)&cap->keyGroupId, sizeof(cap->keyGroupId)); |
| 806 | + } |
| 807 | + if (rc_ifx == 0) { |
| 808 | + rc_ifx = tpm2_ifx_cap_vendor_get(cap, TPM_PT_VENDOR_FIX_FU_COUNTER, |
| 809 | + (uint8_t*)&cap->fwCounter, sizeof(cap->fwCounter)); |
| 810 | + } |
| 811 | + if (rc_ifx == 0) { |
| 812 | + rc_ifx = tpm2_ifx_cap_vendor_get(cap, TPM_PT_VENDOR_FIX_FU_COUNTER_SAME, |
| 813 | + (uint8_t*)&cap->fwCounterSame, sizeof(cap->fwCounterSame)); |
| 814 | + } |
| 815 | + if (rc_ifx != 0) { |
| 816 | + #ifdef DEBUG_WOLFTPM |
| 817 | + printf("Error getting Infineon vendor capabilities 0x%x: %s\n", |
| 818 | + rc_ifx, TPM2_GetRCString(rc_ifx)); |
| 819 | + #endif |
| 820 | + } |
814 | 821 | } |
815 | 822 | #endif |
816 | 823 |
|
@@ -1142,7 +1149,7 @@ int wolfTPM2_Cleanup_ex(WOLFTPM2_DEV* dev, int doShutdown) |
1142 | 1149 | return rc; |
1143 | 1150 | #endif |
1144 | 1151 |
|
1145 | | - if (doShutdown) { |
| 1152 | + if (doShutdown && TPM2_GetActiveCtx() != NULL) { |
1146 | 1153 | Shutdown_In shutdownIn; |
1147 | 1154 | XMEMSET(&shutdownIn, 0, sizeof(shutdownIn)); |
1148 | 1155 | shutdownIn.shutdownType = TPM_SU_CLEAR; |
|
0 commit comments