tpm2-pkcs11
tpm2-pkcs11 copied to clipboard
ctx->did_check_for_encdec2 is never set in src/lib/tpm.c
Hello,
https://github.com/tpm2-software/tpm2-pkcs11/blob/1.7.0/src/lib/tpm.c contains:
static TSS2_RC do_part_encrypt_decrypt(
tpm_ctx *ctx, uint32_t handle,
TPMI_ALG_SYM_MODE mode, TPMI_YES_NO is_decrypt,
const TPM2B_MAX_BUFFER *data_in, const TPM2B_IV *iv_in,
TPM2B_MAX_BUFFER **data_out, TPM2B_IV **iv_out) {
TSS2_RC rval = TSS2_RC_SUCCESS;
/* figure out what command to use */
if (!ctx->did_check_for_encdec2) {
/* do not free, value is cached */
rval = tpm_supports_cc(ctx, TPM2_CC_EncryptDecrypt2,
&ctx->use_encdec2);
if (rval != TSS2_RC_SUCCESS) {
return rval;
}
}
// ...
This code seems to implement some caching of ctx->use_encdec2
using a boolean ctx->did_check_for_encdec2
.
Nevertheless ctx->did_check_for_encdec2
is not set anywhere.
Is a ctx->did_check_for_encdec2 = true;
statement missing, or should the caching mechanism around ctx->use_encdec2
be dropped?
I think it needs the ctx->did_check_for_encdec2 = true;
in that block.