Commit Graph

25 Commits

Author SHA1 Message Date
Randall Spangler
8f400498c6 utilities: Fix coverity warnings
Assorted minor code issues, which we should fix so any new errors stand
out more.

BUG=chromium:643769
BRANCH=none
TEST=make runtests

Change-Id: Ifcb50b3dfcc3d376bf6803e9c06f8e68dafd51a0
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/382611
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-09-14 13:05:04 -07:00
Andrey Pronin
8926d350c8 tpmc: define actions for all commands for tpm2
Implement macros to handle differences between TPM1.2 and TPM2.0.
For all original tpmc commands define if they are to
(1) be implemented, (2) do nothing, or (3) return a "not implemented"
error.
Print TPM mode (1.2 or 2.0) for tpmc in 'tpmc help' output.

BRANCH=none
BUG=chrome-os-partner:55210
BUG=chrome-os-partner:55250
TEST=boot on kevin; verify that the following tpmc commands do
     nothing and return success: ppon, enable, activate; verify
     that 'help' prnts the right mode and command descriptions.

Change-Id: Ifec4e8e5bd4afb45f76f9c2b3249c844ea1b670a
Reviewed-on: https://chromium-review.googlesource.com/363000
Commit-Ready: Andrey Pronin <apronin@chromium.org>
Tested-by: Andrey Pronin <apronin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-07-26 23:54:30 -07:00
Andrey Pronin
3e0a352489 Modify 'tpmc block' to lock only the FW index
As discussed in https://chromium-review.googlesource.com/#/c/361381/,
instead of being a synonym to 'tpmc pplock', the 'tpmc block' command
should protect just the FW index using WriteLock.

Additionally, both TlclSetGlobalLock and TlclLockPhysicalPresence in
tlcl (which are used by 'tpmc block' and 'tpmc pplock') are updated
to first check if the platform hierarchy is already disabled and
return success, if so. That's needed to prevent command failures
when rollback protection is already on.

BRANCH=none
BUG=chrome-os-partner:55210
BUG=chrome-os-partner:55250
TEST=boot on kevin, verify that 'tpmc block' and 'tpmc pplock'
     work as expected:
     - pplock is possible after block
     - pplock and block succeed both for enabled and disabled PH
     - block locks FW index
     - pplock disables PH

Change-Id: I32bff2b590a51315b11da361b97c684dcce8ab36
Reviewed-on: https://chromium-review.googlesource.com/362772
Commit-Ready: Andrey Pronin <apronin@chromium.org>
Tested-by: Andrey Pronin <apronin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-07-26 23:54:28 -07:00
Andrey Pronin
c37f0f8205 tlcl: automatically detect if platform hierarchy is disabled
Instead of passing a special flag when 'tpmc' starts, auto-detect
if platform hierarchy is disabled in TlclLibInit(). See discussion
in https://chromium-review.googlesource.com/#/c/362520/.

BRANCH=none
BUG=chrome-os-partner:55210
BUG=chrome-os-partner:55250
TEST=boot on kevin, verify that 'tpmc read 0x1008 0xd' works

Change-Id: Id94e7faadf835f7ea58a944e914163d6849e85c1
Reviewed-on: https://chromium-review.googlesource.com/362771
Commit-Ready: Andrey Pronin <apronin@chromium.org>
Tested-by: Andrey Pronin <apronin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-07-26 23:54:27 -07:00
Andrey Pronin
0960682caa Implement GetCapabilities and reading flags for tpm2
For TPM2.0:
1) Implement TPM2_GetCapabilities command that allows reading
TPM properties, including PERMANENT and STARTUP_CLEAR flags.
2) Implement 'getpf' and 'getvf' commands in tpmc.

BRANCH=none
BUG=chrome-os-partner:55210
BUG=chrome-os-partner:55250
TEST=boot on kevin, verify 'tpmc getpf' and 'tpmc getvf'

Change-Id: I8490b2c92ebf7c266e27b7cb5898126a1b99b1a8
Reviewed-on: https://chromium-review.googlesource.com/362770
Commit-Ready: Andrey Pronin <apronin@chromium.org>
Tested-by: Andrey Pronin <apronin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-07-26 17:31:56 -07:00
Andrey Pronin
bea3f7979a tlcl: use different NV_Read authorizations for fw and userland
Let's use an earlier version of CL 360944 that relies on the
global flag to decide if the platform authorization is to
be used.

As it turned out, we can't read NVRAM with empty
password authorization if platform hierarchy is still enabled
(as it is in firmware), so we keep platform authorization for
firmware, and use empty password only for userland utilities,
like tpmc.

BRANCH=none
BUG=chrome-os-partner:55531
TEST=Run 'initctl stop trunksd; tpmc read 0x1008 0xd" on
     kevin, verify that it returns the right output.

Change-Id: Ic878ebde9086e803d2487d90c55c0f19001cf94b
Signed-off-by: Andrey Pronin <apronin@google.com>
Reviewed-on: https://chromium-review.googlesource.com/362520
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Andrey Pronin <apronin@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
2016-07-22 14:42:54 +00:00
Andrey Pronin
a071c76978 Support 'tpmc setbgloballock' for tpm2 case
Some scripts call 'tpmc setbgloballock' or 'tpmc block'. For tpm2
it should be equivalent to pplock, i.e. perform rollback protection
actions: writelock for NVRAM firmware index and disable platform
hierarchy.

BRANCH=none
BUG=chrome-os-partner:55210
TEST=run 'tpmc block' on kevin, check that it attempts pplock

Change-Id: I51fae6bd111cf3ff3c1dfbed7441868abad8fc15
Reviewed-on: https://chromium-review.googlesource.com/361381
Commit-Ready: Dan Shi <dshi@google.com>
Tested-by: Andrey Pronin <apronin@chromium.org>
Reviewed-by: Darren Krahn <dkrahn@chromium.org>
2016-07-21 03:15:44 -07:00
Andrey Pronin
1becb0dabe Stub tlcl implementation for tpm2 case
Build a special version of TPM Lightweight Command Library in
libvboot_host for TPM2. Create the framework for implementation, stub
functions for now. libvboot_host is used by tpmc and other user-space
utilities that talk directly to tpm bypassing trunks/trousers.

BRANCH=none
BUG=chrome-os-partner:54981
BUG=chrome-os-partner:55210
TEST=Boot on kevin, verify that 'tpmc read' works.

Change-Id: I4cc41028041193041defc319687697eb9edb1f3e
Reviewed-on: https://chromium-review.googlesource.com/358623
Commit-Ready: Andrey Pronin <apronin@chromium.org>
Tested-by: Stephen Barber <smbarber@chromium.org>
Tested-by: Andrey Pronin <apronin@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2016-07-15 19:23:56 -07:00
Kevin Cernekee
831f91315b Add "tpmc pcrextend" command to extend a PCR
This is useful for testing different configurations without repeatedly
reflashing the firmware, e.g.

    # stop tcsd
    # tpmc pcr 0
    0000000000000000000000000000000000000000
    # tpmc pcrextend 0 c42ac1c46f1d4e211c735cc7dfad4ff8391110e9
    # tpmc pcr 0
    865aedd337518e56f648440b81b4cbd9359fdff3
    <reboot and try another value>

BUG=none
BRANCH=none
TEST=manual

Change-Id: Ie5814ca2a3a5cf5a0eaf0ffee0385315db09bf25
Signed-off-by: Kevin Cernekee <cernekee@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/289009
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
2015-08-10 20:42:12 +00:00
Luigi Semenzato
317e1b4944 Avoid exit code overflow for tpmc.
In case of a TPM error, tpmc returns the TPM error code, which can
be greater than 255.  In that case the error code is truncated.
Some error codes, such as TPM_E_RETRY, end with a zero byte,
resulting in a successful exit code.  This is despicable.

BUG=chromium:234357
TEST=tested with exit codes < 255.  Too hard to generate the others.
BRANCH=none

Change-Id: I891a5c0659c06aac778449e2a0a935c5f82ccdb8
Reviewed-on: https://chromium-review.googlesource.com/66885
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
2013-08-28 15:50:54 +00:00
Bill Richardson
0c3ba249ab Massive refactoring of external header files.
This reduces the number of exported header files to the minimum needed by
the existing userspace utilities and firmware implementations.

BUG=chromium:221544
BRANCH=none
TEST=manual, trybots
CQ-DEPEND=CL:47019,CL:47022,CL:47023

  sudo FEATURES=test emerge vboot_reference
  FEATURES=test emerge-$BOARD \
                vboot_reference \
                chromeos-cryptohome \
                chromeos-installer \
                chromeos-u-boot \
                peach-u-boot \
                depthcharge

Change-Id: I2946cc2dbaf5459a6c5eca92ca57d546498e6d85
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47021
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-04-02 14:12:52 -07:00
Bill Richardson
feb2518166 Wrap all vboot utilities with futility.
This moves all the old userspace utilities generated by vboot_reference into
a subdirectory not in $PATH, and replaces them with symlinks to a single
executable named 'futility'. At the moment that utility just execs the
original utilities (optionally logging that fact first).

Ultimately, the old utilities will be subsumed into a single binary instead
of multiple separate executables.

There is a matching CL needed to make the recovery image creation work.

BUG=chromium-os:37062
BRANCH=none
CQ-DEPEND=CL:44864
TEST=auto

To test, build everything, test everything. It should work as before in all
cases. I have built normal images, test images, factory installers, recovery
images; they all seem to work.

I've run trybots on daisy-paladin link-paladin lumpy-paladin and alex-paladin.

Change-Id: Ie93db676f2ed2a64e4b13b3b5dc6b65a77db0f8c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44871
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
2013-03-11 08:38:46 -07:00
Luigi Semenzato
3428b4bcd9 Make tpmc able to send and receive raw datagrams.
This is immediately needed to debug a Parrot TPM problems, but
we've had similar situation in the past and probably will again
in the future.

BUG=chromium-os:37819
TEST=manually tested with a couple of different packets, and error inputs
BRANCH=none

Change-Id: Id7f66bdbdfe5887fa49cd62af4a9b807fa3d9a89
Reviewed-on: https://gerrit.chromium.org/gerrit/41166
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
2013-01-11 18:15:14 -08:00
Kees Cook
8b6da26a6e tlcl: add GetOwner command
Since the "ownership" permament flag does not indicate if the TPM is
currently owned, the state of TPM Ownership must be read via a Capability
read of TPM_CAP_PROP_OWNER. This adds the "getownership" function.

BUG=chromium-os:22172
TEST=x86-alex build & manual test

Change-Id: I2fc9e933e891ba40190d008436b22496dced1c93
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/24784
Reviewed-by: Will Drewry <wad@chromium.org>
2012-06-13 14:22:12 -07:00
Kees Cook
f0605cbdc3 tpm_lite: implement TPM_GetRandom
Provide TPM_GetRandom function to library callers.

BUG=chromium-os:22172
TEST=lumpy build & manual testing

Change-Id: Id604fd92490ba697033158a580b0b4df1d975932
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/17120
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
2012-03-01 15:25:31 -08:00
Kees Cook
946370d012 tpmc: add PCR reading function
Add ability to report a single PCR value via the tpmc utility. Using
/sys/devices/platform/tpm_tis/pcrs is too slow, since it reads all
PCRs before returning. Anything wanting to read PCR0 on a time-critical
path needs maximum speed.

BUG=chromium-os:22172
TEST=install and test x86-alex.

Change-Id: I2d450961d33fa314d54b909135a74aa756279ec6
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/13891
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
2012-01-09 15:00:52 -08:00
Gaurav Shah
ac6d56033f Fix "tpmc help" description of pplock
BUG=none
TEST=none

Change-Id: I2a976f6e876ff7751a746ea89211795ab454e65d
Reviewed-on: http://gerrit.chromium.org/gerrit/4458
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Tested-by: Gaurav Shah <gauravsh@chromium.org>
2011-07-21 11:13:56 -07:00
Luigi Semenzato
54992f9d33 Added TPM_SaveState command.
Change-Id: If7b6ef3cba733b74ba13db0871e6ac554d0d84ef

BUG=chromium-os:433
TEST=none

Review URL: http://codereview.chromium.org/6696043
2011-03-16 10:56:48 -07:00
Luigi Semenzato
d903cc8333 Add resume command to tpmc.
Change-Id: Ie888a966d9914d0f3396c8fa5139fdddbdb76ff0

BUG=none
TEST=compiled and ran the program

Review URL: http://codereview.chromium.org/4185003
2010-10-27 09:42:51 -07:00
Luigi Semenzato
a8cba996b7 Utility to measure the available size of a TPM NVRAM.
Also change tpmc to return the TPM error code, or 255.

Change-Id: Ie5fc107ff50efd4480c2a47b91f3b8a93b4f95e3

BUG=none
TEST=ran it on a TPM

Review URL: http://codereview.chromium.org/3479003
2010-09-21 14:12:15 -07:00
Luigi Semenzato
1d83dd1ba5 Add a command to enable the physical presence command.
Change-Id: Id8b6ac3c75d1ee34237cde8adde55cea33b25889

Review URL: http://codereview.chromium.org/3163045
2010-08-30 10:23:43 -07:00
Luigi Semenzato
5896b9664d Added new commands and reactivated full rebuild after fixing for ARM ebuild.
Review URL: http://codereview.chromium.org/3116025

Change-Id: Ideb82562f6b1c3ce5cd9e0b79de250d0a7bd976e
2010-08-25 07:16:03 -07:00
Luigi Semenzato
c91e2390cb Add some commands to tpmc.
Review URL: http://codereview.chromium.org/3165023
2010-08-17 14:31:52 -07:00
Luigi Semenzato
56cec581bb Add clear command.
Review URL: http://codereview.chromium.org/3167004
2010-08-10 15:09:37 -07:00
Luigi Semenzato
e72291c636 Command-line utility to execute TPM commands bypassing the TSS stack.
Review URL: http://codereview.chromium.org/3149001
2010-08-10 09:46:09 -07:00