Commit Graph

5 Commits

Author SHA1 Message Date
Vadim Bendebury
8347907c46 ccd: 'pp polling' vendor command option
When implementing 'ccd open' and 'ccd unlock' through gsctool, we need
to be able to pass to the host the state of the physical presences
state machine regarding the expected user action (pressing the PP
button).

Two new VENDOR_CC_CCD subcommands are being added: CCDV_PP_POLL_OPEN
and CCDV_PP_UNLOCK. In response to these commands, the Cr50 always
returns VENDOR_RC_SUCCESS return code and a single byte payload
showing the CCD and PP state:

  - CCDPP_CLOSED - PP process is not running, CCD closed. Maybe user
    missed a button press deadline.

  - CCDPP_AWAITING_PRESS (self explanatory)
  - CCDPP_BETWEEN_PRESSES (self explanatory)

  - CCDPP_PP_DONE - CCD is opened/unlocked (as per user request), PP
    process succeeded.

BRANCH=cr50
BUG=b:62537474
TEST=with the upcoming change to gsctool verified that PP states are
     properly conveyed to the user.

Change-Id: I97b1fef4440eea93c5c5ac01b7c60bfce9a4595c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/861001
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-12 03:27:09 -08:00
Vadim Bendebury
877e5909b4 ccd: prepare for handling crucial CCD commands through TPM task context
We want CCD commands lock, open, password, and unlock (at least to
start with) to be available over both CLI and through crosh (i.e.
coming over /dev/tpm0).

Let's allocate a TPM vendor command for handling all CCD subcommands,
and move to this new framework the 'ccd password' command, which
already is available over vendor command.

BRANCH=cr50
BUG=b:62537474
TEST=verified that 'ccd password' still works both over Suzy-Q CLI and
     using gsctool on the target.

Change-Id: I2d06230b762f47af7e580b188a587bc5678ca169
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/853280
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-10 15:44:29 -08:00
Vadim Bendebury
91c1b0abab ccd: restrict password setting to allowed states
Setting password should be allowed only after the owner logged in for
the first time and before they log out or someone else logs in.

Once any other user but the owner logs in, it should become impossible
to set password until the device is reset.

As proposed here, this would apply to both attempts to set password
through crosh and Cr50 console.

Password handling on Cr50 passes the following states:

- password setting is not allowed after Cr50 reset until an upstart
  (as opposed to resume) TPM startup happens, as signalled by the TPM
  callback.  After the proper TPM reset the state changes to
  'POST_RESET_STATE' which means that the device was just
  reset/rebooted (not resumed) and no user logged in yet.

- if the owner logs in in this state, the state changes to
  'PASSWORD_ALLOWED_STATE'. The owner can open crosh session and set
  the password.

- when the owner logs out or any user but the owner logs in, the state
  changes to PASSWORD_NOT_ALLOWED_STATE and does not change until TPM
  is reset. This makes sure that password can be set only by the owner
  and only before anybody else logged in.

Separate changes to the TPM library code make sure that TPM reset is
reported through the platform layer, so that POST_RESET_STATE is
entered.

BRANCH=cr50
BUG=b:67007578
TEST=with the rest of the infrastructure in place verified that
     password can be set only when the owner logged in for the first
     time before anybody else logs in or the owner logs out.

Change-Id: Ieaa3dc8ff9d2e43ae11151eb31173220f5c75b58
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/804141
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Andrey Pronin <apronin@chromium.org>
2017-12-11 15:16:21 -08:00
Vadim Bendebury
aeb0c8e4b9 rma: process proper auth code
When RMA process has been initialized and the user entered the
expected authentication code value, the Cr50 needs to wipe out TPM
memory, open and unlock CCD and reboot the device.

This patch adds a function to accomplish that. User response is
validated on the TPM task context, and TPM reset request also requires
TPM task processing. To decouple response processing from the
following reset, the response processing is handled by a hook task
callback, delayed for 1s to make sure that user receives the response.

After TPM has successfully reset the CCD is reinitialized with RMA
'opened' and the device is rebooted.

Just in case something goes wrong with the unlock and the hook is not
invoked, add a 10s deferred function to take the EC out of reset so
that the device still can reboot.

BRANCH=none
BUG=b:67007905
TEST=on a Bob device:

   - on the Cr50 console enter 'ccd lock', verify that ccd is locked
     (by examining output of the 'ccd' command)

   - at the bash prompt enter gsctool -r -s -t, copy the
     authentication code from the Cr50 console and pass it to gsctool.

   - observe the device reset TPM wiping out its memory, enable CCD
     and reboot.

Change-Id: I6fafb5e642cb2b6f2040507a7f1989607fd31316
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/729983
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-10-24 12:57:45 -07:00
Randall Spangler
ccb151d013 cr50: Defragment code
For historical reasons, CCD, reset, and power button control were
scattered around several files.  Consolidate the code in more sensible
(in retrospect) places.

No functional changes, just moving code.

BUG=none
BRANCH=cr50
TEST=make buildall; boot cr50

Change-Id: Ic381a5a5d0627753cc771189aa377e88b81b155e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/653766
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-09-09 13:48:49 -07:00