diff mbox series

[5/5] efi_loader: refactor efi_append_scrtm_version()

Message ID 20210707133638.12630-6-masahisa.kojima@linaro.org
State Superseded
Headers show
Series add measurement support | expand

Commit Message

Masahisa Kojima July 7, 2021, 1:36 p.m. UTC
Refactor efi_append_scrtm_version() to use common
function for adding eventlog and extending PCR.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>

---
 lib/efi_loader/efi_tcg2.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

-- 
2.17.1

Comments

Heinrich Schuchardt July 8, 2021, 5:31 p.m. UTC | #1
On 7/7/21 3:36 PM, Masahisa Kojima wrote:
> Refactor efi_append_scrtm_version() to use common

> function for adding eventlog and extending PCR.

>

> Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>

> ---

>   lib/efi_loader/efi_tcg2.c | 14 +-------------

>   1 file changed, 1 insertion(+), 13 deletions(-)

>

> diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c

> index 823abd8217..00e442cea5 100644

> --- a/lib/efi_loader/efi_tcg2.c

> +++ b/lib/efi_loader/efi_tcg2.c

> @@ -1321,23 +1321,11 @@ out:

>    */

>   static efi_status_t efi_append_scrtm_version(struct udevice *dev)

>   {

> -	struct tpml_digest_values digest_list;

>   	u8 ver[] = U_BOOT_VERSION_STRING;

> -	const int pcr_index = 0;

>   	efi_status_t ret;

>

> -	ret = tcg2_create_digest(ver, sizeof(ver), &digest_list);

> -	if (ret != EFI_SUCCESS)

> -		goto out;

> +	ret = tcg2_measure_event(dev, 0, EV_S_CRTM_VERSION, sizeof(ver), ver);


Must we convert the string to UTF-16? What is required to get a correct
listing of the event in the OS?

Best regards

Heinrich

>

> -	ret = tcg2_pcr_extend(dev, pcr_index, &digest_list);

> -	if (ret != EFI_SUCCESS)

> -		goto out;

> -

> -	ret = tcg2_agile_log_append(pcr_index, EV_S_CRTM_VERSION, &digest_list,

> -				    sizeof(ver), ver);

> -

> -out:

>   	return ret;

>   }

>

>
Masahisa Kojima July 9, 2021, 2:05 a.m. UTC | #2
On Fri, 9 Jul 2021 at 02:32, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>

> On 7/7/21 3:36 PM, Masahisa Kojima wrote:

> > Refactor efi_append_scrtm_version() to use common

> > function for adding eventlog and extending PCR.

> >

> > Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>

> > ---

> >   lib/efi_loader/efi_tcg2.c | 14 +-------------

> >   1 file changed, 1 insertion(+), 13 deletions(-)

> >

> > diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c

> > index 823abd8217..00e442cea5 100644

> > --- a/lib/efi_loader/efi_tcg2.c

> > +++ b/lib/efi_loader/efi_tcg2.c

> > @@ -1321,23 +1321,11 @@ out:

> >    */

> >   static efi_status_t efi_append_scrtm_version(struct udevice *dev)

> >   {

> > -     struct tpml_digest_values digest_list;

> >       u8 ver[] = U_BOOT_VERSION_STRING;

> > -     const int pcr_index = 0;

> >       efi_status_t ret;

> >

> > -     ret = tcg2_create_digest(ver, sizeof(ver), &digest_list);

> > -     if (ret != EFI_SUCCESS)

> > -             goto out;

> > +     ret = tcg2_measure_event(dev, 0, EV_S_CRTM_VERSION, sizeof(ver), ver);

>

> Must we convert the string to UTF-16? What is required to get a correct

> listing of the event in the OS?


TCG PC Client spec just says "The event field contains the version string
of the SRTM.".
I think there is no character encoding requirement.

Thanks,
Masahisa Kojima


>

> Best regards

>

> Heinrich

>

> >

> > -     ret = tcg2_pcr_extend(dev, pcr_index, &digest_list);

> > -     if (ret != EFI_SUCCESS)

> > -             goto out;

> > -

> > -     ret = tcg2_agile_log_append(pcr_index, EV_S_CRTM_VERSION, &digest_list,

> > -                                 sizeof(ver), ver);

> > -

> > -out:

> >       return ret;

> >   }

> >

> >

>
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c
index 823abd8217..00e442cea5 100644
--- a/lib/efi_loader/efi_tcg2.c
+++ b/lib/efi_loader/efi_tcg2.c
@@ -1321,23 +1321,11 @@  out:
  */
 static efi_status_t efi_append_scrtm_version(struct udevice *dev)
 {
-	struct tpml_digest_values digest_list;
 	u8 ver[] = U_BOOT_VERSION_STRING;
-	const int pcr_index = 0;
 	efi_status_t ret;
 
-	ret = tcg2_create_digest(ver, sizeof(ver), &digest_list);
-	if (ret != EFI_SUCCESS)
-		goto out;
+	ret = tcg2_measure_event(dev, 0, EV_S_CRTM_VERSION, sizeof(ver), ver);
 
-	ret = tcg2_pcr_extend(dev, pcr_index, &digest_list);
-	if (ret != EFI_SUCCESS)
-		goto out;
-
-	ret = tcg2_agile_log_append(pcr_index, EV_S_CRTM_VERSION, &digest_list,
-				    sizeof(ver), ver);
-
-out:
 	return ret;
 }