use confidential computing provisioned secrets for disk decryption
cover use confidential computing provisioned secrets for disk decryption
This patchset aims to supplement James's previous work, please refer to the following link for details:
https://lists.gnu.org/archive/html/grub-devel/2020-12/msg00257.html
The alterations listed below were made in light of earlier research:
1. As Glenn advised, remove the first commit ([PATCH v3 1/3] cryptodisk:
make the password getter and additional argument to recover_key) while maintaining the original recover key function declaration.
2. To decrypt the disk, use the password that was retrieved from the EFI secret area and store it in the key_data field of the grub_cryptomount_args_t. Then, pass the password to the grub_cryptodisk_scan_device function.
3. Modify the put method's function definition in struct grub_secret_entry, and use grub_errno to log method errors.
We uploaded this series with the intention of receiving feedback, as the title suggests. Any suggestions and feedback regarding this patchset are welcom.
Thanks,
Yong
Hyman Huang (2):
cryptodisk: add OS provided secret support
efi: Add API for retrieving the EFI secret for cryptodisk
grub-core/Makefile.core.def | 8 +++ grub-core/disk/cryptodisk.c | 49 ++++++++++++- grub-core/disk/efi/efisecret.c | 123 +++++++++++++++++++++++++++++++++ include/grub/cryptodisk.h | 14 ++++ include/grub/efi/api.h | 15 ++++ 5 files changed, 206 insertions(+), 3 deletions(-) create mode 100644 grub-core/disk/efi/efisecret.c
Signature · 7 lines
2.39.3 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
RFC PATCH 2/2 efi: Add API for retrieving the EFI secret for cryptodisk
This module is designed to provide an efisecret command which interrogates the EFI configuration table to find the location of the confidential computing secret and tries to register the secret with the cryptodisk.
The secret is stored in a boot allocated area, usually a page in size. The layout of the secret injection area is a header
|GRUB_EFI_SECRET_TABLE_HEADER_GUID|len|
with entries of the form
|guid|len|data|
the guid corresponding to the disk encryption passphrase is GRUB_EFI_DISKPASSWD_GUID and data must be a zero terminated string. To get a high entropy string that doesn't need large numbers of iterations, use a base64 encoding of 33 bytes of random data.
--- grub-core/Makefile.core.def | 8 +++ grub-core/disk/efi/efisecret.c | 123 +++++++++++++++++++++++++++++++++ include/grub/efi/api.h | 15 ++++ 3 files changed, 146 insertions(+) create mode 100644 grub-core/disk/efi/efisecret.c
grub-core/Makefile.core.def +8 -0
@@ -810,6 +810,14 @@ module = { enable = efi; }; +module = { + name = efisecret; + + common = disk/efi/efisecret.c; + + enable = efi; +}; + module = { name = lsefimmap;
grub-core/disk/efi/efisecret.c new file +123 -0
123 lines not on this page · raw message
include/grub/efi/api.h +15 -0
@@ -314,6 +314,21 @@ { 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ } +#define GRUB_EFI_SECRET_TABLE_GUID \ + { 0xadf956ad, 0xe98c, 0x484c, \ + { 0xae, 0x11, 0xb5, 0x1c, 0x7d, 0x33, 0x64, 0x47} \ + } + +#define GRUB_EFI_SECRET_TABLE_HEADER_GUID \ + { 0x1e74f542, 0x71dd, 0x4d66, \ + { 0x96, 0x3e, 0xef, 0x42, 0x87, 0xff, 0x17, 0x3b } \ + } + +#define GRUB_EFI_DISKPASSWD_GUID \ + { 0x736869e5, 0x84f0, 0x4973, \ + { 0x92, 0xec, 0x06, 0x87, 0x9c, 0xe3, 0xda, 0x0b } \ + } +#define GRUB_EFI_ACPI_TABLE_GUID \ { 0xeb9d2d30, 0x2d88, 0x11d3, \ { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
Signature · 7 lines
2.39.3 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
RFC PATCH 1/2 cryptodisk: add OS provided secret support
In reply to Hyman HuangMake use of the new OS provided secrets API so that if the new '-s' option is passed in we try to extract the secret from the API rather than prompting for it.
The primary consumer of this is AMD SEV, which has been programmed to provide an injectable secret to the encrypted virtual machine. OVMF provides the secret area and passes it into the EFI Configuration Tables. The grub EFI layer pulls the secret out and primes the secrets API with it. The upshot of all of this is that a SEV protected VM can do an encrypted boot with a protected boot secret.
--- grub-core/disk/cryptodisk.c | 49 ++++++++++++++++++++++++++++++++++--- include/grub/cryptodisk.h | 14 +++++++++++ 2 files changed, 60 insertions(+), 3 deletions(-)
grub-core/disk/cryptodisk.c +46 -3
@@ -44,7 +44,8 @@ enumOPTION_KEYFILE ,OPTION_KEYFILE_OFFSET ,OPTION_KEYFILE_SIZE , -OPTION_HEADER +OPTION_HEADER , +OPTION_SECRET }; static const struct grub_arg_option options[] =
@@ -58,6 +59,7 @@ static const struct grub_arg_option options[] = {"keyfile-offset", 'O', 0, N_("Key file offset (bytes)"), 0, ARG_TYPE_INT}, {"keyfile-size", 'S', 0, N_("Key file data size (bytes)"), 0, ARG_TYPE_INT}, {"header", 'H', 0, N_("Read header from file"), 0, ARG_TYPE_STRING}, + {"secret", 's', 0, N_("Get secret passphrase from named module and optional identifier"), 0, 0}, {0, 0, 0, 0, 0, 0} };
@@ -78,6 +80,8 @@ static inline int GF_PER_SECTOR (const struct grub_cryptodisk *dev)static grub_cryptodisk_t cryptodisk_list =NULL ;static grub_uint8_t last_cryptodisk_id =0 ; +static struct grub_secret_entry *secret_providers; +static void gf_mul_x (grub_uint8_t *g) {
@@ -1259,13 +1263,25 @@ grub_cryptodisk_scan_device (const char *name,return ret; } +void +grub_cryptodisk_add_secret_provider (struct grub_secret_entry *e) +{ +grub_list_push (GRUB_AS_LIST_P (&secret_providers),GRUB_AS_LIST (e)); +} + +void +grub_cryptodisk_remove_secret_provider (struct grub_secret_entry *e) +{ +grub_list_remove (GRUB_AS_LIST (e)); +} +static grub_err_t grub_cmd_cryptomount (grub_extcmd_context_t ctxt,int argc,char **args) {struct grub_arg_list *state = ctxt->state;struct grub_cryptomount_args cargs = {0 }; -if (argc <1 && !state[OPTION_ALL ].set && !state[OPTION_BOOT ].set) +if (argc <1 && !state[OPTION_ALL ].set && !state[OPTION_BOOT ].set && !state[OPTION_SECRET ].set)return grub_error (GRUB_ERR_BAD_ARGUMENT ,"device name required" );if (grub_cryptodisk_list ==NULL )
@@ -1400,6 +1416,33 @@ grub_cmd_cryptomount (grub_extcmd_context_t ctxt, int argc, char **args)grub_device_iterate (&grub_cryptodisk_scan_device, &cargs);return GRUB_ERR_NONE ; } +else if (state[OPTION_SECRET ].set)/* OS provided secret */ + { +char *os_passwd; +struct grub_secret_entry *se; +grub_err_t rc; + +if (argc <1 ) +return grub_error (GRUB_ERR_BAD_ARGUMENT ,"secret module must be specified" ); +#ifndef GRUB_UTIL +grub_dl_load (args[0 ]); +#endif + se =grub_named_list_find (GRUB_AS_NAMED_LIST (secret_providers), args[0 ]); +if (se ==NULL ) +return grub_error (GRUB_ERR_INVALID_COMMAND ,"No secret provider is found" ); + + rc = se->get (args[1 ], &os_passwd); +if (rc) +return grub_errno; + + cargs.search_uuid =NULL ; + cargs.key_data = (grub_uint8_t *) os_passwd; + cargs.key_len =grub_strlen (os_passwd); + +grub_device_iterate (&grub_cryptodisk_scan_device, &cargs); + se->put (args[1 ], &os_passwd); +return grub_errno; + }else {grub_disk_t disk;
@@ -1590,7 +1633,7 @@ GRUB_MOD_INIT (cryptodisk) cmd =grub_register_extcmd ("cryptomount" , grub_cmd_cryptomount,0 ,N_ ("[ [-p password] | [-k keyfile" " [-O keyoffset] [-S keysize] ] ] [-H file]" -" <SOURCE|-u UUID|-a|-b>" ), +" <SOURCE|-u UUID|-a|-b|-s MOD [ID]>" ),N_ ("Mount a crypto device." ), options);grub_procfs_register ("luks_script" , &luks_script); }
include/grub/cryptodisk.h +14 -0
@@ -187,4 +187,18 @@ grub_util_get_geli_uuid (const char *dev);grub_cryptodisk_t grub_cryptodisk_get_by_uuid (const char *uuid);grub_cryptodisk_t grub_cryptodisk_get_by_source_disk (grub_disk_t disk); +struct grub_secret_entry { +/* as named list */ +struct grub_secret_entry *next; +struct grub_secret_entry **prev; +const char *name; + +/* additional entries */ +grub_err_t (*get)(const char *arg,char **secret); +void (*put)(const char *arg,char **secret); +}; + +void grub_cryptodisk_add_secret_provider (struct grub_secret_entry *e); +void grub_cryptodisk_remove_secret_provider (struct grub_secret_entry *e); +#endif
Signature · 7 lines
2.39.3 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
On Tue, Mar 12, 2024 at 11:03:17AM +0800, Hyman Huang wrote:
Hi Hyman,
Quoted 14 lines
This patchset aims to supplement James's previous work, please refer to the following link for details:
https://lists.gnu.org/archive/html/grub-devel/2020-12/msg00257.htmlThe alterations listed below were made in light of earlier research:
1. As Glenn advised, remove the first commit ([PATCH v3 1/3] cryptodisk:
make the password getter and additional argument torecover_key) while maintaining the original recover key function declaration.2. To decrypt the disk, use the password that was retrieved from the EFI secret area and store it in the
key_datafield of thegrub_cryptomount_args_t. Then, pass the password to thegrub_cryptodisk_scan_devicefunction.
Quoted 7 lines
3. Modify the put method's function definition in struct
grub_secret_entry, and usegrub_errnoto log method errors.We uploaded this series with the intention of receiving feedback, as the title suggests. Any suggestions and feedback regarding this patchset are welcom.
I'm working on disk unlocking with TPM2 and it's a bit similar to your work. Here is my v9 patchset:
https://lists.gnu.org/archive/html/grub-devel/2024-02/msg00007.html
The original patch author, Herman, introduced the key protectors framework, and it may be useful in your case:
- key protectors framework
https://lists.gnu.org/archive/html/grub-devel/2024-02/msg00014.html
- cryptodisk change
https://lists.gnu.org/archive/html/grub-devel/2024-02/msg00016.html
- TPM2 key protector
https://lists.gnu.org/archive/html/grub-devel/2024-02/msg00017.html
In short, it unlocks the disk with the commands like this:
tpm2_key_protector_init --tpm2key=(hd0,gpt1)/efi/grub2/sealed-1.tpm cryptomount -u <PART1_UUID> -P tpm2
Maybe we can work together to support various disk unlocking mechanisms.
Cheers,
Gary Lin
Quoted 8 lines
Thanks,
Yong
Hyman Huang (2):
cryptodisk: add OS provided secret support
efi: Add API for retrieving the EFI secret for cryptodisk
Quoted 16 lines
grub-core/Makefile.core.def | 8 +++ grub-core/disk/cryptodisk.c | 49 ++++++++++++- grub-core/disk/efi/efisecret.c | 123 +++++++++++++++++++++++++++++++++ include/grub/cryptodisk.h | 14 ++++ include/grub/efi/api.h | 15 ++++ 5 files changed, 206 insertions(+), 3 deletions(-) create mode 100644 grub-core/disk/efi/efisecret.cSignature · 7 lines
2.39.3 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 24 lines · Gary Lin
On Tue, Mar 12, 2024 at 11:03:17AM +0800, Hyman Huang wrote:
Hi Hyman,Quoted 14 lines
This patchset aims to supplement James's previous work, please refer to the following link for details:
https://lists.gnu.org/archive/html/grub-devel/2020-12/msg00257.htmlThe alterations listed below were made in light of earlier research:
1. As Glenn advised, remove the first commit ([PATCH v3 1/3] cryptodisk:
make the password getter and additional argument torecover_key) while maintaining the original recover key function declaration.2. To decrypt the disk, use the password that was retrieved from the EFI secret area and store it in the
key_datafield of thegrub_cryptomount_args_t. Then, pass the password to thegrub_cryptodisk_scan_devicefunction.Quoted 7 lines
3. Modify the put method's function definition in struct
grub_secret_entry, and usegrub_errnoto log method errors.We uploaded this series with the intention of receiving feedback, as the title suggests. Any suggestions and feedback regarding this patchset are welcom.
Quoted 7 lines
I'm working on disk unlocking with TPM2 and it's a bit similar to your work. Here is my v9 patchset:
https://lists.gnu.org/archive/html/grub-devel/2024-02/msg00007.htmlThe original patch author, Herman, introduced the key protectors framework, and it may be useful in your case:
I take it that the AMD SEV secret inject can be implemented using the key protector framework feature once it's ready?
Quoted 5 lines
- key protectors framework
https://lists.gnu.org/archive/html/grub-devel/2024-02/msg00014.html
- cryptodisk change
https://lists.gnu.org/archive/html/grub-devel/2024-02/msg00016.html
So, Should I post version 2 and rebase on the patchset then?
Quoted 11 lines
- TPM2 key protector
https://lists.gnu.org/archive/html/grub-devel/2024-02/msg00017.htmlIn short, it unlocks the disk with the commands like this:
tpm2_key_protector_init --tpm2key=(hd0,gpt1)/efi/grub2/sealed-1.tpm cryptomount -u <PART1_UUID> -P tpm2Maybe we can work together to support various disk unlocking mechanisms.
Sure, of course, yes.
Quoted 29 lines
Cheers,
Gary Lin
Quoted 24 lines
Thanks,
Yong
Hyman Huang (2):
cryptodisk: add OS provided secret support
efi: Add API for retrieving the EFI secret for cryptodiskgrub-core/Makefile.core.def | 8 +++ grub-core/disk/cryptodisk.c | 49 ++++++++++++- grub-core/disk/efi/efisecret.c | 123 +++++++++++++++++++++++++++++++++ include/grub/cryptodisk.h | 14 ++++ include/grub/efi/api.h | 15 ++++ 5 files changed, 206 insertions(+), 3 deletions(-) create mode 100644 grub-core/disk/efi/efisecret.c--
2.39.3_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Thanks for the comments, :)
Yong
Signature · 1 line
Best regards
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 30 lines · Yong Huang
Quoted 28 lines · Gary Lin
On Tue, Mar 12, 2024 at 11:03:17AM +0800, Hyman Huang wrote:
Hi Hyman,Quoted 14 lines
This patchset aims to supplement James's previous work, please refer to the following link for details:
https://lists.gnu.org/archive/html/grub-devel/2020-12/msg00257.htmlThe alterations listed below were made in light of earlier research:
1. As Glenn advised, remove the first commit ([PATCH v3 1/3] cryptodisk:
make the password getter and additional argument torecover_key) while maintaining the original recover key function declaration.2. To decrypt the disk, use the password that was retrieved from the EFI secret area and store it in the
key_datafield of thegrub_cryptomount_args_t. Then, pass the password to thegrub_cryptodisk_scan_devicefunction.Quoted 7 lines
3. Modify the put method's function definition in struct
grub_secret_entry, and usegrub_errnoto log method errors.We uploaded this series with the intention of receiving feedback, as the title suggests. Any suggestions and feedback regarding this patchset are welcom.
I'm working on disk unlocking with TPM2 and it's a bit similar to your work. Here is my v9 patchset:
https://lists.gnu.org/archive/html/grub-devel/2024-02/msg00007.html
Quoted 6 lines
Quoted 3 lines
The original patch author, Herman, introduced the key protectors framework, and it may be useful in your case:
I take it that the AMD SEV secret inject can be implemented using the key protector framework feature once it's ready?
That's my first impression. The key protector framework goes through the registered list and provides the password from the specified protector, and it looks similar to your patch.
Quoted 9 lines
Quoted 5 lines
- key protectors framework
https://lists.gnu.org/archive/html/grub-devel/2024-02/msg00014.html
- cryptodisk change
https://lists.gnu.org/archive/html/grub-devel/2024-02/msg00016.htmlSo, Should I post version 2 and rebase on the patchset then?
If you find it's reasonable to use the key protector framework, then yes :)
Thanks,
Gary Lin
Quoted 46 lines
Quoted 5 lines
- TPM2 key protector
https://lists.gnu.org/archive/html/grub-devel/2024-02/msg00017.htmlQuoted 7 lines
In short, it unlocks the disk with the commands like this:
tpm2_key_protector_init --tpm2key=(hd0,gpt1)/efi/grub2/sealed-1.tpm cryptomount -u <PART1_UUID> -P tpm2Maybe we can work together to support various disk unlocking mechanisms.
Sure, of course, yes.
Quoted 29 lines
Cheers,
Gary Lin
Quoted 24 lines
Thanks,
Yong
Hyman Huang (2):
cryptodisk: add OS provided secret support
efi: Add API for retrieving the EFI secret for cryptodiskgrub-core/Makefile.core.def | 8 +++ grub-core/disk/cryptodisk.c | 49 ++++++++++++- grub-core/disk/efi/efisecret.c | 123 +++++++++++++++++++++++++++++++++ include/grub/cryptodisk.h | 14 ++++ include/grub/efi/api.h | 15 ++++ 5 files changed, 206 insertions(+), 3 deletions(-) create mode 100644 grub-core/disk/efi/efisecret.c--
2.39.3_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 6 lines
Thanks for the comments, :)
Yong
Signature · 1 line
Best regards
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel