[PATCH v17 15/20] tpm2: Implement NV index

2024-06-13 Thread Gary Lin via Grub-devel
From: Patrick Colp Currently with the TPM2 protector, only SRK mode is supported and NV index support is just a stub. Implement the NV index option. Note: This only extends support on the unseal path. grub2_protect has not been updated. tpm2-tools can be used to insert a key into the NV index.

[PATCH v17 17/20] cryptodisk: wipe out the cached keys from protectors

2024-06-13 Thread Gary Lin via Grub-devel
An attacker may insert a malicious disk with the same crypto UUID and trick grub2 to mount the fake root. Even though the key from the key protector fails to unlock the fake root, it's not wiped out cleanly so the attacker could dump the memory to retrieve the secret key. To defend such attack, wip

[PATCH v17 06/20] libtasn1: compile into asn1 module

2024-06-13 Thread Gary Lin via Grub-devel
From: Daniel Axtens Create a wrapper file that specifies the module license. Set up the makefile so it is built. Signed-off-by: Daniel Axtens Signed-off-by: Gary Lin Reviewed-by: Vladimir Serbinenko --- autogen.sh | 16 grub-core/Makefile.core.def

[PATCH v17 00/20] Automatic Disk Unlock with TPM2

2024-06-13 Thread Gary Lin via Grub-devel
GIT repo for v17: https://github.com/lcp/grub2/tree/tpm2-unlock-v17 This patch series is based on "Automatic TPM Disk Unlock"(*1) posted by Hernan Gatta to introduce the key protector framework and TPM2 stack to GRUB2, and this could be a useful feature for the systems to implement full disk encry

[PATCH v17 19/20] tpm2: Enable tpm2 module for grub-emu

2024-06-13 Thread Gary Lin via Grub-devel
As a preparation to test TPM 2.0 TSS stack with grub-emu, the new option, --tpm-device, is introduced to specify the TPM device for grub-emu so that grub-emu can share the emulated TPM device with the host. Since grub-emu can directly access the device node on host, it's easy to implement the esse

[PATCH v17 11/20] key_protector: Add TPM2 Key Protector

2024-06-13 Thread Gary Lin via Grub-devel
From: Hernan Gatta The TPM2 key protector is a module that enables the automatic retrieval of a fully-encrypted disk's unlocking key from a TPM 2.0. The theory of operation is such that the module accepts various arguments, most of which are optional and therefore possess reasonable defaults. On

[PATCH v17 12/20] cryptodisk: Support key protectors

2024-06-13 Thread Gary Lin via Grub-devel
From: Hernan Gatta Add a new parameter to cryptomount to support the key protectors framework: -P. The parameter is used to automatically retrieve a key from specified key protectors. The parameter may be repeated to specify any number of key protectors. These are tried in order until one provide

[PATCH v17 14/20] tpm2: Support authorized policy

2024-06-13 Thread Gary Lin via Grub-devel
This commit handles the TPM2_PolicyAuthorize command from the key file in TPM 2.0 Key File format. TPM2_PolicyAuthorize is the essential command to support authorized policy which allows the users to sign TPM policies with their own keys. Per TPM 2.0 Key File(*1), CommandPolicy for TPM2_PolicyAuth

[PATCH v17 18/20] diskfilter: look up cryptodisk devices first

2024-06-13 Thread Gary Lin via Grub-devel
When using disk auto-unlocking with TPM 2.0, the typical grub.cfg may look like this: tpm2_key_protector_init --tpm2key=(hd0,gpt1)/boot/grub2/sealed.tpm cryptomount -u -P tpm2 search --fs-uuid --set=root Since the disk search order is based on the order of module loading, the attacker cou

[PATCH v17 04/20] libtasn1: changes for grub compatibility

2024-06-13 Thread Gary Lin via Grub-devel
Based on the patch from "Daniel Axtens " Do a few things to make libtasn1 compile as part of grub: - remove _asn1_strcat and replace strcat with the bound-checked _asn1_str_cat except the one inside _asn1_str_cat. That strcat is replaced with strcpy. - adjust header paths in libtasn1.h

[PATCH v17 05/20] libtasn1: fix the potential buffer overrun

2024-06-13 Thread Gary Lin via Grub-devel
In _asn1_tag_der(), the first while loop for the long form may end up with a 'k' value with 'ASN1_MAX_TAG_SIZE' and cause the buffer overrun in the second while loop. This commit tweaks the conditional check to avoid producing a too large 'k'. This is a quick fix and may differ from the official u

[PATCH v17 09/20] key_protector: Add key protectors framework

2024-06-13 Thread Gary Lin via Grub-devel
From: Hernan Gatta A key protector encapsulates functionality to retrieve an unlocking key for a fully-encrypted disk from a specific source. A key protector module registers itself with the key protectors framework when it is loaded and unregisters when unloaded. Additionally, a key protector ma

[PATCH v17 13/20] util/grub-protect: Add new tool

2024-06-13 Thread Gary Lin via Grub-devel
From: Hernan Gatta To utilize the key protectors framework, there must be a way to protect full-disk encryption keys in the first place. The grub-protect tool includes support for the TPM2 key protector but other protectors that require setup ahead of time can be supported in the future. For the

[PATCH v17 01/20] posix_wrap: tweaks in preparation for libtasn1

2024-06-13 Thread Gary Lin via Grub-devel
From: Daniel Axtens - Define SIZEOF_UNSIGNED_LONG_INT, it's the same as SIZEOF_UNSIGNED_LONG. - Define WORD_BIT, the size in bits of an int. This is a defined in the Single Unix Specification and in gnulib's limits.h. gnulib assumes it's 32 bits on all our platforms, including 64 bit

[PATCH v17 08/20] libtasn1: Add the documentation

2024-06-13 Thread Gary Lin via Grub-devel
Document libtasn1 in docs/grub-dev.texi and add the upgrade steps. Also add the patches to make libtasn1 compatible with grub code. Signed-off-by: Gary Lin Reviewed-by: Vladimir Serbinenko --- docs/grub-dev.texi | 33 + 1 file changed, 33 insertions(+) diff --gi

[PATCH v17 03/20] libtasn1: disable code not needed in grub

2024-06-13 Thread Gary Lin via Grub-devel
Based on the patch from "Daniel Axtens " We don't expect to be able to write ASN.1, only read it, so we can disable some code. Do that with #if 0/#endif, rather than deletion. This means that the difference between upstream and grub is smaller, which should make updating libtasn1 easier in the fu

Re: [PATCH v16 03/20] libtasn1: disable code not needed in grub

2024-06-13 Thread Gary Lin via Grub-devel
On Wed, Jun 12, 2024 at 06:10:12PM +0200, Daniel Kiper wrote: > On Tue, Jun 11, 2024 at 03:10:56PM +0800, Gary Lin via Grub-devel wrote: > > On Fri, Jun 07, 2024 at 04:14:54PM +0200, Daniel Kiper wrote: > > > On Fri, Jun 07, 2024 at 11:07:31AM +0800, Gary Lin wrote: > > >

Re: [PATCH v16 03/20] libtasn1: disable code not needed in grub

2024-06-11 Thread Gary Lin via Grub-devel
On Fri, Jun 07, 2024 at 04:14:54PM +0200, Daniel Kiper wrote: > On Fri, Jun 07, 2024 at 11:07:31AM +0800, Gary Lin wrote: > > On Wed, Jun 05, 2024 at 05:18:32PM +0200, Daniel Kiper wrote: > > > On Wed, May 15, 2024 at 01:06:55PM +0800, Gary Lin wrote: > > > > From: Daniel Axtens > > > > > > > > We

Re: [PATCH v16 02/20] libtasn1: import libtasn1-4.19.0

2024-06-06 Thread Gary Lin via Grub-devel
On Wed, Jun 05, 2024 at 05:04:46PM +0200, Daniel Kiper wrote: > On Wed, May 15, 2024 at 01:06:54PM +0800, Gary Lin wrote: > > From: Daniel Axtens > > > > Import a very trimmed-down set of libtasn1 files: > > I hope you merge the latest one... > Yes, I updated Daniel's patch to include the latest

Re: [PATCH v16 01/20] posix_wrap: tweaks in preparation for libtasn1

2024-06-06 Thread Gary Lin via Grub-devel
On Wed, Jun 05, 2024 at 04:45:07PM +0200, Daniel Kiper wrote: > On Wed, May 15, 2024 at 01:06:53PM +0800, Gary Lin wrote: > > From: Daniel Axtens > > > > - Define SIZEOF_UNSIGNED_LONG_INT, it's the same as > >SIZEOF_UNSIGNED_LONG. > > > > - Define WORD_BIT, the size in bits of an int. This i

Re: [PATCH v16 03/20] libtasn1: disable code not needed in grub

2024-06-06 Thread Gary Lin via Grub-devel
On Wed, Jun 05, 2024 at 05:18:32PM +0200, Daniel Kiper wrote: > On Wed, May 15, 2024 at 01:06:55PM +0800, Gary Lin wrote: > > From: Daniel Axtens > > > > We don't expect to be able to write ASN.1, only read it, > > so we can disable some code. > > > > Do that with #if 0/#endif, rather than deletio

Re: [PATCH v3 3/5] Adjust import script, definitions and API users for libgcrypt 1.10

2024-05-28 Thread Gary Lin via Grub-devel
On Fri, May 24, 2024 at 08:30:04PM +0300, Vladimir Serbinenko wrote: > diff --git a/conf/Makefile.common b/conf/Makefile.common > index b8f216f6c..1fd3fc9da 100644 > --- a/conf/Makefile.common > +++ b/conf/Makefile.common > @@ -81,8 +81,8 @@ CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/lib/gnulib

Re: [PATCH v3 5/5] keccak: Disable acceleration with SSE asm

2024-05-27 Thread Gary Lin via Grub-devel
On Fri, May 24, 2024 at 08:30:06PM +0300, Vladimir Serbinenko wrote: > --- > .../lib/libgcrypt-patches/02_keccak_sse.diff | 19 +++ > 1 file changed, 19 insertions(+) > create mode 100644 grub-core/lib/libgcrypt-patches/02_keccak_sse.diff > > diff --git a/grub-core/lib/libgcrypt

Re: [PATCH 1/3] Import libgcrypt 1.10.3

2024-05-21 Thread Gary Lin via Grub-devel
On Tue, May 21, 2024 at 01:36:18PM +0300, Vladimir 'phcoder' Serbinenko wrote: > I think at least AUTHORS and COPYING should be included. I see the point to keep AUTHORS and COPYING but other library such minilzo only copies the essential .c/.h files. > Rest is for the ease of update in the futur

Re: [PATCH 1/3] Import libgcrypt 1.10.3

2024-05-21 Thread Gary Lin via Grub-devel
Hi Vladimir, Originally, there are only cipher, mpi, and src in the libgcrypt directory, but the unnecessary stuff, e.g. AUTHORS, COPYING, build-aux, tests, etc., was added and bloated the size of the patch. Could you remove them and only keep the necessary files? Thanks, Gary Lin _

[PATCH v16 13/20] util/grub-protect: Add new tool

2024-05-14 Thread Gary Lin via Grub-devel
From: Hernan Gatta To utilize the key protectors framework, there must be a way to protect full-disk encryption keys in the first place. The grub-protect tool includes support for the TPM2 key protector but other protectors that require setup ahead of time can be supported in the future. For the

[PATCH v16 00/20] Automatic Disk Unlock with TPM2

2024-05-14 Thread Gary Lin via Grub-devel
GIT repo for v16: https://github.com/lcp/grub2/tree/tpm2-unlock-v16 This patch series is based on "Automatic TPM Disk Unlock"(*1) posted by Hernan Gatta to introduce the key protector framework and TPM2 stack to GRUB2, and this could be a useful feature for the systems to implement full disk encry

[PATCH v16 12/20] cryptodisk: Support key protectors

2024-05-14 Thread Gary Lin via Grub-devel
From: Hernan Gatta Add a new parameter to cryptomount to support the key protectors framework: -P. The parameter is used to automatically retrieve a key from specified key protectors. The parameter may be repeated to specify any number of key protectors. These are tried in order until one provide

[PATCH v16 20/20] tests: Add tpm2_test

2024-05-14 Thread Gary Lin via Grub-devel
For the tpm2 module, the TCG2 command submission function is the only difference between the a QEMU instance and grub-emu. To test TPM key unsealing with a QEMU instance, it requires an extra OS image to invoke grub-protect to seal the LUKS key, rather than a simple grub-shell rescue CD image. On t

[PATCH v16 19/20] tpm2: Enable tpm2 module for grub-emu

2024-05-14 Thread Gary Lin via Grub-devel
As a preparation to test TPM 2.0 TSS stack with grub-emu, the new option, --tpm-device, is introduced to specify the TPM device for grub-emu so that grub-emu can share the emulated TPM device with the host. Since grub-emu can directly access the device node on host, it's easy to implement the esse

[PATCH v16 17/20] cryptodisk: wipe out the cached keys from protectors

2024-05-14 Thread Gary Lin via Grub-devel
An attacker may insert a malicious disk with the same crypto UUID and trick grub2 to mount the fake root. Even though the key from the key protector fails to unlock the fake root, it's not wiped out cleanly so the attacker could dump the memory to retrieve the secret key. To defend such attack, wip

[PATCH v16 03/20] libtasn1: disable code not needed in grub

2024-05-14 Thread Gary Lin via Grub-devel
From: Daniel Axtens We don't expect to be able to write ASN.1, only read it, so we can disable some code. Do that with #if 0/#endif, rather than deletion. This means that the difference between upstream and grub is smaller, which should make updating libtasn1 easier in the future. With these ex

[PATCH v16 06/20] libtasn1: compile into asn1 module

2024-05-14 Thread Gary Lin via Grub-devel
From: Daniel Axtens Create a wrapper file that specifies the module license. Set up the makefile so it is built. Signed-off-by: Daniel Axtens Signed-off-by: Gary Lin Reviewed-by: Vladimir Serbinenko --- grub-core/Makefile.core.def| 15 +++ grub-core/lib/libtasn1_wrap/wrap

[PATCH v16 15/20] tpm2: Implement NV index

2024-05-14 Thread Gary Lin via Grub-devel
From: Patrick Colp Currently with the TPM2 protector, only SRK mode is supported and NV index support is just a stub. Implement the NV index option. Note: This only extends support on the unseal path. grub2_protect has not been updated. tpm2-tools can be used to insert a key into the NV index.

[PATCH v16 16/20] cryptodisk: Fallback to passphrase

2024-05-14 Thread Gary Lin via Grub-devel
From: Patrick Colp If a protector is specified, but it fails to unlock the disk, fall back to asking for the passphrase. However, an error was set indicating that the protector(s) failed. Later code (e.g., LUKS code) fails as `grub_errno` is now set. Print the existing errors out first, before pr

[PATCH v16 11/20] key_protector: Add TPM2 Key Protector

2024-05-14 Thread Gary Lin via Grub-devel
From: Hernan Gatta The TPM2 key protector is a module that enables the automatic retrieval of a fully-encrypted disk's unlocking key from a TPM 2.0. The theory of operation is such that the module accepts various arguments, most of which are optional and therefore possess reasonable defaults. On

[PATCH v16 09/20] key_protector: Add key protectors framework

2024-05-14 Thread Gary Lin via Grub-devel
From: Hernan Gatta A key protector encapsulates functionality to retrieve an unlocking key for a fully-encrypted disk from a specific source. A key protector module registers itself with the key protectors framework when it is loaded and unregisters when unloaded. Additionally, a key protector ma

[PATCH v16 18/20] diskfilter: look up cryptodisk devices first

2024-05-14 Thread Gary Lin via Grub-devel
When using disk auto-unlocking with TPM 2.0, the typical grub.cfg may look like this: tpm2_key_protector_init --tpm2key=(hd0,gpt1)/boot/grub2/sealed.tpm cryptomount -u -P tpm2 search --fs-uuid --set=root Since the disk search order is based on the order of module loading, the attacker cou

[PATCH v16 14/20] tpm2: Support authorized policy

2024-05-14 Thread Gary Lin via Grub-devel
This commit handles the TPM2_PolicyAuthorize command from the key file in TPM 2.0 Key File format. TPM2_PolicyAuthorize is the essential command to support authorized policy which allows the users to sign TPM policies with their own keys. Per TPM 2.0 Key File(*1), CommandPolicy for TPM2_PolicyAuth

[PATCH v16 04/20] libtasn1: changes for grub compatibility

2024-05-14 Thread Gary Lin via Grub-devel
From: Daniel Axtens Do a few things to make libtasn1 compile as part of grub: - remove _asn1_strcat and replace strcat with the bound-checked _asn1_str_cat except the one inside _asn1_str_cat. That strcat is replaced with strcpy. - adjust header paths in libtasn1.h - adjust header pat

[PATCH v16 01/20] posix_wrap: tweaks in preparation for libtasn1

2024-05-14 Thread Gary Lin via Grub-devel
From: Daniel Axtens - Define SIZEOF_UNSIGNED_LONG_INT, it's the same as SIZEOF_UNSIGNED_LONG. - Define WORD_BIT, the size in bits of an int. This is a defined in the Single Unix Specification and in gnulib's limits.h. gnulib assumes it's 32 bits on all our platforms, including 64 bit

[PATCH v16 05/20] libtasn1: fix the potential buffer overrun

2024-05-14 Thread Gary Lin via Grub-devel
In _asn1_tag_der(), the first while loop for the long form may end up with a 'k' value with 'ASN1_MAX_TAG_SIZE' and cause the buffer overrun in the second while loop. This commit tweaks the conditional check to avoid producing a too large 'k'. This is a quick fix and may differ from the official u

[PATCH v16 08/20] libtasn1: Add the documentation

2024-05-14 Thread Gary Lin via Grub-devel
Document libtasn1 in docs/grub-dev.texi and add the upgrade steps. Also add the patches to make libtasn1 compatible with grub code. Signed-off-by: Gary Lin Reviewed-by: Vladimir Serbinenko --- docs/grub-dev.texi| 34 ++ ...asn1-disable-code-not-needed-in-grub.patch

Re: [PATCH v15 12/20] cryptodisk: Support key protectors

2024-05-13 Thread Gary Lin via Grub-devel
On Fri, May 10, 2024 at 02:35:00PM +0800, Gary Lin wrote: > From: Hernan Gatta > > Add a new parameter to cryptomount to support the key protectors framework: > -P. > The parameter is used to automatically retrieve a key from specified key > protectors. The parameter may be repeated to specify a

[PATCH v15 15/20] tpm2: Implement NV index

2024-05-09 Thread Gary Lin via Grub-devel
From: Patrick Colp Currently with the TPM2 protector, only SRK mode is supported and NV index support is just a stub. Implement the NV index option. Note: This only extends support on the unseal path. grub2_protect has not been updated. tpm2-tools can be used to insert a key into the NV index.

[PATCH v15 16/20] cryptodisk: Fallback to passphrase

2024-05-09 Thread Gary Lin via Grub-devel
From: Patrick Colp If a protector is specified, but it fails to unlock the disk, fall back to asking for the passphrase. However, an error was set indicating that the protector(s) failed. Later code (e.g., LUKS code) fails as `grub_errno` is now set. Print the existing errors out first, before pr

[PATCH v15 11/20] key_protector: Add TPM2 Key Protector

2024-05-09 Thread Gary Lin via Grub-devel
From: Hernan Gatta The TPM2 key protector is a module that enables the automatic retrieval of a fully-encrypted disk's unlocking key from a TPM 2.0. The theory of operation is such that the module accepts various arguments, most of which are optional and therefore possess reasonable defaults. On

[PATCH v15 08/20] libtasn1: Add the documentation

2024-05-09 Thread Gary Lin via Grub-devel
Document libtasn1 in docs/grub-dev.texi and add the upgrade steps. Also add the patches to make libtasn1 compatible with grub code. Signed-off-by: Gary Lin Reviewed-by: Vladimir Serbinenko --- docs/grub-dev.texi| 34 ++ ...asn1-disable-code-not-needed-in-grub.patch

[PATCH v15 13/20] util/grub-protect: Add new tool

2024-05-09 Thread Gary Lin via Grub-devel
From: Hernan Gatta To utilize the key protectors framework, there must be a way to protect full-disk encryption keys in the first place. The grub-protect tool includes support for the TPM2 key protector but other protectors that require setup ahead of time can be supported in the future. For the

[PATCH v15 06/20] libtasn1: compile into asn1 module

2024-05-09 Thread Gary Lin via Grub-devel
From: Daniel Axtens Create a wrapper file that specifies the module license. Set up the makefile so it is built. Signed-off-by: Daniel Axtens Signed-off-by: Gary Lin Reviewed-by: Vladimir Serbinenko --- grub-core/Makefile.core.def| 15 +++ grub-core/lib/libtasn1_wrap/wrap

[PATCH v15 17/20] cryptodisk: wipe out the cached keys from protectors

2024-05-09 Thread Gary Lin via Grub-devel
An attacker may insert a malicious disk with the same crypto UUID and trick grub2 to mount the fake root. Even though the key from the key protector fails to unlock the fake root, it's not wiped out cleanly so the attacker could dump the memory to retrieve the secret key. To defend such attack, wip

[PATCH v15 18/20] diskfilter: look up cryptodisk devices first

2024-05-09 Thread Gary Lin via Grub-devel
When using disk auto-unlocking with TPM 2.0, the typical grub.cfg may look like this: tpm2_key_protector_init --tpm2key=(hd0,gpt1)/boot/grub2/sealed.tpm cryptomount -u -P tpm2 search --fs-uuid --set=root Since the disk search order is based on the order of module loading, the attacker cou

[PATCH v15 20/20] tests: Add tpm2_test

2024-05-09 Thread Gary Lin via Grub-devel
For the tpm2 module, the TCG2 command submission function is the only difference between the a QEMU instance and grub-emu. To test TPM key unsealing with a QEMU instance, it requires an extra OS image to invoke grub-protect to seal the LUKS key, rather than a simple grub-shell rescue CD image. On t

[PATCH v15 19/20] tpm2: Enable tpm2 module for grub-emu

2024-05-09 Thread Gary Lin via Grub-devel
As a preparation to test TPM 2.0 TSS stack with grub-emu, the new option, --tpm-device, is introduced to specify the TPM device for grub-emu so that grub-emu can share the emulated TPM device with the host. Since grub-emu can directly access the device node on host, it's easy to implement the esse

[PATCH v15 12/20] cryptodisk: Support key protectors

2024-05-09 Thread Gary Lin via Grub-devel
From: Hernan Gatta Add a new parameter to cryptomount to support the key protectors framework: -P. The parameter is used to automatically retrieve a key from specified key protectors. The parameter may be repeated to specify any number of key protectors. These are tried in order until one provide

[PATCH v15 03/20] libtasn1: disable code not needed in grub

2024-05-09 Thread Gary Lin via Grub-devel
From: Daniel Axtens We don't expect to be able to write ASN.1, only read it, so we can disable some code. Do that with #if 0/#endif, rather than deletion. This means that the difference between upstream and grub is smaller, which should make updating libtasn1 easier in the future. With these ex

[PATCH v15 09/20] key_protector: Add key protectors framework

2024-05-09 Thread Gary Lin via Grub-devel
From: Hernan Gatta A key protector encapsulates functionality to retrieve an unlocking key for a fully-encrypted disk from a specific source. A key protector module registers itself with the key protectors framework when it is loaded and unregisters when unloaded. Additionally, a key protector ma

[PATCH v15 00/20] Automatic Disk Unlock with TPM2

2024-05-09 Thread Gary Lin via Grub-devel
GIT repo for v15: https://github.com/lcp/grub2/tree/tpm2-unlock-v15 This patch series is based on "Automatic TPM Disk Unlock"(*1) posted by Hernan Gatta to introduce the key protector framework and TPM2 stack to GRUB2, and this could be a useful feature for the systems to implement full disk encry

[PATCH v15 04/20] libtasn1: changes for grub compatibility

2024-05-09 Thread Gary Lin via Grub-devel
From: Daniel Axtens Do a few things to make libtasn1 compile as part of grub: - remove _asn1_strcat and replace strcat with the bound-checked _asn1_str_cat except the one inside _asn1_str_cat. That strcat is replaced with strcpy. - adjust header paths in libtasn1.h - adjust header pat

[PATCH v15 14/20] tpm2: Support authorized policy

2024-05-09 Thread Gary Lin via Grub-devel
This commit handles the TPM2_PolicyAuthorize command from the key file in TPM 2.0 Key File format. TPM2_PolicyAuthorize is the essential command to support authorized policy which allows the users to sign TPM policies with their own keys. Per TPM 2.0 Key File(*1), CommandPolicy for TPM2_PolicyAuth

[PATCH v15 01/20] posix_wrap: tweaks in preparation for libtasn1

2024-05-09 Thread Gary Lin via Grub-devel
From: Daniel Axtens - Define SIZEOF_UNSIGNED_LONG_INT, it's the same as SIZEOF_UNSIGNED_LONG. - Define WORD_BIT, the size in bits of an int. This is a defined in the Single Unix Specification and in gnulib's limits.h. gnulib assumes it's 32 bits on all our platforms, including 64 bit

[PATCH v15 05/20] libtasn1: fix the potential buffer overrun

2024-05-09 Thread Gary Lin via Grub-devel
In _asn1_tag_der(), the first while loop for the long form may end up with a 'k' value with 'ASN1_MAX_TAG_SIZE' and cause the buffer overrun in the second while loop. This commit tweaks the conditional check to avoid producing a too large 'k'. This is a quick fix and may differ from the official u

Re: [PATCH v14 20/20] tests: Add tpm2_test

2024-05-08 Thread Gary Lin via Grub-devel
On Wed, May 08, 2024 at 03:25:29PM -0500, Glenn Washburn wrote: > On Tue, 7 May 2024 16:19:19 +0800 > Gary Lin wrote: > > > On Mon, May 06, 2024 at 02:09:12PM -0500, Glenn Washburn wrote: > > > On Fri, 3 May 2024 14:48:56 +0800 > > > Gary Lin wrote: > > > > > > > For the tpm2 module, the TCG2

Re: [PATCH v14 20/20] tests: Add tpm2_test

2024-05-07 Thread Gary Lin via Grub-devel
On Mon, May 06, 2024 at 02:09:12PM -0500, Glenn Washburn wrote: > On Fri, 3 May 2024 14:48:56 +0800 > Gary Lin wrote: > > > For the tpm2 module, the TCG2 command submission function is the only > > difference between the a QEMU instance and grub-emu. To test TPM key > > unsealing with a QEMU ins

[PATCH v14 14/20] tpm2: Support authorized policy

2024-05-02 Thread Gary Lin via Grub-devel
This commit handles the TPM2_PolicyAuthorize command from the key file in TPM 2.0 Key File format. TPM2_PolicyAuthorize is the essential command to support authorized policy which allows the users to sign TPM policies with their own keys. Per TPM 2.0 Key File(*1), CommandPolicy for TPM2_PolicyAuth

[PATCH v14 16/20] cryptodisk: Fallback to passphrase

2024-05-02 Thread Gary Lin via Grub-devel
From: Patrick Colp If a protector is specified, but it fails to unlock the disk, fall back to asking for the passphrase. However, an error was set indicating that the protector(s) failed. Later code (e.g., LUKS code) fails as `grub_errno` is now set. Print the existing errors out first, before pr

[PATCH v14 05/20] libtasn1: fix the potential buffer overrun

2024-05-02 Thread Gary Lin via Grub-devel
In _asn1_tag_der(), the first while loop for the long form may end up with a 'k' value with 'ASN1_MAX_TAG_SIZE' and cause the buffer overrun in the second while loop. This commit tweaks the conditional check to avoid producing a too large 'k'. This is a quick fix and may differ from the official u

[PATCH v14 19/20] tpm2: Enable tpm2 module for grub-emu

2024-05-02 Thread Gary Lin via Grub-devel
As a preparation to test TPM 2.0 TSS stack with grub-emu, the new option, --tpm-device, is introduced to specify the TPM device for grub-emu so that grub-emu can share the emulated TPM device with the host. Since grub-emu can directly access the device node on host, it's easy to implement the esse

[PATCH v14 17/20] cryptodisk: wipe out the cached keys from protectors

2024-05-02 Thread Gary Lin via Grub-devel
An attacker may insert a malicious disk with the same crypto UUID and trick grub2 to mount the fake root. Even though the key from the key protector fails to unlock the fake root, it's not wiped out cleanly so the attacker could dump the memory to retrieve the secret key. To defend such attack, wip

[PATCH v14 04/20] libtasn1: changes for grub compatibility

2024-05-02 Thread Gary Lin via Grub-devel
From: Daniel Axtens Do a few things to make libtasn1 compile as part of grub: - remove _asn1_strcat and replace strcat with the bound-checked _asn1_str_cat except the one inside _asn1_str_cat. That strcat is replaced with strcpy. - adjust header paths in libtasn1.h - adjust header pat

[PATCH v14 01/20] posix_wrap: tweaks in preparation for libtasn1

2024-05-02 Thread Gary Lin via Grub-devel
From: Daniel Axtens - Define SIZEOF_UNSIGNED_LONG_INT, it's the same as SIZEOF_UNSIGNED_LONG. - Define WORD_BIT, the size in bits of an int. This is a defined in the Single Unix Specification and in gnulib's limits.h. gnulib assumes it's 32 bits on all our platforms, including 64 bit

[PATCH v14 08/20] libtasn1: Add the documentation

2024-05-02 Thread Gary Lin via Grub-devel
Document libtasn1 in docs/grub-dev.texi and add the upgrade steps. Also add the patches to make libtasn1 compatible with grub code. Signed-off-by: Gary Lin Reviewed-by: Vladimir Serbinenko --- docs/grub-dev.texi| 34 ++ ...asn1-disable-code-not-needed-in-grub.patch

[PATCH v14 11/20] key_protector: Add TPM2 Key Protector

2024-05-02 Thread Gary Lin via Grub-devel
From: Hernan Gatta The TPM2 key protector is a module that enables the automatic retrieval of a fully-encrypted disk's unlocking key from a TPM 2.0. The theory of operation is such that the module accepts various arguments, most of which are optional and therefore possess reasonable defaults. On

[PATCH v14 13/20] util/grub-protect: Add new tool

2024-05-02 Thread Gary Lin via Grub-devel
From: Hernan Gatta To utilize the key protectors framework, there must be a way to protect full-disk encryption keys in the first place. The grub-protect tool includes support for the TPM2 key protector but other protectors that require setup ahead of time can be supported in the future. For the

[PATCH v14 15/20] tpm2: Implement NV index

2024-05-02 Thread Gary Lin via Grub-devel
From: Patrick Colp Currently with the TPM2 protector, only SRK mode is supported and NV index support is just a stub. Implement the NV index option. Note: This only extends support on the unseal path. grub2_protect has not been updated. tpm2-tools can be used to insert a key into the NV index.

[PATCH v14 06/20] libtasn1: compile into asn1 module

2024-05-02 Thread Gary Lin via Grub-devel
From: Daniel Axtens Create a wrapper file that specifies the module license. Set up the makefile so it is built. Signed-off-by: Daniel Axtens Signed-off-by: Gary Lin Reviewed-by: Vladimir Serbinenko --- grub-core/Makefile.core.def| 15 +++ grub-core/lib/libtasn1_wrap/wrap

[PATCH v14 09/20] key_protector: Add key protectors framework

2024-05-02 Thread Gary Lin via Grub-devel
From: Hernan Gatta A key protector encapsulates functionality to retrieve an unlocking key for a fully-encrypted disk from a specific source. A key protector module registers itself with the key protectors framework when it is loaded and unregisters when unloaded. Additionally, a key protector ma

[PATCH v14 00/20] Automatic Disk Unlock with TPM2

2024-05-02 Thread Gary Lin via Grub-devel
GIT repo for v14: https://github.com/lcp/grub2/tree/tpm2-unlock-v14 This patch series is based on "Automatic TPM Disk Unlock"(*1) posted by Hernan Gatta to introduce the key protector framework and TPM2 stack to GRUB2, and this could be a useful feature for the systems to implement full disk encry

[PATCH v14 18/20] diskfilter: look up cryptodisk devices first

2024-05-02 Thread Gary Lin via Grub-devel
When using disk auto-unlocking with TPM 2.0, the typical grub.cfg may look like this: tpm2_key_protector_init --tpm2key=(hd0,gpt1)/boot/grub2/sealed.tpm cryptomount -u -P tpm2 search --fs-uuid --set=root Since the disk search order is based on the order of module loading, the attacker cou

[PATCH v14 20/20] tests: Add tpm2_test

2024-05-02 Thread Gary Lin via Grub-devel
For the tpm2 module, the TCG2 command submission function is the only difference between the a QEMU instance and grub-emu. To test TPM key unsealing with a QEMU instance, it requires an extra OS image to invoke grub-protect to seal the LUKS key, rather than a simple grub-shell rescue CD image. On t

[PATCH v14 03/20] libtasn1: disable code not needed in grub

2024-05-02 Thread Gary Lin via Grub-devel
From: Daniel Axtens We don't expect to be able to write ASN.1, only read it, so we can disable some code. Do that with #if 0/#endif, rather than deletion. This means that the difference between upstream and grub is smaller, which should make updating libtasn1 easier in the future. With these ex

[PATCH v14 12/20] cryptodisk: Support key protectors

2024-05-02 Thread Gary Lin via Grub-devel
From: Hernan Gatta Add a new parameter to cryptomount to support the key protectors framework: -P. The parameter is used to automatically retrieve a key from specified key protectors. The parameter may be repeated to specify any number of key protectors. These are tried in order until one provide

Re: [PATCH v13 20/20] tests: Add tpm2_test

2024-04-30 Thread Gary Lin via Grub-devel
On Mon, Apr 29, 2024 at 04:10:05PM +0800, Gary Lin wrote: > On Fri, Apr 26, 2024 at 05:18:04PM -0500, Glenn Washburn wrote: > > On Thu, 25 Apr 2024 16:02:06 +0800 > > Gary Lin wrote: > > > > > For the tpm2 module, the TCG2 command submission function is the only > > > difference between the a QEM

Re: [PATCH v13 20/20] tests: Add tpm2_test

2024-04-29 Thread Gary Lin via Grub-devel
On Fri, Apr 26, 2024 at 05:18:04PM -0500, Glenn Washburn wrote: > On Thu, 25 Apr 2024 16:02:06 +0800 > Gary Lin wrote: > > > For the tpm2 module, the TCG2 command submission function is the only > > difference between the a QEMU instance and grub-emu. To test TPM key > > unsealing with a QEMU ins

Re: [PATCH v13 08/20] libtasn1: Add the documentation

2024-04-28 Thread Gary Lin via Grub-devel
On Sat, Apr 27, 2024 at 03:27:57AM -0500, Glenn Washburn wrote: > On Thu, 25 Apr 2024 16:01:54 +0800 > Gary Lin wrote: > > > Document libtasn1 in docs/grub-dev.texi and add the upgrade steps. > > Also add the patches to make libtasn1 compatible with grub code. > > > > Signed-off-by: Gary Lin >

[PATCH v13 13/20] util/grub-protect: Add new tool

2024-04-25 Thread Gary Lin via Grub-devel
From: Hernan Gatta To utilize the key protectors framework, there must be a way to protect full-disk encryption keys in the first place. The grub-protect tool includes support for the TPM2 key protector but other protectors that require setup ahead of time can be supported in the future. For the

[PATCH v13 17/20] cryptodisk: wipe out the cached keys from protectors

2024-04-25 Thread Gary Lin via Grub-devel
An attacker may insert a malicious disk with the same crypto UUID and trick grub2 to mount the fake root. Even though the key from the key protector fails to unlock the fake root, it's not wiped out cleanly so the attacker could dump the memory to retrieve the secret key. To defend such attack, wip

[PATCH v13 14/20] tpm2: Support authorized policy

2024-04-25 Thread Gary Lin via Grub-devel
This commit handles the TPM2_PolicyAuthorize command from the key file in TPM 2.0 Key File format. TPM2_PolicyAuthorize is the essential command to support authorized policy which allows the users to sign TPM policies with their own keys. Per TPM 2.0 Key File(*1), CommandPolicy for TPM2_PolicyAuth

[PATCH v13 03/20] libtasn1: disable code not needed in grub

2024-04-25 Thread Gary Lin via Grub-devel
From: Daniel Axtens We don't expect to be able to write ASN.1, only read it, so we can disable some code. Do that with #if 0/#endif, rather than deletion. This means that the difference between upstream and grub is smaller, which should make updating libtasn1 easier in the future. With these ex

[PATCH v13 18/20] diskfilter: look up cryptodisk devices first

2024-04-25 Thread Gary Lin via Grub-devel
When using disk auto-unlocking with TPM 2.0, the typical grub.cfg may look like this: tpm2_key_protector_init --tpm2key=(hd0,gpt1)/boot/grub2/sealed.tpm cryptomount -u -P tpm2 search --fs-uuid --set=root Since the disk search order is based on the order of module loading, the attacker cou

[PATCH v13 20/20] tests: Add tpm2_test

2024-04-25 Thread Gary Lin via Grub-devel
For the tpm2 module, the TCG2 command submission function is the only difference between the a QEMU instance and grub-emu. To test TPM key unsealing with a QEMU instance, it requires an extra OS image to invoke grub-protect to seal the LUKS key, rather than a simple grub-shell rescue CD image. On t

[PATCH v13 11/20] key_protector: Add TPM2 Key Protector

2024-04-25 Thread Gary Lin via Grub-devel
From: Hernan Gatta The TPM2 key protector is a module that enables the automatic retrieval of a fully-encrypted disk's unlocking key from a TPM 2.0. The theory of operation is such that the module accepts various arguments, most of which are optional and therefore possess reasonable defaults. On

[PATCH v13 09/20] key_protector: Add key protectors framework

2024-04-25 Thread Gary Lin via Grub-devel
From: Hernan Gatta A key protector encapsulates functionality to retrieve an unlocking key for a fully-encrypted disk from a specific source. A key protector module registers itself with the key protectors framework when it is loaded and unregisters when unloaded. Additionally, a key protector ma

[PATCH v13 19/20] tpm2: Enable tpm2 module for grub-emu

2024-04-25 Thread Gary Lin via Grub-devel
As a preparation to test TPM 2.0 TSS stack with grub-emu, the new option, --tpm-device, is introduced to specify the TPM device for grub-emu so that grub-emu can share the emulated TPM device with the host. Since grub-emu can directly access the device node on host, it's easy to implement the esse

[PATCH v13 05/20] libtasn1: fix the potential buffer overrun

2024-04-25 Thread Gary Lin via Grub-devel
In _asn1_tag_der(), the first while loop for the long form may end up with a 'k' value with 'ASN1_MAX_TAG_SIZE' and cause the buffer overrun in the second while loop. This commit tweaks the conditional check to avoid producing a too large 'k'. This is a quick fix and may differ from the official u

[PATCH v13 15/20] tpm2: Implement NV index

2024-04-25 Thread Gary Lin via Grub-devel
From: Patrick Colp Currently with the TPM2 protector, only SRK mode is supported and NV index support is just a stub. Implement the NV index option. Note: This only extends support on the unseal path. grub2_protect has not been updated. tpm2-tools can be used to insert a key into the NV index.

[PATCH v13 08/20] libtasn1: Add the documentation

2024-04-25 Thread Gary Lin via Grub-devel
Document libtasn1 in docs/grub-dev.texi and add the upgrade steps. Also add the patches to make libtasn1 compatible with grub code. Signed-off-by: Gary Lin Reviewed-by: Vladimir Serbinenko --- docs/grub-dev.texi| 28 ++ ...asn1-disable-code-not-needed-in-grub.patch

[PATCH v13 12/20] cryptodisk: Support key protectors

2024-04-25 Thread Gary Lin via Grub-devel
From: Hernan Gatta Add a new parameter to cryptomount to support the key protectors framework: -P. The parameter is used to automatically retrieve a key from specified key protectors. The parameter may be repeated to specify any number of key protectors. These are tried in order until one provide

[PATCH v13 16/20] cryptodisk: Fallback to passphrase

2024-04-25 Thread Gary Lin via Grub-devel
From: Patrick Colp If a protector is specified, but it fails to unlock the disk, fall back to asking for the passphrase. However, an error was set indicating that the protector(s) failed. Later code (e.g., LUKS code) fails as `grub_errno` is now set. Print the existing errors out first, before pr

[PATCH v13 04/20] libtasn1: changes for grub compatibility

2024-04-25 Thread Gary Lin via Grub-devel
From: Daniel Axtens Do a few things to make libtasn1 compile as part of grub: - remove _asn1_strcat and replace strcat with the bound-checked _asn1_str_cat except the one inside _asn1_str_cat. That strcat is replaced with strcpy. - adjust header paths in libtasn1.h - adjust header pat

<    1   2   3   4   5   >