Commit graph

179 commits

Author SHA1 Message Date
bunnie
de514ac66f rename packages in prep for upload to crates.io 2022-10-03 00:24:45 +08:00
bunnie
4e40ae6c5d move from target selectors to feature selectors for back-ends
This will allow for e.g. xous on riscv32-imac but not a precursor
target, for example: by using feature selectors we get to have
a bigger range of targets that we support, such as for implementations
that haven't been upstreamed or have official target-triples.

The downsides are:

- patch override libraries don't absorb feature flags. so, for
example, the AES crate that is used to patch other crates won't
be aware of the target features without modifying the referencing
crates.

- features are normally meant to be additive, but target features
are mutually exclusive. The mutex is enforced by a check in
utralib that throws a panic on build if two targets are accidentally
selected at the same time.
2022-10-02 02:56:44 +08:00
bunnie
fb29c9b2c1 refactor utra target line to use explicit feature targets
still need to rework the crate feature selection
2022-10-02 02:20:03 +08:00
bunnie
ecab0ba045 fix default-features in services 2022-09-27 02:44:46 +08:00
bunnie
d667d7e1f5 bump xous-ipc version 2022-09-27 01:14:43 +08:00
bunnie
f188e0f866 re-bump xous-ipc to 0.9.9 2022-09-26 16:50:38 +08:00
bunnie
507ab42836 downgrade xous-ipc to 0.9.7 until i have permissions to push a new version 2022-09-26 16:11:26 +08:00
bunnie
3579dfdd17 update xous-ipc and xous versions 2022-09-26 16:07:35 +08:00
bunnie
114d60bc53 migrate logserver API to external package 2022-09-26 14:06:46 +08:00
bunnie
f70dc246b8 fix hosted mode 2022-08-12 23:26:43 +08:00
bunnie
7aca2d64b3 lower debug level 2022-08-12 23:09:06 +08:00
bunnie
9122186900 eliminate rendundant boot PIN request; fix bug in boot key generation
- boot PIN is not requested on root password init. it's redundant,
as it is actually set when you format the PDDB
- boot key was mistakenly a copy of the encrypted private key
for ed25519 key signing. "oops". didn't catch that bug until now...
i don't think it has a big impact on existing user base, because
the key is never exposed outside the rootkey server, and the
ed25519 key itself is encrypted with the root password and then
used as the boot key. But still -- that's just not what was intended.
- root password is requested twice to check the validity of the password
2022-08-12 20:18:32 +08:00
bunnie
5be62e372d chore: move AES-GCM-SIV off of branch to 0.11.1 official
this patch moves us off the branch we had to hop on for cipher
API compatibility to the one that's officially published by
RustCrypto. This closes #168.
2022-08-01 15:44:16 +08:00
bunnie
e943b35512 fix key wrapping in hosted mode
this will require you to regenerate your hosted mode PDDB
image, no migration was written for this mode.
2022-07-26 03:24:37 +08:00
bunnie
ec5cc29ccd hotfix for incorrect AES-KWP implementation
The crate we originally grabbed for AES-KWP seems to be non-compliant
(or I'm an idiot and I can't figure out how to call it in a way
that is compliant).

See https://github.com/jedisct1/rust-aes-keywrap/issues/9

Turns out that `aes_kw` *is* compliant, but unfortunately, it didn't
exist back when the PDDB was being written. The PDDB started in October
2021, and `aes_kw` was pushed in Jan 2022. *just* barely missed it.

Anyways, caught this error while trying to implement some CI for
backups. Hurray for testing!

This patch removes the encryption path using the incorrect version
of the algorithm, but leaves the decryption path in place. The
system will try to decrypt initially with the correct version,
but if that fails, it will fall back and try the incorrect version.
If that succeeds, it returns an error code with the correct key and
an updated wrapped key, which the caller can store so that future
calls do not fail. Thus, we have a seamless migration from the
incorrect version to the correct version.

Have verified that the aes_kw version *does* work with the CI
script, insofar as it has been written (we just got to that point
and got stuck). So, full speed ahead. Users shouldn't notice this
change.

Also, fwiw, I did take a look at the "incorrect" implementation,
and it doesn't look obviously insecure. Printing out the various
rounds of the wrapping function looks like the first couple rounds
match, but it diverges somewhere probably due to an off-by-one
in a counter or something like that. I didn't chase it out -- just
wanted to make sure that nothing looked like a huge data compromise.

Good news is this comes right on the heels of v0.9.9 release, so
this will be pushed as a hotfix right away.
2022-07-25 02:56:20 +08:00
bunnie
c0bd7f7f8a add note about faulty keywrap implementation 2022-07-25 01:22:04 +08:00
bunnie
6f10061653 reset "don't ask again" flag for password creation during factory test
this facility is necessary in case a worker accidentally picks
the wrong setting, disabling the feature for the device. When
the factory test completes, a call is made to reset the parameter.

This was a slightly complicated affair because the the don't ask
flag is contained within the rootkeys enclave itself, and we can't
just give access to rootkeys willy-nilly. So the flag is passed
through the PDDB and then to the rootkeys enclave. It's not harmful
to have it reset by an unauthorized actor; the pop-up will not
happen if passwords are, in fact, already set.
2022-07-19 23:57:25 +08:00
bunnie
0a4702d6c3 clean up dialog messages to conform to the latest lexicon 2022-07-19 16:30:00 +08:00
bunnie
6ea88dedee fix hosted mode 2022-07-19 05:28:32 +08:00
bunnie
7ad418be7c fix bug where RestoreDna backup op fails to be set. 2022-07-19 05:26:48 +08:00
bunnie
4ead1010cd add retry flow to restore; fix salt bug
salt was reading from the wrong location on a device that
previously was initialized but doing a restore to.
2022-07-19 05:07:22 +08:00
bunnie
7b3c928429 whoops, a debug statement is leaking private info. nuke that. 2022-07-19 04:45:07 +08:00
bunnie
2ca51b7d32 peeling that onion...another key verification failure in restore. 2022-07-17 23:51:45 +08:00
bunnie
c05e66b32c fix issue where pubkey was being erased before access
verification happens after the private key material is erased,
which incidentally nukes public key material, causing verification
to fail. This caches a copy of the pubkey material before
the erase happens.
2022-07-17 21:15:30 +08:00
bunnie
a5685c9e62 add debugging around restore verification
for some reason we're getting a bogus failure on restore...
2022-07-17 18:50:10 +08:00
bunnie
15ca22eacf fix hosted mode 2022-07-17 03:46:28 +08:00
bunnie
646a9fc1e5 fix hosted mode 2022-07-17 03:45:50 +08:00
bunnie
0cc2e46b02 fix dangling method invocation
complicated thing is complicated
2022-07-17 03:36:36 +08:00
bunnie
667470ba05 fix restore bugs
- read order of keys was wrong from staged data
 - make restore a blocking op so the Ux doesn't try to trigger
 other things at boot
 - fix pubkey check to use staged key for backup flow
 - fix some wording and skip redundant messages
2022-07-17 03:10:26 +08:00
bunnie
37154f3350 add edge case handling for restore to new device
Just remembered that the PDDB is *locked* to a given device.
To restore to a new device, you have to unlock all the Bases,
and re-encrypt them to the new device's DNA.

This commit adds the facilities to detect this condition, but
the actual code to do this is quite involved...let's handle that
after we've got a "simple" restore to the same device going.

Why do we lock to a device's DNA? the idea is to prevent
attacks where people are taking static blocks of crypto data
and just swapping it between devices to see if they can
get something to decrypt. It also makes it harder for
an adversary to replace the physical device -- e.g., an
evil maid prepared a replacement with implants in advance, and they
image your PDDB onto the replaced device, hoping that you don't
notice. Because the PDDB is device-locked, the "evil maid"
would have to forge the devices DNA to match yours:
possible, but would require kernel mods that patch over the
reported ID; that would trigger the line across the top of the
screen; or, somehow editing the FPGA itself to force
its device ID to report the same as yours. This last attack
vector would be successful, but afaik there is no known way
to modify an FPGA's DNA code. I'm sure there is some proprietary
secret know that Xilinx uses to set it, and if you were
a large government you may be able to coerce Xilinx into giving
you those codes plus some tool that could set the fuses
plus some unfused devices (the fuses are burn-once) but....
2022-07-16 02:31:18 +08:00
bunnie
13e11b83ae add backup of keyboard layout and language 2022-07-16 00:39:14 +08:00
bunnie
fded17221f improve autoupdate work flow and error messaging
this is hopefully a work-around for #114 as well, assuming
users actually read the message...
2022-07-14 23:20:26 +08:00
bunnie
a5bcc50007 Merge branch 'backups' into main 2022-07-14 19:27:18 +08:00
bunnie
abade9e1af minor fixes in the autoupdate flow
- do not try to create root keys if we just did an SoC update.
that's just too many things going on, we should definitely force
a clean reboot first.

- add a clean reboot step after a no-key soc update

- try to switch USB debug mode on if a backup was created
2022-07-14 19:26:09 +08:00
bunnie
04f34c6320 Merge branch 'backups' into main 2022-07-14 04:46:21 +08:00
bunnie
f7dcbe0ab0 fix some formatting and CI messaging issues 2022-07-14 04:46:02 +08:00
bunnie
45a150362d Merge branch 'backups' into main 2022-07-14 04:20:51 +08:00
bunnie
b2f169c55e fix unpack signature on init flow to allow for both block and nonblock 2022-07-14 04:20:14 +08:00
bunnie
8a5c6000cc fix hosted mode 2022-07-14 03:15:39 +08:00
bunnie
d5d6461dc5 fix details on forward-version autoupdate flow 2022-07-14 02:00:06 +08:00
bunnie
ca7be97dfd remove debug for push to CI 2022-07-13 15:16:53 +08:00
bunnie
a05f9a5c92 revert to debugging 2022-07-13 05:03:42 +08:00
bunnie
df2de92d43 don't commit Debug flag 2022-07-13 05:02:55 +08:00
bunnie
b4b6fc2a49 unbreak hosted mode 2022-07-13 05:01:36 +08:00
bunnie
7b72966c09 add restore flow to the root keys server (still untested)
- also recycles the PDDB when keys are initialized
2022-07-13 04:44:13 +08:00
bunnie
bfb93269f3 create the backup side of the flow 2022-07-12 04:50:03 +08:00
bunnie
09e1b99315 initial infrastructure for running backups
code to serialize/deserialize and encrypt/decrypt the backup
block.

now filling in the UX flow around this.
2022-07-12 03:32:33 +08:00
bunnie
ed2f029874 add SoC autoupdate flow options -- still needs testing 2022-07-11 18:36:00 +08:00
bunnie
7248f47ca8 fix self-signing to reflect extra data for semvers
the loader is a little funky, and requires some maintainer hand-holding
due to the split of the page ownership between the root-keys
crate and the graphics-server crate.

Improved docs so I don't forget this detail in the future.
2022-07-11 16:11:32 +08:00
bunnie
64e82d88dd fix hosted mode missing routine 2022-06-30 23:17:45 +08:00