Skip to content

Commit 30759a7

Browse files
stoo-daviesAndreasFuchsTPM
authored andcommitted
Fixes #3577
Adds pagination to tpm2_getekcertificate & tpm2_nvreadpublic for TPMs with many handles. Signed-off-by: Stoo Davies <189670495+stoo-davies@users.noreply.github.com>
1 parent d785792 commit 30759a7

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

tools/tpm2_getekcertificate.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -987,9 +987,8 @@ tool_rc get_tpm_properties(ESYS_CONTEXT *ectx) {
987987
}
988988

989989
free(capability_data);
990-
rc = tpm2_getcap(ectx, TPM2_CAP_HANDLES,
991-
TPM2_NV_INDEX_FIRST, TPM2_PT_NV_INDEX_MAX, NULL,
992-
&capability_data);
990+
rc = tpm2_capability_get(ectx, TPM2_CAP_HANDLES,
991+
TPM2_NV_INDEX_FIRST, TPM2_MAX_CAP_HANDLES, &capability_data);
993992
if (rc != tool_rc_success) {
994993
LOG_ERR("Failed to read capability data for NV indices.");
995994
ctx.is_cert_on_nv = false;

tools/tpm2_nvreadpublic.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "files.h"
66
#include "tpm2_alg_util.h"
77
#include "tpm2_attr_util.h"
8+
#include "tpm2_capability.h"
89
#include "tpm2_nv_util.h"
910
#include "tpm2_tool.h"
1011

@@ -209,9 +210,8 @@ static tool_rc process_inputs(ESYS_CONTEXT *ectx) {
209210
* 3. Command specific initializations dependent on loaded objects
210211
*/
211212
if (ctx.nv_index == 0 && ctx.is_command_dispatch) {
212-
rc = tpm2_getcap(ectx, TPM2_CAP_HANDLES,
213-
TPM2_NV_INDEX_FIRST, TPM2_PT_NV_INDEX_MAX, NULL,
214-
&ctx.capability_data);
213+
rc = tpm2_capability_get(ectx, TPM2_CAP_HANDLES,
214+
TPM2_NV_INDEX_FIRST, TPM2_MAX_CAP_HANDLES, &ctx.capability_data);
215215
if (rc != tool_rc_success) {
216216
return rc;
217217
}

0 commit comments

Comments
 (0)