summaryrefslogtreecommitdiff
path: root/firmware/lib/tpm2_lite
Commit message (Collapse)AuthorAgeFilesLines
* tlcl, tpmc: extend GetVersion to report vendor specific datastabilize-10032.86.Bstabilize-10032.75.Bstabilize-10032.72.Bstabilize-10032.71.Bstabilize-10032.68.Bstabilize-10032.56.Bstabilize-10032.111.Brelease-R63-10032.Bfirmware-scribe-10045.BAndrey Pronin2017-10-121-1/+48
| | | | | | | | | | | | | | | | 1) Extend TlclGetVersion to return vendor specific data, if requested. 2) Extend 'tpmc getver' to include vendor specific data. BRANCH=none BUG=chromium:771561 TEST=unit tests, running 'tpmc getver' Change-Id: Ic04c242d4e6f33b45a80479be9ab9777b317ebe2 Reviewed-on: https://chromium-review.googlesource.com/706240 Commit-Ready: Andrey Pronin <apronin@chromium.org> Tested-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
* Add support for IFX FieldUpgradeInfoRequest2 commandMattias Nissler2017-08-231-0/+6
| | | | | | | | | | | | | | | | Add tpm_lite library support for the IFX specific TPM_FieldUpgrade subcommand "FieldUpgradeInfoRequest2". Expose this via tpmc so it can be used from shell scripts. BRANCH=none BUG=chromium:728130 TEST=Builds and tpmc ifxfieldupgradeinfo prints plausible results. Change-Id: Ie58ebccef7fe90f7fca65d7cd9c78e1f16f9f29a Reviewed-on: https://chromium-review.googlesource.com/562772 Commit-Ready: Mattias Nissler <mnissler@chromium.org> Tested-by: Mattias Nissler <mnissler@chromium.org> Reviewed-by: Mattias Nissler <mnissler@chromium.org>
* Implement tpmc getversion command.stabilize-9756.BMattias Nissler2017-07-181-0/+19
| | | | | | | | | | | | | | | This command exposes the vendor and TPM firmware version. BRANCH=none BUG=chromium:728130 TEST=Builds and tpmc getversion prints plausible results. Change-Id: Iec556a298e025e10bda00121b40a25d8dc3839d1 Reviewed-on: https://chromium-review.googlesource.com/565287 Commit-Ready: Mattias Nissler <mnissler@chromium.org> Tested-by: Mattias Nissler <mnissler@chromium.org> Reviewed-by: Jorge Lucangeli Obes <jorgelo@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
* 2lib: add VB2_DEBUG_RAW() to print without function nameRandall Spangler2017-01-202-48/+35
| | | | | | | | | | | | | | | | | | | | | | | | Currently, VB2_DEBUG() will print the function name as a prefix to the debug output. Add VB2_DEBUG_RAW() to print without that, so that it's possible to print little bits of debug output. Use this in ec_sync to hex dump the hashes. And then clean up all of the debug calls which explicitly did things like: VB2_DEBUG("%s: foo", __func__); to just: VB2_DEBUG("foo"); so they don't double-print the function name BUG=chromium:683391 BRANCH=none TEST=build_packages --board=reef chromeos-firmware && DEBUG=1 make -j runtests CQ-DEPEND=CL:430978,CL:431111 Change-Id: I0c35519d2e670d55d65d01eaa60d61f3e3edf419 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/431171 Reviewed-by: Julius Werner <jwerner@chromium.org>
* firmware: replace VBDEBUG(()) macro with VB2_DEBUG()Randall Spangler2017-01-122-57/+63
| | | | | | | | | | | | | | | | The original VBDEBUG macro used doubly-nested parens to work with MSVC, which didn't support varargs in macros. We now only use more modern compilers, so replace it with the VB2_DEBUG macro and get rid of the ugly and fragile double parens. BUG=chromium:611535 BRANCH=none TEST=make runtests; build_packages --board=reef chromeos-firmware Change-Id: Ifc0cb0733b14daaa1fde095fab7da4215a538c77 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/425133 Reviewed-by: Shelley Chen <shchen@chromium.org>
* tpm2_lite: use null password authorization for ReadLockAndrey Pronin2016-11-151-1/+2
| | | | | | | | | | | | | | | | | | | | | Most of the indexes used in practice, have AUTHREAD set with null password authentication. The only index, for which READ_STCLEAR is set and TlclReadLock() is called is the one used by mount-encrypted. It has AUTHREAD with empty password and should be lockable after platform hierarchy is disabled. So, use null password authorization instead of platform authorization in TlclReadLock(). BUG=chrome-os-partner:54708 BRANCH=none TEST=Start with OOBE, corporate enroll, reboot, verify that the system doesn't go back to OOBE. Check mount-encrypted.log on start: it should contain "Read-locking NVRAM area succeeded". Change-Id: Iaac78ba4dd048edac992adfab6fb94b69b2e989a Reviewed-on: https://chromium-review.googlesource.com/410780 Commit-Ready: Andrey Pronin <apronin@chromium.org> Tested-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* tpm2: do not lock kernel space when locking physical presenceVadim Bendebury2016-11-111-7/+1
| | | | | | | | | | | | | | | | | | | | There is no direct concept of physical presence in TPM2, the platform hierarchy could be used to manage access to various NVRAM spaces instead. The kernel NVRAM space does not have to be explicitly locked, disabling platform hierarchy is enough to prevent writes into this space. BRANCH=none BUG=chrome-os-partner:59651 TEST=verified that the system boots fine in both normal and recovery modes; using tpmc confirmed that the kernel space is readable in both and writeable only in recovery mode. Change-Id: I3cd8344ad897d061f6b07424f1589a7b547a161f Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/410127 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
* tpm2_lite: implement TlclGetPermissionsAndrey Pronin2016-11-112-2/+110
| | | | | | | | | | | | | | | | | Implement TlclGetPermissions, which sends a TPM2_NV_ReadPublic command and returns the attributes of the NV Index (TPM2 Spec, Part 3, Section 31.6). BUG=chrome-os-partner:58873 BUG=chrome-os-partner:55210 BRANCH=none TEST=Run "tpmc def" with various permissions to define new indexes, verify that "tpmc getp" returns matching permissions for them. Change-Id: I2ad7163332ae8793cd717875645f19baef513b26 Reviewed-on: https://chromium-review.googlesource.com/409618 Commit-Ready: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* tpm2_lite: do not ignore errors reported by TPMVadim Bendebury2016-11-101-3/+3
| | | | | | | | | | | | | | | | Some tpm command wrappers ignore TPM return code, they should not report success in case TPM operation failed. BRANCH=none BUG=chrome-os-partner:55668 TEST=verified that tpmc on reef does not silently ignore tpm write errors any more. Change-Id: Id8955e3757948a3fd0972f88b569fb8828be7715 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/406516 Commit-Ready: Andrey Pronin <apronin@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* tpm2_lite: implement TlclDefineSpaceAndrey Pronin2016-11-092-13/+160
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement TlclDefineSpace, which sends a TPM2_NV_DefineSpace command to define the attributes of an NV Index and cause the TPM to reserve space to hold the data associated with the NV Index (TPM2 Spec, Part 2, Section 31.3.1). Also, update TlclWrite and TlclWriteLock calls to use the platform authorization only for NV Indexes in TPM and Platform ranges, and use empty password authorization otherwise. This allows (1) working with the Off-Disk Early-Access Key Storage used by mount-encrypted through Tlcl API; and (2) testing Tlcl NV define/write/write-lock operations with platform hierarchy disabled. BUG=chrome-os-partner:55210 BUG=chrome-os-partner:59361 BRANCH=none TEST=After clearing the TPM owner run "tpmc def 0x800001 0x3 0x0" to create a TPM index of size 3, which can be read and written to with empty password. Verify that "tpmc write 0x800001 12 34 56" succeeds and "tpmc read 0x800001 0x3" prints "12 34 56" as NVRAM space contents. Change-Id: I185cf8380ef1579d0e9e4d8cead5a30ceda3ead9 Reviewed-on: https://chromium-review.googlesource.com/405792 Commit-Ready: Andrey Pronin <apronin@chromium.org> Tested-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@google.com>
* vboot: use standard memcmp, memcpy, memsetRandall Spangler2016-10-232-13/+13
| | | | | | | | | | | | | | Originally, we didn't trust the firmware to provide these functions from a standard library. Now, with coreboot, we do. BUG=chromium:611535 BRANCH=none TEST=make runtests; emerge-kevin coreboot depthcharge Change-Id: I4e624c40085f2b665275a38624340b2f6aabcf11 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/399120 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* tlcl: add implementations for GetOwnership and Read/WriteLockStephen Barber2016-08-212-3/+53
| | | | | | | | | | | | | | | | mount-encrypted needs to be aware of TPM ownership status, and will also want to issue a read lock for the early access NVRAM index. BRANCH=none BUG=chromium:625037 TEST=mount-encrypted shows ownership at boot with kevin Change-Id: I42f43f91d892137e1c46c7cacd88e3b749ce7f04 Reviewed-on: https://chromium-review.googlesource.com/366443 Commit-Ready: Andrey Pronin <apronin@chromium.org> Tested-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
* tlcl: implement clear, startup, shutdown, self teststabilize-8647.BAndrey Pronin2016-07-262-6/+112
| | | | | | | | | | | | | | | | | Implement TlclStartup, TlclSaveState, TlclResume, TlclSelfTestFull, TlclContinueSelfTest, TlclForceClear. BRANCH=none BUG=chrome-os-partner:55210 BUG=chrome-os-partner:55250 TEST=boot on kevin in recovery mode, verify that 'tpmc ctest', 'tpmc startup', 'tpmc clear' work. Change-Id: I00839eae1984e24c0138ec5bdab8299379e1bcb6 Reviewed-on: https://chromium-review.googlesource.com/362996 Commit-Ready: Andrey Pronin <apronin@chromium.org> Tested-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* tlcl: support sending raw commandsAndrey Pronin2016-07-262-4/+25
| | | | | | | | | | | | | | | Implement TlclSendReceive and TlclPacketSize required for sending raw commands. BRANCH=none BUG=chrome-os-partner:55210 TEST=boot on kevin, verify that 'tpmc raw' works Change-Id: Iba41b95dd7790a6b7a3a7af6cf5f897f45dce1e5 Reviewed-on: https://chromium-review.googlesource.com/363033 Commit-Ready: Andrey Pronin <apronin@chromium.org> Tested-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Modify 'tpmc block' to lock only the FW indexAndrey Pronin2016-07-262-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* tlcl: automatically detect if platform hierarchy is disabledAndrey Pronin2016-07-261-8/+31
| | | | | | | | | | | | | | | | | 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>
* tlcl: tpm2: fix unmarshal_u32 return valueAndrey Pronin2016-07-261-1/+1
| | | | | | | | | | | | | | | Before the fix, unmarshal_u32 returned only 16 bits of the value. BRANCH=none BUG=chrome-os-partner:55210 TEST=boot on keving, verify that 'tpmc getvf' correctly returns the 'orderly' flag (bit 31 of a 32-bit flags value) Change-Id: I182abdd78a6bdcbc21fe631492559099caeb934f Reviewed-on: https://chromium-review.googlesource.com/362994 Commit-Ready: Andrey Pronin <apronin@chromium.org> Tested-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* Implement GetCapabilities and reading flags for tpm2Andrey Pronin2016-07-262-13/+145
| | | | | | | | | | | | | | | | | | 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>
* tlcl: use different NV_Read authorizations for fw and userlandAndrey Pronin2016-07-222-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* Read NVRAM with proper authorization for tpm2Andrey Pronin2016-07-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | In TPM2 case, NVRAM must be read with empty password authorization in tpmc, since platform hierarchy is disabled by firmware or trunksd for rollback prevention. Since all NVRAM indices are now defined with AUTHREAD, switch to empty password authorization from platform authorization for all NVRAM reads in Tlcl. BRANCH=none BUG=chrome-os-partner:55210 BUG=chrome-os-partner:55251 TEST=Run 'initctl stop trunksd; tpmc read 0x1008 0xd" on kevin, verify that it returns the right output. Change-Id: Ifb72ff5080a4ac5f8d63b5c0713e5bb184f176ca Reviewed-on: https://chromium-review.googlesource.com/360944 Commit-Ready: Dan Shi <dshi@google.com> Tested-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* Stub tlcl implementation for tpm2 caseAndrey Pronin2016-07-151-0/+128
| | | | | | | | | | | | | | | | | | | 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>
* tpm2: add nvram lock and hierarchy control commandsVadim Bendebury2016-07-092-2/+87
| | | | | | | | | | | | | | | | | | | | The firmware needs to lock the kernel rollback index before starting up the kernel. The TPM2_NV_WriteLock command is used for that. We also want to limit the amount of control the user space apps have over TPM. With TPM1.2 it was achieved by deasserting physical presence. TPM2 specification allows to achieve the same goal by disabling Platform Hierarchy, which is active out of reset. BRANCH=none BUG=chrome-os-partner:50465 TEST=verified that all commands succeed and chrome OS boots up fine. Change-Id: Ia5893460e0b29f1945cb2aae45a5f10b08fe1ed1 Reviewed-on: https://chromium-review.googlesource.com/358351 Commit-Ready: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Darren Krahn <dkrahn@chromium.org>
* tpm2: refactor tpm2 return value processingVadim Bendebury2016-07-061-8/+10
| | | | | | | | | | | | | | | | There is no point in checking and reporting error code in each function calling tpm_process_command(), let's do it in one place for all commands. BRANCH=none BUG=chrome-os-partner:50645 TEST=Kevin still boots to chrome os Change-Id: I10f45bd15df293f63401c295c5dce833543c50da Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/358174 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Darren Krahn <dkrahn@chromium.org>
* tpm2: add marshaling/unmarshaling and tlcl supportVadim Bendebury2016-07-012-0/+520
The marshaling code is a port of the coreboot patch https://chromium-review.googlesource.com/353915. The only supported commands at this time are NV_read and NV_write. The tlcl layer includes functions necessary to satisfy compilation requirements of rollback_index.c, functions to lock spaces and clear TPM are not yet implemented, they just report being invoked. The missing functions implementation is coming, but even without it it is possible to boot Chrome OS with firmware and kernel rollback counters maintained in the TPM NVRAM. BRANCH=none BUG=chrome-os-partner:50645 TEST=with depthcharge patches applied kevin/gru boards boot into chrome OS with rollback counters read from/written to TPM2 Change-Id: I29fe9069d7c37c33d354f36c93bda15d439bf74f Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/356753 Reviewed-by: Randall Spangler <rspangler@chromium.org>