Skip to content

Commit be07858

Browse files
a3fjarkkojs
authored andcommitted
KEYS: trusted: allow use of TEE as backend without TCG_TPM support
With recent rework, trusted keys are no longer limited to TPM as trust source. The Kconfig symbol is unchanged however leading to a few issues: - TCG_TPM is required, even if only TEE is to be used - Enabling TCG_TPM, but excluding it from available trusted sources is not possible - TEE=m && TRUSTED_KEYS=y will lead to TEE support being silently dropped, which is not the best user experience Remedy these issues by introducing two new boolean Kconfig symbols: TRUSTED_KEYS_TPM and TRUSTED_KEYS_TEE with the appropriate dependencies. Any new code depending on the TPM trusted key backend in particular or symbols exported by it will now need to explicitly state that it depends on TRUSTED_KEYS && TRUSTED_KEYS_TPM The latter to ensure the dependency is built and the former to ensure it's reachable for module builds. There are no such users yet. Reviewed-by: Sumit Garg <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Reviewed-by: Pankaj Gupta <[email protected]> Tested-by: Pankaj Gupta <[email protected]> Tested-by: Andreas Rammhold <[email protected]> Tested-by: Tim Harvey <[email protected]> Tested-by: Michael Walle <[email protected]> # on ls1028a (non-E and E) Tested-by: John Ernberg <[email protected]> # iMX8QXP Signed-off-by: Ahmad Fatoum <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
1 parent af402ee commit be07858

File tree

4 files changed

+42
-17
lines changed

4 files changed

+42
-17
lines changed

security/keys/Kconfig

+7-11
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,19 @@ config BIG_KEYS
7070

7171
config TRUSTED_KEYS
7272
tristate "TRUSTED KEYS"
73-
depends on KEYS && TCG_TPM
74-
select CRYPTO
75-
select CRYPTO_HMAC
76-
select CRYPTO_SHA1
77-
select CRYPTO_HASH_INFO
78-
select ASN1_ENCODER
79-
select OID_REGISTRY
80-
select ASN1
73+
depends on KEYS
8174
help
8275
This option provides support for creating, sealing, and unsealing
8376
keys in the kernel. Trusted keys are random number symmetric keys,
84-
generated and RSA-sealed by the TPM. The TPM only unseals the keys,
85-
if the boot PCRs and other criteria match. Userspace will only ever
86-
see encrypted blobs.
77+
generated and sealed by a trust source selected at kernel boot-time.
78+
Userspace will only ever see encrypted blobs.
8779

8880
If you are unsure as to whether this is required, answer N.
8981

82+
if TRUSTED_KEYS
83+
source "security/keys/trusted-keys/Kconfig"
84+
endif
85+
9086
config ENCRYPTED_KEYS
9187
tristate "ENCRYPTED KEYS"
9288
depends on KEYS

security/keys/trusted-keys/Kconfig

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
config TRUSTED_KEYS_TPM
2+
bool "TPM-based trusted keys"
3+
depends on TCG_TPM >= TRUSTED_KEYS
4+
default y
5+
select CRYPTO
6+
select CRYPTO_HMAC
7+
select CRYPTO_SHA1
8+
select CRYPTO_HASH_INFO
9+
select ASN1_ENCODER
10+
select OID_REGISTRY
11+
select ASN1
12+
help
13+
Enable use of the Trusted Platform Module (TPM) as trusted key
14+
backend. Trusted keys are random number symmetric keys,
15+
which will be generated and RSA-sealed by the TPM.
16+
The TPM only unseals the keys, if the boot PCRs and other
17+
criteria match.
18+
19+
config TRUSTED_KEYS_TEE
20+
bool "TEE-based trusted keys"
21+
depends on TEE >= TRUSTED_KEYS
22+
default y
23+
help
24+
Enable use of the Trusted Execution Environment (TEE) as trusted
25+
key backend.
26+
27+
if !TRUSTED_KEYS_TPM && !TRUSTED_KEYS_TEE
28+
comment "No trust source selected!"
29+
endif

security/keys/trusted-keys/Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
obj-$(CONFIG_TRUSTED_KEYS) += trusted.o
77
trusted-y += trusted_core.o
8-
trusted-y += trusted_tpm1.o
8+
trusted-$(CONFIG_TRUSTED_KEYS_TPM) += trusted_tpm1.o
99

1010
$(obj)/trusted_tpm2.o: $(obj)/tpm2key.asn1.h
11-
trusted-y += trusted_tpm2.o
12-
trusted-y += tpm2key.asn1.o
11+
trusted-$(CONFIG_TRUSTED_KEYS_TPM) += trusted_tpm2.o
12+
trusted-$(CONFIG_TRUSTED_KEYS_TPM) += tpm2key.asn1.o
1313

14-
trusted-$(CONFIG_TEE) += trusted_tee.o
14+
trusted-$(CONFIG_TRUSTED_KEYS_TEE) += trusted_tee.o

security/keys/trusted-keys/trusted_core.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ module_param_named(source, trusted_key_source, charp, 0);
2727
MODULE_PARM_DESC(source, "Select trusted keys source (tpm or tee)");
2828

2929
static const struct trusted_key_source trusted_key_sources[] = {
30-
#if IS_REACHABLE(CONFIG_TCG_TPM)
30+
#if defined(CONFIG_TRUSTED_KEYS_TPM)
3131
{ "tpm", &trusted_key_tpm_ops },
3232
#endif
33-
#if IS_REACHABLE(CONFIG_TEE)
33+
#if defined(CONFIG_TRUSTED_KEYS_TEE)
3434
{ "tee", &trusted_key_tee_ops },
3535
#endif
3636
};

0 commit comments

Comments
 (0)