bound functional component measurements to AIK
This commit is contained in:
@@ -97,10 +97,12 @@ static void do_args(int argc, char *argv[])
|
||||
enum {
|
||||
OP_UNDEF,
|
||||
OP_USAGE,
|
||||
OP_FILES,
|
||||
OP_KEYS,
|
||||
OP_COMPONENTS,
|
||||
OP_PRODUCTS,
|
||||
OP_FILES,
|
||||
OP_HASHES,
|
||||
OP_MEASUREMENTS,
|
||||
OP_PRODUCTS,
|
||||
OP_ADD,
|
||||
OP_DEL,
|
||||
} op = OP_UNDEF;
|
||||
@@ -116,8 +118,10 @@ static void do_args(int argc, char *argv[])
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "components", no_argument, NULL, 'c' },
|
||||
{ "files", no_argument, NULL, 'f' },
|
||||
{ "keys", no_argument, NULL, 'k' },
|
||||
{ "products", no_argument, NULL, 'p' },
|
||||
{ "hashes", no_argument, NULL, 'H' },
|
||||
{ "measurements", no_argument, NULL, 'M' },
|
||||
{ "add", no_argument, NULL, 'a' },
|
||||
{ "delete", no_argument, NULL, 'd' },
|
||||
{ "del", no_argument, NULL, 'd' },
|
||||
@@ -129,6 +133,8 @@ static void do_args(int argc, char *argv[])
|
||||
{ "directory", required_argument, NULL, 'D' },
|
||||
{ "dir", required_argument, NULL, 'D' },
|
||||
{ "file", required_argument, NULL, 'F' },
|
||||
{ "key", required_argument, NULL, 'K' },
|
||||
{ "owner", required_argument, NULL, 'O' },
|
||||
{ "product", required_argument, NULL, 'P' },
|
||||
{ "sha1", no_argument, NULL, '1' },
|
||||
{ "sha256", no_argument, NULL, '2' },
|
||||
@@ -137,6 +143,7 @@ static void do_args(int argc, char *argv[])
|
||||
{ "fid", required_argument, NULL, '5' },
|
||||
{ "pid", required_argument, NULL, '6' },
|
||||
{ "cid", required_argument, NULL, '7' },
|
||||
{ "kid", required_argument, NULL, '8' },
|
||||
{ 0,0,0,0 }
|
||||
};
|
||||
|
||||
@@ -154,12 +161,18 @@ static void do_args(int argc, char *argv[])
|
||||
case 'f':
|
||||
op = OP_FILES;
|
||||
continue;
|
||||
case 'k':
|
||||
op = OP_KEYS;
|
||||
continue;
|
||||
case 'p':
|
||||
op = OP_PRODUCTS;
|
||||
continue;
|
||||
case 'H':
|
||||
op = OP_HASHES;
|
||||
continue;
|
||||
case 'M':
|
||||
op = OP_MEASUREMENTS;
|
||||
continue;
|
||||
case 'a':
|
||||
op = OP_ADD;
|
||||
continue;
|
||||
@@ -199,6 +212,15 @@ static void do_args(int argc, char *argv[])
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
continue;
|
||||
case 'K':
|
||||
if (!attest->set_key(attest, optarg, op == OP_ADD))
|
||||
{
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
continue;
|
||||
case 'O':
|
||||
attest->set_owner(attest, optarg);
|
||||
continue;
|
||||
case 'P':
|
||||
if (!attest->set_product(attest, optarg, op == OP_ADD))
|
||||
{
|
||||
@@ -238,6 +260,12 @@ static void do_args(int argc, char *argv[])
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
continue;
|
||||
case '8':
|
||||
if (!attest->set_kid(attest, atoi(optarg)))
|
||||
{
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -250,6 +278,9 @@ static void do_args(int argc, char *argv[])
|
||||
case OP_PRODUCTS:
|
||||
attest->list_products(attest);
|
||||
break;
|
||||
case OP_KEYS:
|
||||
attest->list_keys(attest);
|
||||
break;
|
||||
case OP_COMPONENTS:
|
||||
attest->list_components(attest);
|
||||
break;
|
||||
@@ -259,6 +290,9 @@ static void do_args(int argc, char *argv[])
|
||||
case OP_HASHES:
|
||||
attest->list_hashes(attest);
|
||||
break;
|
||||
case OP_MEASUREMENTS:
|
||||
attest->list_measurements(attest);
|
||||
break;
|
||||
case OP_ADD:
|
||||
attest->add(attest);
|
||||
break;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -33,40 +33,6 @@ typedef struct attest_db_t attest_db_t;
|
||||
*/
|
||||
struct attest_db_t {
|
||||
|
||||
/**
|
||||
* Set software product to be queried
|
||||
*
|
||||
* @param product software product
|
||||
* @param create if TRUE create database entry if it doesn't exist
|
||||
* @return TRUE if successful
|
||||
*/
|
||||
bool (*set_product)(attest_db_t *this, char *product, bool create);
|
||||
|
||||
/**
|
||||
* Set primary key of the software product to be queried
|
||||
*
|
||||
* @param pid primary key of software product
|
||||
* @return TRUE if successful
|
||||
*/
|
||||
bool (*set_pid)(attest_db_t *this, int pid);
|
||||
|
||||
/**
|
||||
* Set measurement file to be queried
|
||||
*
|
||||
* @param file measurement file
|
||||
* @param create if TRUE create database entry if it doesn't exist
|
||||
* @return TRUE if successful
|
||||
*/
|
||||
bool (*set_file)(attest_db_t *this, char *file, bool create);
|
||||
|
||||
/**
|
||||
* Set primary key of the measurement file to be queried
|
||||
*
|
||||
* @param fid primary key of measurement file
|
||||
* @return TRUE if successful
|
||||
*/
|
||||
bool (*set_fid)(attest_db_t *this, int fid);
|
||||
|
||||
/**
|
||||
* Set functional component to be queried
|
||||
*
|
||||
@@ -101,6 +67,57 @@ struct attest_db_t {
|
||||
*/
|
||||
bool (*set_did)(attest_db_t *this, int did);
|
||||
|
||||
/**
|
||||
* Set measurement file to be queried
|
||||
*
|
||||
* @param file measurement file
|
||||
* @param create if TRUE create database entry if it doesn't exist
|
||||
* @return TRUE if successful
|
||||
*/
|
||||
bool (*set_file)(attest_db_t *this, char *file, bool create);
|
||||
|
||||
/**
|
||||
* Set primary key of the measurement file to be queried
|
||||
*
|
||||
* @param fid primary key of measurement file
|
||||
* @return TRUE if successful
|
||||
*/
|
||||
bool (*set_fid)(attest_db_t *this, int fid);
|
||||
|
||||
/**
|
||||
* Set functional component to be queried
|
||||
*
|
||||
* @param key AIK
|
||||
* @param create if TRUE create database entry if it doesn't exist
|
||||
* @return TRUE if successful
|
||||
*/
|
||||
bool (*set_key)(attest_db_t *this, char *key, bool create);
|
||||
|
||||
/**
|
||||
* Set primary key of the AIK to be queried
|
||||
*
|
||||
* @param kid primary key of AIK
|
||||
* @return TRUE if successful
|
||||
*/
|
||||
bool (*set_kid)(attest_db_t *this, int kid);
|
||||
|
||||
/**
|
||||
* Set software product to be queried
|
||||
*
|
||||
* @param product software product
|
||||
* @param create if TRUE create database entry if it doesn't exist
|
||||
* @return TRUE if successful
|
||||
*/
|
||||
bool (*set_product)(attest_db_t *this, char *product, bool create);
|
||||
|
||||
/**
|
||||
* Set primary key of the software product to be queried
|
||||
*
|
||||
* @param pid primary key of software product
|
||||
* @return TRUE if successful
|
||||
*/
|
||||
bool (*set_pid)(attest_db_t *this, int pid);
|
||||
|
||||
/**
|
||||
* Set measurement hash algorithm
|
||||
*
|
||||
@@ -108,6 +125,14 @@ struct attest_db_t {
|
||||
*/
|
||||
void (*set_algo)(attest_db_t *this, pts_meas_algorithms_t algo);
|
||||
|
||||
/**
|
||||
* Set owner [user/host] of an AIK
|
||||
*
|
||||
* @param owner user/host name
|
||||
* @return TRUE if successful
|
||||
*/
|
||||
void (*set_owner)(attest_db_t *this, char *owner);
|
||||
|
||||
/**
|
||||
* List all products stored in the database
|
||||
*/
|
||||
@@ -123,11 +148,21 @@ struct attest_db_t {
|
||||
*/
|
||||
void (*list_components)(attest_db_t *this);
|
||||
|
||||
/**
|
||||
* List all AIKs stored in the database
|
||||
*/
|
||||
void (*list_keys)(attest_db_t *this);
|
||||
|
||||
/**
|
||||
* List selected measurement hashes stored in the database
|
||||
*/
|
||||
void (*list_hashes)(attest_db_t *this);
|
||||
|
||||
/**
|
||||
* List selected component measurement stored in the database
|
||||
*/
|
||||
void (*list_measurements)(attest_db_t *this);
|
||||
|
||||
/**
|
||||
* Add an entry to the database
|
||||
*/
|
||||
|
||||
@@ -24,16 +24,14 @@ void usage(void)
|
||||
{
|
||||
printf("\
|
||||
Usage:\n\
|
||||
ipsec attest --files|--components|--products|--hashes|--add|--del [options]\n\
|
||||
ipsec attest --files|--products|--keys|--hashes [options]\n\
|
||||
\n\
|
||||
ipsec attest --components|-keys|--measurements|--add|--del [options]\n\
|
||||
\n\
|
||||
ipsec attest --files [--product <name>|--pid <id>]\n\
|
||||
Show a list of files with a software product name or\n\
|
||||
its primary key as an optional selector.\n\
|
||||
\n\
|
||||
ipsec attest --components [--product <name>|--pid <id>]\n\
|
||||
Show a list of components with a software product name or\n\
|
||||
its primary key as an optional selector.\n\
|
||||
\n\
|
||||
ipsec attest --products [--file <path>|--fid <id>]\n\
|
||||
Show a list of supported software products with a file path or\n\
|
||||
its primary key as an optional selector.\n\
|
||||
@@ -46,15 +44,37 @@ Usage:\n\
|
||||
Show a list of measurement hashes for a given file or\n\
|
||||
its primary key as an optional selector.\n\
|
||||
\n\
|
||||
ipsec attest --components [--key <digest>|--kid <id>]\n\
|
||||
Show a list of components with an AIK digest or\n\
|
||||
its primary key as an optional selector.\n\
|
||||
\n\
|
||||
ipsec attest --keys [--components <cfn>|--cid <id>]\n\
|
||||
Show a list of AIK key digests with a component or\n\
|
||||
its primary key as an optional selector.\n\
|
||||
\n\
|
||||
ipsec attest --measurements [--sha1|--sha256|--sha384] [--component <cfn>|--cid <id>]\n\
|
||||
Show a list of component measurements for a given component or\n\
|
||||
its primary key as an optional selector.\n\
|
||||
\n\
|
||||
ipsec attest --measurements [--sha1|--sha256|--sha384] [--key <digest>|--kid <id>]\n\
|
||||
Show a list of component measurements for a given AIK or\n\
|
||||
its primary key as an optional selector.\n\
|
||||
\n\
|
||||
ipsec attest --add --file <path>|--dir <path>|--product <name>|--component <cfn>\n\
|
||||
Add a file, directory, product or component entry\n\
|
||||
Component <cfn> entries must be of the form <vendor_id>/<name>-<qualifier>\n\
|
||||
\n\
|
||||
ipsec attest --add [--owner <name>] --key <digest>\n\
|
||||
Add an AIK public key digest entry preceded by an optional owner name\n\
|
||||
\n\
|
||||
ipsec attest --del --file <path>|--fid <id>|--dir <path>|--did <id>\n\
|
||||
Delete a file or directoryentry referenced either by value or primary key\n\
|
||||
Delete a file or directory entry referenced either by value or primary key\n\
|
||||
\n\
|
||||
ipsec attest --del --product <name>|--pid <id>|--component <cfn>|--cid <id>\n\
|
||||
Delete a product or component entry referenced either by value or primary key\n\
|
||||
\n\
|
||||
ipsec attest --del --key <digest>|--kid <id>\n\
|
||||
Delete an AIK entry referenced either by value or primary key\n\
|
||||
\n");
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -210,9 +210,9 @@ bool imv_attestation_build(pa_tnc_msg_t *msg,
|
||||
{
|
||||
tcg_pts_attr_req_func_comp_evid_t *attr_cast;
|
||||
enumerator_t *enumerator;
|
||||
char *platform_info;
|
||||
pts_component_t *comp;
|
||||
pts_comp_func_name_t *comp_name;
|
||||
chunk_t keyid;
|
||||
int vid, name, qualifier;
|
||||
u_int8_t flags;
|
||||
u_int32_t depth;
|
||||
@@ -221,18 +221,17 @@ bool imv_attestation_build(pa_tnc_msg_t *msg,
|
||||
attestation_state->set_handshake_state(attestation_state,
|
||||
IMV_ATTESTATION_STATE_END);
|
||||
|
||||
/* Get Platform and OS of the PTS-IMC */
|
||||
platform_info = pts->get_platform_info(pts);
|
||||
if (!pts_db || !platform_info)
|
||||
if (!pts->get_aik_keyid(pts, &keyid))
|
||||
{
|
||||
DBG1(DBG_IMV, "%s%s%s not available",
|
||||
(pts_db) ? "" : "pts database",
|
||||
(!pts_db && !platform_info) ? "and" : "",
|
||||
(platform_info) ? "" : "platform info");
|
||||
break;
|
||||
}
|
||||
if (!pts_db)
|
||||
{
|
||||
DBG1(DBG_PTS, "pts database not available");
|
||||
break;
|
||||
}
|
||||
|
||||
enumerator = pts_db->create_comp_evid_enumerator(pts_db, platform_info);
|
||||
enumerator = pts_db->create_comp_evid_enumerator(pts_db, keyid);
|
||||
if (!enumerator)
|
||||
{
|
||||
break;
|
||||
|
||||
@@ -146,6 +146,8 @@ bool imv_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
{
|
||||
tcg_pts_attr_aik_t *attr_cast;
|
||||
certificate_t *aik, *issuer;
|
||||
public_key_t *public;
|
||||
chunk_t keyid;
|
||||
enumerator_t *e;
|
||||
bool trusted = FALSE;
|
||||
|
||||
@@ -158,7 +160,11 @@ bool imv_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
}
|
||||
if (aik->get_type(aik) == CERT_X509)
|
||||
{
|
||||
DBG1(DBG_IMV, "verifying AIK certificate");
|
||||
public = aik->get_public_key(aik);
|
||||
public->get_fingerprint(public, KEYID_PUBKEY_INFO_SHA1, &keyid);
|
||||
DBG1(DBG_IMV, "verifying AIK certificate with keyid %#B", &keyid);
|
||||
public->destroy(public);
|
||||
|
||||
e = pts_credmgr->create_trusted_enumerator(pts_credmgr,
|
||||
KEY_ANY, aik->get_issuer(aik), FALSE);
|
||||
while (e->enumerate(e, &issuer))
|
||||
@@ -285,8 +291,10 @@ bool imv_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
default:
|
||||
case FAILED:
|
||||
attestation_state->set_measurement_error(attestation_state);
|
||||
/* fall through to next case */
|
||||
comp->destroy(comp);
|
||||
break;
|
||||
case SUCCESS:
|
||||
name->log(name, " successfully measured ");
|
||||
comp->destroy(comp);
|
||||
break;
|
||||
case NEED_MORE:
|
||||
|
||||
@@ -7,14 +7,6 @@ CREATE TABLE files (
|
||||
path TEXT NOT NULL
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS components;
|
||||
CREATE TABLE components (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
vendor_id INTEGER NOT NULL,
|
||||
name INTEGER NOT NULL,
|
||||
qualifier INTEGER DEFAULT 0
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS products;
|
||||
CREATE TABLE products (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
@@ -34,15 +26,6 @@ CREATE TABLE product_file (
|
||||
PRIMARY KEY (product, file)
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS product_component;
|
||||
CREATE TABLE product_component (
|
||||
product INTEGER NOT NULL,
|
||||
component INTEGER NOT NULL,
|
||||
depth INTEGER DEFAULT 0,
|
||||
seq_no INTEGER DEFAULT 0,
|
||||
PRIMARY KEY (product, component)
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS file_hashes;
|
||||
CREATE TABLE file_hashes (
|
||||
file INTEGER NOT NULL,
|
||||
@@ -53,13 +36,47 @@ CREATE TABLE file_hashes (
|
||||
PRIMARY KEY(file, directory, product, algo)
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS keys;
|
||||
CREATE TABLE keys (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
keyid BLOB NOT NULL,
|
||||
owner TEXT NOT NULL
|
||||
);
|
||||
DROP INDEX IF EXISTS keys_keyid;
|
||||
CREATE INDEX keys_keyid ON keys (
|
||||
keyid
|
||||
);
|
||||
DROP INDEX IF EXISTS keys_owner;
|
||||
CREATE INDEX keys_owner ON keys (
|
||||
owner
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS components;
|
||||
CREATE TABLE components (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
vendor_id INTEGER NOT NULL,
|
||||
name INTEGER NOT NULL,
|
||||
qualifier INTEGER DEFAULT 0
|
||||
);
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS key_component;
|
||||
CREATE TABLE key_component (
|
||||
key INTEGER NOT NULL,
|
||||
component INTEGER NOT NULL,
|
||||
depth INTEGER DEFAULT 0,
|
||||
seq_no INTEGER DEFAULT 0,
|
||||
PRIMARY KEY (key, component)
|
||||
);
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS component_hashes;
|
||||
CREATE TABLE component_hashes (
|
||||
component INTEGER NOT NULL,
|
||||
product INTEGER NOT NULL,
|
||||
key INTEGER NOT NULL,
|
||||
seq_no INTEGER NOT NULL,
|
||||
pcr INTEGER NOT NULL,
|
||||
algo INTEGER NOT NULL,
|
||||
hash BLOB NOT NULL,
|
||||
PRIMARY KEY(component, product, seq_no, algo)
|
||||
PRIMARY KEY(component, key, seq_no, algo)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user