summaryrefslogtreecommitdiff
path: root/firmware/lib/tpm2_lite
Commit message (Collapse)AuthorAgeFilesLines
* vboot: fix up some more includesJoel Kitching2019-09-232-3/+2
| | | | | | | | | | | | | | | | Should have no extra line breaks in between local includes, and should be sorted alphabetically. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: I83c25d30d7376712857314965a7d93f57190aa3f Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1776281 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: add VB2_ASSERT and VB2_DIE macrosJoel Kitching2019-09-231-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | Sometimes vboot needs to make assertions to work sanely without always having to return VB2_ERROR_* values. Add VB2_ASSERT and VB2_DIE macros to deal with these cases. Convert existing VbAssert macro to use either VB2_ASSERT or TEST_* macros depending on the case. Implement testing infrastructure to check that aborts are being triggered correctly. The TEST_ASSERT macro should be used. BUG=b:124141368, chromium:1005700 TEST=make clean && make runtests BRANCH=none Change-Id: I298384ba50842a94a311df7f868f807bf2109cff Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1813277 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1800112 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot/secdata: rename rollback_index to secdata_tpmJoel Kitching2019-09-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | These secure spaces are now used for more than just rollback versions and should be renamed thus. Note: Originally this rename operation was batched into the CL which rewrites the functions in rollback_index/secdata_tpm, but it made reviewing in Gerrit a pain, since it couldn't pick up on the file renames, and instead showed them as deletes/adds. Doing the rename separately helps ensure all references to rollback_index are updated, and gives us a better review experience in Gerrit. BUG=b:124141368, chromium:972956 TEST=make clean && make runtests BRANCH=none Change-Id: I51e5c731e0d7a071d384c28da56e7adce64ba943 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1776279 Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* vboot: fix up some headers, includes, comments, spacingJoel Kitching2019-08-282-7/+4
| | | | | | | | | | | | | BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: Id97f544da845f7070555e5e8cc6e782b2d45c300 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1758151 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* vboot/tpm: fix return type inconsistenciesJoel Kitching2019-08-061-1/+2
| | | | | | | | | | | | | | | | | | | TPM errors and vboot errors were getting mixed up. Note that this patch changes a function signature in the vboot1 API. Any callers of the function should be updated accordingly. BUG=b:124141368, chromium:988410 TEST=make clean && make runtests BRANCH=none Change-Id: Idf332ca9ac61b5771fccf9e2ce75e8689c0aace9 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:1730374 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1729712 Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org>
* Makefile: Enable more warnings for host utilities / testsJulius Werner2019-05-142-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds a bunch of more warnings that are already enabled in coreboot and thus already enabled for firmware builds anyway (because coreboot just passes its CFLAGS through). Enabling it in the vboot Makefile means they also apply to host utilities and tests, which sounds desirable for consistency. Fix enough of the cruft and bad coding practices that accumulated over the years of not having warnings enabled to get it to build again (this includes making functions static, removing dead code, cleaning up prototypes, etc.). Also remove -fno-strict-aliasing from the x86 firmware build options, because it's not clear why it's there (coreboot isn't doing this, so presumably it's not needed). BRANCH=None BUG=None TEST=make runtests Change-Id: Ie4a42083c4770a4eca133b22725be9ba85b24184 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1598721 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
* firmware: tpm2_lite: Implement TlclGetRandom()Stephen Boyd2018-11-272-3/+47
| | | | | | | | | | | | | | | | | | Implement support for getting random bytes from the TPM in the tpm2 library. The intent is to use this to seed the kaslr-seed DT property on ARM devices. BRANCH=None BUG=None TEST=Generate some random bytes in depthcharge using this API, and 'stop trunksd; tpmc rand <size>' with sizes (0, 1, 0xf0, and 0xf1) on the device and see the last one fail Change-Id: Ied0dc1ead70ac4daa2cee315516160ec100039be Signed-off-by: Stephen Boyd <swboyd@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1327187 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Andrey Pronin <apronin@chromium.org>
* tpmc: Add TlclUndefineSpace/Ex for TPM 1.2/2.0Meng-Huan Yu2018-11-012-0/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | For TPM 1.2, to undefine the space is just define a size 0 space. And all operation should be done under physical presence is set if NvLocked is set. Iirc, NvLocked is usually set before boot. For TPM 2.0, support to undefine space regardless platform hierarchy state. We will use platform authorization when TPMA_NV_PLATFORMCREATE of that space is set. Otherwise, we will try to use owner authorization with NULL password. For owner authorization with customized password is still not supported in UndefineSpace since it is also not support in DefineSpaceEx. BUG=chromium:895549 BRANCH=None TEST=vboot_reference unit test passed and added new link test for TPM 1.2. For TPM 2.0, there is no unit test, but passed manually test with tpmc in the following commit. Also passed depthcharge unit test for TPM 2.0 and TPM 1.2 board. Change-Id: I06dcc70c63a88a04d19f3b248666ff2492a1d2b0 Reviewed-on: https://chromium-review.googlesource.com/1291131 Commit-Ready: Meng-Huan Yu <menghuan@chromium.org> Tested-by: Meng-Huan Yu <menghuan@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
* vboot: bulk fix tabs and spacing inconsistencyJoel Kitching2018-08-032-11/+11
| | | | | | | | | | | | | | | | | | | Problem files were found with: find . -name '*.c' -o -name '*.h' | xargs grep '^ [^*]' and edited manually. Ignores utility/ and cgpt/, since they seem to globally adhere to a two-space tab convention. BUG=None TEST=make clean runtests TEST=emerge vboot_reference depthcharge Change-Id: I5a678484a119c8f1911f717e1968bdb4f1a0810f Reviewed-on: https://chromium-review.googlesource.com/1160131 Commit-Ready: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* tpm_lite: Add TlclGetSpaceInfoMattias Nissler2018-04-131-0/+23
| | | | | | | | | | | | | | | | The new TlclGetSpaceInfo function returns more detailed information about a defined NVRAM space. The existing TlclGetPermissions function is now using TlclGetSpaceInfo behind the scenes. BRANCH=None BUG=chromium:788719 TEST=New unit tests. Change-Id: I6c4f490d575788b696fd742a69e81e2767ec50f1 Reviewed-on: https://chromium-review.googlesource.com/937705 Trybot-Ready: Mattias Nissler <mnissler@chromium.org> Tested-by: Mattias Nissler <mnissler@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
* tpm_lite: Add more general DefineSpaceEx functionMattias Nissler2018-04-131-0/+25
| | | | | | | | | | | | | | | | | Add a TlclDefineSpaceEx function that allows to pass additional parameters when creating NVRAM spaces, i.e. owner authorization as well as PCR bindings. BRANCH=None BUG=chromium:788719 TEST=New unit tests. Change-Id: I73404c05528a89604fea3bcb1f00741fb865ba77 Reviewed-on: https://chromium-review.googlesource.com/814114 Reviewed-by: Andrey Pronin <apronin@chromium.org> Trybot-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Trybot-Ready: Mattias Nissler <mnissler@chromium.org> Tested-by: Mattias Nissler <mnissler@chromium.org>
* firmware: tpm2_lite: fix command/response code typeAndrey Pronin2018-03-271-2/+1
| | | | | | | | | | | | | | | | Responses and commands share the same header structure. The tpm_code field corresponds to TPM_CC in one case and TPM_RC in the other. Make it uint32_t (instead of TPM_CC) in the structure to avoid confusion when dealing with responses. BUG=chromium:825894 BRANCH=none TEST=build Change-Id: I07821f35b0f539a863ee97c0a08c141d0533a4de Signed-off-by: Andrey Pronin <apronin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/981111 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* firmware: tpm2_lite: propagate actual errorsAndrey Pronin2018-03-272-151/+125
| | | | | | | | | | | | | | | | | | | | | | | | | | Propagate the actual error - a non-successful response code from the tpm or communication/serializing failure - to the caller of the Tlcl functions in TPM 2.0 case. Currently, the callers only have special processing for the error codes from TCG TPM 1.2 range, which are never returned in case of communication or serialization failures or from the actual TPM 2.0. (The only case of mapping TPM 2.0 error codes to TPM_E_BADINDEX is preserved in this CL.) Thus, changing the actual values returned from the functions won't change any current behavior in the calling layers. This CL is a preparatory work for adding special processing for communication errors in mount-encrypted. BUG=chromium:702724 BRANCH=none TEST=build; test that tpmc getvf, tpmc read still work. Change-Id: I96b20e7285e83f0038abc01e4b7175c938867e7d Signed-off-by: Andrey Pronin <apronin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/977225 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* 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>