diff options
author | Andreas Steffen <andreas.steffen@strongswan.org> | 2012-07-16 22:44:45 +0200 |
---|---|---|
committer | Andreas Steffen <andreas.steffen@strongswan.org> | 2012-07-16 22:44:45 +0200 |
commit | c8ff69402b7ea57e6fd26ef61d0da8ca61b564f3 (patch) | |
tree | 544af70dbe36f9ff292f18423c2b2f2b30687bdc /src/libpts | |
parent | 915bceb4c7db08a1d0bb2ff942e89d8b943f03c2 (diff) | |
download | strongswan-c8ff69402b7ea57e6fd26ef61d0da8ca61b564f3.tar.bz2 strongswan-c8ff69402b7ea57e6fd26ef61d0da8ca61b564f3.tar.xz |
fixed potential hasher problem in IMA template hash
Diffstat (limited to 'src/libpts')
-rw-r--r-- | src/libpts/plugins/imv_attestation/attest_db.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/libpts/plugins/imv_attestation/attest_db.c b/src/libpts/plugins/imv_attestation/attest_db.c index da483bd7f..13a9f9a20 100644 --- a/src/libpts/plugins/imv_attestation/attest_db.c +++ b/src/libpts/plugins/imv_attestation/attest_db.c @@ -1144,6 +1144,11 @@ METHOD(attest_db_t, add, bool, ima = TRUE; this->algo = PTS_MEAS_ALGO_SHA1; hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1); + if (!hasher) + { + printf("could not create hasher\n"); + return FALSE; + } } pathname = this->did ? this->dir : this->file; @@ -1207,9 +1212,12 @@ METHOD(attest_db_t, add, bool, strncpy(ima_buffer, filename, IMA_MAX_NAME_LEN); ima_buffer[IMA_MAX_NAME_LEN] = '\0'; ima_template = chunk_create(ima_buffer, sizeof(ima_buffer)); - hasher->get_hash(hasher, measurement, NULL); - hasher->get_hash(hasher, ima_template, measurement.ptr); - + if (!hasher->get_hash(hasher, measurement, NULL) || + !hasher->get_hash(hasher, ima_template, measurement.ptr)) + { + printf("could not compute IMA template hash\n"); + break; + } if (!insert_file_hash(this, PTS_MEAS_ALGO_SHA1_IMA, measurement, fid, did, TRUE, &ima_hashes_added)) { |