follow strongswan coding rules

This commit is contained in:
Sansar Choinyambuu
2011-11-28 14:39:52 +01:00
committed by Andreas Steffen
parent 954be9f5e4
commit b8017b5eba
20 changed files with 152 additions and 94 deletions
+24 -14
View File
@@ -521,7 +521,7 @@ METHOD(pts_t, do_measurements, pts_file_meas_t*,
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, "hasher %N not available", hash_algorithm_names, hash_alg);
return NULL;
}
@@ -595,7 +595,8 @@ static bool file_metadata(char *pathname, pts_file_metadata_t **entry)
if (stat(pathname, &st))
{
DBG1(DBG_PTS, "Unable to obtain statistical information about %s", pathname);
DBG1(DBG_PTS, "Unable to obtain statistical information about %s",
pathname);
return FALSE;
}
@@ -714,7 +715,8 @@ METHOD(pts_t, read_pcr, bool,
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS)
{
DBG1(DBG_PTS, "TPM context could not be created: tss error 0x%x", result);
DBG1(DBG_PTS, "TPM context could not be created: tss error 0x%x",
result);
return FALSE;
}
@@ -762,7 +764,8 @@ METHOD(pts_t, extend_pcr, bool,
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS)
{
DBG1(DBG_PTS, "TPM context could not be created: tss error 0x%x", result);
DBG1(DBG_PTS, "TPM context could not be created: tss error 0x%x",
result);
return FALSE;
}
result = Tspi_Context_Connect(hContext, NULL);
@@ -820,7 +823,8 @@ METHOD(pts_t, quote_tpm, bool,
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS)
{
DBG1(DBG_PTS, "TPM context could not be created: tss error 0x%x", result);
DBG1(DBG_PTS, "TPM context could not be created: tss error 0x%x",
result);
return FALSE;
}
result = Tspi_Context_Connect(hContext, NULL);
@@ -834,7 +838,7 @@ METHOD(pts_t, quote_tpm, bool,
goto err1;
}
/* Retrieve SRK from TPM and set the authentication data as well known secret*/
/* Retrieve SRK from TPM and set the authentication to well known secret*/
result = Tspi_Context_LoadKeyByUUID(hContext, TSS_PS_TYPE_SYSTEM,
SRK_UUID, &hSRK);
if (result != TSS_SUCCESS)
@@ -862,7 +866,8 @@ METHOD(pts_t, quote_tpm, bool,
}
/* Create PCR composite object */
result = Tspi_Context_CreateObject(hContext, TSS_OBJECT_TYPE_PCRS, 0, &hPcrComposite);
result = Tspi_Context_CreateObject(hContext,
TSS_OBJECT_TYPE_PCRS, 0, &hPcrComposite);
if (result != TSS_SUCCESS)
{
goto err2;
@@ -981,7 +986,7 @@ METHOD(pts_t, add_pcr_entry, void,
/**
* 1. build a TCPA_PCR_COMPOSITE structure which contains (pcrCompositeBuf)
* TCPA_PCR_SELECTION structure (bitmask length network order + length bytes bitmask)
* TCPA_PCR_SELECTION structure (bitmask length + bitmask)
* UINT32 (network order) gives the number of bytes following (pcr entries * 20)
* TCPA_PCRVALUE[] with the pcr values
*
@@ -1018,7 +1023,8 @@ METHOD(pts_t, get_quote_info, bool,
if (this->pcrs->get_count(this->pcrs) == 0)
{
DBG1(DBG_PTS, "PCR entries unavailable, unable to construct TPM Quote Info");
DBG1(DBG_PTS, "PCR entries unavailable, unable to construct "
"TPM Quote Info");
return FALSE;
}
@@ -1114,14 +1120,16 @@ METHOD(pts_t, verify_quote_signature, bool,
}
/** Implementation using strongswan -> not working */
/*if (!aik_pub_key->verify(aik_pub_key, SIGN_RSA_EMSA_PKCS1_SHA1, data, signature))
/**if (!aik_pub_key->verify(aik_pub_key, SIGN_RSA_EMSA_PKCS1_SHA1,
data, signature))
{
DBG1(DBG_PTS, "signature verification failed for TPM Quote Info");
goto cleanup;
}
*/
if (!aik_pub_key->get_encoding(aik_pub_key, PUBKEY_SPKI_ASN1_DER, &key_encoding))
if (!aik_pub_key->get_encoding(aik_pub_key,
PUBKEY_SPKI_ASN1_DER, &key_encoding))
{
DBG1(DBG_PTS, "failed to get encoding of AIK public key");
goto cleanup;
@@ -1131,7 +1139,7 @@ METHOD(pts_t, verify_quote_signature, bool,
pkey = d2i_PUBKEY(NULL, (const unsigned char**)&p, key_encoding.len);
if (!pkey)
{
DBG1(DBG_PTS, "failed to get EVP_PKEY object from AIK public key encoding");
DBG1(DBG_PTS, "failed to get EVP_PKEY object from AIK public key");
goto cleanup;
}
@@ -1142,7 +1150,8 @@ METHOD(pts_t, verify_quote_signature, bool,
goto cleanup;
}
if (RSA_verify(NID_sha1, data.ptr, data.len, signature.ptr, signature.len, rsa) != 1)
if (RSA_verify(NID_sha1, data.ptr, data.len,
signature.ptr, signature.len, rsa) != 1)
{
DBG1(DBG_PTS, "signature verification failed for TPM Quote Info");
goto cleanup;
@@ -1306,7 +1315,8 @@ static bool has_tpm(private_pts_t *this)
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS)
{
DBG1(DBG_PTS, "TPM context could not be created: tss error 0x%x", result);
DBG1(DBG_PTS, "TPM context could not be created: tss error 0x%x",
result);
return FALSE;
}
result = Tspi_Context_Connect(hContext, NULL);
+10 -7
View File
@@ -148,7 +148,7 @@ struct pts_t {
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 ExternalData
* Calculates assessment secret to be used for TPM Quote as ExternalData
*
* @return TRUE unless both DH public values
* and nonces are set
@@ -205,7 +205,7 @@ struct pts_t {
* @param error_code Output variable for PTS error code
* @return TRUE if path is valid or file/directory
* doesn't exist or path is invalid
* FALSE if local error occured within stat function
* FALSE if local error occured within stat function
*/
bool (*is_path_valid)(pts_t *this, char *path, pts_error_code_t *error_code);
@@ -236,7 +236,8 @@ struct pts_t {
* @param is_directory TRUE if directory contents are requested
* @return PTS File Metadata or NULL if FAILED
*/
pts_file_meta_t* (*get_metadata)(pts_t *this, char *pathname, bool is_directory);
pts_file_meta_t* (*get_metadata)(pts_t *this, char *pathname,
bool is_directory);
/**
* Reads given PCR value and returns it
@@ -257,7 +258,8 @@ struct pts_t {
* @param output Chunk to save PCR value after extension
* @return FALSE in case of TSS error, TRUE otherwise
*/
bool (*extend_pcr)(pts_t *this, u_int32_t pcr_num, chunk_t input, chunk_t *output);
bool (*extend_pcr)(pts_t *this, u_int32_t pcr_num, chunk_t input,
chunk_t *output);
/**
* Quote over PCR's
@@ -276,7 +278,7 @@ struct pts_t {
/**
* Add extended PCR with its corresponding value
*
* @return FALSE in case of any error or non-match, TRUE otherwise
* @return FALSE in case of any error or non-match, TRUE otherwise
*/
void (*add_pcr_entry)(pts_t *this, pcr_entry_t *entry);
@@ -287,14 +289,15 @@ struct pts_t {
* @param quote_info Output variable to store TPM Quote Info
* @return FALSE in case of any error, TRUE otherwise
*/
bool (*get_quote_info)(pts_t *this, chunk_t *pcr_composite, chunk_t *quote_info);
bool (*get_quote_info)(pts_t *this, chunk_t *pcr_composite,
chunk_t *quote_info);
/**
* Constructs and returns PCR Quote Digest structure expected from IMC
*
* @param data Calculated TPM Quote Digest
* @param signature TPM Quote Signature received from IMC
* @return FALSE in case signature is not verified, TRUE otherwise
* @return FALSE in case signature is not verified, TRUE otherwise
*/
bool (*verify_quote_signature)(pts_t *this, chunk_t data, chunk_t signature);
+4 -2
View File
@@ -38,7 +38,8 @@ struct pts_database_t {
* @param product software product (os, vpn client, etc.)
* @return enumerator over all matching files/directories
*/
enumerator_t* (*create_file_enumerator)(pts_database_t *this, char *product);
enumerator_t* (*create_file_enumerator)(pts_database_t *this,
char *product);
/**
* Get files/directories to request metadata of
@@ -46,7 +47,8 @@ struct pts_database_t {
* @param product software product (os, vpn client, etc.)
* @return enumerator over all matching files/directories
*/
enumerator_t* (*create_file_meta_enumerator)(pts_database_t *this, char *product);
enumerator_t* (*create_file_meta_enumerator)(pts_database_t *this,
char *product);
/**
* Get stored measurement hash for single file or directory entries
@@ -20,7 +20,8 @@
#include <bio/bio_reader.h>
#include <debug.h>
typedef struct private_tcg_pts_attr_dh_nonce_finish_t private_tcg_pts_attr_dh_nonce_finish_t;
typedef struct private_tcg_pts_attr_dh_nonce_finish_t
private_tcg_pts_attr_dh_nonce_finish_t;
/**
* PTS DH Nonce Finish
@@ -191,9 +192,10 @@ 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(pts_meas_algorithms_t hash_algo,
chunk_t initiator_value,
chunk_t initiator_nonce)
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;
@@ -74,9 +74,10 @@ struct tcg_pts_attr_dh_nonce_finish_t {
* @param initiator_value DH Initiator Public Value
* @param initiator_nonce DH Initiator Nonce
*/
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);
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
@@ -20,7 +20,8 @@
#include <bio/bio_reader.h>
#include <debug.h>
typedef struct private_tcg_pts_attr_dh_nonce_params_req_t private_tcg_pts_attr_dh_nonce_params_req_t;
typedef struct private_tcg_pts_attr_dh_nonce_params_req_t
private_tcg_pts_attr_dh_nonce_params_req_t;
/**
* PTS DH Nonce Parameters Request
@@ -21,7 +21,8 @@
#ifndef TCG_PTS_ATTR_DH_NONCE_PARAMS_REQ_H_
#define TCG_PTS_ATTR_DH_NONCE_PARAMS_REQ_H_
typedef struct tcg_pts_attr_dh_nonce_params_req_t tcg_pts_attr_dh_nonce_params_req_t;
typedef struct tcg_pts_attr_dh_nonce_params_req_t
tcg_pts_attr_dh_nonce_params_req_t;
#include "tcg_attr.h"
#include "pa_tnc/pa_tnc_attr.h"
@@ -20,7 +20,8 @@
#include <bio/bio_reader.h>
#include <debug.h>
typedef struct private_tcg_pts_attr_dh_nonce_params_resp_t private_tcg_pts_attr_dh_nonce_params_resp_t;
typedef struct private_tcg_pts_attr_dh_nonce_params_resp_t
private_tcg_pts_attr_dh_nonce_params_resp_t;
/**
* PTS DH Nonce Parameters Response
@@ -187,8 +188,8 @@ METHOD(tcg_pts_attr_dh_nonce_params_resp_t, get_dh_group, pts_dh_group_t,
return this->dh_group;
}
METHOD(tcg_pts_attr_dh_nonce_params_resp_t, get_hash_algo_set, pts_meas_algorithms_t,
private_tcg_pts_attr_dh_nonce_params_resp_t *this)
METHOD(tcg_pts_attr_dh_nonce_params_resp_t, get_hash_algo_set,
pts_meas_algorithms_t, private_tcg_pts_attr_dh_nonce_params_resp_t *this)
{
return this->hash_algo_set;
}
@@ -21,7 +21,8 @@
#ifndef TCG_PTS_ATTR_DH_NONCE_PARAMS_RESP_H_
#define TCG_PTS_ATTR_DH_NONCE_PARAMS_RESP_H_
typedef struct tcg_pts_attr_dh_nonce_params_resp_t tcg_pts_attr_dh_nonce_params_resp_t;
typedef struct tcg_pts_attr_dh_nonce_params_resp_t
tcg_pts_attr_dh_nonce_params_resp_t;
#include "tcg_attr.h"
#include "pa_tnc/pa_tnc_attr.h"
@@ -50,7 +51,8 @@ struct tcg_pts_attr_dh_nonce_params_resp_t {
*
* @return Hash algorithm set
*/
pts_meas_algorithms_t (*get_hash_algo_set)(tcg_pts_attr_dh_nonce_params_resp_t *this);
pts_meas_algorithms_t (*get_hash_algo_set)(
tcg_pts_attr_dh_nonce_params_resp_t *this);
/**
* Get DH Responder Nonce
@@ -20,7 +20,8 @@
#include <bio/bio_reader.h>
#include <debug.h>
typedef struct private_tcg_pts_attr_gen_attest_evid_t private_tcg_pts_attr_gen_attest_evid_t;
typedef struct private_tcg_pts_attr_gen_attest_evid_t
private_tcg_pts_attr_gen_attest_evid_t;
/**
* Generate Attestation Evidence
@@ -20,7 +20,8 @@
#include <bio/bio_reader.h>
#include <debug.h>
typedef struct private_tcg_pts_attr_get_tpm_version_info_t private_tcg_pts_attr_get_tpm_version_info_t;
typedef struct private_tcg_pts_attr_get_tpm_version_info_t
private_tcg_pts_attr_get_tpm_version_info_t;
/**
* Get TPM Version Information
@@ -21,7 +21,8 @@
#ifndef TCG_PTS_ATTR_GET_TPM_VERSION_INFO_H_
#define TCG_PTS_ATTR_GET_TPM_VERSION_INFO_H_
typedef struct tcg_pts_attr_get_tpm_version_info_t tcg_pts_attr_get_tpm_version_info_t;
typedef struct tcg_pts_attr_get_tpm_version_info_t
tcg_pts_attr_get_tpm_version_info_t;
#include "tcg_attr.h"
#include "pa_tnc/pa_tnc_attr.h"
@@ -197,7 +197,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
bio_reader_t *reader;
u_int8_t flags;
u_int8_t reserved;
//u_int16_t algorithm;
/** u_int16_t algorithm;*/
if (this->value.len < PTS_SIMPLE_EVID_FINAL_SIZE)
{