Update TPM initialization to better handle errors.

This change modifies slightly the TPM initialization, changing it to use a well-known owner password until the last step, when it changes the owner password to a random string.  This way, if ownership is interrupted, it has a better chance of being able to resume or being diagnosed.

This change allows use of the TPM emulator by adding detection of whether or not the emulator is owned, as well as checking if the SRK needs the owner password before trying to unrestrict it (the unrestrict code path fails on the TPM emulator but not on hardware TPMs--I do not know why, but the tpm_restrictsrk utility also does not work on the emulator).

Change-Id: I4957205bb72b6d1a5009ca3372db6aefd58db3d9

BUG=5561
TEST=manual

Review URL: http://codereview.chromium.org/3118014
2 files changed