Skip to contentSkip to conversation

Instantiate key with user-provided decrypted data.

PATCH In review Yael Tiomkin 2 participants 3 messages Dec 10, 2021 1 message not in the archive

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Instantiate key with user-provided decrypted data.

The encrypted.c class supports instantiation of encrypted keys with either an already-encrypted key material, or by generating new key material based on random numbers. To support encryption of user-provided decrypted data, this patch defines a new datablob
format: [<format>] <master-key name> <decrypted data length> <decrypted data>.

---
 .../security/keys/trusted-encrypted.rst       | 25 +++++++---
 security/keys/encrypted-keys/encrypted.c      | 48 +++++++++++++------
 2 files changed, 52 insertions(+), 21 deletions(-)
Documentation/security/keys/trusted-encrypted.rst +19 -6
index 80d5a5af62a1..2ea6fad394fe 100644
@@ -107,12 +107,13 @@ Encrypted Keys
 --------------
 
 Encrypted keys do not depend on a trust source, and are faster, as they use AES
-for encryption/decryption. New keys are created from kernel-generated random
-numbers, and are encrypted/decrypted using a specified ‘master’ key. The
-‘master’ key can either be a trusted-key or user-key type. The main disadvantage
-of encrypted keys is that if they are not rooted in a trusted key, they are only
-as secure as the user key encrypting them. The master user key should therefore
-be loaded in as secure a way as possible, preferably early in boot.
+for encryption/decryption. New keys are created either from kernel-generated
+random numbers or user-provided decrypted data, and are encrypted/decrypted
+using a specified ‘master’ key. The ‘master’ key can either be a trusted-key or
+user-key type. The main disadvantage of encrypted keys is that if they are not
+rooted in a trusted key, they are only as secure as the user key encrypting
+them. The master user key should therefore be loaded in as secure a way as
+possible, preferably early in boot.
 
 
 Usage
@@ -199,6 +200,8 @@ Usage::
 
     keyctl add encrypted name "new [format] key-type:master-key-name keylen"
         ring
+    keyctl add encrypted name "new [format] key-type:master-key-name keylen
+        decrypted-data" ring
     keyctl add encrypted name "load hex_blob" ring
     keyctl update keyid "update key-type:master-key-name"
 
@@ -303,6 +306,16 @@ Load an encrypted key "evm" from saved blob::
     82dbbc55be2a44616e4959430436dc4f2a7a9659aa60bb4652aeb2120f149ed197c564e0
     24717c64 5972dcb82ab2dde83376d82b2e3c09ffc
 
+Instantiate an encrypted key "evm" using user-provided decrypted data::
+
+    $ keyctl add encrypted evm "new default user:kmk 32 `cat evm.blob`" @u
+    794890253
+
+    $ keyctl print 794890253
+    default user:kmk 32 2375725ad57798846a9bbd240de8906f006e66c03af53b1b382d
+    bbc55be2a44616e4959430436dc4f2a7a9659aa60bb4652aeb2120f149ed197c564e0247
+    17c64 5972dcb82ab2dde83376d82b2e3c09ffc
+
 Other uses for trusted and encrypted keys, such as for disk and file encryption
 are anticipated.  In particular the new format 'ecryptfs' has been defined
 in order to use encrypted keys to mount an eCryptfs filesystem.  More details
security/keys/encrypted-keys/encrypted.c +33 -15

113 lines not on this page · raw message

Signature · 1 line
2.34.1.173.g76aa8bc2d0-goog
#1 lore raw
Quoted 6 lines · Yael Tiomkin

The encrypted.c class supports instantiation of encrypted keys with either an already-encrypted key material, or by generating new key material based on random numbers. To support encryption of user-provided decrypted data, this patch defines a new datablob
format: [<format>] <master-key name> <decrypted data length> <decrypted data>.

What is the use case for this feature?

Also, please send this to all the relevant mailing lists and people. Notably, you didn't send this to the keyrings mailing list. Try running ./scripts/get_maintainer.pl on the patch file.

Please also test patches before sending them. This one doesn't even compile.

- Eric

A message that is not in the archive (sent off-list or not yet received): CAKoutNvnhE+DZW3cS6KG-C2jEH4LE+9cSnCkUcL2adfcXWaKDw@mail.gmail.com

#3 lore raw
Quoted 20 lines · Yael Tiomkin
Quoted 18 lines · Eric Biggers
Quoted 6 lines · Yael Tiomkin

The encrypted.c class supports instantiation of encrypted keys with either an already-encrypted key material, or by generating new key material based on random numbers. To support encryption of user-provided decrypted data, this patch defines a new datablob
format: [<format>] <master-key name> <decrypted data length> <decrypted data>.

What is the use case for this feature?

Also, please send this to all the relevant mailing lists and people. Notably,
you didn't send this to the keyrings mailing list. Try running ./scripts/get_maintainer.pl on the patch file.

Please also test patches before sending them. This one doesn't even compile.

Quoted 8 lines
Quoted 2 lines

- Eric

Hi,

Apologies for having missed additional relevant mailing lists. I sent a previous email asking to disregard this patch and have since sent out a fixed version which does compile.

I don't see your "email asking to disregard this patch". Did you send it in plain text? The Linux kernel mailing lists don't accept non-plain-text email.

Also, the second version isn't marked as "[PATCH v2]" like would be expected. So it looks like a duplicate rather than a new version.

Can you make sure you've read Documentation/process/submitting-patches.rst?

- Eric