security: keys: trusted: Make sealed key properly interoperable
authorJames Bottomley <James.Bottomley@HansenPartnership.com>
Wed, 27 Jan 2021 19:06:17 +0000 (11:06 -0800)
committerJarkko Sakkinen <jarkko@kernel.org>
Wed, 14 Apr 2021 13:30:30 +0000 (16:30 +0300)
commite5fb5d2c5a03e229ded1f45aa2a42f2c288689c7
tree7122d5009a93533f6b1fea5d99b419c794dc295c
parentf2219745250f388edacabe6cca73654131c67d0a
security: keys: trusted: Make sealed key properly interoperable

The current implementation appends a migratable flag to the end of a
key, meaning the format isn't exactly interoperable because the using
party needs to know to strip this extra byte.  However, all other
consumers of TPM sealed blobs expect the unseal to return exactly the
key.  Since TPM2 keys have a key property flag that corresponds to
migratable, use that flag instead and make the actual key the only
sealed quantity.  This is secure because the key properties are bound
to a hash in the private part, so if they're altered the key won't
load.

Backwards compatibility is implemented by detecting whether we're
loading a new format key or not and correctly setting migratable from
the last byte of old format keys.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Tested-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
include/linux/tpm.h
security/keys/trusted-keys/trusted_tpm2.c