Make `cryptohome::Tpm` independent of Cryptohome.
1. Decouple `Tpm` from `TpmInit`.
2. Build TPM into libcrostpm.
3. Move initialization of the TPM from `Tpm` to `TpmInit`.
House keeping functions such as `LoadTpmStatus`, `StoreTpmStatus`, are
moved to `TpmInit`.
Functions related to owner passwords are also moved to `TpmInit`.
4. Move all key loading/saving out of `Tpm` into `TpmInit`.
`Tpm::Init` is removed. `Tpm` no longer depends on `Platform`.
`Tpm` instances now MUST be handed handles to context and key in order for
it to perform any cryptographic operations.
`TpmInit` can load the key blobs on disk. See
`TpmInit::LoadCryptohomeKey`.
5. `CreateCryptohomeKey` is replaced with `CreateWrappedRsaKey`. The later
function uses OpenSSL to generate an RSA key and wraps it with SRK.
6. Add `MockTpmInit`.
7. Make dependency injection clearer in `Init` function. The idiom is:
construct an object with default constructor then call `Init` and
pass in necessary dependencies.
BUG=chromium:355634
TEST=unittest
TEST=create an account on the device before applying this CL. download
some files to its home dir.
TEST=then apply this CL. do it in a way that does not wipe out stateful
partition.
TEST=do the combo (login, let it idle for a minute or two, reboot) a few
times. make sure that the existing accounts can still be used and
downloaded files are still there.
TEST=also make sure that new accounts and guests can login.
TEST=`stop cryptohomed`, then run `cryptohomed --noclose`, make sure
that there is no apparent problems or warnings related to TPM in the log.
Change-Id: I9a582c9aca8b0cad81520c0a42c68cedf43d5251
Reviewed-on: https://chromium-review.googlesource.com/196911
Reviewed-by: Darren Krahn <dkrahn@chromium.org>
Tested-by: Nam Nguyen <namnguyen@chromium.org>
Commit-Queue: Nam Nguyen <namnguyen@chromium.org>
35 files changed