Refactoring to tpm_tss_quote_info object

This commit is contained in:
Andreas Steffen
2016-06-26 18:19:05 +02:00
parent 12e1a06987
commit 721ed31b39
24 changed files with 924 additions and 398 deletions
+1
View File
@@ -7,6 +7,7 @@ AM_LDFLAGS = \
ipseclib_LTLIBRARIES = libtpmtss.la
libtpmtss_la_SOURCES = \
tpm_tss.h tpm_tss.c \
tpm_tss_quote_info.h tpm_tss_quote_info.c \
tpm_tss_trousers.h tpm_tss_trousers.c \
tpm_tss_tss2.h tpm_tss_tss2.c \
tpm_tss_tss2_names.h tpm_tss_tss2_names.c
+9 -15
View File
@@ -21,10 +21,12 @@
#ifndef TPM_TSS_H_
#define TPM_TSS_H_
#include "tpm_tss_quote_info.h"
#include <library.h>
#include <crypto/hashers/hasher.h>
typedef enum tpm_version_t tpm_version_t;
typedef enum tpm_quote_mode_t tpm_quote_mode_t;
typedef struct tpm_tss_t tpm_tss_t;
/**
@@ -36,15 +38,6 @@ enum tpm_version_t {
TPM_VERSION_2_0,
};
/**
* TPM Quote Modes
*/
enum tpm_quote_mode_t {
TPM_QUOTE,
TPM_QUOTE2,
TPM_QUOTE2_VERSION_INFO
};
/**
* TPM access via TSS public interface
*/
@@ -114,14 +107,15 @@ struct tpm_tss_t {
* @param pcr_sel selection of PCR registers
* @param alg hash algorithm to be used for quote signature
* @param data additional data to be hashed into the quote
* @param mode define current and legacy TPM quote modes
* @param pcr_comp returns hash of PCR composite
* @param sig returns quote signature
* @param quote_mode define current and legacy TPM quote modes
* @param quote_info returns various info covered by quote signature
* @param quote_sig returns quote signature
* @return TRUE if quote signature succeeded
*/
bool (*quote)(tpm_tss_t *this, uint32_t aik_handle, uint32_t pcr_sel,
hash_algorithm_t alg, chunk_t data, tpm_quote_mode_t mode,
chunk_t *pcr_comp, chunk_t *quote_sig);
hash_algorithm_t alg, chunk_t data,
tpm_quote_mode_t *quote_mode,
tpm_tss_quote_info_t **quote_info, chunk_t *quote_sig);
/**
* Destroy a tpm_tss_t.
+330
View File
@@ -0,0 +1,330 @@
/*
* Copyright (C) 2016 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include <tpm_tss_quote_info.h>
#include <bio/bio_writer.h>
#ifndef TPM_TAG_QUOTE_INFO2
#define TPM_TAG_QUOTE_INFO2 0x0036
#endif
#ifndef TPM_LOC_ZERO
#define TPM_LOC_ZERO 0x01
#endif
typedef struct private_tpm_tss_quote_info_t private_tpm_tss_quote_info_t;
/**
* Private data of an tpm_tss_quote_info_t object.
*/
struct private_tpm_tss_quote_info_t {
/**
* Public tpm_tss_quote_info_t interface.
*/
tpm_tss_quote_info_t public;
/**
* TPM Quote Mode
*/
tpm_quote_mode_t quote_mode;
/**
* TPM Qualified Signer
*/
chunk_t qualified_signer;
/**
* TPM Clock Info
*/
chunk_t clock_info;
/**
* TPM Version Info
*/
chunk_t version_info;
/**
* TPM PCR Selection
*/
chunk_t pcr_select;
/**
* TPM PCR Composite Hash
*/
chunk_t pcr_digest;
/**
* TPM PCR Composite Hash algoritm
*/
hash_algorithm_t pcr_digest_alg;
/**
* Reference count
*/
refcount_t ref;
};
METHOD(tpm_tss_quote_info_t, get_quote_mode, tpm_quote_mode_t,
private_tpm_tss_quote_info_t *this)
{
return this->quote_mode;
}
METHOD(tpm_tss_quote_info_t, get_pcr_digest_alg, hash_algorithm_t,
private_tpm_tss_quote_info_t *this)
{
return this->pcr_digest_alg;
}
METHOD(tpm_tss_quote_info_t, get_pcr_digest, chunk_t,
private_tpm_tss_quote_info_t *this)
{
return this->pcr_digest;
}
METHOD(tpm_tss_quote_info_t, get_quote, bool,
private_tpm_tss_quote_info_t *this, chunk_t nonce,
tpm_tss_pcr_composite_t *composite, chunk_t *quoted)
{
chunk_t pcr_composite, pcr_digest;
bio_writer_t *writer;
hasher_t *hasher;
bool equal_digests;
/* Construct PCR Composite */
writer = bio_writer_create(32);
switch (this->quote_mode)
{
case TPM_QUOTE:
case TPM_QUOTE2:
case TPM_QUOTE2_VERSION_INFO:
writer->write_data16(writer, composite->pcr_select);
writer->write_data32(writer, composite->pcr_composite);
break;
case TPM_QUOTE_TPM2:
writer->write_data(writer, composite->pcr_composite);
break;
case TPM_QUOTE_NONE:
break;
}
pcr_composite = writer->extract_buf(writer);
writer->destroy(writer);
DBG2(DBG_PTS, "constructed PCR Composite: %B", &pcr_composite);
/* Compute PCR Composite Hash */
hasher = lib->crypto->create_hasher(lib->crypto, this->pcr_digest_alg);
if (!hasher || !hasher->allocate_hash(hasher, pcr_composite, &pcr_digest))
{
DESTROY_IF(hasher);
chunk_free(&pcr_composite);
return FALSE;
}
hasher->destroy(hasher);
chunk_free(&pcr_composite);
DBG2(DBG_PTS, "constructed PCR Composite digest: %B", &pcr_digest);
equal_digests = chunk_equals(pcr_digest, this->pcr_digest);
/* Construct Quote Info */
writer = bio_writer_create(32);
switch (this->quote_mode)
{
case TPM_QUOTE:
/* Version number */
writer->write_data(writer, chunk_from_chars(1, 1, 0, 0));
/* Magic QUOT value */
writer->write_data(writer, chunk_from_str("QUOT"));
/* PCR Composite Hash */
writer->write_data(writer, pcr_digest);
/* Secret assessment value 20 bytes (nonce) */
writer->write_data(writer, nonce);
break;
case TPM_QUOTE2:
case TPM_QUOTE2_VERSION_INFO:
/* TPM Structure Tag */
writer->write_uint16(writer, TPM_TAG_QUOTE_INFO2);
/* Magic QUT2 value */
writer->write_data(writer, chunk_from_str("QUT2"));
/* Secret assessment value 20 bytes (nonce) */
writer->write_data(writer, nonce);
/* PCR selection */
writer->write_data16(writer, composite->pcr_select);
/* TPM Locality Selection */
writer->write_uint8(writer, TPM_LOC_ZERO);
/* PCR Composite Hash */
writer->write_data(writer, pcr_digest);
if (this->quote_mode == TPM_QUOTE2_VERSION_INFO)
{
/* TPM version Info */
writer->write_data(writer, this->version_info);
}
break;
case TPM_QUOTE_TPM2:
/* Magic */
writer->write_data(writer, chunk_from_chars(0xff,0x54,0x43,0x47));
/* Type */
writer->write_uint16(writer, 0x8018);
/* Qualified Signer */
writer->write_data16(writer, this->qualified_signer);
/* Extra Data */
writer->write_data16(writer, nonce);
/* Clock Info */
writer->write_data(writer, this->clock_info);
/* Firmware Version */
writer->write_data(writer, this->version_info);
/* PCR Selection */
writer->write_data(writer, this->pcr_select);
/* PCR Composite Hash */
writer->write_data16(writer, pcr_digest);
break;
case TPM_QUOTE_NONE:
break;
}
chunk_free(&pcr_digest);
*quoted = writer->extract_buf(writer);
writer->destroy(writer);
DBG2(DBG_PTS, "constructed TPM Quote Info: %B", quoted);
if (!equal_digests)
{
DBG1(DBG_IMV, "received PCR Composite digest does not match "
"constructed one");
chunk_free(quoted);
}
return equal_digests;
}
METHOD(tpm_tss_quote_info_t, set_version_info, void,
private_tpm_tss_quote_info_t *this, chunk_t version_info)
{
chunk_free(&this->version_info);
this->version_info = chunk_clone(version_info);
}
METHOD(tpm_tss_quote_info_t, get_version_info, chunk_t,
private_tpm_tss_quote_info_t *this)
{
return this->version_info;
}
METHOD(tpm_tss_quote_info_t, set_tpm2_info, void,
private_tpm_tss_quote_info_t *this, chunk_t qualified_signer,
chunk_t clock_info, chunk_t pcr_select)
{
chunk_free(&this->qualified_signer);
this->qualified_signer = chunk_clone(qualified_signer);
chunk_free(&this->clock_info);
this->clock_info = chunk_clone(clock_info);
chunk_free(&this->pcr_select);
this->pcr_select = chunk_clone(pcr_select);
}
METHOD(tpm_tss_quote_info_t, get_tpm2_info, void,
private_tpm_tss_quote_info_t *this, chunk_t *qualified_signer,
chunk_t *clock_info, chunk_t *pcr_select)
{
if (qualified_signer)
{
*qualified_signer = this->qualified_signer;
}
if (clock_info)
{
*clock_info = this->clock_info;
}
if (pcr_select)
{
*pcr_select = this->pcr_select;
}
}
METHOD(tpm_tss_quote_info_t, get_ref, tpm_tss_quote_info_t*,
private_tpm_tss_quote_info_t *this)
{
ref_get(&this->ref);
return &this->public;
}
METHOD(tpm_tss_quote_info_t, destroy, void,
private_tpm_tss_quote_info_t *this)
{
if (ref_put(&this->ref))
{
chunk_free(&this->qualified_signer);
chunk_free(&this->clock_info);
chunk_free(&this->version_info);
chunk_free(&this->pcr_select);
chunk_free(&this->pcr_digest);
free(this);
}
}
/**
* See header
*/
tpm_tss_quote_info_t *tpm_tss_quote_info_create(tpm_quote_mode_t quote_mode,
hash_algorithm_t pcr_digest_alg, chunk_t pcr_digest)
{
private_tpm_tss_quote_info_t *this;
INIT(this,
.public = {
.get_quote_mode = _get_quote_mode,
.get_pcr_digest_alg = _get_pcr_digest_alg,
.get_pcr_digest = _get_pcr_digest,
.get_quote = _get_quote,
.set_version_info = _set_version_info,
.get_version_info = _get_version_info,
.set_tpm2_info = _set_tpm2_info,
.get_tpm2_info = _get_tpm2_info,
.get_ref = _get_ref,
.destroy = _destroy,
},
.quote_mode = quote_mode,
.pcr_digest_alg = pcr_digest_alg,
.pcr_digest = chunk_clone(pcr_digest),
.ref = 1,
);
return &this->public;
}
+151
View File
@@ -0,0 +1,151 @@
/*
* Copyright (C) 2016 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/**
* @defgroup tpm_tss_quote_info tpm_tss_quote_info
* @{ @ingroup libtpmtss
*/
#ifndef TPM_TSS_QUOTE_INFO_H_
#define TPM_TSS_QUOTE_INFO_H_
#include <library.h>
#include <crypto/hashers/hasher.h>
typedef enum tpm_quote_mode_t tpm_quote_mode_t;
typedef struct tpm_tss_quote_info_t tpm_tss_quote_info_t;
typedef struct tpm_tss_pcr_composite_t tpm_tss_pcr_composite_t;
/**
* TPM Quote Modes
*/
enum tpm_quote_mode_t {
TPM_QUOTE_NONE,
TPM_QUOTE,
TPM_QUOTE2,
TPM_QUOTE2_VERSION_INFO,
TPM_QUOTE_TPM2
};
struct tpm_tss_pcr_composite_t {
/**
* Bit map of selected PCRs
*/
chunk_t pcr_select;
/**
* Array of selected PCRs
*/
chunk_t pcr_composite;
};
/**
* TPM Quote Information needed to verify the Quote Signature
*/
struct tpm_tss_quote_info_t {
/**
* Get TPM Quote Mode
*
* @return TPM Quote Mode
*/
tpm_quote_mode_t (*get_quote_mode)(tpm_tss_quote_info_t *this);
/**
* Get PCR Composite digest algorithm
*
* @return PCR Composite digest algorithm
*/
hash_algorithm_t (*get_pcr_digest_alg)(tpm_tss_quote_info_t *this);
/**
* Get PCR Composite digest
*
* @return PCR Composite digest
*/
chunk_t (*get_pcr_digest)(tpm_tss_quote_info_t *this);
/**
* Get TPM Quote Info digest, the basis of the TPM Quote Singature
*
* @param nonce Derived from the Diffie-Hellman exchange
* @param composite PCR Composite as computed by IMV
* @param quoted Encoded TPM Quote
* @return TRUE if TPM Quote was successfully constructed
*/
bool (*get_quote)(tpm_tss_quote_info_t *this, chunk_t nonce,
tpm_tss_pcr_composite_t *composite,
chunk_t *quoted);
/**
* Set TPM version info (needed for TPM 1.2)
*
* @param version_info TPM 1.2 version info
*/
void (*set_version_info)(tpm_tss_quote_info_t *this, chunk_t version_info);
/**
* Get TPM 2.0 version info (needed for TPM 2.0)
*
* @return TPM 2.0 firmwareVersioin
*/
chunk_t (*get_version_info)(tpm_tss_quote_info_t *this);
/**
* Set TPM 2.0 info parameters (needed for TPM 2.0)
*
* @param qualified_signer TPM 2.0 qualifiedSigner
* @param clock_info TPM 2.0 clockInfo
* @param pcr_select TPM 2.0 pcrSelect
*/
void (*set_tpm2_info)(tpm_tss_quote_info_t *this, chunk_t qualified_signer,
chunk_t clock_info, chunk_t pcr_select);
/**
* Get TPM 2.0 info parameters (needed for TPM 2.0)
*
* @param qualified_signer TPM 2.0 qualifiedSigner
* @param clock_info TPM 2.0 clockInfo
* @param pcr_select TPM 2.0 pcrSelect
*/
void (*get_tpm2_info)(tpm_tss_quote_info_t *this, chunk_t *qualified_signer,
chunk_t *clock_info, chunk_t *pcr_select);
/**
* Get reference to Quote Info object.
*/
tpm_tss_quote_info_t* (*get_ref)(tpm_tss_quote_info_t *this);
/**
* Destroy a tpm_tss_quote_info_t.
*/
void (*destroy)(tpm_tss_quote_info_t *this);
};
/**
* Create a tpm_tss_quote_info instance.
*
* @param quote_mode TPM Quote mode
* @param pcr_digest_alg PCR Composite digest algorithm
* @param pcr_digest PCR Composite digest
*/
tpm_tss_quote_info_t *tpm_tss_quote_info_create(tpm_quote_mode_t quote_mode,
hash_algorithm_t pcr_digest_alg, chunk_t pcr_digest);
#endif /** TPM_TSS_QUOTE_INFO_H_ @}*/
+18 -18
View File
@@ -431,8 +431,8 @@ METHOD(tpm_tss_t, extend_pcr, bool,
METHOD(tpm_tss_t, quote, bool,
private_tpm_tss_trousers_t *this, uint32_t aik_handle, uint32_t pcr_sel,
hash_algorithm_t alg, chunk_t data, tpm_quote_mode_t mode, chunk_t *pcr_comp,
chunk_t *quote_sig)
hash_algorithm_t alg, chunk_t data, tpm_quote_mode_t *quote_mode,
tpm_tss_quote_info_t **quote_info, chunk_t *quote_sig)
{
TSS_HKEY hAIK;
TSS_HKEY hSRK;
@@ -446,7 +446,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_info;
chunk_t quote_chunk, pcr_digest;
enumerator_t *enumerator;
bool success = FALSE;
@@ -503,8 +503,8 @@ METHOD(tpm_tss_t, quote, bool,
/* Create PCR composite object */
result = Tspi_Context_CreateObject(this->hContext, TSS_OBJECT_TYPE_PCRS,
(mode == TPM_QUOTE) ? TSS_PCRS_STRUCT_INFO :
TSS_PCRS_STRUCT_INFO_SHORT,
(*quote_mode == TPM_QUOTE) ? TSS_PCRS_STRUCT_INFO :
TSS_PCRS_STRUCT_INFO_SHORT,
&hPcrComposite);
if (result != TSS_SUCCESS)
{
@@ -518,7 +518,7 @@ METHOD(tpm_tss_t, quote, bool,
{
if (pcr_sel & (1 << pcr))
{
result = (mode == TPM_QUOTE) ?
result = (*quote_mode == TPM_QUOTE) ?
Tspi_PcrComposite_SelectPcrIndex(hPcrComposite, pcr) :
Tspi_PcrComposite_SelectPcrIndexEx(hPcrComposite, pcr,
TSS_PCRS_DIRECTION_RELEASE);
@@ -536,22 +536,20 @@ METHOD(tpm_tss_t, quote, bool,
valData.rgbExternalData = data.ptr;
/* TPM Quote */
result = (mode == TPM_QUOTE) ?
result = (*quote_mode == TPM_QUOTE) ?
Tspi_TPM_Quote (this->hTPM, hAIK, hPcrComposite, &valData) :
Tspi_TPM_Quote2(this->hTPM, hAIK, mode == TPM_QUOTE2_VERSION_INFO,
Tspi_TPM_Quote2(this->hTPM, hAIK,
*quote_mode == TPM_QUOTE2_VERSION_INFO,
hPcrComposite, &valData, &version_info_size,
&version_info);
if (result != TSS_SUCCESS)
{
DBG1(DBG_PTS, "%s Tspi_TPM_Quote%s failed: 0x%x", LABEL,
(mode == TPM_QUOTE) ? "" : "2", result);
(*quote_mode == TPM_QUOTE) ? "" : "2", result);
goto err2;
}
/* Extract TPM_Composite_Hash */
*pcr_comp = chunk_alloc(HASH_SIZE_SHA1);
if (mode == TPM_QUOTE)
if (*quote_mode == TPM_QUOTE)
{
/* TPM_Composite_Hash starts at byte 8 of TPM_Quote_Info structure */
comp_hash = valData.rgbData + 8;
@@ -562,15 +560,17 @@ METHOD(tpm_tss_t, quote, bool,
comp_hash = valData.rgbData + valData.ulDataLength - version_info_size -
HASH_SIZE_SHA1;
}
memcpy(pcr_comp->ptr, comp_hash, HASH_SIZE_SHA1);
DBG3(DBG_PTS, "Hash of PCR Composite: %#B", pcr_comp);
pcr_digest = chunk_create(comp_hash, HASH_SIZE_SHA1);
DBG2(DBG_PTS, "PCR composite digest: %B", &pcr_digest);
quote_info = chunk_create(valData.rgbData, valData.ulDataLength);
DBG3(DBG_PTS, "TPM Quote Info: %B",&quote_info);
quote_chunk = chunk_create(valData.rgbData, valData.ulDataLength);
DBG2(DBG_PTS, "TPM Quote Info: %B", &quote_chunk);
*quote_info = tpm_tss_quote_info_create(*quote_mode, HASH_SHA1, pcr_digest);
*quote_sig = chunk_clone(chunk_create(valData.rgbValidationData,
valData.ulValidationDataLength));
DBG3(DBG_PTS, "TPM Quote Signature: %B",quote_sig);
DBG2(DBG_PTS, "TPM Quote Signature: %B", quote_sig);
success = TRUE;
+65 -17
View File
@@ -20,6 +20,7 @@
#include <asn1/asn1.h>
#include <asn1/oid.h>
#include <bio/bio_reader.h>
#include <tss2/tpm20.h>
#include <tcti/tcti_socket.h>
@@ -90,6 +91,26 @@ static TPM_ALG_ID hash_alg_to_tpm_alg_id(hash_algorithm_t alg)
}
}
/**
* Convert TPM_ALG_ID to hash algorithm
*/
static hash_algorithm_t hash_alg_from_tpm_alg_id(TPM_ALG_ID alg)
{
switch (alg)
{
case TPM_ALG_SHA1:
return HASH_SHA1;
case TPM_ALG_SHA256:
return HASH_SHA256;
case TPM_ALG_SHA384:
return HASH_SHA384;
case TPM_ALG_SHA512:
return HASH_SHA512;
default:
return HASH_UNKNOWN;
}
}
/**
* Check if an algorithm given by its TPM_ALG_ID is supported by the TPM
*/
@@ -483,19 +504,21 @@ METHOD(tpm_tss_t, extend_pcr, bool,
METHOD(tpm_tss_t, quote, bool,
private_tpm_tss_tss2_t *this, uint32_t aik_handle, uint32_t pcr_sel,
hash_algorithm_t alg, chunk_t data, tpm_quote_mode_t mode, chunk_t *pcr_comp,
chunk_t *quote_sig)
hash_algorithm_t alg, chunk_t data, tpm_quote_mode_t *quote_mode,
tpm_tss_quote_info_t **quote_info, chunk_t *quote_sig)
{
chunk_t quote_info;
chunk_t quoted_chunk, qualified_signer, extra_data, clock_info,
firmware_version, pcr_select, pcr_digest;
hash_algorithm_t pcr_digest_alg;
bio_reader_t *reader;
uint32_t rval;
TPM2B_DATA qualifying_data;
TPML_PCR_SELECTION pcr_selection;
TPMS_ATTEST *attest;
TPM2B_ATTEST quoted = { { sizeof(TPM2B_ATTEST)-2, } };
TPM2B_DIGEST digest;
TPMT_SIGNATURE sig;
TPMT_SIG_SCHEME scheme;
TPMT_SIGNATURE sig;
TPMI_ALG_HASH hash_alg;
TPMS_AUTH_COMMAND session_data_cmd;
TPMS_AUTH_RESPONSE session_data_rsp;
TSS2_SYS_CMD_AUTHS sessions_data_cmd;
@@ -524,11 +547,8 @@ METHOD(tpm_tss_t, quote, bool,
scheme.scheme = TPM_ALG_NULL;
memset(&sig, 0x00, sizeof(sig));
if (mode == TPM_QUOTE || mode == TPM_QUOTE2_VERSION_INFO)
{
DBG1(DBG_PTS, "%s TPM Quote mode not supported", LABEL);
return FALSE;
}
/* set Quote mode */
*quote_mode = TPM_QUOTE_TPM2;
if (!init_pcr_selection(this, pcr_sel, alg, &pcr_selection))
{
@@ -543,14 +563,29 @@ METHOD(tpm_tss_t, quote, bool,
DBG1(DBG_PTS,"%s Tss2_Sys_Quote failed: 0x%06x", LABEL, rval);
return FALSE;
}
quoted_chunk = chunk_create(quoted.t.attestationData, quoted.t.size);
attest = (TPMS_ATTEST *)quoted.t.attestationData;
digest = attest->attested.quote.pcrDigest;
*pcr_comp = chunk_clone(chunk_create(digest.t.buffer, digest.t.size));
DBG2(DBG_PTS, "Hash of PCR Composite: %#B", pcr_comp);
reader = bio_reader_create(chunk_skip(quoted_chunk, 6));
if (!reader->read_data16(reader, &qualified_signer) ||
!reader->read_data16(reader, &extra_data) ||
!reader->read_data (reader, 17, &clock_info) ||
!reader->read_data (reader, 8, &firmware_version) ||
!reader->read_data (reader, 10, &pcr_select) ||
!reader->read_data16(reader, &pcr_digest))
{
DBG1(DBG_PTS, "%s parsing of quoted struct failed", LABEL);
reader->destroy(reader);
return FALSE;
}
reader->destroy(reader);
quote_info = chunk_create(quoted.t.attestationData, quoted.t.size);
DBG2(DBG_PTS, "TPM Quote Info: %B",&quote_info);
DBG2(DBG_PTS, "PCR Composite digest: %B", &pcr_digest);
DBG2(DBG_PTS, "TPM Quote Info: %B", &quoted_chunk);
DBG2(DBG_PTS, "qualifiedSigner: %B", &qualified_signer);
DBG2(DBG_PTS, "extraData: %B", &extra_data);
DBG2(DBG_PTS, "clockInfo: %B", &clock_info);
DBG2(DBG_PTS, "firmwareVersion: %B", &firmware_version);
DBG2(DBG_PTS, "pcrSelect: %B", &pcr_select);
/* extract signature */
switch (sig.sigAlg)
@@ -561,6 +596,7 @@ METHOD(tpm_tss_t, quote, bool,
chunk_create(
sig.signature.rsassa.sig.t.buffer,
sig.signature.rsassa.sig.t.size));
hash_alg = sig.signature.rsassa.hash;
break;
case TPM_ALG_ECDSA:
case TPM_ALG_ECDAA:
@@ -573,14 +609,26 @@ METHOD(tpm_tss_t, quote, bool,
chunk_create(
sig.signature.ecdsa.signatureS.t.buffer,
sig.signature.ecdsa.signatureS.t.size));
hash_alg = sig.signature.ecdsa.hash;
break;
default:
DBG1(DBG_PTS, "%s unsupported %N signature algorithm",
LABEL, tpm_alg_id_names, sig.sigAlg);
return FALSE;
};
DBG2(DBG_PTS, "PCR digest algorithm is %N", tpm_alg_id_names, hash_alg);
pcr_digest_alg = hash_alg_from_tpm_alg_id(hash_alg);
DBG2(DBG_PTS, "TPM Quote Signature: %B", quote_sig);
/* Create and initialize Quote Info object */
*quote_info = tpm_tss_quote_info_create(*quote_mode, pcr_digest_alg,
pcr_digest);
(*quote_info)->set_tpm2_info(*quote_info, qualified_signer, clock_info,
pcr_select);
(*quote_info)->set_version_info(*quote_info, firmware_version);
return TRUE;
}