the key setup seems to work correctly
but the data ACL setting doesn't "stick". The region
could be write-protected by some other element in the
CP/IFR config, need to dig a lot more. For now we need
to move on and crank out something to stick on the alpha
dabao boards...
this code audits the status of the data/key slots,
initializes them according to the platform, and sets
the permissions on them to prevent read-out later on.
A TRNG routine is built into boot1 now, I think it's
reasonably conservatively coded but more testing/inspection
is always good.
Not locking them down in boot0: allowing them to be set up
in boot1. this is less hermetic, but already I have thought
of a couple of reasons to modify the tables; for example,
the dabao configuraiton if someone wanted to make a secured
version, you might not want PID 3 to be the trusted PID;
or if you wanted to have two different sets of keys for
different purposes, you can use the other permission levels
to separate them.
So, leaving it configurable. for now.
add read/write specs as well to the slot definitions.
Not terribly happy with how this all worked out. The subtle
differences between Data and Keys is really irritating.
it's the sort of thing you would say "let's make a trait"
for it but then the two behave just differently enough
that I worry I can't make a trait generic enough to encompass
all the weird stuff that exists in the hardware.
The existing implementation definitely looks like trait
territory, but it currently hides the subtleties around
key/data chaining and secure crypto engine handling of
the two regions as distinct entities. so long as we don't
plan to use those things, traits are a good idea, but
i don't feel like I can reject using the crypto engine
features out of hand this early on just to make the
APIs nice and square.
I think it belongs here, because this "should" be a "baked in"
setting. Maybe I'll regret that, because it really enforces
a hardware one-way door on changing/updating the coreuser maps,
but also, I think it makes it a bit stronger if there is no
easy way to bypass/override that setting.
'coreuser' is a slightly confusing term from the hardware
system because it's overloaded to mean some conceptually
related items that aren't implementation-wise essentially linked.
coreuser defines both some access protections on the main
array of the RRAM, and also some access protections on key
and data slots.
this patch includes some code that sets up the coreuser
functionality to a very simple scheme where just one PID
is trusted and the rest are not trusted. More complicated
schemes could be introduced with varying levels of trust
and dependencies but I like the analytical simplicity of
two states, so let's start there and complicate only when
absolutely necessary.
Data and key slots are hardware access-controlled areas that
can store sensitive data. Slot definitions come with a "spec"
field that defines what the access controls *should* be,
so that we can check them later.
In practice no user code should be manipulating these, but
there is an initial stage where a totally blank device needs
to be provisioned, hence the focus on correct specification
and checking of state, rather than convenient runtime manipulation
and update of the same.
on dabao targets the duart is unavailable, so, it's convenient to
have a uart-based debug option in the HAL. this patch creates a
flag that can allow either target.
- add range checking to control access to main array or secure
array. This is purely a software enforced check, but it is in
theory backed by hardware gating that is a back stop in case
an adversary can gain arbitrary code access
- rework the rram primitive to return an error type
- add a `std` implementation stub. It is still missing an IRQ
context handler which ensures that all RRAM writes are atomic,
e.g. you can't take an interrupt in the middle of an RRAM
write because it would screw up the buffer staging.
this does not seem to have a large effect on update times and
allows us to operate over more platform configurations absent
specific power-on control code