tpm: fix RC value check in tpm2_seal_trusted
authorJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Wed, 25 Jan 2017 21:00:22 +0000 (23:00 +0200)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Fri, 3 Feb 2017 20:03:14 +0000 (22:03 +0200)
commit7d761119a914ec0ac05ec2a5378d1f86e680967d
tree6bc37ee3c9fedc7a375104bb1beab183f25de855
parent419a16d9cda3408090704d5e3956c866e18f0af6
tpm: fix RC value check in tpm2_seal_trusted

The error code handling is broken as any error code that has the same
bits set as TPM_RC_HASH passes. Implemented tpm2_rc_value() helper to
parse the error value from FMT0 and FMT1 error codes so that these types
of mistakes are prevented in the future.

Fixes: 5ca4c20cfd37 ("keys, trusted: select hash algorithm for TPM2 chips")
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
drivers/char/tpm/tpm.h
drivers/char/tpm/tpm2-cmd.c