TPM derived keys
Subsystems (4)
cover TPM derived keys
TPM derived keys get their payload from an HMAC primary key in the owner hierarchy mixed with some metadata from the requesting process.
They are similar to trusted keys in the sense that the key security is rooted in the TPM, but may provide easier key management for some use-cases.
One inconvenience with trusted keys is that the cryptographic material should be provided externally. This means either wrapping the key to the TPM on the executing system (which briefly exposes plaintext cryptographic material to userspace) or creating the wrapped blob externally, but then we need to gather and transfer the TPM public key to the remote system, which may be a logistical problem sometimes.
Moreover, we need to store the wrapped key blob somewhere, and if we lose it, the application cannot recover its data anymore.
TPM derived keys may make key management for applications easier, especially on stateless systems as the application can always recreate its keys and the encrypted data is bound to the device and its TPM. They allow the application to wrap/unwrap some data to the device without worrying too much about key management and provisioning. They are similar in a sense to device unique keys present on many mobile devices and some IoT systems, but even better as every application has its own unique device key.
It is also easy to quickly "wipe" all the application keys by just resetting the TPM owner hierarchy.
It is worth mentioning that this functionality can be implemented in userspace as a /sbin/request-key plugin. However, the advantage of the in-kernel implementation is that the derived key material never leaves the kernel space (unless explicitly read into userspace with proper permissions).
Current implementation supports two modes (as demonstrated by the keyctl userspace tool):
1. keyctl add derived test '32 path' - will derive a 32 byte key based on the TPM seed and the filesystem path of the requesting application. That is /usr/bin/keyctl and /opt/bin/keyctl would generate different keys.
2. keyctl add derived test '32 csum' - will derive a 32 byte key based on the TPM seed and the IMA measurement of the requesting application. That is /usr/bin/keyctl and /opt/bin/keyctl would generate the same key IFF their code exactly matches bit for bit. The implementation does not measure the requesting binary itself, but rather relies on already available measurement. This means for this mode to work IMA needs to be enabled and configured for requesting applications. For example:
# echo 'audit func=BPRM_CHECK' > \
/sys/kernel/security/integrity/ima/policy
Open questions (apart from the obvious "is this useful?"):
* should any other modes/derivation parameters be considered?
* apparently in checksum mode, when calling keyring syscalls from scripts, we mix in the measurement of the interpreter, not the script itself. Is there any way to improve this?
Ignat Korchagin (2):
tpm: add some algorithm and constant definitions from the TPM spec
KEYS: implement derived keys
include/linux/tpm.h | 16 +- security/keys/Kconfig | 16 ++ security/keys/Makefile | 1 + security/keys/derived-keys/Makefile | 8 + security/keys/derived-keys/derived.c | 226 +++++++++++++++++++++ security/keys/derived-keys/derived.h | 4 + security/keys/derived-keys/tpm2_shash.c | 257 ++++++++++++++++++++++++ 7 files changed, 524 insertions(+), 4 deletions(-) create mode 100644 security/keys/derived-keys/Makefile create mode 100644 security/keys/derived-keys/derived.c create mode 100644 security/keys/derived-keys/derived.h create mode 100644 security/keys/derived-keys/tpm2_shash.c
Signature · 1 line
2.39.2
RFC PATCH 1/2 tpm: add some algorithm and constant definitions from the TPM spec
In preparation for implementing TPM derived keys we need to use some new TPM functionality in the kernel, so add relevant constant definitions.
--- include/linux/tpm.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
include/linux/tpm.h +12 -4
@@ -35,6 +35,7 @@ struct trusted_key_options;enum tpm_algorithms {TPM_ALG_ERROR =0x0000 ,TPM_ALG_SHA1 =0x0004 , +TPM_ALG_HMAC =0x0005 ,TPM_ALG_KEYEDHASH =0x0008 ,TPM_ALG_SHA256 =0x000B ,TPM_ALG_SHA384 =0x000C ,
@@ -209,6 +210,7 @@ enum tpm2_return_codes {TPM2_RC_DISABLED =0x0120 ,TPM2_RC_UPGRADE =0x012D ,TPM2_RC_COMMAND_CODE =0x0143 , +TPM2_RC_OBJECT_MEMORY =0x0902 ,TPM2_RC_TESTING =0x090A ,/* RC_WARN */ TPM2_RC_REFERENCE_H0 =0x0910 , TPM2_RC_RETRY = 0x0922,
@@ -227,6 +229,7 @@ enum tpm2_command_codes {TPM2_CC_CREATE =0x0153 ,TPM2_CC_LOAD =0x0157 ,TPM2_CC_SEQUENCE_UPDATE =0x015C , +TPM2_CC_SIGN =0x015D ,TPM2_CC_UNSEAL =0x015E ,TPM2_CC_CONTEXT_LOAD =0x0161 , TPM2_CC_CONTEXT_SAVE = 0x0162,
@@ -234,6 +237,7 @@ enum tpm2_command_codes {TPM2_CC_VERIFY_SIGNATURE =0x0177 ,TPM2_CC_GET_CAPABILITY =0x017A ,TPM2_CC_GET_RANDOM =0x017B , +TPM2_CC_HASH =0x017D ,TPM2_CC_PCR_READ =0x017E ,TPM2_CC_PCR_EXTEND =0x0182 , TPM2_CC_EVENT_SEQUENCE_COMPLETE = 0x0185,
@@ -243,7 +247,8 @@ enum tpm2_command_codes { };enum tpm2_permanent_handles { -TPM2_RS_PW =0x40000009 , +TPM2_RH_OWNER =0x40000001 , +TPM2_RS_PW =0x40000009 , };enum tpm2_capabilities {
@@ -312,9 +317,12 @@ struct tpm_buf { };enum tpm2_object_attributes { -TPM2_OA_FIXED_TPM =BIT (1 ), -TPM2_OA_FIXED_PARENT =BIT (4 ), -TPM2_OA_USER_WITH_AUTH =BIT (6 ), +TPM2_OA_FIXED_TPM =BIT (1 ), +TPM2_OA_FIXED_PARENT =BIT (4 ), +TPM2_OA_SENSITIVE_DATA_ORIGIN =BIT (5 ), +TPM2_OA_USER_WITH_AUTH =BIT (6 ), +TPM2_OA_RESTRICTED =BIT (16 ), +TPM2_OA_SIGN =BIT (18 ), };enum tpm2_session_attributes {
Signature · 1 line
2.39.2
Jarkko Sakkinen
maintainerRe: [RFC PATCH 1/2] tpm: add some algorithm and constant definitions from the TPM spec
I'll go through the code changes. I've barely skimmed them because I needed to understand the gist of the cover letter first and was busy with 6.10 release and asymmetric keys.
Quoted 2 lines · Ignat Korchagin
In preparation for implementing TPM derived keys we need to use some new TPM functionality in the kernel, so add relevant constant definitions.
Define "TPM derived key" what is. It is *undefined* at this point of the Git history.
Quoted 11 lines
Signed-off-by Ignat Korchagin <[email protected]>--- include/linux/tpm.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)include/linux/tpm.h +0
-0
include/linux/tpm.h struct trusted_key_options; · line 41
Quoted 7 lines
include/linux/tpm.h +1
-0@@ -35,6 +35,7 @@ struct trusted_key_options;enum tpm_algorithms {TPM_ALG_ERROR =0x0000 ,TPM_ALG_SHA1 =0x0004 , +TPM_ALG_HMAC =0x0005 ,TPM_ALG_KEYEDHASH =0x0008 ,TPM_ALG_SHA256 =0x000B ,TPM_ALG_SHA384 =0x000C ,
I had a point after all when asking for split and it was about this patch. This should be a separate comment and with a clear rationale what for this is required for the new key type.
It is a logically separate change [1].
include/linux/tpm.h enum tpm2_return_codes { · line 216
Quoted 8 lines
include/linux/tpm.h +1
-0@@ -209,6 +210,7 @@ enum tpm2_return_codes {TPM2_RC_DISABLED =0x0120 ,TPM2_RC_UPGRADE =0x012D ,TPM2_RC_COMMAND_CODE =0x0143 , +TPM2_RC_OBJECT_MEMORY =0x0902 ,TPM2_RC_TESTING =0x090A ,/* RC_WARN */ TPM2_RC_REFERENCE_H0 =0x0910 , TPM2_RC_RETRY = 0x0922,
Ditto.
include/linux/tpm.h enum tpm2_command_codes { · line 235
Quoted 8 lines
include/linux/tpm.h +1
-0@@ -227,6 +229,7 @@ enum tpm2_command_codes {TPM2_CC_CREATE =0x0153 ,TPM2_CC_LOAD =0x0157 ,TPM2_CC_SEQUENCE_UPDATE =0x015C , +TPM2_CC_SIGN =0x015D ,TPM2_CC_UNSEAL =0x015E ,TPM2_CC_CONTEXT_LOAD =0x0161 , TPM2_CC_CONTEXT_SAVE = 0x0162,
Ditto.
include/linux/tpm.h enum tpm2_command_codes { · line 243
Quoted 8 lines
include/linux/tpm.h +1
-0@@ -234,6 +237,7 @@ enum tpm2_command_codes {TPM2_CC_VERIFY_SIGNATURE =0x0177 ,TPM2_CC_GET_CAPABILITY =0x017A ,TPM2_CC_GET_RANDOM =0x017B , +TPM2_CC_HASH =0x017D ,TPM2_CC_PCR_READ =0x017E ,TPM2_CC_PCR_EXTEND =0x0182 , TPM2_CC_EVENT_SEQUENCE_COMPLETE = 0x0185,
Ditto.
include/linux/tpm.h enum tpm2_command_codes { · line 250
Quoted 6 lines
include/linux/tpm.h +1
-1@@ -243,7 +247,8 @@ enum tpm2_command_codes { };enum tpm2_permanent_handles { -TPM2_RS_PW =0x40000009 , +TPM2_RH_OWNER =0x40000001 ,
Ditto.
Quoted 10 lines
include/linux/tpm.h +1
-2+ TPM2_RS_PW = 0x40000009, };enum tpm2_capabilities {@@ -312,9 +317,12 @@ struct tpm_buf { };enum tpm2_object_attributes { -TPM2_OA_FIXED_TPM =BIT (1 ), -TPM2_OA_FIXED_PARENT =BIT (4 ),
include/linux/tpm.h struct tpm_buf { · line 328
Quoted 10 lines
include/linux/tpm.h +6
-1- TPM2_OA_USER_WITH_AUTH = BIT(6), +TPM2_OA_FIXED_TPM =BIT (1 ), +TPM2_OA_FIXED_PARENT =BIT (4 ), +TPM2_OA_SENSITIVE_DATA_ORIGIN =BIT (5 ), +TPM2_OA_USER_WITH_AUTH =BIT (6 ), +TPM2_OA_RESTRICTED =BIT (16 ), + TPM2_OA_SIGN = BIT(18), }; enum tpm2_session_attributes {
Ditto.
[1] https://www.kernel.org/doc/html/latest/process/submitting-patches.html#separate-your-changes
BR, Jarkko
Jarkko Sakkinen
maintainerRe: [RFC PATCH 1/2] tpm: add some algorithm and constant definitions from the TPM spec
Quoted 11 lines · Jarkko Sakkinen
include/linux/tpm.h enum tpm2_command_codes { · line 235
Quoted 8 lines
include/linux/tpm.h +1
-0@@ -227,6 +229,7 @@ enum tpm2_command_codes {TPM2_CC_CREATE =0x0153 ,TPM2_CC_LOAD =0x0157 ,TPM2_CC_SEQUENCE_UPDATE =0x015C , +TPM2_CC_SIGN =0x015D ,TPM2_CC_UNSEAL =0x015E ,TPM2_CC_CONTEXT_LOAD =0x0161 , TPM2_CC_CONTEXT_SAVE = 0x0162,Ditto.
Quoted 11 lines
include/linux/tpm.h enum tpm2_command_codes { · line 243
Quoted 8 lines
include/linux/tpm.h +1
-0@@ -234,6 +237,7 @@ enum tpm2_command_codes {TPM2_CC_VERIFY_SIGNATURE =0x0177 ,TPM2_CC_GET_CAPABILITY =0x017A ,TPM2_CC_GET_RANDOM =0x017B , +TPM2_CC_HASH =0x017D ,TPM2_CC_PCR_READ =0x017E ,TPM2_CC_PCR_EXTEND =0x0182 , TPM2_CC_EVENT_SEQUENCE_COMPLETE = 0x0185,Ditto.
These can be in the same patch but both need a rationale.
BR, Jarkko
RFC PATCH 2/2 KEYS: implement derived keys
In reply to Ignat KorchaginDerived keys are similar to user keys, but their payload is derived from the primary TPM seed and some metadata of the requesting process. This way every application can get a unique secret/key, which is cryptographically bound to the TPM without the need to provide the key material externally (unlike trusted keys). Also, the whole key derivation process is deterministic, so as long as the TPM is available, applications can always recover their keys, which may allow for easier key management on stateless systems.
In this implementation the following factors will be used as a key derivation factor:
* requested key length
* requesting process effective user id
* either the application executable path or the application integrity metadata (if available)
Key length is used so requests for keys with different sizes result in keys with different cryptographic material.
User id is mixed, so different users get different keys even when executing the same binary. Additionally this is useful for derived keys based on path derivation parameter: without this an unprivileged user can create a user and a mount namespace, put an executable to a normally privileged location (like /usr/sbin) and recover the key for some system tool.
If an application chooses to use its path as a key derivation factor, this key will be implicitly available for any executable located at the path. For example, a service under /usr/sbin/sshd would always be able to recover its key regardless of its version or implementation, but if the binary is moved elsewhere, the key would be different.
If the application chooses to use integrity metadata as a key derivation factor, the resulting key would be cryptographically bound to this metadata. In practice this means that a particular binary executable will always have access to its key regardless where it is executed from. However, if the executable code changes, the key would change as well.
--- security/keys/Kconfig | 16 ++ security/keys/Makefile | 1 + security/keys/derived-keys/Makefile | 8 + security/keys/derived-keys/derived.c | 226 +++++++++++++++++++++ security/keys/derived-keys/derived.h | 4 + security/keys/derived-keys/tpm2_shash.c | 257 ++++++++++++++++++++++++ 6 files changed, 512 insertions(+) create mode 100644 security/keys/derived-keys/Makefile create mode 100644 security/keys/derived-keys/derived.c create mode 100644 security/keys/derived-keys/derived.h create mode 100644 security/keys/derived-keys/tpm2_shash.c
security/keys/Kconfig +16 -0
@@ -112,6 +112,22 @@ config USER_DECRYPTED_DATA If you are unsure as to whether this is required, answer N. +config DERIVED_KEYS + tristate "DERIVED KEYS" + depends on KEYS + depends on TCG_TPM + select CRYPTO + select CRYPTO_HMAC + select CRYPTO_SHA256 + select CRYPTO_KDF800108_CTR + help + This option provides support for deriving keys from a trust source + in the kernel. Derived keys are instantiated using a KDF with a seed + from a trust source, so are unique per system/trust source. These keys + can always be recovered as long as the trust source is available. + + If you are unsure as to whether this is required, answer N. + config KEY_DH_OPERATIONS bool "Diffie-Hellman operations on retained keys" depends on KEYS
security/keys/Makefile +1 -0
@@ -30,3 +30,4 @@ obj-$(CONFIG_ASYMMETRIC_KEY_TYPE) += keyctl_pkey.o obj-$(CONFIG_BIG_KEYS) += big_key.o obj-$(CONFIG_TRUSTED_KEYS) += trusted-keys/ obj-$(CONFIG_ENCRYPTED_KEYS) += encrypted-keys/ +obj-$(CONFIG_DERIVED_KEYS) += derived-keys/
security/keys/derived-keys/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for derived keys +# + +obj-$(CONFIG_DERIVED_KEYS) += derived-keys.o +derived-keys-y += derived.o +derived-keys-y += tpm2_shash.o
security/keys/derived-keys/derived.c new file +226 -0
226 lines not on this page · raw message
security/keys/derived-keys/derived.h new file +4 -0
@@ -0,0 +1,4 @@ +#define TPM2_HASH_IMPL_NAME "tpm2-hmac-internal" + +int register_tpm2_shash (void ); +void unregister_tpm2_shash (void );
security/keys/derived-keys/tpm2_shash.c new file +257 -0
257 lines not on this page · raw message
Signature · 1 line
2.39.2
kernel test robot
build botRe: [RFC PATCH 2/2] KEYS: implement derived keys
kernel test robot noticed the following build errors:
Hi Ignat,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on zohar-integrity/next-integrity] [also build test ERROR on linus/master v6.9-rc7 next-20240503] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Ignat-Korchagin/tpm-add-some-algorithm-and-constant-definitions-from-the-TPM-spec/20240504-061938 base: https://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity.git next-integrity patch link: https://lore.kernel.org/r/20240503221634.44274-3-ignat%40cloudflare.com patch subject: [RFC PATCH 2/2] KEYS: implement derived keys config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20240506/[email protected]/config) compiler: m68k-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240506/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>, old ones prefixed by <<):
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-audio-manager.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-gbphy.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-gpio.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-i2c.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-pwm.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-sdio.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-spi.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-uart.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-usb.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/platform/goldfish/goldfish_pipe.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/platform/chrome/cros_kunit_proto_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mailbox/mtk-cmdq-mailbox.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/devfreq/governor_simpleondemand.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/devfreq/governor_performance.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/devfreq/governor_powersave.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/devfreq/governor_userspace.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hwtracing/intel_th/intel_th_msu_sink.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/nvmem/nvmem-apple-efuses.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/nvmem/nvmem_brcm_nvram.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/nvmem/nvmem_u-boot-env.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/interconnect/imx/imx-interconnect.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/interconnect/imx/imx8mm-interconnect.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/interconnect/imx/imx8mq-interconnect.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/interconnect/imx/imx8mn-interconnect.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/interconnect/imx/imx8mp-interconnect.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hte/hte-tegra194-test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/vdpa/vdpa.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/parport/parport.o
WARNING: modpost: drivers/parport/parport_amiga: section mismatch in reference: amiga_parallel_driver+0x8 (section: .data) -> amiga_parallel_remove (section: .exit.text)
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mtd/parsers/brcm_u-boot.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mtd/parsers/tplink_safeloader.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mtd/chips/cfi_util.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mtd/chips/cfi_cmdset_0020.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mtd/maps/map_funcs.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/spmi/hisi-spmi-controller.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/spmi/spmi-pmic-arb.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/uio/uio.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/uio/uio_pruss.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pcmcia/pcmcia_rsrc.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pcmcia/i82365.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hwmon/corsair-cpro.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hwmon/mr75203.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/vhost/vringh.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/greybus/greybus.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/greybus/gb-es2.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/rpmsg/rpmsg_char.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/iio/adc/ingenic-adc.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/iio/adc/xilinx-ams.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/iio/buffer/kfifo_buf.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fsi/fsi-core.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fsi/fsi-master-hub.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fsi/fsi-master-aspeed.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fsi/fsi-master-gpio.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fsi/fsi-master-ast-cf.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fsi/fsi-scom.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/siox/siox-bus-gpio.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/counter/ftm-quaddec.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/oss/dmasound/dmasound_core.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/oss/dmasound/dmasound_atari.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/oss/dmasound/dmasound_paula.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/core/snd-pcm-dmaengine.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/core/sound_kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/drivers/snd-pcmtest.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/pci/hda/snd-hda-cirrus-scodec-test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/soc-topology-test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/codecs/snd-soc-ab8500-codec.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/codecs/snd-soc-sigmadsp.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/codecs/snd-soc-wm-adsp.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/fsl/imx-pcm-dma.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/mxs/snd-soc-mxs-pcm.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/qcom/snd-soc-qcom-common.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/qcom/snd-soc-qcom-sdw.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/qcom/qdsp6/snd-q6dsp-common.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/sof/intel/snd-sof-intel-atom.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/sof/intel/snd-sof-acpi-intel-byt.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/sof/intel/snd-sof-acpi-intel-bdw.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/sof/imx/snd-sof-imx8.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/sof/imx/snd-sof-imx8m.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/sof/imx/snd-sof-imx8ulp.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/sof/imx/imx-common.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/sof/mediatek/mtk-adsp-common.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/sof/mediatek/mt8195/snd-sof-mt8195.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/sof/mediatek/mt8186/snd-sof-mt8186.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/sof/snd-sof-utils.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/sof/snd-sof-acpi.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/sof/snd-sof-of.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/xilinx/snd-soc-xlnx-i2s.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/soc/xilinx/snd-soc-xlnx-formatter-pcm.o
WARNING: modpost: missing MODULE_DESCRIPTION() in sound/ac97_bus.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/vfio-mdev/mtty.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/vfio-mdev/mdpy.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/vfio-mdev/mdpy-fb.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/vfio-mdev/mbochs.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/configfs/configfs_sample.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kfifo/bytestream-example.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kfifo/dma-example.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kfifo/inttype-example.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kfifo/record-example.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kobject/kobject-example.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kobject/kset-example.o
>> ERROR: modpost: "ima_iint_find" [security/keys/derived-keys/derived-keys.ko] undefined! >> ERROR: modpost: "get_task_exe_file" [security/keys/derived-keys/derived-keys.ko] undefined!
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Jarkko Sakkinen
maintainerRe: [RFC PATCH 2/2] KEYS: implement derived keys
In reply to Ignat KorchaginQuoted 2 lines · Ignat Korchagin
Derived keys are similar to user keys, but their payload is derived from the primary TPM seed and some metadata of the requesting process. This way every
What is exactly "some metadata"?
Quoted 1 line
application can get a unique secret/key, which is cryptographically bound to
What is "cryptographically bound". Please go straight to the point and cut out *all* white paper'ish phrases. We do not need it and will make painful to backtrack this commit once in the mainline.
Quoted 2 lines
the TPM without the need to provide the key material externally (unlike trusted keys). Also, the whole key derivation process is deterministic, so as long as
Why trusted keys is inside braces. It is not important for the point you are trying to make here?
Quoted 2 lines
the TPM is available, applications can always recover their keys, which may allow for easier key management on stateless systems.
Please drop "stateless system" unless you provide a rigid definition what it is. I have no idea what you mean by it. Probably not that important, right?
Quoted 7 lines
In this implementation the following factors will be used as a key derivation factor:
* requested key length
* requesting process effective user id
* either the application executable path or the application integrity metadata (if available)
NAK for path for any possible key derivation. They are racy and and ambiguous.
This should have been in the beginning instead of "some data". What other implementations exist. For me "this implementation" implies that this one competing alternative to multiple implementations of the same thing.
I do not like this science/white paper style at all. Just express short, open code everything right at start when you need and cut extras like "stateless system" unless you can provide exact, sound and unambiguous definiton of it.
Just want to underline how this really needs a complete rewrite with clear and concise explanation :-) This won't ever work.
Quoted 3 lines
Key length is used so requests for keys with different sizes result in keys with different cryptographic material.
What is "key length"? Please refer the exact attribute.
Quoted 2 lines
User id is mixed, so different users get different keys even when executing the
First of all it would be more clear to just s/User id/UID/
And make obvious whether we are talking about ruid or euid and how this interacts with GIDs.
I'll look at the code change next round if the commit message starts making any sense.
BR, Jarkko
Jarkko Sakkinen
maintainerRe: [RFC PATCH 2/2] KEYS: implement derived keys
Quoted 58 lines · Jarkko Sakkinen
Quoted 2 lines · Ignat Korchagin
Derived keys are similar to user keys, but their payload is derived from the primary TPM seed and some metadata of the requesting process. This way every
What is exactly "some metadata"?
Quoted 1 line
application can get a unique secret/key, which is cryptographically bound to
What is "cryptographically bound". Please go straight to the point and cut out *all* white paper'ish phrases. We do not need it and will make painful to backtrack this commit once in the mainline.
Quoted 2 lines
the TPM without the need to provide the key material externally (unlike trusted keys). Also, the whole key derivation process is deterministic, so as long as
Why trusted keys is inside braces. It is not important for the point you are trying to make here?
Quoted 2 lines
the TPM is available, applications can always recover their keys, which may allow for easier key management on stateless systems.
Please drop "stateless system" unless you provide a rigid definition what it is. I have no idea what you mean by it. Probably not that important, right?
Quoted 7 lines
In this implementation the following factors will be used as a key derivation factor:
* requested key length
* requesting process effective user id
* either the application executable path or the application integrity metadata (if available)NAK for path for any possible key derivation. They are racy and and ambiguous.
This should have been in the beginning instead of "some data". What other implementations exist. For me "this implementation" implies that this one competing alternative to multiple implementations of the same thing.
I do not like this science/white paper style at all. Just express short, open code everything right at start when you need and cut extras like "stateless system" unless you can provide exact, sound and unambiguous definiton of it.
Just want to underline how this really needs a complete rewrite with clear and concise explanation :-) This won't ever work.
Quoted 3 lines
Key length is used so requests for keys with different sizes result in keys with different cryptographic material.
What is "key length"? Please refer the exact attribute.
Quoted 2 lines
User id is mixed, so different users get different keys even when executing the
Quoted 7 lines
First of all it would be more clear to just s/User id/UID/
And make obvious whether we are talking about ruid or euid and how this interacts with GIDs.
I'll look at the code change next round if the commit message starts making any sense.
Right and neither UIDs and GIDs are applicable for key derivation for quite obvious reasons. So NAK for that too.
You can make them point out unlimited different identities...
BR, Jarkko
Jarkko Sakkinen
maintainerRe: [RFC PATCH 2/2] KEYS: implement derived keys
Quoted 11 lines · Jarkko Sakkinen
Quoted 11 lines
What is "key length"? Please refer the exact attribute.
Quoted 2 lines
User id is mixed, so different users get different keys even when executing the
First of all it would be more clear to just s/User id/UID/
And make obvious whether we are talking about ruid or euid and how this interacts with GIDs.
Quoted 7 lines
Quoted 2 lines
I'll look at the code change next round if the commit message starts making any sense.
Right and neither UIDs and GIDs are applicable for key derivation for quite obvious reasons. So NAK for that too.
You can make them point out unlimited different identities...
Please drop the whole stateless system argument from the next patch set version. It looks to me that only it has been considered and we don't even have definition what it is. I think it only distorts and confuses and is totally app specific in the end of the day.
This looks more like a tool for identity theft than a key in its current state. This could never ever exist in a "stateful system" and this mainline code base so would be quite irresponsible to ever take this.
There's only one attribute I'm aware that you could ever possibly use for key derivation: mm_struct->exe_file.
BR, Jarkko
Re: [RFC PATCH 2/2] KEYS: implement derived keys
In reply to Jarkko SakkinenQuoted 62 lines · Jarkko Sakkinen
Quoted 60 lines · Jarkko Sakkinen
Quoted 2 lines · Ignat Korchagin
Derived keys are similar to user keys, but their payload is derived from the primary TPM seed and some metadata of the requesting process. This way every
What is exactly "some metadata"?
Quoted 1 line
application can get a unique secret/key, which is cryptographically bound to
What is "cryptographically bound". Please go straight to the point and cut out *all* white paper'ish phrases. We do not need it and will make painful to backtrack this commit once in the mainline.
Quoted 2 lines
the TPM without the need to provide the key material externally (unlike trusted keys). Also, the whole key derivation process is deterministic, so as long as
Why trusted keys is inside braces. It is not important for the point you are trying to make here?
Quoted 2 lines
the TPM is available, applications can always recover their keys, which may allow for easier key management on stateless systems.
Please drop "stateless system" unless you provide a rigid definition what it is. I have no idea what you mean by it. Probably not that important, right?
Quoted 7 lines
In this implementation the following factors will be used as a key derivation factor:
* requested key length
* requesting process effective user id
* either the application executable path or the application integrity metadata (if available)NAK for path for any possible key derivation. They are racy and and ambiguous.
This should have been in the beginning instead of "some data". What other implementations exist. For me "this implementation" implies that this one competing alternative to multiple implementations of the same thing.
I do not like this science/white paper style at all. Just express short, open code everything right at start when you need and cut extras like "stateless system" unless you can provide exact, sound and unambiguous definiton of it.
Just want to underline how this really needs a complete rewrite with clear and concise explanation :-) This won't ever work.
Quoted 3 lines
Key length is used so requests for keys with different sizes result in keys with different cryptographic material.
What is "key length"? Please refer the exact attribute.
Quoted 2 lines
User id is mixed, so different users get different keys even when executing the
First of all it would be more clear to just s/User id/UID/
Quoted 8 lines
Quoted 5 lines
And make obvious whether we are talking about ruid or euid and how this interacts with GIDs.
I'll look at the code change next round if the commit message starts making any sense.
Right and neither UIDs and GIDs are applicable for key derivation for quite obvious reasons. So NAK for that too.
Can you, please, clarify a bit here? Not very obvious for me. I added euid for two reasons:
* an unprivileged user might run a normally privileged application,
for example /usr/sbin/sshd, and depending on the code could "leak" the key
* without it and with unprivileged user namespaces it is possible to
create an unprivileged container with code at the same path as a privileged application
Why do you think UIDs/GIDs are not applicable as mixins?
Ignat
Quoted 3 lines
You can make them point out unlimited different identities...
BR, Jarkko
Jarkko Sakkinen
maintainerRe: [RFC PATCH 2/2] KEYS: implement derived keys
Quoted 81 lines · Ignat Korchagin
Quoted 62 lines · Jarkko Sakkinen
Quoted 60 lines · Jarkko Sakkinen
Quoted 2 lines · Ignat Korchagin
Derived keys are similar to user keys, but their payload is derived from the primary TPM seed and some metadata of the requesting process. This way every
What is exactly "some metadata"?
Quoted 1 line
application can get a unique secret/key, which is cryptographically bound to
What is "cryptographically bound". Please go straight to the point and cut out *all* white paper'ish phrases. We do not need it and will make painful to backtrack this commit once in the mainline.
Quoted 2 lines
the TPM without the need to provide the key material externally (unlike trusted keys). Also, the whole key derivation process is deterministic, so as long as
Why trusted keys is inside braces. It is not important for the point you are trying to make here?
Quoted 2 lines
the TPM is available, applications can always recover their keys, which may allow for easier key management on stateless systems.
Please drop "stateless system" unless you provide a rigid definition what it is. I have no idea what you mean by it. Probably not that important, right?
Quoted 7 lines
In this implementation the following factors will be used as a key derivation factor:
* requested key length
* requesting process effective user id
* either the application executable path or the application integrity metadata (if available)NAK for path for any possible key derivation. They are racy and and ambiguous.
This should have been in the beginning instead of "some data". What other implementations exist. For me "this implementation" implies that this one competing alternative to multiple implementations of the same thing.
I do not like this science/white paper style at all. Just express short, open code everything right at start when you need and cut extras like "stateless system" unless you can provide exact, sound and unambiguous definiton of it.
Just want to underline how this really needs a complete rewrite with clear and concise explanation :-) This won't ever work.
Quoted 3 lines
Key length is used so requests for keys with different sizes result in keys with different cryptographic material.
What is "key length"? Please refer the exact attribute.
Quoted 2 lines
User id is mixed, so different users get different keys even when executing the
First of all it would be more clear to just s/User id/UID/
Quoted 8 lines
Quoted 5 lines
And make obvious whether we are talking about ruid or euid and how this interacts with GIDs.
I'll look at the code change next round if the commit message starts making any sense.
Right and neither UIDs and GIDs are applicable for key derivation for quite obvious reasons. So NAK for that too.
Can you, please, clarify a bit here? Not very obvious for me. I added euid for two reasons:
* an unprivileged user might run a normally privileged application,
for example/usr/sbin/sshd, and depending on the code could "leak" the key
* without it and with unprivileged user namespaces it is possible to
create an unprivileged container with code at the same path as a privileged application
Quoted 1 line
Why do you think UIDs/GIDs are not applicable as mixins?
I did as much clarification as I possibly can.
Also, if you look at confidential computing platforms there's exactly two assets that they use lock into machine:
- Binary
- CPU material
Only carved into stone immutable material for key derivation.
You can use mm_struct->exe_file binary if that will work out for you. I'm done with this version.
BR, Jarkko
Jarkko Sakkinen
maintainerRe: [RFC PATCH 2/2] KEYS: implement derived keys
Quoted 5 lines · Jarkko Sakkinen
I did as much clarification as I possibly can.
Also, if you look at confidential computing platforms there's exactly two assets that they use lock into machine:
Quoted 7 lines
- Binary
- CPU materialOnly carved into stone immutable material for key derivation.
You can use
mm_struct->exe_filebinary if that will work out for you. I'm done with this version.
Pretty good case for having SGX, TDX and SNP in something else than just Xeon's and EPYC's ;-)
But yeah within time limits I have I've used more quota for this than I should have.
I look at +1 (if there is one).
BR, Jarkko
Re: [RFC PATCH 2/2] KEYS: implement derived keys
In reply to Jarkko SakkinenQuoted 34 lines · Jarkko Sakkinen
Quoted 2 lines · Ignat Korchagin
Derived keys are similar to user keys, but their payload is derived from the primary TPM seed and some metadata of the requesting process. This way every
What is exactly "some metadata"?
Quoted 1 line
application can get a unique secret/key, which is cryptographically bound to
What is "cryptographically bound". Please go straight to the point and cut out *all* white paper'ish phrases. We do not need it and will make painful to backtrack this commit once in the mainline.
Quoted 2 lines
the TPM without the need to provide the key material externally (unlike trusted keys). Also, the whole key derivation process is deterministic, so as long as
Why trusted keys is inside braces. It is not important for the point you are trying to make here?
Quoted 2 lines
the TPM is available, applications can always recover their keys, which may allow for easier key management on stateless systems.
Please drop "stateless system" unless you provide a rigid definition what it is. I have no idea what you mean by it. Probably not that important, right?
Quoted 7 lines
In this implementation the following factors will be used as a key derivation factor:
* requested key length
* requesting process effective user id
* either the application executable path or the application integrity metadata (if available)
Quoted 2 lines
NAK for path for any possible key derivation. They are racy and and ambiguous.
Can you elaborate here? What kind of a problem you see specifically? (This is exactly what I want to get from this discussion)
Quoted 4 lines
This should have been in the beginning instead of "some data". What other implementations exist. For me "this implementation" implies that this one competing alternative to multiple implementations of the same thing.
With "this implementation" I meant the current RFC patchset because I do expect there would be more iterations and just wanted to solicit comments.
Quoted 7 lines
I do not like this science/white paper style at all. Just express short, open code everything right at start when you need and cut extras like "stateless system" unless you can provide exact, sound and unambiguous definiton of it.
Just want to underline how this really needs a complete rewrite with clear and concise explanation :-) This won't ever work.
Understood.
Quoted 19 lines
Quoted 3 lines
Key length is used so requests for keys with different sizes result in keys with different cryptographic material.
What is "key length"? Please refer the exact attribute.
Quoted 2 lines
User id is mixed, so different users get different keys even when executing the
First of all it would be more clear to just s/User id/UID/
And make obvious whether we are talking about ruid or euid and how this interacts with GIDs.
I'll look at the code change next round if the commit message starts making any sense.
BR, Jarkko
Jarkko Sakkinen
maintainerQuoted 2 lines · Ignat Korchagin
TPM derived keys get their payload from an HMAC primary key in the owner hierarchy mixed with some metadata from the requesting process.
What metadata?
What is "the requesting process"?
Quoted 3 lines
They are similar to trusted keys in the sense that the key security is rooted in the TPM, but may provide easier key management for some use-cases.
Which use cases?
Two first paragraphs are confusers not motivators with three undefined assets.
Quoted 6 lines
One inconvenience with trusted keys is that the cryptographic material should be provided externally. This means either wrapping the key to the TPM on the executing system (which briefly exposes plaintext cryptographic material to userspace) or creating the wrapped blob externally, but then we need to gather and transfer the TPM public key to the remote system, which may be a logistical problem sometimes.
What are the *existential* issues?
You are start by inconviences with trusted keys without describing for what the trusted keys are used for.
Quoted 2 lines
Moreover, we need to store the wrapped key blob somewhere, and if we lose it, the application cannot recover its data anymore.
I don't frankly understand what you are trying to say here. Somewhere is not a place. It is an indeterministic entity.
Quoted 8 lines
TPM derived keys may make key management for applications easier, especially on stateless systems as the application can always recreate its keys and the encrypted data is bound to the device and its TPM. They allow the application to wrap/unwrap some data to the device without worrying too much about key management and provisioning. They are similar in a sense to device unique keys present on many mobile devices and some IoT systems, but even better as every application has its own unique device key.
Does it or does it not make it easier? Please decide.
That said hard fine from mainline perspective unless there is an existential issue.
Quoted 8 lines
It is also easy to quickly "wipe" all the application keys by just resetting the TPM owner hierarchy.
It is worth mentioning that this functionality can be implemented in userspace as a
/sbin/request-keyplugin. However, the advantage of the in-kernel implementation is that the derived key material never leaves the kernel space (unless explicitly read into userspace with proper permissions).
Please describe the implementation with request-key in the context of the use case where it is used. That is what this should have started. Then the motivation. Then the proposal for solution. And also focus only on existential factors.
I have no idea for what the key created with this is even used, which makes this impossible to review.
BR, Jarkko
Quoted 2 lines · Jarkko Sakkinen
I have no idea for what the key created with this is even used, which makes this impossible to review.
Additionally, there is nothing in Documentation/ for how userspace might use or create them. This includes things like their description format and describing available options.
--Ben
Jarkko Sakkinen
maintainerQuoted 7 lines · Ben Boeckel
Quoted 2 lines · Jarkko Sakkinen
I have no idea for what the key created with this is even used, which makes this impossible to review.
Additionally, there is nothing in
Documentation/for how userspace might use or create them. This includes things like their description format and describing available options.
The whole user story is plain out broken. Documenting a feature that has no provable use case won't fix that part.
So it is better to start with the cover letter. With the *existing* knowledge of the *real* issue I don't think we need this tbh.
BR, Jarkko
Jarkko Sakkinen
maintainerQuoted 9 lines · Jarkko Sakkinen
Quoted 7 lines · Ben Boeckel
Quoted 2 lines · Jarkko Sakkinen
I have no idea for what the key created with this is even used, which makes this impossible to review.
Additionally, there is nothing in
Documentation/for how userspace might use or create them. This includes things like their description format and describing available options.
Quoted 5 lines
The whole user story is plain out broken. Documenting a feature that has no provable use case won't fix that part.
So it is better to start with the cover letter. With the *existing* knowledge of the *real* issue I don't think we need this tbh.
As for code I'd suggest the "Describe your changes" part from
https://www.kernel.org/doc/html/latest/process/submitting-patches.html
and most essentially how to split them properly.
My best bet could something along the lines that perhaps there is some issue to be sorted out but I don't honestly believe that this will ever be a solution for any possible problem that exist in this planet.
BR, Jarkko
Quoted 19 lines · Jarkko Sakkinen
Quoted 9 lines · Jarkko Sakkinen
Quoted 7 lines · Ben Boeckel
Quoted 2 lines · Jarkko Sakkinen
I have no idea for what the key created with this is even used, which makes this impossible to review.
Additionally, there is nothing in
Documentation/for how userspace might use or create them. This includes things like their description format and describing available options.Quoted 5 lines
The whole user story is plain out broken. Documenting a feature that has no provable use case won't fix that part.
So it is better to start with the cover letter. With the *existing* knowledge of the *real* issue I don't think we need this tbh.
As for code I'd suggest the "Describe your changes" part from
Quoted 7 lines
https://www.kernel.org/doc/html/latest/process/submitting-patches.html
and most essentially how to split them properly.
My best bet could something along the lines that perhaps there is some issue to be sorted out but I don't honestly believe that this will ever be a solution for any possible problem that exist in this planet.
Sorry, I must admit I wrote the description hastingly and too high-level (it was pre-travelling, so probably not the right focus and in a rush). Let me restart from scratch and describe particular use-cases we're concerned about:
Trusted and encrypted keys are a great way to manage cryptographic keys inside the kernel, while never exposing plaintext cryptographic material to userspace: keys can only be read to userspace as encrypted blobs and with trusted keys - these blobs are created with the TPM, so only the TPM can unwrap the blobs.
One of the simplest way to create a trusted key is for an application to request the kernel to generate a new one [1], like below with the help of keyctl utility from keyutils:
$ keyctl add trusted kmk "new 32 keyhandle=0x81000001" @u
However, after the application generates a trusted key, it is the responsibility of the application to manage/store it. For example, if the application wants to reuse the key after a reboot, it needs to read the key into userspace as an encrypted blob and store it on persistent storage. This is challenging and sometimes not possible for stateless/immutable/ephemeral systems, so such systems are effectively locked out from using hardware-protected cryptographic keys.
Another point: while the fact that the application can't read the plaintext cryptographic material into userspace is a feature of trusted keys, it can also be a disadvantage. Since keys in plaintext exist only in kernel context, they are useful mostly for in-kernel systems, like dm-crypt, IMA, ecryptfs. Applications cannot easily use trusted keys for cryptographic purposes for their own workloads: for example, generating encrypted or MACed configuration files or encrypting in-transit data. While since commit 7984ceb134bf ("crypto:af_alg - Support symmetric encryption via keyring keys") it is possible to use a trusted key via Linux Crypto API userspace interface [2], it might not always be practical/desirable:
* due to limitations in the Linux Crypto API implementation it is
not possible to process more than ~64Kb of data using AEAD ciphers [3]
* needed algorithm implementations might not be enabled in the
kernel configuration file
* compliance constraints: the utilised cryptographic implementation
must be FIPS-validated
* performance constraints: passing large blobs of data to the kernel
for encryption is slow even with Crypto API's "zero-copy" interface
[3]
TPM derived keys attempt to address the above use cases by allowing applications to deterministically derive unique cryptographic keys for their own purposes directly from the TPM seed in the owner hierarchy. The idea is that when an application requests a new key, instead of generating a random key and wrapping it with the TPM, the implementation generates a key via KDF(hierarchy seed, application specific info). Therefore, the resulting keys will always be cryptographically bound to the application itself and the device they were generated on.
The applications then may either use in-kernel facilities, like [2], to do crypto operations inside the kernel, so the generated cryptographic material is never exposed to userspace (similar to trusted/encrypted keys). Or, if they are subject to performance/compliance/other constraints mentioned above, they can read the key material to userspace and use a userspace crypto library. Even with the latter approach they still get the benefit of using a key, security of which is rooted in the TPM.
TPM derived keys also address the key storage problem for stateless/immutable/ephemeral systems: since the derivation process is deterministic, the same application can always re-create their keys on the same system and doesn't need to store or back up any wrapped key blobs. One notable use case (ironically not for a stateless system) can be setting up proper full-disk encryption (dm-crypt plain mode without a LUKS header), for example, to provide deniable encryption or better resiliency to damage of encrypted media [4].
Current implementation provides two options for KDF's input for application specific info to ensure key uniqueness:
1. A key, which is unique to a filesystem path:
$ keyctl add derived test '32 path'
Above will derive a 32 byte key based on the TPM seed and the filesystem path of the requesting application. That is /usr/bin/keyctl and /opt/bin/keyctl would generate different keys.
2. A key, which is cryptographically bound to the code of the requesting application:
$ keyctl add derived test '32 csum'
Above will derive a 32 byte key based on the TPM seed and the IMA measurement of the requesting application. That is /usr/bin/keyctl and /opt/bin/keyctl would generate the same key if and only if their code exactly matches bit for bit. The implementation does not measure the requesting binary itself, but rather relies on already available measurement. This means for this mode to work IMA needs to be enabled and configured for requesting applications. For example:
# echo 'audit func=BPRM_CHECK' > \ /sys/kernel/security/integrity/ima/policy
Open questions:
* should any other modes/derivation parameters be considered as part
of application specific info?
* apparently in checksum mode, when calling keyring syscalls from
scripts, we mix in the measurement of the interpreter, not the script itself. Is there any way to improve this?
I would like to mention that in Cloudflare we have found large infrastructure key management based on derived keys from per-device unique seeds quite convenient and almost infinitely scalable and I believe TPM derived keys can be the next evolution bringing hardware security to the table. I understand that folks here are not required to follow links for additional information, but if someone is interested in more details for our approach, which has been working well for almost 9 years, see [5].
Hope it is better this time.
Ignat
[1]: https://www.kernel.org/doc/html/latest/security/keys/trusted-encrypted.html#examples-of-trusted-and-encrypted-key-usage
[2]: https://www.kernel.org/doc/html/latest/crypto/userspace-if.html
[3]: https://blog.cloudflare.com/the-linux-crypto-api-for-user-applications
[4]: https://wiki.archlinux.org/title/Dm-crypt/Encrypting_an_entire_system#Plain_dm-crypt
[5]: https://youtu.be/2RPcIbP2xsM?si=nKbyY0gss50i04CG
Quoted 1 line
BR, Jarkko
James Bottomley
maintainerOn Mon, 2024-05-13 at 18:09 +0100, Ignat Korchagin wrote:
[...]
Quoted 9 lines
TPM derived keys attempt to address the above use cases by allowing applications to deterministically derive unique cryptographic keys for their own purposes directly from the TPM seed in the owner hierarchy. The idea is that when an application requests a new key, instead of generating a random key and wrapping it with the TPM, the implementation generates a key via
KDF(hierarchy seed, application specific info). Therefore, the resulting keys will always be cryptographically bound to the application itself and the device they were generated on.
So I think what confuses me is what the expected cryptographic secrecy properties of the derived keys are. I get they're a KDF of seed and deterministic properties, but if those mixing values are well known (as the path or binary checksum cases) then anyone with access to the TPM can derive the key from user space because they can easily obtain the mixing parameters and there's no protection to the TPM keyed hash operation.
Consider the use case where two users are using derived keys on the same system (so same TPM). Assuming they use them to protect sensitive information, what prevents user1 from simply deriving user2's key and getting the information, or am I missing the point of this?
James
Quoted 21 lines · James Bottomley
On Mon, 2024-05-13 at 18:09 +0100, Ignat Korchagin wrote:
[...]Quoted 9 lines
TPM derived keys attempt to address the above use cases by allowing applications to deterministically derive unique cryptographic keys for their own purposes directly from the TPM seed in the owner hierarchy. The idea is that when an application requests a new key, instead of generating a random key and wrapping it with the TPM, the implementation generates a key via
KDF(hierarchy seed, application specific info). Therefore, the resulting keys will always be cryptographically bound to the application itself and the device they were generated on.So I think what confuses me is what the expected cryptographic secrecy properties of the derived keys are. I get they're a KDF of seed and deterministic properties, but if those mixing values are well known (as the path or binary checksum cases) then anyone with access to the TPM can derive the key from user space because they can easily obtain the mixing parameters and there's no protection to the TPM keyed hash operation.
Quoted 4 lines
Consider the use case where two users are using derived keys on the same system (so same TPM). Assuming they use them to protect sensitive information, what prevents user1 from simply deriving user2's key and getting the information, or am I missing the point of this?
You are correct: it is possible, but in practice it would be limited only to privileged users/applications. I remember there was a push to set a 666 mask for the TPM device file, but it is not how it is done today by default. Also I think the same applies to trusted keys as well, at least without any additional authorizations or PCR restrictions on the blob (I remember I could manually unwrap a trusted key blob in userspace as root).
It would be fixed if we could limit access to some TPM ops only from the kernel, but I remember from one of your presentations that it is generally a hard problem and that some solution was in the works (was it based on limiting access to a resettable PCR?). I'm happy to consider adopting it here as well somehow.
Quoted 2 lines
James
James Bottomley
maintainerQuoted 29 lines · Ignat Korchagin
Quoted 21 lines · James Bottomley
On Mon, 2024-05-13 at 18:09 +0100, Ignat Korchagin wrote:
[...]Quoted 9 lines
TPM derived keys attempt to address the above use cases by allowing applications to deterministically derive unique cryptographic keys for their own purposes directly from the TPM seed in the owner hierarchy. The idea is that when an application requests a new key, instead of generating a random key and wrapping it with the TPM, the implementation generates a key via
KDF(hierarchy seed, application specific info). Therefore, the resulting keys will always be cryptographically bound to the application itself and the device they were generated on.So I think what confuses me is what the expected cryptographic secrecy properties of the derived keys are. I get they're a KDF of seed and deterministic properties, but if those mixing values are well known (as the path or binary checksum cases) then anyone with access to the TPM can derive the key from user space because they can easily obtain the mixing parameters and there's no protection to the TPM keyed hash operation.
Quoted 5 lines
Consider the use case where two users are using derived keys on the same system (so same TPM). Assuming they use them to protect sensitive information, what prevents user1 from simply deriving user2's key and getting the information, or am I missing the point of this?
Quoted 4 lines
You are correct: it is possible, but in practice it would be limited only to privileged users/applications. I remember there was a push to set a 666 mask for the TPM device file, but it is not how it is done today by default.
No, it's 660, but in consequence of that every user of the TPM is a member of the tpm group which, since TPM use from userspace is growing, is everyone, so it might as well have been 666. In other words relying on access restrictions to the TPM itself is largely useless.
Quoted 4 lines
Also I think the same applies to trusted keys as well, at least
without any additional authorizations or PCR restrictions on the blob (I remember I could manually unwrap a trusted key blob in userspace as root).
Well, that's correct, but a TPM key file without policy still has two
protections: the file itself (so the key owner can choose what permissions and where it is) and the key authority (or password) although for the mechanical (unsupervised insertion) use case keys tend not to have an authority.
Quoted 5 lines
It would be fixed if we could limit access to some TPM ops only from the kernel, but I remember from one of your presentations that it is generally a hard problem and that some solution was in the works (was it based on limiting access to a resettable PCR?). I'm happy to consider adopting it here as well somehow.
Well, that was based on constructing a policy that meant only the kernel could access the data (so it requires PCR policy).
In addition to the expected secrecy property question which I don't think is fully answered I did think of another issue: what if the application needs to rotate keys because of a suspected compromise? For sealed keys, we just generate a new one an use that in place of the old, but for your derived keys we'd have to change one of the mixing values, which all look to be based on fairly permanent properties of the system.
James
Quoted 61 lines · James Bottomley
Quoted 29 lines · Ignat Korchagin
Quoted 21 lines · James Bottomley
On Mon, 2024-05-13 at 18:09 +0100, Ignat Korchagin wrote:
[...]Quoted 9 lines
TPM derived keys attempt to address the above use cases by allowing applications to deterministically derive unique cryptographic keys for their own purposes directly from the TPM seed in the owner hierarchy. The idea is that when an application requests a new key, instead of generating a random key and wrapping it with the TPM, the implementation generates a key via
KDF(hierarchy seed, application specific info). Therefore, the resulting keys will always be cryptographically bound to the application itself and the device they were generated on.So I think what confuses me is what the expected cryptographic secrecy properties of the derived keys are. I get they're a KDF of seed and deterministic properties, but if those mixing values are well known (as the path or binary checksum cases) then anyone with access to the TPM can derive the key from user space because they can easily obtain the mixing parameters and there's no protection to the TPM keyed hash operation.
Quoted 5 lines
Consider the use case where two users are using derived keys on the same system (so same TPM). Assuming they use them to protect sensitive information, what prevents user1 from simply deriving user2's key and getting the information, or am I missing the point of this?
Quoted 4 lines
You are correct: it is possible, but in practice it would be limited only to privileged users/applications. I remember there was a push to set a 666 mask for the TPM device file, but it is not how it is done today by default.
No, it's 660, but in consequence of that every user of the TPM is a member of the tpm group which, since TPM use from userspace is growing, is everyone, so it might as well have been 666. In other words relying on access restrictions to the TPM itself is largely useless.
Quoted 4 lines
Also I think the same applies to trusted keys as well, at least
without any additional authorizations or PCR restrictions on the blob (I remember I could manually unwrap a trusted key blob in userspace as root).Well, that's correct, but a TPM key file without policy still has two
protections: the file itself (so the key owner can choose what permissions and where it is) and the key authority (or password) although for the mechanical (unsupervised insertion) use case keys tend not to have an authority.Quoted 5 lines
It would be fixed if we could limit access to some TPM ops only from the kernel, but I remember from one of your presentations that it is generally a hard problem and that some solution was in the works (was it based on limiting access to a resettable PCR?). I'm happy to consider adopting it here as well somehow.
Well, that was based on constructing a policy that meant only the kernel could access the data (so it requires PCR policy).
Quoted 7 lines
In addition to the expected secrecy property question which I don't think is fully answered I did think of another issue: what if the application needs to rotate keys because of a suspected compromise? For sealed keys, we just generate a new one an use that in place of the old, but for your derived keys we'd have to change one of the mixing values, which all look to be based on fairly permanent properties of the system.
For our current (non-TPM based) derived key hierarchy we do allow applications to specify a "freeform" mixing value, which in practice may contain a key version, like "v1"/"v2" etc. This also allows applications to derive multiple different keys for different purposes. Perhaps, we can do the same here, for example keyctl add derived test "<key len> (path|csum) <the rest is used as is as another mixin>". We can also "just ship" a new version of the code (for the csum case), which would rotate the key. Another option could be using some optional xattr as a mixin, which can specify the version of the key or just be a freeform input.
Quoted 2 lines
James
Quoted 9 lines · Ignat Korchagin
TPM derived keys get their payload from an HMAC primary key in the owner hierarchy mixed with some metadata from the requesting process.
They are similar to trusted keys in the sense that the key security is rooted in the TPM, but may provide easier key management for some use-cases.
One inconvenience with trusted keys is that the cryptographic material should be provided externally. This means either wrapping the key to the TPM on the
I would like to point out to myself I was wrong: it is possible to ask the kernel to generate a trusted key inside the kernel locally with "keyctl add trusted kmk "new 32" @u"
Quoted 67 lines
executing system (which briefly exposes plaintext cryptographic material to userspace) or creating the wrapped blob externally, but then we need to gather and transfer the TPM public key to the remote system, which may be a logistical problem sometimes.
Moreover, we need to store the wrapped key blob somewhere, and if we lose it, the application cannot recover its data anymore.
TPM derived keys may make key management for applications easier, especially on stateless systems as the application can always recreate its keys and the encrypted data is bound to the device and its TPM. They allow the application to wrap/unwrap some data to the device without worrying too much about key management and provisioning. They are similar in a sense to device unique keys present on many mobile devices and some IoT systems, but even better as every application has its own unique device key.
It is also easy to quickly "wipe" all the application keys by just resetting the TPM owner hierarchy.
It is worth mentioning that this functionality can be implemented in userspace as a
/sbin/request-keyplugin. However, the advantage of the in-kernel implementation is that the derived key material never leaves the kernel space (unless explicitly read into userspace with proper permissions).Current implementation supports two modes (as demonstrated by the keyctl userspace tool):
1. keyctl add derived test '32 path' - will derive a 32 byte key based on the TPM seed and the filesystem path of the requesting application. That is/usr/bin/keyctland/opt/bin/keyctlwould generate different keys.2. keyctl add derived test '32 csum' - will derive a 32 byte key based on the TPM seed and the IMA measurement of the requesting application. That is
/usr/bin/keyctland/opt/bin/keyctlwould generate the same key IFF their code exactly matches bit for bit. The implementation does not measure the requesting binary itself, but rather relies on already available measurement. This means for this mode to work IMA needs to be enabled and configured for requesting applications. For example:
# echo 'audit func=BPRM_CHECK' > \
/sys/kernel/security/integrity/ima/policyOpen questions (apart from the obvious "is this useful?"):
* should any other modes/derivation parameters be considered?
* apparently in checksum mode, when calling keyring syscalls from scripts, we mix in the measurement of the interpreter, not the script itself. Is there any way to improve this?Ignat Korchagin (2):
tpm: add some algorithm and constant definitions from the TPM spec
KEYS: implement derived keysinclude/linux/tpm.h | 16 +- security/keys/Kconfig | 16 ++ security/keys/Makefile | 1 + security/keys/derived-keys/Makefile | 8 + security/keys/derived-keys/derived.c | 226 +++++++++++++++++++++ security/keys/derived-keys/derived.h | 4 + security/keys/derived-keys/tpm2_shash.c | 257 ++++++++++++++++++++++++ 7 files changed, 524 insertions(+), 4 deletions(-) create mode 100644 security/keys/derived-keys/Makefile create mode 100644 security/keys/derived-keys/derived.c create mode 100644 security/keys/derived-keys/derived.h create mode 100644 security/keys/derived-keys/tpm2_shash.c--
2.39.2
Jarkko Sakkinen
maintainerQuoted 4 lines · Ignat Korchagin
On Fri, May 3, 2024 at 11:16 PM Ignat Korchagin <[email protected]> wrote:
I would like to point out to myself I was wrong: it is possible to ask the kernel to generate a trusted key inside the kernel locally with "keyctl add trusted kmk "new 32" @u"
Not in a full-time kernel position ATM as I'm working as contract researcher up until beginning of Oct (took some industry break after a startup went down of business), so please, politely asking, write a bit more compact descriptions ;-) I'm trying to find a new position by the beginning of Oct but right now I'd appreciate a bit more thought out text descriptions.
I'm working out a small patch set with James Prestwood to add asymmetric TPM2 keys based on his old patch set [1] but laid out on top of the existing baseline.
I did already the key type shenanigans etc. for it and James P is laying his pre-existing RSA code and new ECDSA on top of that. So this will give x.509 compatibility [2]. This patch set will be out soon and likely part of 6.11 (or almost guaranteed as most of it is done).
So by plain guess this might be along the lines what you might want?
[1] https://lore.kernel.org/all/[email protected]/
[2] https://datatracker.ietf.org/doc/draft-woodhouse-cert-best-practice/
BR, Jarkko
Quoted 14 lines · Jarkko Sakkinen
Quoted 4 lines · Ignat Korchagin
On Fri, May 3, 2024 at 11:16 PM Ignat Korchagin <[email protected]> wrote:
I would like to point out to myself I was wrong: it is possible to ask the kernel to generate a trusted key inside the kernel locally with "keyctl add trusted kmk "new 32" @u"Not in a full-time kernel position ATM as I'm working as contract researcher up until beginning of Oct (took some industry break after a startup went down of business), so please, politely asking, write a bit more compact descriptions ;-) I'm trying to find a new position by the beginning of Oct but right now I'd appreciate a bit more thought out text descriptions.
Quoted 6 lines
I'm working out a small patch set with James Prestwood to add asymmetric TPM2 keys based on his old patch set [1] but laid out on top of the existing baseline.
I did already the key type shenanigans etc. for it and James P is laying his pre-existing RSA code and new ECDSA on top of that. So this will
This is great. Perhaps we can finally have ECDSA software signature support as well, which I have been trying to get in for some time now
[1]
Quoted 4 lines
give x.509 compatibility [2]. This patch set will be out soon and likely part of 6.11 (or almost guaranteed as most of it is done).
So by plain guess this might be along the lines what you might want?
I don't think so. I have seen this patchset, but unless the new version is fundamentally different, it looks to me that the asymmetric TPM keys are the same as trusted keys except they are asymmetric instead of being symmetric. That is, they are still of limited use on stateless systems and are subject to the same restrictions I described in my revised cover description.
On top of that I'm not sure they would be widely used as "leaf" keys by applications, maybe more as root/intermediate keys in some kind of key hierarchy. TPMs are slow and I don't see a high-performance web-server, for example, using asymmetric TPM keys for TLS operations. Also, as we learned the hard way operating many TPMs in production, some TPMs are quite unreliable and fail really fast, if you "spam" them with a lot of crypto ops. I understand this is a HW/TPM vendor problem, but in practice we're trying to build systems, where TPM is used to protect/generate other keys, but most of the "leaf" crypto operations are done in software, so we don't make the TPM do too much crypto.
Just to clarify - I'm not arguing about the usefulness of TPM asymmetric keys in the kernel. I would really want to see this building block available as well, but I think it just serves a different purpose/use case from what I'm trying to figure out in this RFC thread.
Quoted 4 lines
[1] https://lore.kernel.org/all/[email protected]/
[2] https://datatracker.ietf.org/doc/draft-woodhouse-cert-best-practice/BR, Jarkko
Jarkko Sakkinen
maintainerQuoted 19 lines · Ignat Korchagin
Quoted 18 lines · Jarkko Sakkinen
Quoted 4 lines · Ignat Korchagin
On Fri, May 3, 2024 at 11:16 PM Ignat Korchagin <[email protected]> wrote:
I would like to point out to myself I was wrong: it is possible to ask the kernel to generate a trusted key inside the kernel locally with "keyctl add trusted kmk "new 32" @u"Not in a full-time kernel position ATM as I'm working as contract researcher up until beginning of Oct (took some industry break after a startup went down of business), so please, politely asking, write a bit more compact descriptions ;-) I'm trying to find a new position by the beginning of Oct but right now I'd appreciate a bit more thought out text descriptions.
I'm working out a small patch set with James Prestwood to add asymmetric TPM2 keys based on his old patch set [1] but laid out on top of the existing baseline.
Quoted 6 lines
Quoted 2 lines
I did already the key type shenanigans etc. for it and James P is laying his pre-existing RSA code and new ECDSA on top of that. So this will
This is great. Perhaps we can finally have ECDSA software signature support as well, which I have been trying to get in for some time now
[1]
Yes exactly both.
Quoted 4 lines
Quoted 4 lines
give x.509 compatibility [2]. This patch set will be out soon and likely part of 6.11 (or almost guaranteed as most of it is done).
Quoted 8 lines
Quoted 1 line
So by plain guess this might be along the lines what you might want?
I don't think so. I have seen this patchset, but unless the new version is fundamentally different, it looks to me that the asymmetric TPM keys are the same as trusted keys except they are asymmetric instead of being symmetric. That is, they are still of limited use on stateless systems and are subject to the same restrictions I described in my revised cover description.
OK, hmm... can you an "apples and oranges" example what would be most trivial use case where these don't cut?
Quoted 11 lines
On top of that I'm not sure they would be widely used as "leaf" keys by applications, maybe more as root/intermediate keys in some kind of key hierarchy. TPMs are slow and I don't see a high-performance web-server, for example, using asymmetric TPM keys for TLS operations. Also, as we learned the hard way operating many TPMs in production, some TPMs are quite unreliable and fail really fast, if you "spam" them with a lot of crypto ops. I understand this is a HW/TPM vendor problem, but in practice we're trying to build systems, where TPM is used to protect/generate other keys, but most of the "leaf" crypto operations are done in software, so we don't make the TPM do too much crypto.
So what about SGX/SNP/TDX?
TPM is definitely not made for workloads :-)
Quoted 5 lines
Just to clarify - I'm not arguing about the usefulness of TPM asymmetric keys in the kernel. I would really want to see this building block available as well, but I think it just serves a different purpose/use case from what I'm trying to figure out in this RFC thread.
Got it :-) NP
BR, Jarkko
Quoted 43 lines · Jarkko Sakkinen
Quoted 19 lines · Ignat Korchagin
Quoted 18 lines · Jarkko Sakkinen
Quoted 4 lines · Ignat Korchagin
On Fri, May 3, 2024 at 11:16 PM Ignat Korchagin <[email protected]> wrote:
I would like to point out to myself I was wrong: it is possible to ask the kernel to generate a trusted key inside the kernel locally with "keyctl add trusted kmk "new 32" @u"Not in a full-time kernel position ATM as I'm working as contract researcher up until beginning of Oct (took some industry break after a startup went down of business), so please, politely asking, write a bit more compact descriptions ;-) I'm trying to find a new position by the beginning of Oct but right now I'd appreciate a bit more thought out text descriptions.
I'm working out a small patch set with James Prestwood to add asymmetric TPM2 keys based on his old patch set [1] but laid out on top of the existing baseline.
Quoted 6 lines
Quoted 2 lines
I did already the key type shenanigans etc. for it and James P is laying his pre-existing RSA code and new ECDSA on top of that. So this will
This is great. Perhaps we can finally have ECDSA software signature support as well, which I have been trying to get in for some time now
[1]Yes exactly both.
Quoted 4 lines
Quoted 4 lines
give x.509 compatibility [2]. This patch set will be out soon and likely part of 6.11 (or almost guaranteed as most of it is done).
Quoted 8 lines
Quoted 1 line
So by plain guess this might be along the lines what you might want?
I don't think so. I have seen this patchset, but unless the new version is fundamentally different, it looks to me that the asymmetric TPM keys are the same as trusted keys except they are asymmetric instead of being symmetric. That is, they are still of limited use on stateless systems and are subject to the same restrictions I described in my revised cover description.
Quoted 2 lines
OK, hmm... can you an "apples and oranges" example what would be most trivial use case where these don't cut?
For example, a cheap NAS box with no internal storage (disks connected externally via USB). We want:
* disks to be encrypted and decryptable only by this NAS box
* if someone steals one of the disks - we don't want them to see it
has encrypted data (no LUKS header)
Additionally we may want to SSH into the NAS for configuration and we don't want the SSH server key to change after each boot (regardless if disks are connected or not).
Quoted 13 lines
Quoted 12 lines
On top of that I'm not sure they would be widely used as "leaf" keys by applications, maybe more as root/intermediate keys in some kind of key hierarchy. TPMs are slow and I don't see a high-performance web-server, for example, using asymmetric TPM keys for TLS operations. Also, as we learned the hard way operating many TPMs in production, some TPMs are quite unreliable and fail really fast, if you "spam" them with a lot of crypto ops. I understand this is a HW/TPM vendor problem, but in practice we're trying to build systems, where TPM is used to protect/generate other keys, but most of the "leaf" crypto operations are done in software, so we don't make the TPM do too much crypto.
Quoted 1 line
So what about SGX/SNP/TDX?
In theory yes, but I have chased the tech for a while on commodity HW and it keeps having problems.
Quoted 11 lines
TPM is definitely not made for workloads :-)
Quoted 5 lines
Just to clarify - I'm not arguing about the usefulness of TPM asymmetric keys in the kernel. I would really want to see this building block available as well, but I think it just serves a different purpose/use case from what I'm trying to figure out in this RFC thread.
Got it :-) NP
BR, Jarkko
Jarkko Sakkinen
maintainerQuoted 3 lines · Ignat Korchagin
For example, a cheap NAS box with no internal storage (disks connected externally via USB). We want:
* disks to be encrypted and decryptable only by this NAS box
So how this differs from LUKS2 style, which also systemd supports where the encryption key is anchored to PCR's? If I took hard drive out of my Linux box, I could not decrypt it in another machine because of this.
Quoted 2 lines
* if someone steals one of the disks - we don't want them to see it
has encrypted data (no LUKS header)
So what happens when you reconnect?
Quoted 3 lines
Additionally we may want to SSH into the NAS for configuration and we don't want the SSH server key to change after each boot (regardless if disks are connected or not).
Right, interesting use case. Begin before any technical jargon exactly with a great example like this. Then it is easier to start to anchoring stuff and not be misleaded.
BR, Jarkko
Jarkko Sakkinen
maintainerQuoted 8 lines · Jarkko Sakkinen
Quoted 3 lines · Ignat Korchagin
For example, a cheap NAS box with no internal storage (disks connected externally via USB). We want:
* disks to be encrypted and decryptable only by this NAS boxSo how this differs from LUKS2 style, which also systemd supports where the encryption key is anchored to PCR's? If I took hard drive out of my Linux box, I could not decrypt it in another machine because of this.
Maybe you could replace the real LUKS2 header with a dummy LUKS2 header, which would need to be able the describe "do not use this" and e.g. SHA256 of the actual header. And then treat the looked up header as the header when the drive is mounted.
LUKS2 would also need to be able to have pre-defined (e.g. kernel command-line or bootconfig) small internal storage, which would be also encrypted with TPM's PRCs containing an array of LUKS2 header and then look up that with SHA256 as the key.
Without knowing LUKS2 implementation to me these do not sound reaching the impossible engineer problems so maybe this would be worth of investigating...
BR, Jarkko
Jarkko Sakkinen
maintainerQuoted 15 lines · Jarkko Sakkinen
Quoted 8 lines · Jarkko Sakkinen
Quoted 3 lines · Ignat Korchagin
For example, a cheap NAS box with no internal storage (disks connected externally via USB). We want:
* disks to be encrypted and decryptable only by this NAS boxSo how this differs from LUKS2 style, which also systemd supports where the encryption key is anchored to PCR's? If I took hard drive out of my Linux box, I could not decrypt it in another machine because of this.
Maybe you could replace the real LUKS2 header with a dummy LUKS2 header, which would need to be able the describe "do not use this" and e.g. SHA256 of the actual header. And then treat the looked up header as the header when the drive is mounted.
Quoted 8 lines
LUKS2 would also need to be able to have pre-defined (e.g. kernel command-line or bootconfig) small internal storage, which would be also encrypted with TPM's PRCs containing an array of LUKS2 header and then look up that with SHA256 as the key.
Without knowing LUKS2 implementation to me these do not sound reaching the impossible engineer problems so maybe this would be worth of investigating...
Or why you could not just encrypt the whole header with another key that is only in that device? Then it would appear as random full length.
I.e. unsealing
1. Decrypt LUKS2 header with TPM2 key
2. Use the new resulting header as it was in the place of encrypted stored to the external drive.
3. Decrypt key from the LUK2S header etc.
?
BR, Jarkko
Jarkko Sakkinen
maintainerQuoted 29 lines · Jarkko Sakkinen
Quoted 15 lines · Jarkko Sakkinen
Quoted 8 lines · Jarkko Sakkinen
Quoted 3 lines · Ignat Korchagin
For example, a cheap NAS box with no internal storage (disks connected externally via USB). We want:
* disks to be encrypted and decryptable only by this NAS boxSo how this differs from LUKS2 style, which also systemd supports where the encryption key is anchored to PCR's? If I took hard drive out of my Linux box, I could not decrypt it in another machine because of this.
Maybe you could replace the real LUKS2 header with a dummy LUKS2 header, which would need to be able the describe "do not use this" and e.g. SHA256 of the actual header. And then treat the looked up header as the header when the drive is mounted.
Quoted 8 lines
LUKS2 would also need to be able to have pre-defined (e.g. kernel command-line or bootconfig) small internal storage, which would be also encrypted with TPM's PRCs containing an array of LUKS2 header and then look up that with SHA256 as the key.
Without knowing LUKS2 implementation to me these do not sound reaching the impossible engineer problems so maybe this would be worth of investigating...
Or why you could not just encrypt the whole header with another key that is only in that device? Then it would appear as random full length.
Quoted 6 lines
I.e. unsealing
1. Decrypt LUKS2 header with TPM2 key
2. Use the new resulting header as it was in the place of encrypted stored to the external drive.
3. Decrypt key from the LUK2S header etc.
Maybe something like:
1. Asymmetric for LUKS2 (just like it is)
2. Additional symmetric key, which is created as non-migratable and stored to the TPM2 chip. This deciphers the header, i.e. takes the random away.
BR, Jarkko
Quoted 38 lines · Jarkko Sakkinen
Quoted 29 lines · Jarkko Sakkinen
Quoted 15 lines · Jarkko Sakkinen
Quoted 8 lines · Jarkko Sakkinen
Quoted 3 lines · Ignat Korchagin
For example, a cheap NAS box with no internal storage (disks connected externally via USB). We want:
* disks to be encrypted and decryptable only by this NAS boxSo how this differs from LUKS2 style, which also systemd supports where the encryption key is anchored to PCR's? If I took hard drive out of my Linux box, I could not decrypt it in another machine because of this.
Maybe you could replace the real LUKS2 header with a dummy LUKS2 header, which would need to be able the describe "do not use this" and e.g. SHA256 of the actual header. And then treat the looked up header as the header when the drive is mounted.
Quoted 8 lines
LUKS2 would also need to be able to have pre-defined (e.g. kernel command-line or bootconfig) small internal storage, which would be also encrypted with TPM's PRCs containing an array of LUKS2 header and then look up that with SHA256 as the key.
Without knowing LUKS2 implementation to me these do not sound reaching the impossible engineer problems so maybe this would be worth of investigating...
Or why you could not just encrypt the whole header with another key that is only in that device? Then it would appear as random full length.
Quoted 6 lines
I.e. unsealing
1. Decrypt LUKS2 header with TPM2 key
2. Use the new resulting header as it was in the place of encrypted stored to the external drive.
3. Decrypt key from the LUK2S header etc.
Quoted 6 lines
Maybe something like:
1. Asymmetric for LUKS2 (just like it is)
2. Additional symmetric key, which is created as non-migratable and stored to the TPM2 chip. This deciphers the header, i.e. takes the random away.
This could work, but you still have the problem of - if the header gets wiped, all the data is lost.
As for storing things on the TPM chip - that doesn't scale. Today you only think about disk encryption, tomorrow there is a new application, which wants to do the same thing and so on. One of the features of derived keys - you don't store anything, just recreate/derive when needed and it scales infinitely.
Quoted 1 line
BR, Jarkko
Jarkko Sakkinen
maintainerQuoted 46 lines · Ignat Korchagin
Quoted 38 lines · Jarkko Sakkinen
Quoted 29 lines · Jarkko Sakkinen
Quoted 15 lines · Jarkko Sakkinen
Quoted 8 lines · Jarkko Sakkinen
Quoted 3 lines · Ignat Korchagin
For example, a cheap NAS box with no internal storage (disks connected externally via USB). We want:
* disks to be encrypted and decryptable only by this NAS boxSo how this differs from LUKS2 style, which also systemd supports where the encryption key is anchored to PCR's? If I took hard drive out of my Linux box, I could not decrypt it in another machine because of this.
Maybe you could replace the real LUKS2 header with a dummy LUKS2 header, which would need to be able the describe "do not use this" and e.g. SHA256 of the actual header. And then treat the looked up header as the header when the drive is mounted.
Quoted 8 lines
LUKS2 would also need to be able to have pre-defined (e.g. kernel command-line or bootconfig) small internal storage, which would be also encrypted with TPM's PRCs containing an array of LUKS2 header and then look up that with SHA256 as the key.
Without knowing LUKS2 implementation to me these do not sound reaching the impossible engineer problems so maybe this would be worth of investigating...
Or why you could not just encrypt the whole header with another key that is only in that device? Then it would appear as random full length.
Quoted 6 lines
I.e. unsealing
1. Decrypt LUKS2 header with TPM2 key
2. Use the new resulting header as it was in the place of encrypted stored to the external drive.
3. Decrypt key from the LUK2S header etc.Quoted 6 lines
Maybe something like:
1. Asymmetric for LUKS2 (just like it is)
2. Additional symmetric key, which is created as non-migratable and stored to the TPM2 chip. This deciphers the header, i.e. takes the random away.
Quoted 7 lines
This could work, but you still have the problem of - if the header gets wiped, all the data is lost.
As for storing things on the TPM chip - that doesn't scale. Today you only think about disk encryption, tomorrow there is a new application, which wants to do the same thing and so on. One of the features of derived keys - you don't store anything, just recreate/derive when needed and it scales infinitely.
OK, so now I know the problem at least and that is probably the most important thing in this discussion, right?
So make a better story, now you also probably have better idea, also split the patch properly by subsystem, send the patch set, and I'll promise to revisit.
Fair enough? :-)
BR, Jarkko
Quoted 56 lines · Jarkko Sakkinen
Quoted 46 lines · Ignat Korchagin
Quoted 38 lines · Jarkko Sakkinen
Quoted 29 lines · Jarkko Sakkinen
Quoted 15 lines · Jarkko Sakkinen
Quoted 8 lines · Jarkko Sakkinen
Quoted 3 lines · Ignat Korchagin
For example, a cheap NAS box with no internal storage (disks connected externally via USB). We want:
* disks to be encrypted and decryptable only by this NAS boxSo how this differs from LUKS2 style, which also systemd supports where the encryption key is anchored to PCR's? If I took hard drive out of my Linux box, I could not decrypt it in another machine because of this.
Maybe you could replace the real LUKS2 header with a dummy LUKS2 header, which would need to be able the describe "do not use this" and e.g. SHA256 of the actual header. And then treat the looked up header as the header when the drive is mounted.
Quoted 8 lines
LUKS2 would also need to be able to have pre-defined (e.g. kernel command-line or bootconfig) small internal storage, which would be also encrypted with TPM's PRCs containing an array of LUKS2 header and then look up that with SHA256 as the key.
Without knowing LUKS2 implementation to me these do not sound reaching the impossible engineer problems so maybe this would be worth of investigating...
Or why you could not just encrypt the whole header with another key that is only in that device? Then it would appear as random full length.
Quoted 6 lines
I.e. unsealing
1. Decrypt LUKS2 header with TPM2 key
2. Use the new resulting header as it was in the place of encrypted stored to the external drive.
3. Decrypt key from the LUK2S header etc.Quoted 6 lines
Maybe something like:
1. Asymmetric for LUKS2 (just like it is)
2. Additional symmetric key, which is created as non-migratable and stored to the TPM2 chip. This deciphers the header, i.e. takes the random away.Quoted 7 lines
This could work, but you still have the problem of - if the header gets wiped, all the data is lost.
As for storing things on the TPM chip - that doesn't scale. Today you only think about disk encryption, tomorrow there is a new application, which wants to do the same thing and so on. One of the features of derived keys - you don't store anything, just recreate/derive when needed and it scales infinitely.
Quoted 2 lines
OK, so now I know the problem at least and that is probably the most important thing in this discussion, right?
Yes, I think so.
Quoted 2 lines
So make a better story, now you also probably have better idea, also split the patch properly by subsystem, send the patch set,
I'm actually not super clear on this part - I have two patches: one for TPM header definitions and another one for the keyring subsystem? Any other subsystems in play here?
Quoted 1 line
and I'll promise to revisit.
Thanks. Would probably take some time as I want to think more on the open questions I raised in the description, try to address some comments from James B from other replies (key rotation for example) and rebase on recently merged TPM encrypted sessions. But since this is an RFC I would like to continue the discussion and gather opinions from folks here, if there are any more concerns.
Quoted 3 lines
Fair enough? :-)
BR, Jarkko
Jarkko Sakkinen
maintainerQuoted 60 lines · Ignat Korchagin
Quoted 56 lines · Jarkko Sakkinen
Quoted 46 lines · Ignat Korchagin
Quoted 38 lines · Jarkko Sakkinen
Quoted 29 lines · Jarkko Sakkinen
Quoted 15 lines · Jarkko Sakkinen
Quoted 8 lines · Jarkko Sakkinen
Quoted 3 lines · Ignat Korchagin
For example, a cheap NAS box with no internal storage (disks connected externally via USB). We want:
* disks to be encrypted and decryptable only by this NAS boxSo how this differs from LUKS2 style, which also systemd supports where the encryption key is anchored to PCR's? If I took hard drive out of my Linux box, I could not decrypt it in another machine because of this.
Maybe you could replace the real LUKS2 header with a dummy LUKS2 header, which would need to be able the describe "do not use this" and e.g. SHA256 of the actual header. And then treat the looked up header as the header when the drive is mounted.
Quoted 8 lines
LUKS2 would also need to be able to have pre-defined (e.g. kernel command-line or bootconfig) small internal storage, which would be also encrypted with TPM's PRCs containing an array of LUKS2 header and then look up that with SHA256 as the key.
Without knowing LUKS2 implementation to me these do not sound reaching the impossible engineer problems so maybe this would be worth of investigating...
Or why you could not just encrypt the whole header with another key that is only in that device? Then it would appear as random full length.
Quoted 6 lines
I.e. unsealing
1. Decrypt LUKS2 header with TPM2 key
2. Use the new resulting header as it was in the place of encrypted stored to the external drive.
3. Decrypt key from the LUK2S header etc.Quoted 6 lines
Maybe something like:
1. Asymmetric for LUKS2 (just like it is)
2. Additional symmetric key, which is created as non-migratable and stored to the TPM2 chip. This deciphers the header, i.e. takes the random away.Quoted 7 lines
This could work, but you still have the problem of - if the header gets wiped, all the data is lost.
As for storing things on the TPM chip - that doesn't scale. Today you only think about disk encryption, tomorrow there is a new application, which wants to do the same thing and so on. One of the features of derived keys - you don't store anything, just recreate/derive when needed and it scales infinitely.Quoted 2 lines
OK, so now I know the problem at least and that is probably the most important thing in this discussion, right?
Quoted 8 lines
Yes, I think so.
Quoted 2 lines
So make a better story, now you also probably have better idea, also split the patch properly by subsystem, send the patch set,
I'm actually not super clear on this part - I have two patches: one for TPM header definitions and another one for the keyring subsystem? Any other subsystems in play here?
You're absolutely right the split is fine. I look patches every day so that must have stuck me somewhere else (sometimes does happen).
Sorry.
Quoted 8 lines
Quoted 1 line
and I'll promise to revisit.
Thanks. Would probably take some time as I want to think more on the open questions I raised in the description, try to address some comments from James B from other replies (key rotation for example) and rebase on recently merged TPM encrypted sessions. But since this is an RFC I would like to continue the discussion and gather opinions from folks here, if there are any more concerns.
Yeah, not trying to argue of anything. Just have shoot with stupid questions until it gets through, and not pretending of understanding if I actually do not :-)
So I'll be ready once the next version is out.
Quoted 4 lines
Quoted 4 lines
Fair enough? :-)
BR, Jarkko
BR, Jarkko
Quoted 9 lines · Jarkko Sakkinen
Quoted 3 lines · Ignat Korchagin
For example, a cheap NAS box with no internal storage (disks connected externally via USB). We want:
* disks to be encrypted and decryptable only by this NAS boxSo how this differs from LUKS2 style, which also systemd supports where the encryption key is anchored to PCR's? If I took hard drive out of my Linux box, I could not decrypt it in another machine because of this.
It differs with the fact that the disk has a clearly identifiable LUKS2 header, which tells an adversary that this is a disk with some data that is encrypted. With derived keys and plain dm-crypt mode there is no LUKS header, so it is not possible to tell if it is an encrypted disk or a disk with just random data. Additionally, if I accidentally wipe the sector with the LUKS2 header - all my data is lost (because the data encryption key from the header is lost). With derived keys I can always decrypt at least some data, if the disk is available.
Quoted 4 lines
Quoted 2 lines
* if someone steals one of the disks - we don't want them to see it
has encrypted data (no LUKS header)So what happens when you reconnect?
We recover/derive the encryption key and unlock the disk again.
Quoted 9 lines
Quoted 3 lines
Additionally we may want to SSH into the NAS for configuration and we don't want the SSH server key to change after each boot (regardless if disks are connected or not).
Right, interesting use case. Begin before any technical jargon exactly with a great example like this. Then it is easier to start to anchoring stuff and not be misleaded.
BR, Jarkko
Jarkko Sakkinen
maintainerQuoted 11 lines · Ignat Korchagin
Quoted 9 lines · Jarkko Sakkinen
Quoted 3 lines · Ignat Korchagin
For example, a cheap NAS box with no internal storage (disks connected externally via USB). We want:
* disks to be encrypted and decryptable only by this NAS boxSo how this differs from LUKS2 style, which also systemd supports where the encryption key is anchored to PCR's? If I took hard drive out of my Linux box, I could not decrypt it in another machine because of this.
Quoted 9 lines
It differs with the fact that the disk has a clearly identifiable LUKS2 header, which tells an adversary that this is a disk with some data that is encrypted. With derived keys and plain dm-crypt mode there is no LUKS header, so it is not possible to tell if it is an encrypted disk or a disk with just random data. Additionally, if I accidentally wipe the sector with the LUKS2 header - all my data is lost (because the data encryption key from the header is lost). With derived keys I can always decrypt at least some data, if the disk is available.
I figured most of this out myself and sent a follow-up but yeah thnaks for confirming my toughts. I get this part now.
Follow-ups to my follow-up...
BR, Jarkko
James Bottomley
maintainerQuoted 2 lines · Ignat Korchagin
* if someone steals one of the disks - we don't want them to see it has encrypted data (no LUKS header)
What is the use case that makes this important? In usual operation over the network, the fact that we're setting up encryption is easily identifiable to any packet sniffer (DHE key exchanges are fairly easy to fingerprint), but security relies on the fact that even knowing that we're setting up encryption, the attacker can't gain access to it. The fact that we are setting up encryption isn't seen as a useful thing to conceal, so why is it important for your encrypted disk use case?
James
Quoted 5 lines · James Bottomley
Quoted 2 lines · Ignat Korchagin
* if someone steals one of the disks - we don't want them to see it
has encrypted data (no LUKS header)
Quoted 7 lines
What is the use case that makes this important? In usual operation over the network, the fact that we're setting up encryption is easily identifiable to any packet sniffer (DHE key exchanges are fairly easy to fingerprint), but security relies on the fact that even knowing that we're setting up encryption, the attacker can't gain access to it. The fact that we are setting up encryption isn't seen as a useful thing to conceal, so why is it important for your encrypted disk use case?
In some "jurisdictions" authorities can demand that you decrypt the data for them for "reasons". On the other hand if they can't prove there is a ciphertext in the first place - it makes their case harder.
Quoted 2 lines
James
James Bottomley
maintainerQuoted 16 lines · Ignat Korchagin
Quoted 5 lines · James Bottomley
Quoted 2 lines · Ignat Korchagin
* if someone steals one of the disks - we don't want them to see it has encrypted data (no LUKS header)
Quoted 8 lines
What is the use case that makes this important? In usual operation over the network, the fact that we're setting up encryption is easily identifiable to any packet sniffer (DHE key exchanges are fairly easy to fingerprint), but security relies on the fact that even knowing that we're setting up encryption, the attacker can't gain access to it. The fact that we are setting up encryption isn't seen as a useful thing to conceal, so why is it important for your encrypted disk use case?
Quoted 4 lines
In some "jurisdictions" authorities can demand that you decrypt the data for them for "reasons". On the other hand if they can't prove there is a ciphertext in the first place - it makes their case harder.
Well, this isn't necessarily a good assumption: the way to detect an encrypted disk is to look at the entropy of the device blocks. If the disk is encrypted, the entropy will be pretty much maximal unlike every other use case. The other thing is that if the authorities have your TPM, they already have access to the disk in this derived key scenario. If *you* still have access to your TPM, you can update the storage seed to shred the data.
James
Quoted 23 lines · James Bottomley
Quoted 16 lines · Ignat Korchagin
Quoted 5 lines · James Bottomley
Quoted 2 lines · Ignat Korchagin
* if someone steals one of the disks - we don't want them to
see it has encrypted data (no LUKS header)Quoted 8 lines
What is the use case that makes this important? In usual operation over the network, the fact that we're setting up encryption is easily identifiable to any packet sniffer (DHE key exchanges are fairly easy to fingerprint), but security relies on the fact that even knowing that we're setting up encryption, the attacker can't gain access to it. The fact that we are setting up encryption isn't seen as a useful thing to conceal, so why is it important for your encrypted disk use case?
Quoted 4 lines
In some "jurisdictions" authorities can demand that you decrypt the data for them for "reasons". On the other hand if they can't prove there is a ciphertext in the first place - it makes their case harder.
Quoted 4 lines
Well, this isn't necessarily a good assumption: the way to detect an encrypted disk is to look at the entropy of the device blocks. If the disk is encrypted, the entropy will be pretty much maximal unlike every other use case. The other thing is that if the authorities have your
What if the disk is filled with random data? Would it not be at maximal entropy?
Quoted 1 line
TPM, they already have access to the disk in this derived key scenario.
I'm thinking more of a datacenter scenario here - it is much easier to "steal" a disk rather than a server from a datacenter. So it is possible that someone has the disk but no access to the TPM.
Quoted 2 lines
If *you* still have access to your TPM, you can update the storage seed to shred the data.
The point here is not if I was able to shred the data or not, but the fact I have something encrypted. Even if I shred the key I would be considered "uncooperative and refusing to provide the key" vs "I don't have anything encrypted in the first place".
Quoted 2 lines
James