Commit graph

10340 commits

Author SHA1 Message Date
bunnie
b836a5afec Merge branch 'bunnie-dev' into main - pddb merge
All the PDDB infrastructure is now in place. The core filesystem is
fairly well tested, but the server APIs are entirely untested. However,
this merge at least gets the clean build into the mainline and will
cause a Precursor to create and format a PDDB. Note: this takes about
15 minutes -- about 7 minutes to erase the memory, 9 minutes to fill it
with random data. This is primarily limited by the raw speed of the
FLASH memory itself.
2022-01-08 00:13:14 +08:00
bunnie
6623d58f43 reduce some debug logging 2022-01-07 23:36:05 +08:00
bunnie
00ce905088 clean up hosted mode flow 2022-01-07 23:33:53 +08:00
bunnie
904847fc89 improve error message 2022-01-07 23:25:53 +08:00
bunnie
9fcd7e17ae warning-clean. need to clean up the hosted mode flow a bit. 2022-01-07 23:22:12 +08:00
bunnie
75fe309059 clean up an old warning and explain its presence 2022-01-07 23:14:43 +08:00
bunnie
aa5447cb4a add missing feature: basis retention policy 2022-01-07 22:51:02 +08:00
bunnie
3f4fea1274 clean up some easy warnings 2022-01-07 22:19:39 +08:00
bunnie
b4bfaefa64 start a cleanup pass on warnings 2022-01-07 22:10:54 +08:00
bunnie
11c22b6d19 add listing routines 2022-01-07 21:03:40 +08:00
bunnie
7d660a3592 add key attribute query, clean up some warning 2022-01-07 16:18:44 +08:00
bunnie
fa7a9db348 add more key manipulation APIs 2022-01-07 15:43:50 +08:00
bunnie
2118233657 diagnose alignment bug in CI code 2022-01-06 23:16:01 +08:00
bunnie
0c71622740 fix alignment bug in analysis code 2022-01-06 23:15:24 +08:00
bunnie
c046422746 tighten up the on-boarding password flow
- check the password with a double-entry on the first boot
- if we see a blank disk, bypass the usual checks and allow the mount
to fail, then, enter the setup routine.
2022-01-06 22:13:00 +08:00
bunnie
4c927f2c99 fix name records so they encode a length
This is one of the truly redeeming features of Rust is that a
major refactor of a core structure like this doesn't leave me
shaking in my boots -- I feel pretty good that this works
since everything passes the CI tests.

The original FS implementation did the "stupid C thing" which
just creates a fixed lenth field and uses null-terminated C
strings. Which actually restricts PDDB entry names to be ascii
as valid UTF-8 can encode single-byte nulls.

The intention was for names to be fully utf-8 compliant, but in
order to do that we have to burn one byte of potential filename
length and encode an overall length field for the name strings.

This change does that, which both makes the code a bit safer
at the expense of losing a character off of the maximum filename
length.
2022-01-06 18:53:01 +08:00
bunnie
233a7cb7d3 getting started on dict management, but just realized we did strings in a dumb way
we really should have coded a length field in all the name string
stored in the PDDB (derp, old C habits die hard).

let's fix that before we move on.
2022-01-06 17:12:30 +08:00
bunnie
d318e31666 flesh out the basis management opcodes 2022-01-06 16:36:19 +08:00
bunnie
20e28395d8 start to lay in the end user API, beginning with basis management commands 2022-01-06 14:50:56 +08:00
bunnie
6e5506a23d add pddb shell debug commands 2022-01-06 14:50:44 +08:00
bunnie
489a26dd11 fix an issue where we don't decrement the connection counter on drop 2022-01-05 20:01:54 +08:00
bunnie
bc98064a59 add a function to recycle the PDDB for faster PDDB testing cycles 2022-01-05 11:22:29 +08:00
bunnie
8b37303b06 add a check on correct password entry
The rootkey enclave actually doesn't check if your password is
correct -- it has no way of knowing because it doesn't know how
the keys will be used. Password checking is delegated to the
requesting process because also the password retry method and
policy depends upon the application, and is a significant amount
of UX plumbing (in fact the rootkeys should have less UX plumbing
than it has right now - this is something to do in the near future).

Add a mechanism in the PDDB to check if a password was entered
correctly, and retry if it isn't. Without this, an incorrect
password would actually trigger a reformat of the PDDB, since
it can't find the system basis structure with a bad password.
2022-01-05 11:17:13 +08:00
bunnie
ab4baeb96e fix typo 2022-01-05 00:56:13 +08:00
bunnie
c6bba1b13e increase PDDB size to the full disk size; test on real hardware
takes about 15 minutes to fully initialize a 100MiB PDDB.

time is dominated by the sector erase time (which is fundamental
to the device) and data write rate (also fundamental to the device).
2022-01-04 21:59:26 +08:00
bunnie
a8282413ef make locale builds only take in i18n.json files
because .json files are splattered everywhere and this causse troubles.
2022-01-04 21:58:04 +08:00
bunnie
3a0dfe5c3b add bulk erase command to accelerate PDDB init 2022-01-04 21:57:47 +08:00
bunnie
89f5b49c96 remove debug prints that leak secret info 2022-01-04 21:57:31 +08:00
bunnie
55abbd3f3e fix bugs in progress bar computation 2022-01-04 21:57:09 +08:00
bunnie
5129b42dd9 remove shellchat services that conflict with the pddb 2022-01-04 21:56:50 +08:00
bunnie
ef6e45658a add comment to remind about alignment requirements of regions 2022-01-04 11:37:06 +08:00
bunnie
d87920a772 add argument to erase the entire PDDB region. 2022-01-04 11:12:30 +08:00
bunnie
5b66e692d3 fix cipher sync bug; reduce logging rate
- logging rate reduced for UX for significant speedup
- fix issue where on AES key re-generation a pre-keyed cipher
was not being retired.
2022-01-04 11:11:36 +08:00
bunnie
de991df43c fix slicing to match that of the Xous environment 2022-01-04 10:50:56 +08:00
bunnie
77e44075a6 add debug help to tokens, remove the unused RTC token entry 2022-01-03 19:20:31 +08:00
bunnie
ce61d5415a change default order of login password policy for low-security logins 2022-01-03 19:19:38 +08:00
bunnie
fe04f5684f fix a critical bug that prevents root key initialization
This is going to require users to update their devices before
doing a key initialization.

The problem is that we can't trust the length of data presented
to us to self-sign, so we sign the whole area. In v0.9.2 of the
loader, a check was introduced to check the putative length of
the signed area against the actual length of the signed area,
by encoding the length of the signed area within the signed
region.

This would require the rootkeys algorithm to also encode that
new length at the end of the signed area, but this was never
done. However, this bug was never found during testing probably
because I failed to completely erase the original key provisioning
(I was more fixated on checking that existing keys were not damaged by
firmware updates at the time), and thus did not trigger a full
rootkey provisioning cycle when I did the test. I had only just
caught it now while porting the PDDB from simulation to real
hardware.
2022-01-03 19:06:21 +08:00
bunnie
0844b3e961 add formatting check and UX flow for formatting; redo salt (again)
probably should have split this into two commits. oh well.

first part introduces a check to see if root keys are initialized,
and if so, tries to mount the PDDB. If it can't mount, it asks
the user if they want to format it. It also updates the progress
of the fromatting.

the second part redoes the salt once again. After some discussion
SHA512/256 is also resistant to length extension attacsk so we
don't need to use the HMAC technique suggested. Would prefer to
reduce the number of algos to analyze, so we're going to a simple
SHA512/256 hash of the salt/basis name/plaintext password to generate
the salt that goes into the bcrypt routine that ultimately generates
the final key used by the system.
2022-01-03 16:51:51 +08:00
bunnie
2317c71e3a perhaps an ill-fated exercise to randomize journal number starting points
trying to avoid a situation where inspection of the system basis
can lead to conclusions about how old the system "should" be.

This is of course slightly upset by the fact that we need to track `Age`
numbers within keys to implement LRU caching algorithms (coming real soon
now), but at least this decouples the pages' low-level journal entry
count from the age parameter.
2022-01-02 20:26:36 +08:00
bunnie
7094c00590 update comment 2022-01-02 19:43:44 +08:00
bunnie
6d655c8085 convert salt to use an HMAC instead of SHA to harden against length extension attacks
(as reccommended by reviewer)
2022-01-02 19:37:30 +08:00
bunnie
9910547e21 modify salt generation scheme
based on feedback that the current mechanism is overly complicated
and doesn't add any real security, and it's better to stick with
something simple e.g. just a tried-and-true hash of the basics
2022-01-02 17:53:00 +08:00
bunnie
0965c4ccc6 remove suspend/resume opcode, we shouldn't need to be aware of it... 2022-01-02 16:44:44 +08:00
bunnie
630dd6a784 make the CI options command line driven 2022-01-02 16:41:23 +08:00
bunnie
350276c08a clean up more warnings and errors 2022-01-02 15:31:56 +08:00
bunnie
421a3814d8 clean up some warnings before moving on to further integration 2022-01-02 15:07:48 +08:00
bunnie
c2ee9f7c7a refactor tests and CI into a feature 2022-01-02 05:21:05 +08:00
bunnie
33b0593f9a fx fspace cache entry space check issue
was counting total number of pages, not actual free pages.
2022-01-02 01:41:55 +08:00
bunnie
fef355423b fix CI red herrings; add more debug granularty 2022-01-01 15:14:44 +08:00
bunnie
c02a8933ef speed up the analysis tool so it's a bit more practical to use in CI 2022-01-01 14:14:09 +08:00