[PATCH v2 05/11] libtasn1: compile into asn1 module

2023-03-22 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 --- grub-core/Makefile.core.def| 15 +++ grub-core/lib/libtasn1_wrap/wrap.c | 26 ++

[PATCH v2 04/11] libtasn1: changes for grub compatibility

2023-03-22 Thread Gary Lin via Grub-devel
From: Daniel Axtens Do a few things to make libtasn1 compile as part of grub: - redefine _asn1_strcat. grub removed strcat so replace it with the appropriate calls to memcpy and strlen. Use this internally where strcat was used. - replace c_isdigit with grub_isdigit (and don't import c-

[PATCH v2 10/11] cryptodisk: Support key protectors

2023-03-22 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 v2 11/11] util/grub-protect: Add new tool

2023-03-22 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 v2 09/11] protectors: Add TPM2 Key Protector

2023-03-22 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 v2 00/11] Automatic Disk Unlock with TPM2

2023-03-22 Thread Gary Lin via Grub-devel
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 encryption. To support TPM 2.0 Key File format(*2), patch 1~6 are grabbed

Re: [PATCH v2 00/11] Automatic Disk Unlock with TPM2

2023-03-24 Thread Gary Lin via Grub-devel
On Fri, Mar 24, 2023 at 03:22:43AM +, Glenn Washburn wrote: > Hi Gary, > Hi Glenn, > Usually a v2 series will also include what changed from v1 -> v2 and > subsequent versions will keep the changelog. Also, for such a large series, > using --range-diff with git format-patch can be helpful for

Re: [PATCH v2 10/11] cryptodisk: Support key protectors

2023-03-24 Thread Gary Lin via Grub-devel
On Fri, Mar 24, 2023 at 03:21:57AM +, Glenn Washburn wrote: > On 3/22/23 08:10, 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 > >

[PATCH v3 01/12] posix_wrap: tweaks in preparation for libtasn1

2023-04-11 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 v3 05/12] libtasn1: compile into asn1 module

2023-04-11 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 --- grub-core/Makefile.core.def| 15 +++ grub-core/lib/libtasn1_wrap/wrap.c | 26 ++

[PATCH v3 07/12] libtasn1: Add the documentation

2023-04-11 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 --- docs/grub-dev.texi| 27 ++ ...asn1-disable-code-not-needed-in-grub.patch | 311 ++ ...tasn1

[PATCH v3 08/12] protectors: Add key protectors framework

2023-04-11 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 v3 04/12] libtasn1: changes for grub compatibility

2023-04-11 Thread Gary Lin via Grub-devel
From: Daniel Axtens Do a few things to make libtasn1 compile as part of grub: - redefine _asn1_strcat. grub removed strcat so replace it with the appropriate calls to memcpy and strlen. Use this internally where strcat was used. - replace c_isdigit with grub_isdigit (and don't import c-

[PATCH v3 11/12] cryptodisk: Support key protectors

2023-04-11 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 v3 12/12] util/grub-protect: Add new tool

2023-04-11 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 v3 10/12] protectors: Add TPM2 Key Protector

2023-04-11 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 v3 03/12] libtasn1: disable code not needed in grub

2023-04-11 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 v3 00/12] Automatic Disk Unlock with TPM2

2023-04-11 Thread Gary Lin via Grub-devel
GIT repo for v3: https://github.com/lcp/grub2/tree/tpm2-unlock-v3 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 encrypt

Re: [PATCH v3 11/12] cryptodisk: Support key protectors

2023-04-17 Thread Gary Lin via Grub-devel
On Wed, Apr 12, 2023 at 03:20:18PM -0300, Glenn Washburn wrote: > On 4/12/23 06:15, 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 > >

[PATCH v4 01/12] posix_wrap: tweaks in preparation for libtasn1

2023-04-20 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 v4 04/12] libtasn1: changes for grub compatibility

2023-04-20 Thread Gary Lin via Grub-devel
From: Daniel Axtens Do a few things to make libtasn1 compile as part of grub: - redefine _asn1_strcat. grub removed strcat so replace it with the appropriate calls to memcpy and strlen. Use this internally where strcat was used. - replace c_isdigit with grub_isdigit (and don't import c-

[PATCH v4 07/12] libtasn1: Add the documentation

2023-04-20 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 --- docs/grub-dev.texi| 27 ++ ...asn1-disable-code-not-needed-in-grub.patch | 311 ++ ...tasn1

[PATCH v4 05/12] libtasn1: compile into asn1 module

2023-04-20 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 --- grub-core/Makefile.core.def| 15 +++ grub-core/lib/libtasn1_wrap/wrap.c | 26 ++

[PATCH v4 10/12] protectors: Add TPM2 Key Protector

2023-04-20 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 v4 11/12] cryptodisk: Support key protectors

2023-04-20 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 v4 12/12] util/grub-protect: Add new tool

2023-04-20 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 v4 03/12] libtasn1: disable code not needed in grub

2023-04-20 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 v4 08/12] protectors: Add key protectors framework

2023-04-20 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 v4 00/12] Automatic Disk Unlock with TPM2

2023-04-20 Thread Gary Lin via Grub-devel
GIT repo for v4: https://github.com/lcp/grub2/tree/tpm2-unlock-v4 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 encrypt

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

2023-08-16 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 v5 04/20] libtasn1: changes for grub compatibility

2023-08-16 Thread Gary Lin via Grub-devel
From: Daniel Axtens Do a few things to make libtasn1 compile as part of grub: - redefine _asn1_strcat. grub removed strcat so replace it with the appropriate calls to memcpy and strlen. Use this internally where strcat was used. - replace c_isdigit with grub_isdigit (and don't import c-

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

2023-08-16 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 v5 05/20] libtasn1: compile into asn1 module

2023-08-16 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 --- grub-core/Makefile.core.def| 15 +++ grub-core/lib/libtasn1_wrap/wrap.c | 26 ++

[PATCH v5 08/20] protectors: Add key protectors framework

2023-08-16 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 v5 13/20] tpm2: Add TPM2 types, structures, and command constants

2023-08-16 Thread Gary Lin via Grub-devel
Add new TPM2 types and structures as the preparation to support authorized policy. * New types: TPM_ALG_ECDAA, TPM_ALG_ECDSA, TPM_ALG_ECSCHNORR, TPM_ALG_RSASSA, TPM_ALG_RSAPSS, TPM_ALG_SM2, and TPMI_ALG_SIG_SCHEME * New structures: TPMS_EMPTY, TPMS_SIGNATURE_RSA, TPMS_SIGNATURE_ECC, TPMS_

[PATCH v5 10/20] protectors: Add TPM2 Key Protector

2023-08-16 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 v5 14/20] tpm2: Add more marshal/unmarshal functions

2023-08-16 Thread Gary Lin via Grub-devel
Add a few more marshal/unmarshal functions to support authorized policy. * Marshal: grub_tpm2_mu_TPMU_SENSITIVE_COMPOSITE_Marshal() grub_tpm2_mu_TPMT_SENSITIVE_Marshal() grub_tpm2_mu_TPM2B_SENSITIVE_Marshal() grub_tpm2_mu_TPMS_SIGNATURE_RSA_Marshal() grub_tpm2_mu_TPMS_SIGNATURE_ECC_Marsh

[PATCH v5 11/20] cryptodisk: Support key protectors

2023-08-16 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 v5 12/20] util/grub-protect: Add new tool

2023-08-16 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 v5 15/20] tpm2: Implement more TPM2 commands

2023-08-16 Thread Gary Lin via Grub-devel
This commit implements a few more TPM2 commands as the preparation for the authorized policy support. * TPM2_LoadExternal This command is added to load the external public key to verify the signed policy digest * TPM2_HashSequenceStart, TPM2_SequenceUpdate, TPM2_SequenceComplete, and TPM2_Ha

[PATCH v5 07/20] libtasn1: Add the documentation

2023-08-16 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 --- docs/grub-dev.texi| 27 ++ ...asn1-disable-code-not-needed-in-grub.patch | 311 ++ ...tasn1

[PATCH v5 16/20] tpm2: Support authorized policy

2023-08-16 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 v5 19/20] cryptodisk: wipe out the cached keys from protectors

2023-08-16 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 v5 20/20] diskfilter: look up cryptodisk devices first

2023-08-16 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 v5 17/20] protectors: Implement NV index

2023-08-16 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 v5 18/20] cryptodisk: Fallback to passphrase

2023-08-16 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 v5 00/20] Automatic Disk Unlock with TPM2

2023-08-16 Thread Gary Lin via Grub-devel
GIT repo for v5: https://github.com/lcp/grub2/tree/tpm2-unlock-v5 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 encrypt

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

2023-10-03 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 v6 05/20] libtasn1: compile into asn1 module

2023-10-03 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 --- grub-core/Makefile.core.def| 15 +++ grub-core/lib/libtasn1_wrap/wrap.c | 26 ++

[PATCH v6 11/20] cryptodisk: Support key protectors

2023-10-03 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 v6 10/20] protectors: Add TPM2 Key Protector

2023-10-03 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 v6 14/20] tpm2: Add more marshal/unmarshal functions

2023-10-03 Thread Gary Lin via Grub-devel
Add a few more marshal/unmarshal functions to support authorized policy. * Marshal: grub_tpm2_mu_TPMU_SENSITIVE_COMPOSITE_Marshal() grub_tpm2_mu_TPMT_SENSITIVE_Marshal() grub_tpm2_mu_TPM2B_SENSITIVE_Marshal() grub_tpm2_mu_TPMS_SIGNATURE_RSA_Marshal() grub_tpm2_mu_TPMS_SIGNATURE_ECC_Marsh

[PATCH v6 17/20] protectors: Implement NV index

2023-10-03 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 v6 01/20] posix_wrap: tweaks in preparation for libtasn1

2023-10-03 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 v6 08/20] protectors: Add key protectors framework

2023-10-03 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 v6 13/20] tpm2: Add TPM2 types, structures, and command constants

2023-10-03 Thread Gary Lin via Grub-devel
Add new TPM2 types and structures as the preparation to support authorized policy. * New types: TPM_ALG_ECDAA, TPM_ALG_ECDSA, TPM_ALG_ECSCHNORR, TPM_ALG_RSASSA, TPM_ALG_RSAPSS, TPM_ALG_SM2, and TPMI_ALG_SIG_SCHEME * New structures: TPMS_EMPTY, TPMS_SIGNATURE_RSA, TPMS_SIGNATURE_ECC, TPMS_

[PATCH v6 12/20] util/grub-protect: Add new tool

2023-10-03 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 v6 07/20] libtasn1: Add the documentation

2023-10-03 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 --- docs/grub-dev.texi| 27 ++ ...asn1-disable-code-not-needed-in-grub.patch | 311 ++ ...tasn1

[PATCH v6 16/20] tpm2: Support authorized policy

2023-10-03 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 v6 19/20] cryptodisk: wipe out the cached keys from protectors

2023-10-03 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 v6 04/20] libtasn1: changes for grub compatibility

2023-10-03 Thread Gary Lin via Grub-devel
From: Daniel Axtens Do a few things to make libtasn1 compile as part of grub: - redefine _asn1_strcat. grub removed strcat so replace it with the appropriate calls to memcpy and strlen. Use this internally where strcat was used. - replace c_isdigit with grub_isdigit (and don't import c-

[PATCH v6 18/20] cryptodisk: Fallback to passphrase

2023-10-03 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 v6 20/20] diskfilter: look up cryptodisk devices first

2023-10-03 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 v6 15/20] tpm2: Implement more TPM2 commands

2023-10-03 Thread Gary Lin via Grub-devel
This commit implements a few more TPM2 commands as the preparation for the authorized policy support. * TPM2_LoadExternal This command is added to load the external public key to verify the signed policy digest * TPM2_HashSequenceStart, TPM2_SequenceUpdate, TPM2_SequenceComplete, and TPM2_Ha

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

2023-10-03 Thread Gary Lin via Grub-devel
GIT repo for v6: https://github.com/lcp/grub2/tree/tpm2-unlock-v6 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 encrypt

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

2023-11-19 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 v7 04/20] libtasn1: changes for grub compatibility

2023-11-19 Thread Gary Lin via Grub-devel
From: Daniel Axtens Do a few things to make libtasn1 compile as part of grub: - redefine _asn1_strcat. grub removed strcat so replace it with the appropriate calls to memcpy and strlen. Use this internally where strcat was used. - replace c_isdigit with grub_isdigit (and don't import c-

[PATCH v7 10/20] protectors: Add TPM2 Key Protector

2023-11-19 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 v7 05/20] libtasn1: compile into asn1 module

2023-11-19 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 --- grub-core/Makefile.core.def| 15 +++ grub-core/lib/libtasn1_wrap/wrap.c | 26 ++

[PATCH v7 08/20] protectors: Add key protectors framework

2023-11-19 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 v7 13/20] tpm2: Add TPM2 types, structures, and command constants

2023-11-19 Thread Gary Lin via Grub-devel
Add new TPM2 types and structures as the preparation to support authorized policy. * New types: TPM_ALG_ECDAA, TPM_ALG_ECDSA, TPM_ALG_ECSCHNORR, TPM_ALG_RSASSA, TPM_ALG_RSAPSS, TPM_ALG_SM2, and TPMI_ALG_SIG_SCHEME * New structures: TPMS_EMPTY, TPMS_SIGNATURE_RSA, TPMS_SIGNATURE_ECC, TPMS_

[PATCH v7 11/20] cryptodisk: Support key protectors

2023-11-19 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 v7 14/20] tpm2: Add more marshal/unmarshal functions

2023-11-19 Thread Gary Lin via Grub-devel
Add a few more marshal/unmarshal functions to support authorized policy. * Marshal: grub_tpm2_mu_TPMU_SENSITIVE_COMPOSITE_Marshal() grub_tpm2_mu_TPMT_SENSITIVE_Marshal() grub_tpm2_mu_TPM2B_SENSITIVE_Marshal() grub_tpm2_mu_TPMS_SIGNATURE_RSA_Marshal() grub_tpm2_mu_TPMS_SIGNATURE_ECC_Marsh

[PATCH v7 07/20] libtasn1: Add the documentation

2023-11-19 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 --- docs/grub-dev.texi| 27 ++ ...asn1-disable-code-not-needed-in-grub.patch | 311 ++ ...tasn1

[PATCH v7 18/20] cryptodisk: Fallback to passphrase

2023-11-19 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 v7 20/20] diskfilter: look up cryptodisk devices first

2023-11-19 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 v7 17/20] protectors: Implement NV index

2023-11-19 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 v7 01/20] posix_wrap: tweaks in preparation for libtasn1

2023-11-19 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 v7 19/20] cryptodisk: wipe out the cached keys from protectors

2023-11-19 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 v7 12/20] util/grub-protect: Add new tool

2023-11-19 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 v7 15/20] tpm2: Implement more TPM2 commands

2023-11-19 Thread Gary Lin via Grub-devel
This commit implements a few more TPM2 commands as the preparation for the authorized policy support. * TPM2_LoadExternal This command is added to load the external public key to verify the signed policy digest * TPM2_HashSequenceStart, TPM2_SequenceUpdate, TPM2_SequenceComplete, and TPM2_Ha

[PATCH v7 16/20] tpm2: Support authorized policy

2023-11-19 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 v7 00/20] Automatic Disk Unlock with TPM2

2023-11-19 Thread Gary Lin via Grub-devel
GIT repo for v7: https://github.com/lcp/grub2/tree/tpm2-unlock-v7 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 encrypt

[PATCH] tests: switch password quality check off for luks2 test

2023-12-29 Thread Gary Lin via Grub-devel
When adding/changing the password for the luks2 partition, cryptsetup may reject the command due to the weak password. Since this is only for testing, add '--force-password' to switch password quality check off to avoid the unexpected failure. Signed-off-by: Gary Lin --- tests/grub_cmd_cryptomou

[PATCH v8 01/22] posix_wrap: tweaks in preparation for libtasn1

2024-01-16 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 v8 05/22] libtasn1: compile into asn1 module

2024-01-16 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 --- grub-core/Makefile.core.def| 15 +++ grub-core/lib/libtasn1_wrap/wrap.c | 26 ++

[PATCH v8 08/22] protectors: Add key protectors framework

2024-01-16 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 v8 13/22] tpm2: Add TPM2 types, structures, and command constants

2024-01-16 Thread Gary Lin via Grub-devel
Add new TPM2 types and structures as the preparation to support authorized policy. * New types: TPM_ALG_ECDAA, TPM_ALG_ECDSA, TPM_ALG_ECSCHNORR, TPM_ALG_RSASSA, TPM_ALG_RSAPSS, TPM_ALG_SM2, and TPMI_ALG_SIG_SCHEME * New structures: TPMS_EMPTY, TPMS_SIGNATURE_RSA, TPMS_SIGNATURE_ECC, TPMS_

[PATCH v8 11/22] cryptodisk: Support key protectors

2024-01-16 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 v8 00/22] Automatic Disk Unlock with TPM2

2024-01-16 Thread Gary Lin via Grub-devel
GIT repo for v8: https://github.com/lcp/grub2/tree/tpm2-unlock-v8 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 encrypt

[PATCH v8 17/22] protectors: Implement NV index

2024-01-16 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 v8 19/22] cryptodisk: wipe out the cached keys from protectors

2024-01-16 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 v8 15/22] tpm2: Implement more TPM2 commands

2024-01-16 Thread Gary Lin via Grub-devel
This commit implements a few more TPM2 commands as the preparation for the authorized policy support. * TPM2_LoadExternal This command is added to load the external public key to verify the signed policy digest * TPM2_HashSequenceStart, TPM2_SequenceUpdate, TPM2_SequenceComplete, and TPM2_Ha

[PATCH v8 16/22] tpm2: Support authorized policy

2024-01-16 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 v8 09/22] tpm2: Add TPM Software Stack (TSS)

2024-01-16 Thread Gary Lin via Grub-devel
From: Hernan Gatta A Trusted Platform Module (TPM) Software Stack (TSS) provides logic to compose, submit, and parse TPM commands and responses. A limited number of TPM commands may be accessed via the EFI TCG2 protocol. This protocol exposes functionality that is primarily geared toward TPM usa

[PATCH v8 12/22] util/grub-protect: Add new tool

2024-01-16 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 v8 14/22] tpm2: Add more marshal/unmarshal functions

2024-01-16 Thread Gary Lin via Grub-devel
Add a few more marshal/unmarshal functions to support authorized policy. * Marshal: grub_tpm2_mu_TPMU_SENSITIVE_COMPOSITE_Marshal() grub_tpm2_mu_TPMT_SENSITIVE_Marshal() grub_tpm2_mu_TPM2B_SENSITIVE_Marshal() grub_tpm2_mu_TPMS_SIGNATURE_RSA_Marshal() grub_tpm2_mu_TPMS_SIGNATURE_ECC_Marsh

[PATCH v8 21/22] tpm2: Enable tpm2 module for grub-emu

2024-01-16 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 v8 04/22] libtasn1: changes for grub compatibility

2024-01-16 Thread Gary Lin via Grub-devel
From: Daniel Axtens Do a few things to make libtasn1 compile as part of grub: - redefine _asn1_strcat. grub removed strcat so replace it with the appropriate calls to memcpy and strlen. Use this internally where strcat was used. - replace c_isdigit with grub_isdigit (and don't import c-

[PATCH v8 07/22] libtasn1: Add the documentation

2024-01-16 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 --- docs/grub-dev.texi| 27 ++ ...asn1-disable-code-not-needed-in-grub.patch | 311 ++ ...tasn1

<    1   2   3   4   5   6   7   >