Open cfrantz opened 1 year ago
This is great.
Does this proposal need to consider access controls to a given keyset as well, or is that orthogonal (or somehow implied by location == "offline"
)?
At the risk of stating something that is probably really obvious to everyone - we want signing anything with PROD keys to be a significant choice and not one that can easily be triggered by a typo / wrong-argument (or likely automated at all, in all honesty).
DEV and TEST keys I am far less concerned about, though we might have to have some access controls there ultimately as well.
Access control to key material is implied by location = "offline"
.
Any user can attempt to sign with offline keys, but unless that user has a token and the unlock credentials for that token, such signing is impossible -- they will only ever get as far as generating the pre-signing artifacts.
Thanks for the extra info. That all sounds like best practices to me.
@cfrantz anything to update here?
I'd like to address this as part of the current build rules refactoring and SiVal enablement.
Ok triaging into SV0. Please move to another SV milestone as appropriate.
Description
Introduction
Currently, we have a number of private keys present in the codebase for the
earlgrey
product under//sw/device/silicon_creator/rom/keys/fake
. These keys are used by thesign_bin
rule (//rules:opentitan.bzl`) to apply RSA signatures to firmware images.Soon, we will need to generate the real
earlgrey
product keys in an HSM and import the public components of those keys into the codebase. Part of the key generation process will be to initialize personal security tokens (e.g. Nitrokey or Yubikey) that hold the less privileged DEV and TEST keys, thus allowing developers to unilaterally sign firmware for DEV and TEST devices. Such signing will be required in order to run test code on sample silicon (ie: the so-called "fake keys" will no longer work).In order to facilitate automated build and test flows, we'll need to have a better management strategy for the keys than "a bunch of files on disk". I'm assuming that we'll want building test code for silicon to be no more complicated than "insert your signing token into the usb port and type
bazel build //the/target
.Background
Keys stored in an HSM are accessed and wielded via their HSM label. Signing a firmware image generally consists of 4 steps:
Proposal
In order to make this process easy, we should always refer to keys by a nickname. The nickname refers to the public component of the key during the preparation step and refers to the HSM resource during the signing step. I'd suggest that the nickname should be the same as the HSM label; I think the existing key names like
test_key_0
(etc) are perfectly good nicknames.We should group these keys together into a
keyset
that encapsulates the properties of a group of keys together. I've been thinking about something like this:When we want to sign something, we'll give the keyset name and key nickname to the
sign_bin
rule. To maintain compatibility with existing bazel infrastructure, thesign_bin
rule will also accept a private key file and key nickname.The
opentitan_flash_binary
rule currently accepts a dict of key nicknames to key files. This can easily be changed to a dict of key nicnames to keyset names.The main advantage of migrating to using keysets is that the keyset carries with it the tooling information to perform the signing. The signing rules can use that information to invoke the correct tool to perform the signing operation (ie: opentitantool for fake keys, hsmtool for keys held in HSMs or tokens).
To discuss
fake_test_key_0
vstest_key_0
?)earlgrey
) into the filename transformation?