All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jamin Lin <jamin_lin@aspeedtech.com>
To: Andrew Jeffery <andrew@aj.id.au>
Cc: "openbmc@lists.ozlabs.org" <openbmc@lists.ozlabs.org>,
	Troy Lee <troy_lee@aspeedtech.com>,
	Steven Lee <steven_lee@aspeedtech.com>
Subject: Re: Create AST2600 OTP image
Date: Fri, 17 Dec 2021 16:06:02 +0800	[thread overview]
Message-ID: <20211217080601.GA4293@aspeedtech.com> (raw)
In-Reply-To: <f42a6852-ab70-48b8-ba5d-74ba503e63dd@www.fastmail.com>

The 12/16/2021 22:43, Andrew Jeffery wrote:
> Hi Jamin,
> 
> On Thu, 16 Dec 2021, at 17:11, Jamin Lin wrote:
> > Hi OpenBMC team
> >
> > I have some questions about OTP image creation in OpenBMC. To support 
> > AST2600 RoT(Root of Trust, AST2600 ROM code verified SPL), users should 
> > program "A public key" in OTP and uses "A private key" with SPL image 
> > to create signature and place it in SPL.
> > The SOCESEC tool help user to create OTP and SPL images for AST2600 
> > secure boot support.
> > The following are my questions and solutions
> >
> >   1.  There was a socsec-sign.bbclass in OpenBMC and it is used for SPL 
> > image generation with SOCSEC tool. Do you agree if I modify 
> > socsec-sign.bbclass to create OTP image?
> 
> I'm not convinced on this one. While the OTP configuration and the 
> output of the socsec signing process are tightly coupled they involve 
> separate processes. Off the top of my head, the fact that socsec and 
> otptool are separate utilities suggests to me that they should use 
> separate bbclasses in the build process.
> 
> >
> > If no, I will try to use solution 2.
> >
> 
> This is the path you should follow - I have some comments below.
> 
> >
> >
> >   1.  I will create a new recipe to create OTP image and this recipe 
> > will be placed in meta-aspeed/recipes-aspeed/otp/otp.bb
> 
> Okay.
> 
> >
> > To successfully build the OTP and SPL images, we should create the 
> > key-pair one for OTP(public key) and another for SPL(private key).
> >
> > Do you have any suggestion to place these keys in where?
> >
> >   1.  So far, we placed both private key and public keys here, 
> > https://github.com/openbmc/openbmc/tree/master/meta-aspeed/recipes-bsp/u-boot/files
> >
> > How to get the public key in OTP recipe? It seems I need to place 
> > public key, 
> > https://github.com/openbmc/openbmc/blob/master/meta-aspeed/recipes-bsp/u-boot/files/rsa_pub_oem_dss_key.pem
> >
> > in meta-aspeed/recipes-aspeed/otp/files and private key in u-boot, 
> > https://github.com/openbmc/openbmc/blob/master/meta-aspeed/recipes-bsp/u-boot/files/rsa_oem_dss_key.pem
> 
> We might need a separate recipe e.g. called 'aspeed-ast2600-rot-keys', 
> and move the files you've pointed to above into that recipe. From there 
> both the OTP and u-boot recipes can depend on 'aspeed-ast2600-rot-keys' 
> to gain access to the files.
> 
> >
> >   1.  The socsec tool settings should be consistent. For example: If 
> > user set the algorithm "RSA4096_SHA512" in SPL, it is required to use 
> > the corresponding *.json config in OTP.
> >
> > https://github.com/openbmc/openbmc/blob/master/meta-aspeed/classes/socsec-sign.bbclass#L8
> 
> Yes, but maybe this creates too many headaches to enforce? We'd have to 
> parse the json and line it up with SOCSEC_SIGN_ALGO in the recipe. It 
> seems much easier if we just do a `socsec verify ...` once we've 
> generated all the artefacts, feeding in the OTP image we've also built 
> through the otptool bbclass. If the verification fails then the build 
> fails and someone can look at what happened.
> 
> >
> > By default, it set SOCSEC_SIGN_ALGO ?= "RSA4096_SHA512" to create SPL, 
> > it is required to use 
> > https://github.com/AspeedTech-BMC/openbmc/blob/aspeed-master/meta-aspeed-sdk/recipes-aspeed/security/aspeed-secure-config/configs/ast2600/security/otp/evbA3_RSA4096_SHA512.json 
> > for OTP image generation.
> 
> This isn't true. How I want this to work is that each platform provides 
> its own OTP json configuration, and the otptool bbclass consumes that 
> to produce the OTP image.
> 
> Platform designers should have the freedom to pick their own 
> platform-specific OTP settings with respect to e.g. the ABR, boot 
> source fallback, secureboot etc features. There's no point generating 
> the cartesian product of configurations out of the box, it would just 
> be confusing and a *huge* amount of noise.
> 
> I've cooked up a platform-specific config for our p10bmc systems for 
> instance, and was planning on integrating that into the OpenBMC tree.
> 
> >
> >   How to share the environment variable between u-boot and otp recipes?
> >
> >   Do you prefer to add "SOCSEC_SIGN_ALGO" in machine configuration 
> > file, so this variable can be recognized between otp and u-boot recipes.
> >
> >   Do you have any suggestion?
> 
> It should be set by the platform config and so should be available to 
> any recipe executed in the build process, included e.g. an otptool 
> recipe. Platform bitbake configs shouldn't rely on any particular 
> default value being set in socsec-sign bbclass for SOCSEC_SIGN_ALGO (we 
> might change the default in the future - then any platforms relying on 
> a particular default value would break).
> 
> >
> >   1.  How to trigger the build process to build create OTP image if 
> > user only issues "bitbake obmc-phosphor-image"?
> >
> > https://github.com/AspeedTech-BMC/openbmc/blob/aspeed-master/meta-aspeed-sdk/classes/image_types_phosphor_aspeed.bbclass#L84
> >
> > Our solution set the do_generate_static_tar task dependencies. So, 
> > build process create the otp image first, then run 
> > do_generate_static_tar task.
> 
> You probably want to add it as a dependency of u-boot. This way the 
> socsec-sign bbclass can implement the functionality to run `socsec 
> verify ...` with the OTP blob as its last step, triggered from the 
> u-boot recipe.
> 
> >
> > Do you have any suggestion? Do I need to modify this bbclass, 
> > https://github.com/openbmc/openbmc/blob/master/meta-phosphor/classes/image_types_phosphor.bbclass 
> 
> No, I don't expect so.
> 
> Andrew

Hi Andrew
Thanks for all your suggestions and review.
I created two patches and waiting for review.
Thanks-Jamin


      reply	other threads:[~2021-12-17  8:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-16  6:41 Create AST2600 OTP image Jamin Lin
2021-12-16  9:23 ` Jamin Lin
2021-12-16 22:43 ` Andrew Jeffery
2021-12-17  8:06   ` Jamin Lin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211217080601.GA4293@aspeedtech.com \
    --to=jamin_lin@aspeedtech.com \
    --cc=andrew@aj.id.au \
    --cc=openbmc@lists.ozlabs.org \
    --cc=steven_lee@aspeedtech.com \
    --cc=troy_lee@aspeedtech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.