Commit graph

118 commits

Author SHA1 Message Date
bunnie
dd18d94a03 e2e demo of pddb working now, we can store an ssid/password pair...finally. 2022-01-09 13:12:36 +08:00
bunnie
5523d81669 add commands to check mount status and to initiate mount manually 2022-01-08 23:33:10 +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
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
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
489a26dd11 fix an issue where we don't decrement the connection counter on drop 2022-01-05 20:01:54 +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
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
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
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
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
656f17f621 add extensive CI test 2021-12-29 05:49:07 +08:00
bunnie
6990513278 fixed a subtle bug in the pte sync algorithm
was mixing deletions and updates and because they are in arbitrary
order due to the hashset structure, sometimes i'd delete an entry
after it was updated.

this is now found and fixed.
2021-12-28 06:47:33 +08:00
bunnie
713c0d6e73 add a multi-iteration CI loop around the pddb test
this allows us to capture seeds and corners of interest
2021-12-27 16:15:51 +08:00
bunnie
dd14dfc4c6 retrofit the seed into an atomicu64 so we can set it elsewhere 2021-12-27 02:49:08 +08:00
bunnie
809dbbdbc2 fix a bug in the reserved amount of data in large keys 2021-12-26 16:29:35 +08:00
bunnie
0bd110c163 determinism achieved for testing. now to squash some bugs. 2021-12-26 01:50:30 +08:00
bunnie
37b46fae98 make determinism an optional feature 2021-12-26 01:42:36 +08:00
bunnie
d4027fa8a2 sort all the lists in the test code so the vectors are deterministic
not converting core structures from HashSet to BTreeSet though --
the idea is that in production the mappings should be fully random,
but we are just trying to get reproducibility in hosted mode so
that we can debug some hairy edge cases more easily.
2021-12-25 16:44:24 +08:00
bunnie
66606ed3e0 initial attempt to make hosted mode more deterministic
replace all threadRng with a seeded Rng
2021-12-25 15:58:27 +08:00
bunnie
c1c57edfd6 some mods to the logging infra to chase down a "rare" issue 2021-12-22 07:09:30 +08:00
bunnie
5d226a002a prepare to start using the modals server for the pddb 2021-12-17 03:11:06 +08:00
bunnie
725d943198 add interlocking so multiple threads don't interfere with each other 2021-12-17 01:55:36 +08:00
bunnie
dcad15284d refactor tests into a separate file 2021-12-16 01:48:11 +08:00
bunnie
60d6d08933 basic framework for modal API wrapping in place 2021-12-15 13:46:24 +08:00
bunnie
de4e84abf5 starting in on the larger system integration of the PDDB
Trying to find a new approach to making dialog boxes that
are cleaner and don't require as much code repetition. Probably
about to go on a long tangent.
2021-12-13 14:24:14 +08:00
bunnie
c84ed61ecd basis overlay test done & passing
the formatting of the listing output is a bit messed up but
i'm too tired and too late to deal with that. at least the
core logic seems functionally correct!
2021-11-30 00:38:29 +08:00
bunnie
8066b8fb5e fixed the bug with the pt map encryption, now we hvae two basis!
more testing needed, but looking good so far.
2021-11-29 00:25:09 +08:00
bunnie
c15841cfdc test framework in place to look at multiple basis
found one bug already, need to refactor how PT encryptor is
handled
2021-11-28 23:54:58 +08:00