Commit graph

4007 commits

Author SHA1 Message Date
bunnie
c1ae6b2e5f add more dependencies to propagate key-testing flag 2026-02-04 15:57:59 +08:00
bunnie
0aeb9daa37 add a method to force-rewrite keys
This is useful in CI to test various stages of dev-key signed
image vs secret key erase without having to go through a complete
suicide cycle on the chip.

This command is gated behind a feature flag that would only be
invoked for beta testing. I think it's still safe to have even
as a beta-signed feature because the worst you can do with this
is replace existing keys - so it could be used to DoS/brick, but not
leak secrets.
2026-02-04 15:55:34 +08:00
bunnie
e349703fd5 automatically adjust BIO clock dividers on sleep
this allows the BIO to continue to function even though
the CPU core is in WFI. It isn't running at full speed, but
for some applications (such as WS2812 LED driving) the lower
speed is perfectly adequate and you save a lot of power
by turning off the CPU core.
2026-02-02 23:37:48 +08:00
bunnie
7d7ddae73e pin the irq handler object for the iox banks 2026-02-02 01:29:19 +08:00
bunnie
0f19750831 remove autodrop on other hal service items 2026-02-02 01:28:32 +08:00
bunnie
2005293e11 remove autodrop on trng service 2026-02-02 01:28:15 +08:00
bunnie
70639470bf cleanup an unecessary static mut and make it an Atomic 2026-02-02 01:26:42 +08:00
bunnie
54c070b433 remove old comment that is no longer valid 2026-02-02 01:26:25 +08:00
bunnie
b1121daef6 security-relevant: modify collateral test to not panic on failure
The panic on failure causes incompatibility with older boot0's
that don't set up the collateral area correctly.

Make the failure more graceful, but we also promise ourselves
to add CI tests to check for this explicitly, because we can't
just rely on panics to enforce behavior.
2026-01-30 04:01:09 +08:00
bunnie
3f869ca389 bump utralib version for publication 2026-01-29 19:12:00 +08:00
bunnie
ca630c6472 add maintenance comment on USB driver 2026-01-29 18:59:29 +08:00
bunnie
88ccc7e042 fully specify the bao1x target on blitstr2 for bao1x builds 2026-01-29 18:58:55 +08:00
bunnie
b0adea6c6a fix hosted mode regression 2026-01-29 00:28:42 +08:00
bunnie
2805f7a14a fix deadlock on boot issue
io need to be active early on to get clocks to function on baosec
putting that in its own thread fixes the issue.
2026-01-29 00:09:10 +08:00
bunnie
1d3f264be4 fix hosted mode regression 2026-01-29 00:08:56 +08:00
bunnie
b2cf705c59 bump ticktimer version to drop susres dependency 2026-01-28 20:53:57 +08:00
bunnie
dc56fc7a09 fix precursor builds 2026-01-28 15:44:18 +08:00
bunnie
3bc1c23425 add missing feature flag 2026-01-28 15:31:22 +08:00
bunnie
c2640458f5 fix hosted mode and warnings 2026-01-28 15:21:39 +08:00
bunnie
3b0edbb442 add some more test routines - some of these will be culled shortly 2026-01-28 15:09:52 +08:00
bunnie
22c8ce4308 fix dangling susres api migration 2026-01-28 15:09:08 +08:00
bunnie
3e4cbe441f add apis to access clock state via the susres manager
this requires a PlatformSpecific extension to the
susres API.

In addition to that, a DeepSleep op is added so we're
no longer overloading the meaning of the SuspendRequest
operation.
2026-01-28 15:07:22 +08:00
bunnie
6ae6b22ff3 more cleanup from susres localization 2026-01-28 15:03:40 +08:00
bunnie
45632385d5 downgrade susres to a common api
doesn't make sense to push this to crates.io because it's not
common across all platforms, I think.
2026-01-28 00:36:05 +08:00
bunnie
5a3319ae57 optimize camera frame rate
it's now around 30Hz.
2026-01-27 22:06:18 +08:00
bunnie
8b06b212bb add oem-baosec-lite support to usb driver
there is currently no method to detect USB power connect
in this board. Considering adding a simple circuit to enable
this. This design is not meant to be battery powered but
it is possible that an aftermarket modification would introduce
a battery, in which case, vbus detection does become A Thing.
2026-01-24 23:54:21 +08:00
bunnie
bcf73733c3 oem-baosec-lite support in hal-service
this one is a little bit tricky. The lite version of baosec
forgoes the off-chip TRNG to save cost. Thus, there is an
"anti-feature" in the configuration, and so in this case
the dabao version of the server has to be selected despite
the baosec flag.
2026-01-24 23:52:37 +08:00
bunnie
e329ebeb1d oem-baosec-lite support to bao-video
remap pwm lock output. This reduces power consumption in
camera mode by removing an I/O conflict with the keyboard
scanner.
2026-01-24 23:51:22 +08:00
bunnie
10ef6bda02
add information about root key seed to regular sign_image
Three pieces of inforation are leaked about the root seed:

- whether or not the first 64 bits are all 0
- whether or not the first 64 bits are all 3's
- whether if none of the above are true

It's fairly indirect leakage, and I think it is a relatively
minor price to pay for the confidence it gives that some underlying
library behavior didn't accidentally lead to faulty keygen.

Note that these 64 bits are 64 bits out of tens of thousands
of bits that go into the keygen, because the nuisance keys
and the chaff key are all blended together to create the final
derived root key. Thus the security margin on the key is quite
large and even a full disclosure of these 64-bits is a minor
impact on overall security.
2026-01-18 20:52:51 +08:00
bunnie
cc00201774 add collateral erasure check to keystore
in no case should any baochip firmware be holding secret
collateral used by third party firmwares, thus a non-erased
state is a panic
2026-01-18 02:58:32 +08:00
bunnie
f6c7d9c89e enable USB console by default
this helps with production & ci
2026-01-17 16:23:53 +08:00
bunnie
4c3d2f677c fix hosted mode 2026-01-16 17:52:00 +08:00
bunnie
5a73d17a0a handle the no-arg case correctly 2026-01-16 17:40:17 +08:00
bunnie
2a7cffb86e add bootwait command line API to test
also refactor the test argument parsing so that i can use the
more modern version of the api
2026-01-16 17:35:41 +08:00
bunnie
2b19c4bd21 add a command for setting the bootwait flag
The keystore is a sensitive server, and the one-way counters
have security-critical propoerties. So instead of revealing a
generic one-way counter API to the world, specific, limited
requests to do things are going to be created for the keystore.

In this case, the bootwait flag would be convenient to be able
to set from userspace. The motivation for this requirement is
actually continuous integration - a normal human could just
hold down a button while turning on power, but in CI, I don't
have a robotic thumb (or an alternative electrical signal) to
simulate the nerve-pinch on boot.

Previously I was "cheating" and simulating this by nuking the
loader, which effectively forces a bootwait.

However, in production, this is *not possible* because the JTAG
port is sealed off. Thus, this may be the first of a series
of small PRs to incorporate CI tooling that clears up tech
debt like nuking the loader to get into boot wait.
2026-01-16 17:32:12 +08:00
bunnie
533607b9ec gdb-stub: disable userspace console
The serial port going to the userspace console is disabled to allow
for gdb access to the kernel.
2026-01-14 03:13:39 +08:00
bunnie
fba011db3a commit version bump so that we may publish our packages 2026-01-08 03:04:19 +08:00
bunnie
42e96d723a hook the debug info output in the "test" command
this command and its dependencies will probably be stripped out
or modified for production, so i think this is a good place to hang
these.
2026-01-08 03:02:04 +08:00
bunnie
e27b30d818 fix edge case in swapper
A particular edge case was finally reproduced & fixed. The edge
case occurs when a swap is triggered while handling an interrupt,
and an OOM happens during the context switch to/from the interrupt.

The background on this is that the hardware drivers for the swapper,
as well as much of the logical heavy lifting on e.g. what pages to
swap out, live in a userspace process known as xous-swapper.

The userspace process has to run free of interrupts - when you're
OOM'd or trying to swap, interrupts should not happen. The way to
do this in Xous is to run that code inside an interurpt context,
as interrupts are not interruptable.

Thus, the xous swapper userspace consists of two halves: a regular
userspace stub that provides some amount of control/debug over
the swapper, and a handler that gets run in a "pseudo-interrupt"
context.

Like all other interrupts, the handler "borrows" the stack of the currently
running thread - interrupt contexts don't have an explicit stack, they
just grow on top of the current stack of the current thread in the
current process at the time of the interrupt.

This is broken because when you have a swap event inside an interrupt
context, there are conditions where you might not have a stack. What
was in fact happening is that the stack pointer was being orphaned
as being the "exception stack" - which is a temporary location,
only accessible by the kernel, used for storing all the registers
going into and out of exceptions. Since no stack pointer is set up,
the moment the userspace starts to run and spill its registers to
stack, the system trips a "nested swap" event, which leads to a panic
because this is not allowed.

The fix to this is to devote two hard-wired pages, mapped in the
loader, to be the swapper's private stack area. Instead of behaving
like an interrupt and borrowing the caller's stack, the swapper instead
goes back to its hard-wired stack to do all the processing.

This should also improve the performance of swap handling in some
cases because we can now guarantee the stack is always in-memory
and doesn't need to be swapped in during swap processing.

One complication is that the "reserved memory" that the swapper
puts aside in case it *does* need to allocate extra pages during
handling can't be freed at the top of the OOM routine. Thus if
the swapper ends up using new pages, we should expect yet another
crash.

However, in practice, this doesn't seem to happen, because the
cases in which we hit needing a new page are typically related
to cases early on in boot where superpages/new page table entries
are being allocated, or if we're growing the heap that passes
data back and forth between swap and userspace. Because this call
triggers in such a specific condition, I hypothesize that actually
in practice it should generally be able to run without allocations.

One case where maybe it could hit an allocation is if the swapper
hit, for the first time, in an interrupt handler that was swapped
out, and never hit before, and the interrupt handler needed a
superpage to be allocated, thus triggering an allocation request
for a new PTE or two. I think this is probably pretty unlikely, but
if we do hit it, the fix would be to, for the purposes of targets
with "swap" enabled, to mark unmap_memory and map_memory to be
legal syscalls in interrupt contexts. These are normally illegal
because interrupts should always return - and these calls could
potentially fail or block. However, I think in this case it's
a trade-off between "we should be failing if we run out of memory"
and that failure being a potentially incorrect behavior that is guarded
against by a runtime check to discourage such calls.
2026-01-08 02:08:03 +08:00
bunnie
415fa27758 add a pair of swap test servers
these do nothing but allocate a bunch of memory and revisit the
allocated memory, to exercise swapping.
2026-01-08 02:02:23 +08:00
bunnie
cabfbde7f2 cleanup false positive warnings in latest rustc 2026-01-06 13:41:54 +08:00
bunnie
e676ccbed8 cleanup dead code warnings found by latest rustc 2026-01-06 13:41:04 +08:00
bunnie
e675ca231c cleanup warning 2026-01-05 22:02:54 +08:00
bunnie
92180af349 move the AV trng into the BIO subsystem
this also removes the board-specific hacks that track BIO usage
for the TRNG as set up by the loader
2026-01-05 21:54:30 +08:00
bunnie
bf78ba150f debug and implementation for composable I/O 2026-01-05 08:57:57 +08:00
bunnie
5f2cbd4ca4 quiet down debug 2026-01-02 12:26:27 +08:00
bunnie
5971187a62 add BIO services for resource tracking 2026-01-02 11:26:47 +08:00
bunnie
c7f835a93f fix xous implementation 2025-12-31 23:36:00 +08:00
bunnie
58df51ae43 bio implementation in bao1x-hal-service 2025-12-26 21:03:40 +08:00
bunnie
1c0d8eea17 update the xous API to handle bitmask-based setting of the BIO pins 2025-12-26 20:18:49 +08:00
bunnie
476f747c78 add skeletal bio service 2025-12-26 20:16:13 +08:00
bunnie
77f55941f0 cleanup import path 2025-12-24 13:17:19 +08:00
bunnie
444d7b310e re-enable keyboard bouncer inside bao-video hosted mode 2025-12-24 13:14:48 +08:00
bunnie
a313887c26 re-organize usb server so that hosted mode can be cleanly turned on 2025-12-24 13:14:11 +08:00
bunnie
0859b01071 add susres skeleton to emulator 2025-12-24 13:13:33 +08:00
bunnie
6f0a9c4275 fix keyboard scan configuration
turns out that when the keyboard is activated, *all* the keyboard
lines take over the GPIOs - and this will fight with the the doubled-up
PF7_PA2/PF8_PA1/PF9_PA0 I/Os.

Using the keyboard controller means that *all* of the PF2-PF9 pins
are now driven by the keyboard controller, regardless of the GPIO
setting.

This is because when the core is powered off, the GPIO output mappings
are lost (they are in the core domain, not always on), and the KPC
was implemented without the ability to selectively demux unused
rows/cols.

In particular on baosec this can lead to high power consumption on
the 24MHz clock when driving the camera, because the KPC fights
with the clock.

The mitigation for the current baosec hardware is to configure
the KPC such that the internal pull-up is responsible for the
"high" level, and it's only driven when "low". This reduces the
amount of fighting with the oscillator.

A future rev of hardware will move the osc to the PA3 pin, where
there is a PWM output but no muxing with the KPC, eliminating
the conflict entirely.
2025-12-23 23:36:17 +08:00
bunnie
f98dea3097 add missing dependency 2025-12-22 16:51:22 +08:00
bunnie
192a9148dc catch the deep sleep request 2025-12-22 02:11:54 +08:00
bunnie
3427c4965e note RTC todo's 2025-12-22 02:11:29 +08:00
bunnie
0487d5a2a3 add shipmode and deepsleep mode tests
- shipmode is for long-term storage. it disconnects the battery
from the system so that the shelf life can be ~years
- deep sleep effectively shuts down the system but leaves the
real time clock running. Requires a full reboot to recover
from deep sleep.
2025-12-22 02:10:26 +08:00
bunnie
2f2a1bcd23 fix version string retrieval 2025-12-19 03:23:24 +08:00
bunnie
cd075729c4 quite down a debug statement 2025-12-18 02:21:20 +08:00
bunnie
87dc26d832 update the keystore to ignore the deprecated board type checks 2025-12-18 02:20:44 +08:00
bunnie
d874c3e5c2 commit for version bump 2025-12-16 02:02:37 +08:00
bunnie
21d508f64b add susres dependency 2025-12-16 01:16:10 +08:00
bunnie
b0b72bc28b remove wfi api - using susres manager instead 2025-12-16 01:15:30 +08:00
bunnie
257bafcc5f structural rework of the main loop to allow for deferred blocking scalars
also invoke the susres thread manager
2025-12-16 01:14:45 +08:00
bunnie
8536b4fda4 rework power management scheme to use susres API 2025-12-16 01:10:30 +08:00
bunnie
b0ec2929d7 cleanup warning in rtc 2025-12-16 01:09:12 +08:00
bunnie
5ebc40453c add suspend/resume manager to the HAL
this gives us a clean API for power savings mode entry/exit
2025-12-16 01:08:41 +08:00
bunnie
e4eeb4603f rework ticktimer to use the susres interface 2025-12-16 01:08:17 +08:00
bunnie
9b9948e8da fix hosted mode warning 2025-12-16 01:07:49 +08:00
bunnie
e1cde0328c cleanup broken alt-target builds 2025-12-16 01:07:35 +08:00
bunnie
d261090f31 convert test routine to use susres api to enter sleep 2025-12-16 01:07:16 +08:00
bunnie
a94595ca9f RTC: rework to give milliseconds time
The original RTC was set to a 1Hz tick, which isn't sufficient
for the time API

This has been reworked to give a 1/1024 second increment.
Rollover logic is implemented in the RTC. Requires the system
to be powered on at least once every 48 days to capture the
rollover, otherwise it could miss a rollover event. This is
fine because the backup battery doesn't last that long, and
scans of QR codes for password login always reset the RTC anyways.

The RTC offset randomization code is now gone because we're
not tracking long-term power-on information in the RTC.
2025-12-15 15:16:10 +08:00
bunnie
074b0429d3 add timing dither to ticktimer
add a little bit of timing dither to one of the core delay routines
this hardens the OS against glitch attacks by making the timing of
concurrent tasks less predictable
2025-12-14 16:05:12 +08:00
bunnie
5f1b769822 cleanup warnings 2025-12-11 02:27:56 +08:00
bunnie
def8da571b add a wfi api 2025-12-11 02:22:01 +08:00
bunnie
e2d15e26e6 expand test routines 2025-12-11 02:21:02 +08:00
bunnie
261ea7a880 update apis in hal-service 2025-12-11 02:18:44 +08:00
bunnie
8950a24327 move i2c in bao1x-hal-services into bao1x-hal
this makes i2c accessible without having to rely explicitly
on the server itself, making the library callable in more contexts.
necessitated avoiding a name space collision and moving the
I2C hardware drivers to a stucture named I2cDriver; the I2C
object now unambiguously refers to the userspace interface
to I2C.
2025-12-11 02:13:21 +08:00
bunnie
8269f9f759 update apis to accommodate power savings mode 2025-12-11 02:10:25 +08:00
bunnie
b6f761a9a9 move power manager to a server
this is because the power manager itself relies on the HAL
server to manipulate GPIOs and it'll block the main loop if
the calls are handled there.
2025-12-11 02:07:17 +08:00
bunnie
0ada90fec5 fix power consumption on camera
mclk wasn't stopping correctly, causing lots of leakage power.
2025-12-11 02:03:43 +08:00
bunnie
a3a566b240 add API calls for debugging kernel under baochip targets
also updated some really bit-rotted docs

we will deprecate the docs/ directory soon, they are wrong
and misleading at this point.
2025-12-09 16:19:04 +08:00
bunnie
c9d513599c fix hosted mode 2025-12-08 01:41:44 +08:00
bunnie
772c818908 reduce power from camera 2025-12-08 01:09:12 +08:00
bunnie
c3757248a8 fix hosted mode 2025-12-07 20:52:46 +08:00
bunnie
9ade5a4a0d add notes about coding capacity:
40 bytes gives 320 bits which fits nicely into a version 3 code,
which allows 4 pixels per module rendering.

if we have to move to 3 pixels per module, the next code up that optimally
uses the full screen is version 6. This would give 102 bytes of transfer
in a single scan.

The equation for capacity is:
`binary_bytes = floor((alphanumeric_capacity / 3) × 2)`

where `alphameric_capacity` is the capacity of the QR code version
per spec lookup table.
2025-12-07 19:08:06 +08:00
bunnie
c3a0a50c9e add test routine for QR code generation/scan
a 40-byte message can be encoded in a version 3 code with
medium ECC. This is pretty optimal because it allows 4 pixels
per module in the QR code, which is a nice size for viewing.

base45 is added as a dependency to the project. Base45 is weird but
apparently it's the most efficient way to code binary data into a
QR code.

40 bytes (320 bits) is enough to exchange a 256-bit key plus
64 bits of sideband data. I think this is going to be enough for
basic device-to-device handshaking.
2025-12-07 19:01:14 +08:00
bunnie
c813aa1b92 add hook on bao-video to handle the qr_render case 2025-12-07 19:01:00 +08:00
bunnie
6ecaa36d98 cleanup warning 2025-12-07 19:00:44 +08:00
bunnie
ebb7e8dfae refactor QR code notification implementation
Previous implementation sent the QR code as draw commands.
This is inefficient as it would require hundreds of draw
commands to be sent per QR code rendered.

This implementation codes the QR code as a bool and sends
it in a single memory message, and implements a QR code renderer
on the receiver side.

The QR code rendering is also cleaned up so that the QR code is
always centered and takes the full screen, to give the best
conditions for someone scanning the code from another device.
2025-12-07 18:58:33 +08:00
bunnie
b012038c1d
fix argument to hazardous-debug print
this allows us to check that things are being done correctly
in CI.
2025-12-06 00:16:36 +08:00
bunnie
78036d71dc
add code to check the flag
there's a dummy flag checked in, and this code helps check that
the flag is treated correctly during CI testing
2025-12-04 15:10:51 +08:00
bunnie
3663ea1276 revert inadvertent testing flag that was checked in
this only makes sense for testing on specific builds.
2025-12-02 02:39:28 +08:00
bunnie
9b54fdb64f fix dabao target dependencies 2025-12-02 02:27:01 +08:00
bunnie
01475137bb add code to test the random seed 2025-12-02 01:40:39 +08:00
bunnie
fcc6fc5538 add chaffing feature to the swapper
the main imagined attack vector on the swapper is recovery
of the AES key through side channel analysis.
2025-12-02 01:06:36 +08:00
bunnie
5b4d6c1932 add benchmark data on chaffing
unchaffed AES is 5.36us/block
chaffed AES is 10.27us/block

so ~2x overhead for chaffing - about what we expect for the
implementation.
2025-12-02 01:05:26 +08:00
bunnie
da44e98257 add chaffing implementation to AES 2025-12-02 01:04:17 +08:00
bunnie
9034a08b5e fix TTS target API change 2025-11-30 22:21:31 +08:00
bunnie
d9a65a51d9 fix hosted mode 2025-11-30 21:56:32 +08:00
bunnie
381dee01eb fix interfaces in GAM for stateful lists 2025-11-30 21:32:26 +08:00
bunnie
49456db837 fix typos 2025-11-30 21:32:08 +08:00
bunnie
98e9d99de8 add stateful list creation
this allows us to have "pre-checked" checklists
2025-11-30 21:31:39 +08:00
bunnie
7d7fa75e7d add debug telemetry for keyboard connect error
sometimes on boot, a process tries to send keyboard an incorrectly
formatted message. I think this might be the IOX interrupt handler
firing due to random noise. Corrective action towards debugging
includes instrumenting the keyboard call with debug info, and also
ensuring that the iox interrupt handler banks are initialized to 0.
2025-11-29 15:49:40 +08:00
bunnie
b702a68c1c test what local time returns 2025-11-29 01:01:24 +08:00
bunnie
4ec0eda2b5 migrate service name to some place public 2025-11-29 01:01:04 +08:00
bunnie
6918e275d0 map the center key to "fire"
This allows the center key to be used as a UI trigger action
without creating a carriage return on the console. this prevents
console actions from errantly triggering during complex ui navs.

probably later on we should filter out more of the UI nav items
going to the console because the console is always listening
2025-11-28 18:43:59 +08:00
bunnie
3b1784d346 make screen panic messages somewhat more useful
some panic messages are hundreds of characters long, most of them
are path hashes or paths to crates that are less useful.

truncate any panic messages to the last set of displayable
characters, so that the "most useful" portion (e.g. file name
and line number) are always visible in a panic.
2025-11-28 18:41:53 +08:00
bunnie
106f7153a1 filter key presses through the video layer
the video layer is the "traffic cop" managing when modals
get focus. This patch creates a feed from the video layer
that listers to subscribe to that filters out key presses
destined for modals.
2025-11-28 18:40:56 +08:00
bunnie
647ec0dfb4 fix dabao target - keyboard server
dabao needs to have a vestigial keyboard server which handles
forwarding USB/serial key events to listeners. otherwise, there
is no input interface.
2025-11-28 11:35:17 +08:00
bunnie
84a083017c gate off incompatible features for hosted mode 2025-11-27 22:11:13 +08:00
bunnie
80eba30099 use screen real estate a bit more efficiently on panic 2025-11-27 17:57:41 +08:00
bunnie
6df070e95e notify waiters that mount is successful 2025-11-27 17:57:24 +08:00
bunnie
fbb04d96ab make center keypress a unique key so we handle it separately 2025-11-27 16:51:15 +08:00
bunnie
1f9ab022f2 implement on-demand QR code scanning 2025-11-27 16:50:47 +08:00
bunnie
a24aaaa944 increase keyup delay slightly
this prevents some keyboard stutter in case of ui lag
2025-11-27 12:34:13 +08:00
bunnie
72144ad35d builds with no timestamp should still display a git version
version descriptions should be reproducible, by definition.
2025-11-27 12:33:43 +08:00
bunnie
434e0c7ae5 refactor organization of code to fix dabao target
kpc isn't possible on dabao due to the pins not being broken out,
so gate out the service entirely for that target.
2025-11-26 21:37:31 +08:00
bunnie
cdf4a56d76 add backup manager ref in keystore
this claims the backup memory region - eventually we'll do
something with it
2025-11-26 20:48:29 +08:00
bunnie
601d2763e8 add keyboard userland abstractions 2025-11-26 20:45:50 +08:00
bunnie
40c94b5abc add kpc_aoint abstraction layers 2025-11-26 20:45:12 +08:00
bunnie
41f750163f change timing of PDDB mount
moving it a shy later into the boot makes the mount process faster
because it's not fighting for swap memory with everything else
trying to initialize at the time.
2025-11-25 01:08:47 +08:00
bunnie
c677f6f78a add apis & services for the rtc 2025-11-24 18:56:03 +08:00
bunnie
543f455ad0 fix scalar return discipline in usb-bao1x
also add ability to read keyboard led state
2025-11-24 18:54:50 +08:00
bunnie
62b656db8a add some test routines for checking RTC functions 2025-11-24 18:28:50 +08:00
bunnie
d30d889774 add rtc hardware drivers and service 2025-11-24 18:28:00 +08:00
bunnie
49dcc7aaa2 add CI telemetry for keystore init 2025-11-19 14:00:59 +08:00
bunnie
90362b2604 fix hosted mode 2025-11-18 23:59:17 +08:00
bunnie
22f44f82b9
add debug telemetry to the keystore
this is constructed in a way such that

1. it's gated off in production builds
2. if it was accidentally gated on, there is some security impact
but not a significant loss of security

We do need the telemetry so that during CI we can confirm that things
are actually working. I think the risk of being too buttoned-up
and then accidentally doing something like accidentally never
initializing keys and leaving them all zero is greater than the
risk of accidental partial leakage of information due to a procedural
mix-up in the image signing ceremony.
2025-11-18 23:20:31 +08:00
bunnie
ad116b5af6 reduce leakage during hazardous-debug
in theory, no production images should be signed that have this
feature enabled. But, reducing the amount of leakage just in
case an accident happens and this flag is somehow slipped
into a signed production image.
2025-11-18 22:46:20 +08:00
bunnie
0723306085 update docstring 2025-11-18 22:40:36 +08:00
bunnie
fdb613cfb3 fix corner case on non-word aligned buffers 2025-11-18 22:40:09 +08:00
bunnie
69b77f3072 allow gen2 to use the seeded trng fill 2025-11-18 19:35:59 +08:00
bunnie
0942858bbc add test cases for trng 2025-11-18 19:35:48 +08:00
bunnie
4f39532471 clean up filling API
previous implementation was full of too many special cases

also add a version that allows us to fill using a seeded CSPRNG
for better performance on bulk fills
2025-11-18 19:34:57 +08:00
bunnie
52c5400fca
cleanup debug 2025-11-13 18:36:03 +08:00
bunnie
9213755a6b
move keystore init to userspace
This moves the key store initialization to the key manager
process itself.

It has been tested to work with signed images, and to also
protect the system in case of another process trying to access
the key data as well as in the case of developer keys being
used.
2025-11-13 18:32:04 +08:00
bunnie
c3c86e857b improve pddb init 2025-11-12 22:08:01 +08:00
bunnie
59325e0571 fix warnings in placeholders in bao1x-emu 2025-11-12 15:28:42 +08:00
bunnie
f4b88ce964 fix deps in other build modes 2025-11-12 15:27:00 +08:00
bunnie
315bee22dc add placeholders for ephemeral/volatile data in keystore 2025-11-12 15:26:35 +08:00
bunnie
8c421c6050
Merge branch 'main' into vault2 2025-11-11 08:47:10 +08:00
bunnie
dd42267eb9 fix mount/format on boot ordering
pddb is working again in hardware, this time with real keys
2025-11-11 08:18:57 +08:00
bunnie
c2c135bfdc fix trng service in baosec environment
fix missing initializers
2025-11-11 07:53:52 +08:00
bunnie
54f476edd3 fixup hosted mode emulation for baosec 2025-11-08 04:20:30 +08:00
bunnie
fa8325c2ed cleanup pddb for gen2 targets
gate out modals entirely from gen2 pddb

passwords in gen2 are now entirely handled outside of the
respective service crates, cleaning up the APIs

some history - on gen1 (precursor) devices, the thesis was to
reduce the amount of distance a password has to travel from
the point of a user entering it to the point of use. I think this
is academically interesting, but it pulls in a lot of code
into each service to manage the passwords, conflating services
with UI layers.

it was a nice experiment.

in gen2 (and hopefully beyond) targets, we now commit to
the idea that something else is passing in the sensitive key
materials. This means that, in fact, keying material has to
transition between process spaces, which increases the attack
surface to recover this. However, it also makes the crates
more portable and maintainable.

This is mitigated partially by the fact that in gen2 targets
the entirety of the code base runs within a piece of silicon,
so "sniffing" (passive observation of data going to memory)
attacks are a good bit harder.
2025-11-08 03:52:39 +08:00
bunnie
792de177b0 implement keystore calls needed for pddb compatibility 2025-11-08 03:52:20 +08:00