Commit graph

793 commits

Author SHA1 Message Date
bunnie
4e522873f0 add preemptionstate opcode to the hal api 2025-10-26 13:38:28 +08:00
bunnie
1c435909a2
fix the sense of the access permission bits
I had read the docs as saying 1 is denied access, but in fact,
1 is allowed access, at least empirically.
2025-10-26 01:55:27 +08:00
bunnie
bce08a1d27 clarify comments on coreuser protection 2025-10-26 01:46:57 +08:00
bunnie
0a1813b28c fix off by one in assert statement 2025-10-25 21:37:19 +08:00
bunnie
d11d2f8cd5 modify default voltages; normalize the setting location 2025-10-25 01:37:21 +08:00
bunnie
c92af3c25a fix up pin mappings for v2 board release 2025-10-25 01:30:58 +08:00
bunnie
d44f489a83 map out PID 0's access in going to secure mode 2025-10-24 21:16:00 +08:00
bunnie
04d46b9549 update location of system timer interval definition 2025-10-24 21:12:00 +08:00
bunnie
caf6fc3a61
Implement erase_secrets() on entry into developer mode 2025-10-21 23:46:06 +08:00
bunnie
391af0313f
fix typo 2025-10-21 19:15:22 +08:00
bunnie
917154ae74
fixup coreuser settings
the more i test things the less confidence i have.

this fixes up a missing table entry in the table definition,
and then also adds a bypass routine - this is not actually
a hidden vulnerability, it's an explicit vulnerability until
the protect() routine is called. But it looks like we may have
to exploit it in order to transform our userstate in
the bootloader to one that has write-access to keys in order
to erase them in case of a developer boot.
2025-10-21 19:12:30 +08:00
bunnie
be038e56aa
cleanup comments
figured out why the data region acl wouldn't write - had
to be in boot0 declared mode
2025-10-21 19:11:52 +08:00
bunnie
e3140609e4
designate the eraseable keys
only some keys are marked as writeable to harden against
potential oracle attacks, i.e., if we made all keys
erasable and an oracle attack was found, then the entire
key region can be exposed by the oracle attack.

Instead, some key material always persists, but a sufficiently
large amount of seed material is erased such that the key is not
recoverable by guessing the key.
2025-10-21 19:08:35 +08:00
bunnie
3e4b0b6571
Add bao2 signing keys 2025-10-21 02:39:11 +08:00
bunnie
2559ddd02d
stash state on some issues in ACL setup
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...
2025-10-21 02:19:40 +08:00
bunnie
2095acfe13
slot manager debug.
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.
2025-10-20 23:32:29 +08:00
bunnie
5c60de32ce
debug the slot manager and rram APIs 2025-10-20 23:31:01 +08:00
bunnie
0943b67972
implementation of the ACL APIs and coreuser functionality
'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.
2025-10-20 02:15:20 +08:00
bunnie
a64337679f
Add API for defining key/data slots, and initial ranges for the same
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.
2025-10-20 02:07:19 +08:00
bunnie
8f208cac4c
refactor debug-print in bao1x-hal
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.
2025-10-19 01:19:30 +08:00
bunnie
fe4ef1bc39
refactor rram API
- 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.
2025-10-19 01:09:58 +08:00
bunnie
951f088625
add coreuser templates
coreuser is the signal that sets the security level of the system
2025-10-19 01:09:15 +08:00
bunnie
39ceef55f3
Add protected-rram module
this lays the foundation for access control, data slots,
key slots, etc.
2025-10-19 01:07:44 +08:00
bunnie
b59bff2223 cleanup/redefine keyslot regions 2025-10-19 01:06:54 +08:00
bunnie
a40bb7c244 other half of the adjustment 2025-10-18 01:16:16 +08:00
bunnie
3b4e035a4f
revise auth_data handling for key header block
auth_data actually changes with each signing operation (ostensibly
to prevent replay of signatures coming from tokens) so it has
to be presented as data parallel to the signature, instead of
as a static filed baked into the key header.

This commit revises the header record to reflect this organizatio
of data and also revises the signature check to be in-line
with the protocol.
2025-10-06 23:31:02 +08:00
bunnie
7d6630b7ec fix one way counter offset calculations 2025-10-06 23:24:42 +08:00
bunnie
03ea3c9d0c changes to the apis to accommodate the public key record format 2025-10-06 15:20:34 +08:00
bunnie
a1a5ff1592 add public key templates
Beta/developer keys are fully filled out.

Placeholders for production signing keys are also provided.
2025-10-06 15:19:19 +08:00
bunnie
3c68eea714
Merge branch 'main' into signing 2025-10-06 13:45:29 +08:00
bunnie
dbb0a75118 bump versions
have to absorb a version change due to xous-semver change

might as well also update the utra/svd generator dependencies
since that's been held off for a long time now.
2025-10-06 13:23:18 +08:00
bunnie
69d81042b9 upgrade signature check to handle domain separation data
this is needed to handle the fido2/webauthn style signatures
2025-10-06 03:49:11 +08:00
bunnie
95f192ca38 add dabao target 2025-10-05 17:15:05 +08:00
bunnie
01a78e4474 fixup app region start and add freq/voltage configs for board targets
this is the agnostic version of all of the board targets, which
allows the boot1 to lookup based on the current configuration
which configurations to apply.

I think I've talked myself into giving away $0.20 of parts with
every dabao board so that everyone can run at full frequency.
Originally I thought I'd limit to the minimal configuration with
low frequency operation but since this is the main developer
platform all the benchmarks and first impressions will come
through this board. Crippling it with a slower clock frequency
by omitting the supplementary digital regulator seems
short-sighted, even if it means up slightly subsidizing things
with this extra cost.
2025-10-05 17:12:40 +08:00
bunnie
c6fb0565ff add frequency/voltage exports from api into the hal
also cleanup some small debug messages
2025-10-05 17:12:04 +08:00
bunnie
2f5af89547 make the swap header length explicitly controlled
previously it was just "4096" in the image writer
2025-10-04 18:52:30 +08:00
bunnie
c86844a39a make signatureinflash structure data
this cleans up one unsafe step where we have to assume an
alignment of the data at the cost of the structure being copied
to stack. I think this is a fine trade-off.
2025-10-04 18:51:34 +08:00
bunnie
b91d54c5cf add SPIM optional target for signature checking
this allows us to check the signature on stuff in off-chip swap
memory through the SPI interface.
2025-10-04 18:50:49 +08:00
bunnie
7f9b783027 mirror board constants from API; make SPIM channel a const
this implements the API/HAL split on the HAL side, and also
reveals SPIM channel as a constant that can be just read out
so that spim accessors that need to build from raw parts
can do it without having to re-allocate IOs.
2025-10-04 00:53:22 +08:00
bunnie
869da85ef7 add swap descriptors as structures; add offsets for boards
In the API layer, the boards aren't setup with convenience flags.
they are all laid out and the caller needs to know which board
it's trying to resolve. This is because the API layer is agnostic
to board and assumes the tool working with it knows what board
it's working with already.

The HAL layer tries to hide the board-specific stuff, and so
API defines are re-imported there in a board-transparent fashion.

Also add swap descriptors to the API crate, so that the image
generation tools can refer to the exact same structures as
are used inside the code, simplifying image creation maintenance.
2025-10-04 00:51:25 +08:00
bunnie
07e7197517 upgrade the sigcheck boot routine to pass kernel arguments
all other boot modes would get an a0 with the address that the
kernel is "supposed" to be located. this is neither security
sensitive or problematic.
2025-10-01 23:36:14 +08:00
bunnie
ec9aed29dd fix kernel offset so signature doesn't shift the image
the image needs to be page-aligned so it can do direct-map
to memory.
2025-10-01 23:35:24 +08:00
bunnie
e77d412bad extract the peripheral reset line 2025-10-01 14:29:04 +08:00
bunnie
346d7cd4d4 indicate the space for the marquee line on the boot logo 2025-10-01 14:28:45 +08:00
bunnie
03744c2dca ops are no-std stafe 2025-10-01 14:28:13 +08:00
bunnie
2eaaa99f6e fix kernel config conflict
no signature checking is necessary in the kernel so don't
introduce the dependencies
2025-10-01 02:57:55 +08:00
bunnie
cdb60eed0f update the static table definition 2025-09-30 21:52:45 +08:00
bunnie
dec6c1944b add overflow handler to big reads (to fake big disks) 2025-09-30 17:28:42 +08:00
bunnie
cade3980cc fix double-offset error in oneway counter readback 2025-09-30 00:37:57 +08:00
bunnie
15562abf00 add functional code slice
this puts a domain separator in every signature block
a domain separator meaning, even though the same private key
maybe be used to sign multiple blocks, because a functional code
is embedded in the block that is tied to the block's function, you
can't take a pre-signed block and shove it into another block's slot
and expect it to work.
2025-09-29 22:17:56 +08:00