]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
libtpmtss: Fix build with DEBUG_LEVEL < 2
authorTobias Brunner <tobias@strongswan.org>
Tue, 2 May 2023 09:16:22 +0000 (11:16 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 8 May 2023 15:32:17 +0000 (17:32 +0200)
src/libtpmtss/tpm_tss_trousers.c
src/libtpmtss/tpm_tss_tss2_session.c
src/libtpmtss/tpm_tss_tss2_v2.c

index 50401e8535d4275545f03b947387084d9b93886f..8c3541eb4d51ce4a486cb44b59a247f8d5cbcc3b 100644 (file)
@@ -124,7 +124,6 @@ static bool initialize_context(private_tpm_tss_trousers_t *this)
        uint32_t version_len;
 
        TSS_RESULT result;
-       TPM_CAP_VERSION_INFO *info;
 
        result = Tspi_Context_Create(&this->hContext);
        if (result != TSS_SUCCESS)
@@ -159,12 +158,14 @@ static bool initialize_context(private_tpm_tss_trousers_t *this)
                return FALSE;
        }
 
-       info = (TPM_CAP_VERSION_INFO *)version_ptr;
+#if DEBUG_LEVEL > 2
+       TPM_CAP_VERSION_INFO *info = (TPM_CAP_VERSION_INFO *)version_ptr;
        DBG2(DBG_PTS, "TPM Version Info: Chip Version: %u.%u.%u.%u, "
                 "Spec Level: %u, Errata Rev: %u, Vendor ID: %.4s",
                 info->version.major, info->version.minor,
                 info->version.revMajor, info->version.revMinor,
                 untoh16(&info->specLevel), info->errataRev, info->tpmVendorID);
+#endif
 
        this->version_info = chunk_clone(chunk_create(version_ptr, version_len));
 
@@ -466,7 +467,7 @@ METHOD(tpm_tss_t, quote, bool,
        uint32_t version_info_size, pcr;
        aik_t *aik;
        chunk_t aik_blob = chunk_empty;
-       chunk_t quote_chunk, pcr_digest;
+       chunk_t quote_chunk DBG_UNUSED, pcr_digest;
        enumerator_t *enumerator;
        bool success = FALSE;
 
index 3a7ce29b0224c800c3257b2906112f3da563472c..a62b148544146b62c3e41dbb9278312150c6dc66 100644 (file)
@@ -133,7 +133,7 @@ METHOD(tpm_tss_tss2_session_t, set_cmd_auths, bool,
        hasher_t *hasher;
        pseudo_random_function_t prf_alg;
        prf_t *prf;
-       chunk_t data, cp_hash, cp_hmac, nonce_caller, nonce_tpm, session_attributes;
+       chunk_t data, cp_hash, nonce_caller, nonce_tpm, session_attributes;
        bool success;
        uint32_t rval;
 
@@ -233,8 +233,8 @@ METHOD(tpm_tss_tss2_session_t, set_cmd_auths, bool,
                DBG1(DBG_PTS, "cpHmac computation failed");
                return FALSE;
        }
-       cp_hmac = chunk_create(cmd.auths[0].hmac.buffer, cmd.auths[0].hmac.size);
-       DBG2(DBG_PTS, LABEL "cpHmac: %B", &cp_hmac);
+       DBG2(DBG_PTS, LABEL "cpHmac: %b", cmd.auths[0].hmac.buffer,
+                cmd.auths[0].hmac.size);
 
        rval = Tss2_Sys_SetCmdAuths(this->sys_context, &cmd);
        if (rval != TSS2_RC_SUCCESS)
@@ -319,7 +319,7 @@ METHOD(tpm_tss_tss2_session_t, get_rsp_auths, bool,
        prf_t *prf;
        crypter_t *crypter;
        chunk_t kdf_label = chunk_from_chars('C','F','B', 0x00);
-       chunk_t data, rp_hash, rp_hmac, nonce_caller, nonce_tpm, session_attributes;
+       chunk_t data, rp_hash, nonce_caller, nonce_tpm, session_attributes;
        chunk_t key_mat, aes_key, aes_iv;
        bool success;
        uint32_t rval;
@@ -410,8 +410,7 @@ METHOD(tpm_tss_tss2_session_t, get_rsp_auths, bool,
                DBG1(DBG_PTS, "computation of rpHmac failed");
                return FALSE;
        }
-       rp_hmac = chunk_create(rpHmac.buffer, rpHmac.size);
-       DBG2(DBG_PTS, LABEL "rpHMAC: %B", &rp_hmac);
+       DBG2(DBG_PTS, LABEL "rpHMAC: %b", rpHmac.buffer, rpHmac.size);
 
        /* verify rpHmac */
        if (!memeq(rsp.auths[0].hmac.buffer, rpHmac.buffer, rpHmac.size))
index ef56a16eb0f36c3df127940aa4428d53e36217c2..6deefe910feff5b452520030846ba934b2b87656 100644 (file)
@@ -664,6 +664,8 @@ METHOD(tpm_tss_t, get_public, chunk_t,
                        DBG1(DBG_PTS, LABEL "unsupported key type");
                        return chunk_empty;
        }
+
+#if DEBUG_LEVEL >= 1
        if (public.publicArea.objectAttributes & TPMA_OBJECT_SIGN_ENCRYPT)
        {
                TPMT_ASYM_SCHEME *s;
@@ -682,6 +684,7 @@ METHOD(tpm_tss_t, get_public, chunk_t,
                                          tpm_alg_id_names, s->algorithm,
                                          tpm_alg_id_names, s->mode, s->keyBits.sym);
        }
+#endif
 
        return aik_pubkey;
 }