Pass semver from --git-describe to swap image signing code path.
PR #817 added --git-describe and --git-rev support but the swap
image code path in xous-create-image was not updated to use the
semver for signing.
Changes:
- swap_writer.rs: Add semver parameter to encrypt_to()
- xous-create-image.rs: Parse --git-describe and pass to encrypt_to()
- xous-app-uf2.rs: Same changes for consistency
- builder.rs: Pass --git-describe to xous-create-image
Fixes#818
Enable reproducible builds without git state by accepting
version info as CLI arguments:
- --git-describe: version string for signing (e.g., v0.10.0-19-g0d934e1)
- --git-rev: commit hash for swap nonce (last 16 hex chars used)
Renames xtask --gitrev to --git-describe for clarity.
It occurs to me that the same boot1 code will be on both
die steppings, so adding a piece of code that *should* be
able to detect A0/A1 stepping - assuming the A1 stepping
behaves as intended.
Crypto refers to the deprecated PyCrypto package, and this breaks on Fedora because the SHA512 class doesn't include the truncate argument. Update it to Cryptodome.
this picks a toolchain that matches the actual target we're building
instead of just the first toolchain in the list (which with the addition
of -emc toolchain causes things to break).
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.
this makes it much easier to check for errors - and one was found,
the erase coupon was accidentally off by one, and equal to the
master key slot. oops! 🤦
When SOURCE_DATE_EPOCH is set, use it instead of Local::now() for the
embedded build timestamp. This enables deterministic builds via Guix,
Nix, and other reproducible build systems.
See: https://reproducible-builds.org/docs/source-date-epoch/
Design notes:
- Panics on invalid SOURCE_DATE_EPOCH rather than warn-and-fallback,
because silent fallback would produce non-reproducible output while
the user expects reproducibility. Build systems should fail loudly
on misconfiguration.
- Preserves Local::now() fallback when SOURCE_DATE_EPOCH is unset,
keeping local timezone for developer convenience during debugging.
the "audit" command is moved to its own file, as it has
turned into A Thing.
auto-audit now happens on the first few boots to help
verify chip probe infrastructure.
hashes of the boot regions are also printed as a diagnostic
in the audit code.
for the first few boots (3 in this case), automatically
print an audit to the console. This is used to verify that
the chip was programmed correctly in chip probe.
this allows build systems that lack git state to build an image.
The effective git revision must be correctly computed by the build
system or substituted for everything to work correctly.
Note that completely faking the entry will lead to subtle problems
down the road; for example, a purpose of the revision is to check
which versions are compatible for upgrades against each other
(some upgrade paths require a hop through an older version). Faking
this can bypass the mechanism and then lead to instability down
the road.
However, some build systems (such as guix) strip out the git state,
but the revision can be safely generated in the calling environment
and passed as a variable.
this bug highlights a fairly big weakness in the rkyv-based
serialization in that there is no inherent type checking of
the sender to the receiver. In this case, a typo of just one
character lead to a regression which, probably in an earlier
version of rkyv, was not a problem because the ordering of
elements was different. In this case it lead to incorrect behavior,
which upon debugging lead to panics because we were interpreting
the data incorrectly after it was unpacked.
This is probably an issue to be worried about in the longer-term,
and it leaves me with a lingering question of what attack
surface exists through the deserialization mechanism for
attackers who send malformed buffers as messages.
there was a thought to speed up CI testing by introducing a
"cheater" routine that allowed us to re-initialize the keystore.
Turns out this doesn't work because it's not possible to fully
revert a system out of developer mode - because, in my infinite
previous-self wisdom, I realized that this is something someone
might try and there is a one-way counter that logs if the
system has *ever* been in developer mode, and that has no
known bypass.
This means that even if you could repopulate the keystore, it
would be cleared on the next boot by merit of the developer
flag being set.
So - we did it the hard way, every single test we have to
re-image the system from scratch. C'est la vie.
Removing this patch eliminates a code path that could later be
abused for unforeseen ill purposes.
the first check should *never* print a message because an attacker
can trigger a glitch off of the UART. this eliminates the diagnostic
print on the first check.
- 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.
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.
i feel a little more comfortable with this because there are
checks that *any* key in that slot would be treated as a devkey
and would lead to key erasure. so just in case i messed up
something in the other checks, this would trigger a key erasure.
I think there is no way around signing at least a beta image
containing the third party keys if i truly want to check all
the paths, so trying to isolate what it can do is important.
by doing this we make this safer by ensuring that the public
keys are valid public keys, allowing us to sign these images
with production keys and not accidentally signing a weak
public key.