Commit graph

50 commits

Author SHA1 Message Date
bunnie
1a43540037
minor improvements across boot0 flow
- improve bollards to include "die" jumps where appropriate
- cleanup warnings in unsafe-dev feature
- panic handler calls die repeatedly
- upgrade jump api
2026-02-15 03:34:35 +08:00
bunnie
59bd74a01c
panic directly on illegal instruction
the original stub for illegal instruction handling advances
the program counter - this was copypasta from the kernel
irq routine, where this behavior is needed to handle syscalls.

However, this behavior is contra-indicated for the purpose
of dying on a bollard - you don't want to skip past the
bollard for any reason.
2026-02-15 03:29:50 +08:00
bunnie
f462e3dc3c repl code in boot0 is not used in production
strip out old stuff that doesn't work anymore -- eventually this
code may be entirely struck since it's not even been compiled
for many months.
2026-02-15 03:28:50 +08:00
bunnie
a2330e8911
add optionality to turn on clock skipping manually
this is off by default, because it doesn't seem to be entirely
stable. For now, the default configuration when it is turned on,
only activates it for the PKE block. When the CPU block clock
skipping is enabled, instability is occasionally observed.
2026-02-10 22:56:14 +08:00
bunnie
0bb693449b
boot0 improvements
- rcrr register multiply-written on boot to glitch harden
the register. I only realize now that the top-line ECO had
an asterisk on it which means that setting the register is
still critical
- correctness comparison of boot1 keys to IFR copy introduced
this is yet another check to prevent tampering with the key block.
2026-02-08 12:47:09 +08:00
bunnie
56c1230b2e add error printing on boot0 signature failure
this will at least give us a hint as to why a boot1 failed to
boot. It does hand an attacker some information, but we also
need information to debug e.g. RMA and field failures.
2026-02-03 03:23:07 +08:00
bunnie
3f869ca389 bump utralib version for publication 2026-01-29 19:12:00 +08:00
bunnie
dce0bac16e add receipt processing to boot0 2026-01-22 23:17:26 +08:00
bunnie
24c76b077e
update boot0 to implement collateral protocol
this also makes boot0 erase secret keys in the case that the
signing public keys on boot0 or boot1 don't match the indelible
values expected in IFR.
2026-01-18 02:54:08 +08:00
bunnie
fba011db3a commit version bump so that we may publish our packages 2026-01-08 03:04:19 +08:00
bunnie
544a0368fc setup the security dependency to pull in sigcheck in crates that use it 2025-12-22 16:18:21 +08:00
bunnie
0c18c62d0a move the key consistency check to a library
this allows us to refer to it in boot1 if we eventually decide
it's useful to do it there.

however, as a matter of policy, boot1 checks loader signatures
against *boot1*'s public key block - so if the loader is to be
signed with a different key, boot1 needs to be updated.
2025-12-19 16:06:50 +08:00
bunnie
2a70991d96
remove superfluous prints in boot0
removing prints in boot0 gives less handle for glitchers to time
off of. Also makes debugging chips harder, but I think the boot0
is starting to get stable enough that this is OK?

also removed the frac-PLL setting because it's broken. this causes
the PLL in the boot0 to be subtly different from boot1, and I
think I like it - it makes the timing of glitches between the
two phases different.
2025-12-19 03:30:56 +08:00
bunnie
0c690d8be4
add boot1 pubkey integrity checking
this should erase the secret keys if the boot1 pubkeys don't match

this enables OEM-signed boot1 images. the policy is that all OEM
images signed by baochip are considered to be untrusted, and thus
loading them onto a device would wipe any secret keys, making
them less useful for extracting secrets.

There are 2048 keys and about 500 keys are used by baochip,
so there are still plenty of keyslots available for OEMs to
use to implement their own version of security.
2025-12-19 01:14:51 +08:00
bunnie
d874c3e5c2 commit for version bump 2025-12-16 02:02:37 +08:00
bunnie
fb7da782cf cleanup perclk setting on boot0 2025-12-16 00:56:10 +08:00
bunnie
41d09786ae tighten up clock gates in boot0
confirmed that these settings do not affect the glitch sensors.
2025-12-08 16:54:23 +08:00
bunnie
c85425ae91
add dynamic glitch response via IRQs
non-paranoid mode responses happen through IRQs (recall that
paranoid mode is a hair-trigger hardware reset with no
exceptions). This patch installs the IRQ handlers in boot0
and boot1.

- boot0 in particular now even has an IRQ handler. Previously,
it didn't have the IRQ facility configured, because there was no need
for one.
- boot0 sets up the sensors, and the IRQs
- boot1 merely continues with boot0's settings, but re-installing
the trap handler to be its own and double-checking some
register settings.

An old testing IRQ handler stub for keyboard presses was also removed,
as it can never be triggered as that IRQ is never set up.
2025-12-07 01:37:55 +08:00
bunnie
66272a82e4
ensure secret erasure if developer mode bit is set
this is the final part of the developer mode bit hardening.
If an adversary manages to increment the developer mode
bit, the next reboot they have to contend with active counter-
measures that would attempt to erase the secrets due to
the developer mode bit being set.

As noted in the top of the commit set, previously, without
this, the attacker would have the luxury of being able to
flip the bit and try many times to bypass the developer
mode check.
2025-12-06 18:39:58 +08:00
bunnie
006eab2084
add multi-pass validation in paranoid mode to boot0
this patch uses the previously modified APIs and implements
a multi-pass check on signatures in the case that paranoid
mode is turned on. This may effectively double the boot time but
it also reduces the chance of a successful glitch attack
on signature validation by a multiple of the glitch
success probability.

this also updates other API calls and implements the
XOR-on-target-address code.
2025-12-05 23:12:15 +08:00
bunnie
ae120c7632
add a known answer test after loading hash constants
This test helps ensure that attempts to tamper with the
hasher constant loading don't propagate through to actual
usages of the hasher.
2025-12-05 23:10:22 +08:00
bunnie
1c210b3541
other boot0 hardening
- harden the check that the boot0 public keys match those in the
data array
- security mesh setup
- insertion of random delays & bollards
- upgrade API on signature verification to allow for random delays
during the signature check
2025-12-04 15:28:52 +08:00
bunnie
b00acba907
boot0 platform hardening
- paranoid mode entry is implemented here. The main outcome of
paranoid mode is that when activated, the system will automatically
reset anytime a voltage glitch is detected.

- clean up PLL mode setting. For boot0, the mode is fixed & hardened
to 175MHz CPU operation, running off the PLL, under the theory that
running at this speed makes glitch attacks harder as the cycle time
is now 5.71ns, and simply disturbing the XTAL clock doesn't cause
the PLL to straight-up stop.

- some hardening to ensure that we are actually in PLL mode, and
that the switch to PLL mode wasn't glitched over
2025-12-04 15:15:16 +08:00
bunnie
d8aa8cddd7
harden boot0
- setup rram security bits immediately
- setup coreuser mapping immediately
- check boot0 pubkey region against data slots, and note if
issues are found (and erase keys)
2025-10-28 03:39:20 +08:00
bunnie
fb3c89949c fix boot delay calibrations 2025-10-27 19:07:33 +08:00
bunnie
2f957d3f35 improve error messages 2025-10-26 19:30:18 +08:00
bunnie
2be1b48653 fix import path 2025-10-25 01:38:55 +08:00
bunnie
04d46b9549 update location of system timer interval definition 2025-10-24 21:12:00 +08:00
bunnie
1eeaa23516
Realizing that the permission level settings could change
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.
2025-10-20 23:36:34 +08:00
bunnie
356ab47c3c
add coreuser table setup to boot0
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.
2025-10-20 02:18:28 +08:00
bunnie
92a3b05627 reduce boot freq / voltage even lower
this allows boot on extremely "weak" systems where very little
power is available.
2025-10-19 01:02:43 +08:00
bunnie
b864445dff version generators should not be checked in 2025-10-19 01:02:20 +08:00
bunnie
a5704d292d
Merge branch 'main' into protected-rram 2025-10-18 01:19:50 +08:00
bunnie
201c143762
Merge pull request #701 from betrusted-io/db-selfstest
Add selftest feature for dabao
2025-10-18 01:19:37 +08:00
bunnie
464d26e7b0 adjust default voltages & freqs to be in-line with validation numbers 2025-10-18 01:15:52 +08:00
bunnie
59c3ca5c7e
Merge branch 'main' into protected-rram 2025-10-16 23:39:35 +08:00
bunnie
36b1868fc4 add ram zeorization to top of boot
this slows down boot a little bit but I think this is a good
idea from a security perspective.
2025-10-16 23:37:35 +08:00
bunnie
0bd4de961a I think I won't regret putting a semver into the boot0 stage too
Even though boot0 DUART output may be inaccessible, the string
could still be found by looking in the binary and searching
for it.
2025-10-16 23:25:44 +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
2fb72be487 update signature check api in boot0/boot1
pass `None` for the spim field as these are direct RRAM checks.
2025-10-04 18:53:13 +08:00
bunnie
a6769c46ba track change in statics struct 2025-09-30 21:51:28 +08:00
bunnie
6b8d8f09f7 cleanup functional code specifiers for boot partitions 2025-09-29 22:17:38 +08:00
bunnie
54b16cdf64 fix public key origin for signature checks
in general the public key should come from a trusted block, not
the image itself. The initial prototype of the image was written
for self-checking of boot0; but for other images, the public key
should "chain" from the trusted image (i.e. boot0's key should check
boot1, boot1's key should check baremetal/loader, etc.)
2025-09-29 16:18:21 +08:00
bunnie
59ae767741 fix statics origin in boot0 2025-09-29 14:48:48 +08:00
bunnie
8cbdb75dc8 cleanup boot0 code
remove things that we don't need in boot0. Boot0 originated from
a much larger, more featureful space and needs to be whittled down
to remove attack surface and space for bugs.

Some further cleanup to do would include:

- hardening the PLL setting. Right now it's done computationally
based on the demanded frequency. But in practice, because the
target frequency is hard-coded, we could just compute the actual PLL value
results and jam them into the register and lose a whole bunch of
code.

Actually I think that's all that needs to be cleaned up off the
top of my head.
2025-09-29 13:46:42 +08:00
bunnie
63e2834e9d return the key index that passed from sigcheck 2025-09-27 00:31:24 +08:00
bunnie
f76b85c95e signature checking now works
also some light benchmarking code.
2025-09-26 22:56:49 +08:00
bunnie
a035bb669c add initial signature check code on bao1x 2025-09-25 16:13:09 +08:00
bunnie
c1ab8972fa update boot offsets to handle embedded signature block 2025-09-25 00:00:13 +08:00
bunnie
39142b4c18 add scaffolding for bao1x-boot and also the sha2 implementation for baremetal 2025-09-24 01:02:07 +08:00