aikgen: Fix computation of key ID of the AIK public key

We don't have direct access to the modulus and exponent of the key anymore.
This commit is contained in:
Tobias Brunner
2016-06-30 12:56:41 +02:00
parent c05d49632f
commit a8d6501036
+8 -7
View File
@@ -192,8 +192,7 @@ int main(int argc, char *argv[])
bool force = FALSE; bool force = FALSE;
chunk_t identity_req; chunk_t identity_req;
chunk_t aik_blob; chunk_t aik_blob;
chunk_t aik_modulus; hasher_t *hasher;
chunk_t aik_exponent;
atexit(library_deinit); atexit(library_deinit);
if (!library_init(NULL, "aikgen")) if (!library_init(NULL, "aikgen"))
@@ -347,7 +346,7 @@ int main(int argc, char *argv[])
} }
if (!tpm->generate_aik(tpm, ca_modulus, &aik_blob, &aik_pubkey, if (!tpm->generate_aik(tpm, ca_modulus, &aik_blob, &aik_pubkey,
&identity_req)) &identity_req))
{ {
exit_aikgen("could not generate AIK"); exit_aikgen("could not generate AIK");
} }
@@ -383,12 +382,14 @@ int main(int argc, char *argv[])
aikpubkey_filename, aik_pubkey.len); aikpubkey_filename, aik_pubkey.len);
/* display AIK keyid derived from subjectPublicKeyInfo encoding */ /* display AIK keyid derived from subjectPublicKeyInfo encoding */
if (!lib->encoding->encode(lib->encoding, KEYID_PUBKEY_INFO_SHA1, NULL, hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
&aik_keyid, CRED_PART_RSA_MODULUS, aik_modulus, if (!hasher || !hasher->allocate_hash(hasher, aik_pubkey, &aik_keyid))
CRED_PART_RSA_PUB_EXP, aik_exponent, CRED_PART_END))
{ {
exit_aikgen("computation of AIK keyid failed"); DESTROY_IF(hasher);
exit_aikgen("SHA1 hash algorithm not supported, computation of AIK "
"keyid failed");
} }
hasher->destroy(hasher);
DBG1(DBG_LIB, "AIK keyid: %#B", &aik_keyid); DBG1(DBG_LIB, "AIK keyid: %#B", &aik_keyid);
exit_aikgen(NULL); exit_aikgen(NULL);