refactored DH group nonce exchange

This commit is contained in:
Andreas Steffen
2011-11-28 14:39:50 +01:00
parent 6728e09d39
commit cc1406d6fa
10 changed files with 364 additions and 398 deletions
+180 -116
View File
@@ -51,10 +51,25 @@ struct private_pts_t {
pts_meas_algorithms_t algorithm;
/**
* PTS Diffie Hellman Secret
* DH Hash Algorithm
*/
pts_meas_algorithms_t dh_hash_algorithm;
/**
* PTS Diffie-Hellman Secret
*/
diffie_hellman_t *dh;
/**
* PTS Diffie-Hellman Initiator Nonce
*/
chunk_t initiator_nonce;
/**
* PTS Diffie-Hellman Responder Nonce
*/
chunk_t responder_nonce;
/**
* Secret assessment value to be used for TPM Quote as an external data
*/
@@ -65,6 +80,11 @@ struct private_pts_t {
*/
char *platform_info;
/**
* TRUE if IMC-PTS, FALSE if IMV-PTS
*/
bool is_imc;
/**
* Do we have an activated TPM
*/
@@ -89,7 +109,7 @@ METHOD(pts_t, get_proto_caps, pts_proto_caps_flag_t,
}
METHOD(pts_t, set_proto_caps, void,
private_pts_t *this, pts_proto_caps_flag_t flags)
private_pts_t *this, pts_proto_caps_flag_t flags)
{
this->proto_caps = flags;
DBG2(DBG_PTS, "supported PTS protocol capabilities: %s%s%s%s%s",
@@ -101,102 +121,141 @@ METHOD(pts_t, set_proto_caps, void,
}
METHOD(pts_t, get_meas_algorithm, pts_meas_algorithms_t,
private_pts_t *this)
private_pts_t *this)
{
return this->algorithm;
}
METHOD(pts_t, set_meas_algorithm, void,
private_pts_t *this, pts_meas_algorithms_t algorithm)
private_pts_t *this, pts_meas_algorithms_t algorithm)
{
hash_algorithm_t hash_alg;
hash_alg = pts_meas_to_hash_algorithm(algorithm);
hash_alg = pts_meas_algo_to_hash(algorithm);
DBG2(DBG_PTS, "selected PTS measurement algorithm is %N",
hash_algorithm_names, hash_alg);
hash_algorithm_names, hash_alg);
if (hash_alg != HASH_UNKNOWN)
{
this->algorithm = algorithm;
}
}
METHOD(pts_t, create_dh, bool,
private_pts_t *this, pts_dh_group_t group)
METHOD(pts_t, get_dh_hash_algorithm, pts_meas_algorithms_t,
private_pts_t *this)
{
return this->dh_hash_algorithm;
}
METHOD(pts_t, set_dh_hash_algorithm, void,
private_pts_t *this, pts_meas_algorithms_t algorithm)
{
hash_algorithm_t hash_alg;
hash_alg = pts_meas_algo_to_hash(algorithm);
DBG2(DBG_PTS, "selected DH hash algorithm is %N",
hash_algorithm_names, hash_alg);
if (hash_alg != HASH_UNKNOWN)
{
this->dh_hash_algorithm = algorithm;
}
}
METHOD(pts_t, create_dh_nonce, bool,
private_pts_t *this, pts_dh_group_t group, int nonce_len)
{
diffie_hellman_group_t dh_group;
chunk_t *nonce;
rng_t *rng;
dh_group = pts_dh_group_to_strongswan_dh_group(group);
if (dh_group != MODP_NONE)
dh_group = pts_dh_group_to_ike(group);
DBG2(DBG_PTS, "selected PTS DH group is %N",
diffie_hellman_group_names, dh_group);
DESTROY_IF(this->dh);
this->dh = lib->crypto->create_dh(lib->crypto, dh_group);
rng = lib->crypto->create_rng(lib->crypto, RNG_STRONG);
if (!rng)
{
this->dh = lib->crypto->create_dh(lib->crypto, dh_group);
DBG2(DBG_PTS, "selected PTS DH group is %N",
diffie_hellman_group_names, dh_group);
return TRUE;
}
DBG1(DBG_PTS, "unable to create DH group %N",
diffie_hellman_group_names, dh_group);
return FALSE;
}
METHOD(pts_t, get_my_public_value, void,
private_pts_t *this, chunk_t *value)
{
this->dh->get_my_public_value(this->dh, value);
}
METHOD(pts_t, set_peer_public_value, void,
private_pts_t *this, chunk_t value)
{
this->dh->set_other_public_value(this->dh, value);
}
METHOD(pts_t, calculate_secret, bool,
private_pts_t *this, chunk_t initiator_nonce, chunk_t responder_nonce,
pts_meas_algorithms_t algorithm)
{
hasher_t *hasher;
hash_algorithm_t hash_alg;
u_char output[HASH_SIZE_SHA384];
chunk_t shared_secret;
/* Create a hasher */
hash_alg = pts_meas_to_hash_algorithm(algorithm);
hasher = lib->crypto->create_hasher(lib->crypto, hash_alg);
if (!hasher)
{
DBG1(DBG_PTS, " hasher %N not available", hash_algorithm_names, hash_alg);
DBG1(DBG_PTS, "no rng available");
return FALSE;
}
DBG2(DBG_PTS, "nonce length is %d", nonce_len);
nonce = this->is_imc ? &this->responder_nonce : &this->initiator_nonce;
chunk_free(nonce);
rng->allocate_bytes(rng, nonce_len, nonce);
rng->destroy(rng);
if (this->dh->get_shared_secret(this->dh, &shared_secret) != SUCCESS)
{
DBG1(DBG_PTS, "shared secret couldn't be calculated");
hasher->destroy(hasher);
return FALSE;
}
hasher->get_hash(hasher, chunk_create("1", sizeof("1")), NULL);
hasher->get_hash(hasher, initiator_nonce, NULL);
hasher->get_hash(hasher, responder_nonce, NULL);
hasher->get_hash(hasher, shared_secret, output);
/**
* Link the hash output to the secret and set the length
* Truncate the output to 20 bytes to fit ExternalDate argument of TPM Quote
*/
this->secret = chunk_create(output, HASH_SIZE_SHA1);
DBG3(DBG_PTS, "secret assessment value: %B", &this->secret);
chunk_free(&shared_secret);
hasher->destroy(hasher);
return TRUE;
}
METHOD(pts_t, get_secret, chunk_t,
private_pts_t *this)
METHOD(pts_t, get_my_public_value, void,
private_pts_t *this, chunk_t *value, chunk_t *nonce)
{
return this->secret;
this->dh->get_my_public_value(this->dh, value);
*nonce = this->is_imc ? this->responder_nonce : this->initiator_nonce;
}
METHOD(pts_t, set_peer_public_value, void,
private_pts_t *this, chunk_t value, chunk_t nonce)
{
this->dh->set_other_public_value(this->dh, value);
nonce = chunk_clone(nonce);
if (this->is_imc)
{
this->initiator_nonce = nonce;
}
else
{
this->responder_nonce = nonce;
}
}
METHOD(pts_t, calculate_secret, bool,
private_pts_t *this)
{
hasher_t *hasher;
hash_algorithm_t hash_alg;
chunk_t shared_secret;
/* Check presence of nonces */
if (!this->initiator_nonce.len || !this->responder_nonce.len)
{
DBG1(DBG_PTS, "initiator and/or responder nonce is not available");
return FALSE;
}
DBG3(DBG_PTS, "initiator nonce: %B", &this->initiator_nonce);
DBG3(DBG_PTS, "responder nonce: %B", &this->responder_nonce);
/* Calculate the DH secret */
if (this->dh->get_shared_secret(this->dh, &shared_secret) != SUCCESS)
{
DBG1(DBG_PTS, "shared DH secret computation failed");
return FALSE;
}
DBG4(DBG_PTS, "shared DH secret: %B", &shared_secret);
/* Calculate the secret assessment value */
hash_alg = pts_meas_algo_to_hash(this->dh_hash_algorithm);
hasher = lib->crypto->create_hasher(lib->crypto, hash_alg);
hasher->allocate_hash(hasher, chunk_from_chars('1'), NULL);
hasher->allocate_hash(hasher, this->initiator_nonce, NULL);
hasher->allocate_hash(hasher, this->responder_nonce, NULL);
hasher->allocate_hash(hasher, shared_secret, &this->secret);
hasher->destroy(hasher);
/* The DH secret must be destroyed */
chunk_clear(&shared_secret);
/*
* Truncate the hash to 20 bytes to fit the ExternalData
* argument of the TPM Quote command
*/
this->secret.len = min(this->secret.len, 20);
DBG4(DBG_PTS, "secret assessment value: %B", &this->secret);
return TRUE;
}
/**
@@ -227,20 +286,20 @@ static void print_tpm_version_info(private_pts_t *this)
}
METHOD(pts_t, get_platform_info, char*,
private_pts_t *this)
private_pts_t *this)
{
return this->platform_info;
}
METHOD(pts_t, set_platform_info, void,
private_pts_t *this, char *info)
private_pts_t *this, char *info)
{
free(this->platform_info);
this->platform_info = strdup(info);
}
METHOD(pts_t, get_tpm_version_info, bool,
private_pts_t *this, chunk_t *info)
private_pts_t *this, chunk_t *info)
{
if (!this->has_tpm)
{
@@ -252,7 +311,7 @@ METHOD(pts_t, get_tpm_version_info, bool,
}
METHOD(pts_t, set_tpm_version_info, void,
private_pts_t *this, chunk_t info)
private_pts_t *this, chunk_t info)
{
this->tpm_version_info = chunk_clone(info);
print_tpm_version_info(this);
@@ -297,20 +356,20 @@ static void load_aik(private_pts_t *this)
}
METHOD(pts_t, get_aik, certificate_t*,
private_pts_t *this)
private_pts_t *this)
{
return this->aik;
}
METHOD(pts_t, set_aik, void,
private_pts_t *this, certificate_t *aik)
private_pts_t *this, certificate_t *aik)
{
DESTROY_IF(this->aik);
this->aik = aik->get_ref(aik);
}
METHOD(pts_t, hash_file, bool,
private_pts_t *this, hasher_t *hasher, char *pathname, u_char *hash)
private_pts_t *this, hasher_t *hasher, char *pathname, u_char *hash)
{
u_char buffer[PTS_BUF_SIZE];
FILE *file;
@@ -357,8 +416,8 @@ static char* get_filename(char *pathname)
return filename;
}
METHOD(pts_t, is_path_valid, bool, private_pts_t *this, char *path,
pts_error_code_t *error_code)
METHOD(pts_t, is_path_valid, bool,
private_pts_t *this, char *path, pts_error_code_t *error_code)
{
struct stat st;
@@ -389,7 +448,7 @@ METHOD(pts_t, is_path_valid, bool, private_pts_t *this, char *path,
}
METHOD(pts_t, do_measurements, pts_file_meas_t*,
private_pts_t *this, u_int16_t request_id, char *pathname, bool is_directory)
private_pts_t *this, u_int16_t request_id, char *pathname, bool is_directory)
{
hasher_t *hasher;
hash_algorithm_t hash_alg;
@@ -398,7 +457,7 @@ METHOD(pts_t, do_measurements, pts_file_meas_t*,
pts_file_meas_t *measurements;
/* Create a hasher */
hash_alg = pts_meas_to_hash_algorithm(this->algorithm);
hash_alg = pts_meas_algo_to_hash(this->algorithm);
hasher = lib->crypto->create_hasher(lib->crypto, hash_alg);
if (!hasher)
{
@@ -529,7 +588,7 @@ static bool file_metadata(char *pathname, pts_file_metadata_t **entry)
}
METHOD(pts_t, get_metadata, pts_file_meta_t*,
private_pts_t *this, char *pathname, bool is_directory)
private_pts_t *this, char *pathname, bool is_directory)
{
pts_file_meta_t *metadata;
pts_file_metadata_t *entry;
@@ -601,7 +660,7 @@ METHOD(pts_t, get_metadata, pts_file_meta_t*,
}
METHOD(pts_t, read_pcr, bool,
private_pts_t *this, u_int32_t pcr_num, chunk_t *output)
private_pts_t *this, u_int32_t pcr_num, chunk_t *output)
{
TSS_HCONTEXT hContext;
TSS_HTPM hTPM;
@@ -649,7 +708,7 @@ METHOD(pts_t, read_pcr, bool,
}
METHOD(pts_t, extend_pcr, bool,
private_pts_t *this, u_int32_t pcr_num, chunk_t input, chunk_t *output)
private_pts_t *this, u_int32_t pcr_num, chunk_t input, chunk_t *output)
{
TSS_HCONTEXT hContext;
TSS_HTPM hTPM;
@@ -699,8 +758,8 @@ METHOD(pts_t, extend_pcr, bool,
}
METHOD(pts_t, quote_tpm, bool,
private_pts_t *this, linked_list_t *pcrs,
chunk_t *pcr_composite, chunk_t *quote_signature)
private_pts_t *this, linked_list_t *pcrs, chunk_t *pcr_composite,
chunk_t *quote_signature)
{
TSS_HCONTEXT hContext;
TSS_HTPM hTPM;
@@ -886,10 +945,12 @@ METHOD(pts_t, quote_tpm, bool,
}
METHOD(pts_t, destroy, void,
private_pts_t *this)
private_pts_t *this)
{
DESTROY_IF(this->aik);
DESTROY_IF(this->dh);
free(this->initiator_nonce.ptr);
free(this->responder_nonce.ptr);
free(this->platform_info);
free(this->tpm_version_info.ptr);
free(this);
@@ -1051,33 +1112,36 @@ pts_t *pts_create(bool is_imc)
private_pts_t *this;
INIT(this,
.public = {
.get_proto_caps = _get_proto_caps,
.set_proto_caps = _set_proto_caps,
.get_meas_algorithm = _get_meas_algorithm,
.set_meas_algorithm = _set_meas_algorithm,
.create_dh = _create_dh,
.get_my_public_value = _get_my_public_value,
.set_peer_public_value = _set_peer_public_value,
.calculate_secret = _calculate_secret,
.get_secret = _get_secret,
.get_platform_info = _get_platform_info,
.set_platform_info = _set_platform_info,
.get_tpm_version_info = _get_tpm_version_info,
.set_tpm_version_info = _set_tpm_version_info,
.get_aik = _get_aik,
.set_aik = _set_aik,
.is_path_valid = _is_path_valid,
.hash_file = _hash_file,
.do_measurements = _do_measurements,
.get_metadata = _get_metadata,
.read_pcr = _read_pcr,
.extend_pcr = _extend_pcr,
.quote_tpm = _quote_tpm,
.destroy = _destroy,
},
.proto_caps = PTS_PROTO_CAPS_V,
.algorithm = PTS_MEAS_ALGO_SHA256,
.public = {
.get_proto_caps = _get_proto_caps,
.set_proto_caps = _set_proto_caps,
.get_meas_algorithm = _get_meas_algorithm,
.set_meas_algorithm = _set_meas_algorithm,
.get_dh_hash_algorithm = _get_dh_hash_algorithm,
.set_dh_hash_algorithm = _set_dh_hash_algorithm,
.create_dh_nonce = _create_dh_nonce,
.get_my_public_value = _get_my_public_value,
.set_peer_public_value = _set_peer_public_value,
.calculate_secret = _calculate_secret,
.get_platform_info = _get_platform_info,
.set_platform_info = _set_platform_info,
.get_tpm_version_info = _get_tpm_version_info,
.set_tpm_version_info = _set_tpm_version_info,
.get_aik = _get_aik,
.set_aik = _set_aik,
.is_path_valid = _is_path_valid,
.hash_file = _hash_file,
.do_measurements = _do_measurements,
.get_metadata = _get_metadata,
.read_pcr = _read_pcr,
.extend_pcr = _extend_pcr,
.quote_tpm = _quote_tpm,
.destroy = _destroy,
},
.is_imc = is_imc,
.proto_caps = PTS_PROTO_CAPS_V,
.algorithm = PTS_MEAS_ALGO_SHA256,
.dh_hash_algorithm = PTS_MEAS_ALGO_SHA256,
);
if (is_imc)
+31 -29
View File
@@ -40,12 +40,7 @@ typedef struct pts_t pts_t;
#define REVERSE_SOLIDUS_UTF 0x5C
/**
* Lenght of the generated nonce used for calculation of shared secret
*/
#define NONCE_LEN 20
/**
* Lenght of the generated nonce used for calculation of shared secret
* Length of the generated nonce used for calculation of shared secret
*/
#define ASSESSMENT_SECRET_LEN 20
@@ -55,12 +50,12 @@ typedef struct pts_t pts_t;
#define MAX_NUM_PCR 24
/**
* Number of bytes can be savedin a PCR of TPM, TPM Spec 1.2
* Number of bytes that can be saved in a PCR of TPM, TPM Spec 1.2
*/
#define PCR_LEN 20
/**
* Class implementing the TCG Platform Trust System (PTS)
* Class implementing the TCG Platform Trust Service (PTS)
*
*/
struct pts_t {
@@ -82,57 +77,64 @@ struct pts_t {
/**
* Get PTS Measurement Algorithm
*
* @return Measurement algorithm
* @return PTS measurement algorithm
*/
pts_meas_algorithms_t (*get_meas_algorithm)(pts_t *this);
/**
* Set PTS Measurement Algorithm
*
* @param algorithm Measurement algorithm
* @param algorithm PTS measurement algorithm
*/
void (*set_meas_algorithm)(pts_t *this, pts_meas_algorithms_t algorithm);
/**
* Set PTS Diffie-Hellman object
* Get DH Hash Algorithm
*
* @param dh DH object
* @return DH hash algorithm
*/
bool (*create_dh)(pts_t *this, pts_dh_group_t group);
pts_meas_algorithms_t (*get_dh_hash_algorithm)(pts_t *this);
/**
* Set DH Hash Algorithm
*
* @param algorithm DH hash algorithm
*/
void (*set_dh_hash_algorithm)(pts_t *this, pts_meas_algorithms_t algorithm);
/**
* Create PTS Diffie-Hellman object and nonce
*
* @param group PTS DH group
* @param nonce_len Nonce length
* @return TRUE if creation was successful
*
*/
bool (*create_dh_nonce)(pts_t *this, pts_dh_group_t group, int nonce_len);
/**
* Get my Diffie-Hellman public value
*
* @param value My public DH value
* @param nonce My DH nonce
*/
void (*get_my_public_value)(pts_t *this, chunk_t *value);
void (*get_my_public_value)(pts_t *this, chunk_t *value, chunk_t *nonce);
/**
* Set peer Diffie.Hellman public value
*
* @param value Peer public DH value
* @param nonce Peer DH nonce
*/
void (*set_peer_public_value) (pts_t *this, chunk_t value);
void (*set_peer_public_value) (pts_t *this, chunk_t value, chunk_t nonce);
/**
* Calculates secret assessment value to be used for TPM Quote as an external data
* Calculates secret assessment value to be used for TPM Quote as ExternalData
*
* @param initiator_nonce Initiator nonce (IMV nonce)
* @param responder_nonce Responder nonce (IMC nonce)
* @param algorithm Hashing algorithm
* @return TRUE unless both DH public values
* and nonces are set
*/
bool (*calculate_secret) (pts_t *this, chunk_t initiator_nonce,
chunk_t responder_nonce,
pts_meas_algorithms_t algorithm);
/**
* Returns secret assessment value to be used for TPM Quote as an external data
*
* @return Secret assessment value
*/
chunk_t (*get_secret) (pts_t *this);
bool (*calculate_secret) (pts_t *this);
/**
* Get Platform and OS Info
+5 -5
View File
@@ -88,33 +88,33 @@ bool pts_dh_group_update(char *dh_group, pts_dh_group_t *dh_groups)
/* nothing to update, all groups are supported */
return TRUE;
}
else if (strcaseeq(dh_group, "ecp256"))
if (strcaseeq(dh_group, "ecp256"))
{
/* remove DH group 20 */
*dh_groups &= ~PTS_DH_GROUP_IKE20;
return TRUE;
}
else if (strcaseeq(dh_group, "modp2048"))
if (strcaseeq(dh_group, "modp2048"))
{
/* remove DH groups 19 and 20 */
*dh_groups &= ~(PTS_DH_GROUP_IKE20 | PTS_DH_GROUP_IKE19);
return TRUE;
}
else if (strcaseeq(dh_group, "modp1536"))
if (strcaseeq(dh_group, "modp1536"))
{
/* remove DH groups 14, 19 and 20 */
*dh_groups &= ~(PTS_DH_GROUP_IKE20 | PTS_DH_GROUP_IKE19 |
PTS_DH_GROUP_IKE14);
return TRUE;
}
else if (strcaseeq(dh_group, "modp1024"))
if (strcaseeq(dh_group, "modp1024"))
{
/* remove DH groups 5, 14, 19 and 20 */
*dh_groups &= ~(PTS_DH_GROUP_IKE20 | PTS_DH_GROUP_IKE19 |
PTS_DH_GROUP_IKE14 | PTS_DH_GROUP_IKE5);
return TRUE;
}
DBG1(DBG_PTS, "unknown DH group: %s configured", dh_group);
DBG1(DBG_PTS, "unknown DH group '%s' configured", dh_group);
return FALSE;
}
+1 -1
View File
@@ -96,7 +96,7 @@ bool pts_meas_algo_update(char *hash_alg, pts_meas_algorithms_t *algorithms)
*algorithms &= ~(PTS_MEAS_ALGO_SHA384 | PTS_MEAS_ALGO_SHA256);
return TRUE;
}
DBG1(DBG_PTS, "unknown hash algorithm: %s configured", hash_alg);
DBG1(DBG_PTS, "unknown hash algorithm '%s' configured", hash_alg);
return FALSE;
}
+18 -34
View File
@@ -71,11 +71,6 @@ struct private_tcg_pts_attr_dh_nonce_finish_t {
*/
bool noskip_flag;
/**
* Length of nonce
*/
u_int8_t nonce_len;
/**
* Selected Hashing Algorithm
*/
@@ -84,7 +79,7 @@ struct private_tcg_pts_attr_dh_nonce_finish_t {
/**
* DH Initiator Public Value
*/
chunk_t initiator_pub_val;
chunk_t initiator_value;
/**
* DH Initiator Nonce
@@ -129,9 +124,9 @@ METHOD(pa_tnc_attr_t, build, void,
writer = bio_writer_create(PTS_DH_NONCE_FINISH_SIZE);
writer->write_uint8 (writer, PTS_DH_NONCE_FINISH_RESERVED);
writer->write_uint8 (writer, this->nonce_len);
writer->write_uint8 (writer, this->initiator_nonce.len);
writer->write_uint16(writer, this->hash_algo);
writer->write_data (writer, this->initiator_pub_val);
writer->write_data (writer, this->initiator_value);
writer->write_data (writer, this->initiator_nonce);
this->value = chunk_clone(writer->get_buf(writer));
@@ -142,7 +137,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
private_tcg_pts_attr_dh_nonce_finish_t *this, u_int32_t *offset)
{
bio_reader_t *reader;
u_int8_t reserved;
u_int8_t reserved, nonce_len;
u_int16_t hash_algo;
if (this->value.len < PTS_DH_NONCE_FINISH_SIZE)
@@ -153,15 +148,14 @@ METHOD(pa_tnc_attr_t, process, status_t,
}
reader = bio_reader_create(this->value);
reader->read_uint8 (reader, &reserved);
reader->read_uint8 (reader, &this->nonce_len);
reader->read_uint8 (reader, &nonce_len);
reader->read_uint16(reader, &hash_algo);
reader->read_data(reader, reader->remaining(reader) - nonce_len,
&this->initiator_value);
reader->read_data(reader, nonce_len, &this->initiator_nonce);
this->hash_algo = hash_algo;
reader->read_data(reader, reader->remaining(reader) - this->nonce_len,
&this->initiator_pub_val);
this->initiator_pub_val = chunk_clone(this->initiator_pub_val);
reader->read_data(reader, this->nonce_len, &this->initiator_nonce);
this->initiator_value = chunk_clone(this->initiator_value);
this->initiator_nonce = chunk_clone(this->initiator_nonce);
reader->destroy(reader);
return SUCCESS;
@@ -171,27 +165,21 @@ METHOD(pa_tnc_attr_t, destroy, void,
private_tcg_pts_attr_dh_nonce_finish_t *this)
{
free(this->value.ptr);
free(this->initiator_pub_val.ptr);
free(this->initiator_value.ptr);
free(this->initiator_nonce.ptr);
free(this);
}
METHOD(tcg_pts_attr_dh_nonce_finish_t, get_nonce_len, u_int8_t,
private_tcg_pts_attr_dh_nonce_finish_t *this)
{
return this->nonce_len;
}
METHOD(tcg_pts_attr_dh_nonce_finish_t, get_hash_algo, pts_meas_algorithms_t,
private_tcg_pts_attr_dh_nonce_finish_t *this)
{
return this->hash_algo;
}
METHOD(tcg_pts_attr_dh_nonce_finish_t, get_initiator_pub_val, chunk_t,
METHOD(tcg_pts_attr_dh_nonce_finish_t, get_initiator_value, chunk_t,
private_tcg_pts_attr_dh_nonce_finish_t *this)
{
return this->initiator_pub_val;
return this->initiator_value;
}
METHOD(tcg_pts_attr_dh_nonce_finish_t, get_initiator_nonce, chunk_t,
@@ -203,10 +191,9 @@ METHOD(tcg_pts_attr_dh_nonce_finish_t, get_initiator_nonce, chunk_t,
/**
* Described in header.
*/
pa_tnc_attr_t *tcg_pts_attr_dh_nonce_finish_create(u_int8_t nonce_len,
pts_meas_algorithms_t hash_algo,
chunk_t initiator_nonce,
chunk_t initiator_pub_val)
pa_tnc_attr_t *tcg_pts_attr_dh_nonce_finish_create(pts_meas_algorithms_t hash_algo,
chunk_t initiator_value,
chunk_t initiator_nonce)
{
private_tcg_pts_attr_dh_nonce_finish_t *this;
@@ -222,17 +209,15 @@ pa_tnc_attr_t *tcg_pts_attr_dh_nonce_finish_create(u_int8_t nonce_len,
.process = _process,
.destroy = _destroy,
},
.get_nonce_len = _get_nonce_len,
.get_hash_algo = _get_hash_algo,
.get_initiator_nonce = _get_initiator_nonce,
.get_initiator_pub_val = _get_initiator_pub_val,
.get_initiator_value = _get_initiator_value,
},
.vendor_id = PEN_TCG,
.type = TCG_PTS_DH_NONCE_FINISH,
.nonce_len = nonce_len,
.hash_algo = hash_algo,
.initiator_value = initiator_value,
.initiator_nonce = chunk_clone(initiator_nonce),
.initiator_pub_val = initiator_pub_val,
);
return &this->public.pa_tnc_attribute;
@@ -257,10 +242,9 @@ pa_tnc_attr_t *tcg_pts_attr_dh_nonce_finish_create_from_data(chunk_t value)
.process = _process,
.destroy = _destroy,
},
.get_nonce_len = _get_nonce_len,
.get_hash_algo = _get_hash_algo,
.get_initiator_nonce = _get_initiator_nonce,
.get_initiator_pub_val = _get_initiator_pub_val,
.get_initiator_value = _get_initiator_value,
},
.vendor_id = PEN_TCG,
.type = TCG_PTS_DH_NONCE_FINISH,
@@ -56,7 +56,7 @@ struct tcg_pts_attr_dh_nonce_finish_t {
*
* @return DH Initiator Public Value
*/
chunk_t (*get_initiator_pub_val)(tcg_pts_attr_dh_nonce_finish_t *this);
chunk_t (*get_initiator_value)(tcg_pts_attr_dh_nonce_finish_t *this);
/**
* Get DH Initiator Nonce
@@ -70,15 +70,13 @@ struct tcg_pts_attr_dh_nonce_finish_t {
/**
* Creates an tcg_pts_attr_dh_nonce_finish_t object
*
* @param nonce_len Length of nonce
* @param hash_algo Selected hash algorithm
* @param initiator_value DH Initiator Public Value
* @param initiator_nonce DH Initiator Nonce
* @param initiator_pub_val DH Initiator Public value
*/
pa_tnc_attr_t* tcg_pts_attr_dh_nonce_finish_create(u_int8_t nonce_len,
pts_meas_algorithms_t hash_algo,
chunk_t initiator_nonce,
chunk_t initiator_pub_val);
pa_tnc_attr_t* tcg_pts_attr_dh_nonce_finish_create(pts_meas_algorithms_t hash_algo,
chunk_t initiator_value,
chunk_t initiator_nonce);
/**
* Creates an tcg_pts_attr_dh_nonce_finish_t object from received data
@@ -73,11 +73,6 @@ struct private_tcg_pts_attr_dh_nonce_params_resp_t {
*/
bool noskip_flag;
/**
* Length of nonce
*/
u_int8_t nonce_len;
/**
* Selected Diffie Hellman group
*/
@@ -96,7 +91,7 @@ struct private_tcg_pts_attr_dh_nonce_params_resp_t {
/**
* DH Responder Public Value
*/
chunk_t responder_pub_val;
chunk_t responder_value;
};
@@ -137,11 +132,11 @@ METHOD(pa_tnc_attr_t, build, void,
writer = bio_writer_create(PTS_DH_NONCE_PARAMS_RESP_SIZE);
writer->write_uint24(writer, PTS_DH_NONCE_PARAMS_RESP_RESERVED);
writer->write_uint8 (writer, this->nonce_len);
writer->write_uint8 (writer, this->responder_nonce.len);
writer->write_uint16(writer, this->dh_group);
writer->write_uint16(writer, this->hash_algo_set);
writer->write_data (writer, this->responder_nonce);
writer->write_data (writer, this->responder_pub_val);
writer->write_data (writer, this->responder_value);
this->value = chunk_clone(writer->get_buf(writer));
writer->destroy(writer);
@@ -152,6 +147,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
{
bio_reader_t *reader;
u_int32_t reserved;
u_int8_t nonce_len;
u_int16_t dh_group, hash_algo_set;
if (this->value.len < PTS_DH_NONCE_PARAMS_RESP_SIZE)
@@ -162,15 +158,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
}
reader = bio_reader_create(this->value);
reader->read_uint24(reader, &reserved);
reader->read_uint8 (reader, &this->nonce_len);
reader->read_uint8 (reader, &nonce_len);
reader->read_uint16(reader, &dh_group);
this->dh_group = dh_group;
reader->read_uint16(reader, &hash_algo_set);
reader->read_data(reader, nonce_len, &this->responder_nonce);
reader->read_data(reader, reader->remaining(reader), &this->responder_value);
this->dh_group = dh_group;
this->hash_algo_set = hash_algo_set;
reader->read_data(reader, this->nonce_len, &this->responder_nonce);
this->responder_nonce = chunk_clone(this->responder_nonce);
reader->read_data(reader, reader->remaining(reader), &this->responder_pub_val);
this->responder_pub_val = chunk_clone(this->responder_pub_val);
this->responder_value = chunk_clone(this->responder_value);
reader->destroy(reader);
return SUCCESS;
@@ -181,16 +177,10 @@ METHOD(pa_tnc_attr_t, destroy, void,
{
free(this->value.ptr);
free(this->responder_nonce.ptr);
free(this->responder_pub_val.ptr);
free(this->responder_value.ptr);
free(this);
}
METHOD(tcg_pts_attr_dh_nonce_params_resp_t, get_nonce_len, u_int8_t,
private_tcg_pts_attr_dh_nonce_params_resp_t *this)
{
return this->nonce_len;
}
METHOD(tcg_pts_attr_dh_nonce_params_resp_t, get_dh_group, pts_dh_group_t,
private_tcg_pts_attr_dh_nonce_params_resp_t *this)
{
@@ -209,20 +199,19 @@ METHOD(tcg_pts_attr_dh_nonce_params_resp_t, get_responder_nonce, chunk_t,
return this->responder_nonce;
}
METHOD(tcg_pts_attr_dh_nonce_params_resp_t, get_responder_pub_val, chunk_t,
METHOD(tcg_pts_attr_dh_nonce_params_resp_t, get_responder_value, chunk_t,
private_tcg_pts_attr_dh_nonce_params_resp_t *this)
{
return this->responder_pub_val;
return this->responder_value;
}
/**
* Described in header.
*/
pa_tnc_attr_t *tcg_pts_attr_dh_nonce_params_resp_create(u_int8_t nonce_len,
pts_dh_group_t dh_group,
pts_meas_algorithms_t hash_algo_set,
chunk_t responder_nonce,
chunk_t responder_pub_val)
pa_tnc_attr_t *tcg_pts_attr_dh_nonce_params_resp_create(pts_dh_group_t dh_group,
pts_meas_algorithms_t hash_algo_set,
chunk_t responder_nonce,
chunk_t responder_value)
{
private_tcg_pts_attr_dh_nonce_params_resp_t *this;
@@ -238,19 +227,17 @@ pa_tnc_attr_t *tcg_pts_attr_dh_nonce_params_resp_create(u_int8_t nonce_len,
.process = _process,
.destroy = _destroy,
},
.get_nonce_len = _get_nonce_len,
.get_dh_group = _get_dh_group,
.get_hash_algo_set = _get_hash_algo_set,
.get_responder_nonce = _get_responder_nonce,
.get_responder_pub_val = _get_responder_pub_val,
.get_responder_value = _get_responder_value,
},
.vendor_id = PEN_TCG,
.type = TCG_PTS_DH_NONCE_PARAMS_RESP,
.nonce_len = nonce_len,
.dh_group = dh_group,
.hash_algo_set = hash_algo_set,
.responder_nonce = chunk_clone(responder_nonce),
.responder_pub_val = responder_pub_val,
.responder_value = responder_value,
);
return &this->public.pa_tnc_attribute;
@@ -275,11 +262,10 @@ pa_tnc_attr_t *tcg_pts_attr_dh_nonce_params_resp_create_from_data(chunk_t value)
.process = _process,
.destroy = _destroy,
},
.get_nonce_len = _get_nonce_len,
.get_dh_group = _get_dh_group,
.get_hash_algo_set = _get_hash_algo_set,
.get_responder_nonce = _get_responder_nonce,
.get_responder_pub_val = _get_responder_pub_val,
.get_responder_value = _get_responder_value,
},
.vendor_id = PEN_TCG,
.type = TCG_PTS_DH_NONCE_PARAMS_RESP,
@@ -38,13 +38,6 @@ struct tcg_pts_attr_dh_nonce_params_resp_t {
*/
pa_tnc_attr_t pa_tnc_attribute;
/**
* Get nonce length
*
* @return Length of nonce
*/
u_int8_t (*get_nonce_len)(tcg_pts_attr_dh_nonce_params_resp_t *this);
/**
* Get selected Diffie Hellman Group
*
@@ -71,24 +64,22 @@ struct tcg_pts_attr_dh_nonce_params_resp_t {
*
* @return DH Responder Public Value
*/
chunk_t (*get_responder_pub_val)(tcg_pts_attr_dh_nonce_params_resp_t *this);
chunk_t (*get_responder_value)(tcg_pts_attr_dh_nonce_params_resp_t *this);
};
/**
* Creates an tcg_pts_attr_dh_nonce_params_resp_t object
*
* @param nonce_len Length of nonce
* @param dh_group Selected DH group
* @param hash_algo_set Set of supported hash algorithms
* @param responder_nonce DH Responder Nonce
* @param responder_pub_val DH Responder Public value
*/
pa_tnc_attr_t* tcg_pts_attr_dh_nonce_params_resp_create(u_int8_t nonce_len,
pts_dh_group_t dh_group,
pts_meas_algorithms_t hash_algo_set,
chunk_t responder_nonce,
chunk_t responder_pub_val);
pa_tnc_attr_t* tcg_pts_attr_dh_nonce_params_resp_create(pts_dh_group_t dh_group,
pts_meas_algorithms_t hash_algo_set,
chunk_t responder_nonce,
chunk_t responder_value);
/**
* Creates an tcg_pts_attr_dh_nonce_params_resp_t object from received data