cryptohome: check that init was completed in IsTpmReady

When determining if tpm is ready (fully owned and initialized),
check the on-disk "owned" status file, which is created after the
tpm initialization procedure is complete.

Without that, if tpm initialization is interrupted after the
tpm owner password is set (including the default password), until
re-initialization is kicked off and is completed after reboot,
cryptohomed may incorrectly think that tpm is ready already.

Indeed, if some password is set, IsTpmEnabled() and IsTpmOwned() will
return TRUE. IsTpmBeingOwned() will return FALSE unless
re-initialization is kicked-off already (and even in some cases if it
is ongoing). And the overall pre-fix IsTpmReady() will return TRUE.

BUG=b:66923649
TEST=combined with CL:691143, check that tpm-bound key is
     not created for homedir after interrupted tpm initialization
     until it is complete.

Change-Id: I2e6479e20b73cf7a3808472e6b2dbea9513128f4
Reviewed-on: https://chromium-review.googlesource.com/691142
Commit-Ready: Andrey Pronin <apronin@chromium.org>
Tested-by: Andrey Pronin <apronin@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
(cherry picked from commit ba414d80b4a06c4d3d3c5b6ef7b9a93c718eb106)
Reviewed-on: https://chromium-review.googlesource.com/692500
Reviewed-by: Andrey Pronin <apronin@chromium.org>
Commit-Queue: Andrey Pronin <apronin@chromium.org>
2 files changed