• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import logging
6from autotest_lib.client.common_lib.cros import tpm_utils
7from autotest_lib.server import test, autotest
8
9class platform_CryptohomeTPMReOwnServer(test.test):
10    """
11    The server-side controller for verifying that cryptohome can re-create a
12    user's vault if the TPM is cleared and re-owned.
13    """
14    version = 1
15    n_client_reboots = 0
16    client_at = None
17
18    # Run the client subtest named [subtest].
19    def tpm_run(self, subtest, ignore_status=False):
20        self.client_at.run_test(self.client_test,
21                                subtest=subtest,
22                                check_client_result=(not ignore_status))
23
24
25    def reboot_client(self):
26        # Reboot the client
27        logging.info('CryptohomeTPMReOwnServer: rebooting %s number %d',
28                     self.client.hostname, self.n_client_reboots)
29        self.client.reboot()
30        self.n_client_reboots += 1
31
32
33    def run_once(self, host=None):
34        self.client = host
35        self.client_at = autotest.Autotest(self.client)
36        self.client_test = 'platform_CryptohomeTPMReOwn'
37
38        # Set up the client in the unowned state and init the TPM again.
39        tpm_utils.ClearTPMOwnerRequest(self.client)
40        self.tpm_run("take_tpm_ownership", ignore_status=True)
41
42        self.tpm_run("mount_cryptohome")
43
44        self.reboot_client()
45        self.tpm_run("mount_cryptohome_after_reboot")
46
47        # Clear and re-own the TPM on the next boot.
48        tpm_utils.ClearTPMOwnerRequest(self.client)
49        self.tpm_run("take_tpm_ownership", ignore_status=True)
50
51        self.tpm_run("mount_cryptohome_check_recreate")
52