diff --git a/Cargo.lock b/Cargo.lock index ab7528927..c5d5227bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1527,6 +1527,7 @@ dependencies = [ "root-keys", "sha2", "spinor", + "subtle", "susres", "ticktimer-server", "trng", @@ -2278,9 +2279,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "subtle" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "susres" diff --git a/RELEASE-v0.9.md b/RELEASE-v0.9.md index ed8d1eceb..cb7c492e3 100644 --- a/RELEASE-v0.9.md +++ b/RELEASE-v0.9.md @@ -68,14 +68,57 @@ for examples of idiomatic ways to write code for Xous. - Initial support of emulation of EC - No COM-based inter-chip communication yet -## New in 0.9.1 +## New in 0.9.5 - `modals` server for a simple "Pure Rust" API for creating dialog boxes and getting user input. See the `tests.rs` file for some examples how to use the applcation calls. +## New in 0.9.6 +- Networking: DNS, UDP, Ping and TCP + - Basic demo of ping, rudimentary http get/serve + - EC offload of ARP and DHCP – thanks to samblenny for adding that, along with a solid refactor of the EC code base! The EC now also has the capability to act as a coarse packet filter for the core CPU. +- Connection manager + - Maintains a list of known SSID/password combos + - Manages passive SSID scanning and re-connection + - Enrolling in and saving a network profile is done via shellchat's wlan series of commands + - Only WPA2 is supported + - Still a lot of corner cases to work through +- PDDB: Plausibly Deniable DataBase for system config and user data storage. + - Uniform filesystem for all user-specific Xous data + - Fully encrypted database + - Plausibly deniable secret overlays + - See this blog post for more details + - Rust API bindings available, but as of now, few command line tools +- EC events – asynchronous callbacks triggered by network and battery events +- CPU load monitor in status bar +- Improved fonts + - B/W display optimized emoji + - Chinese-native Hanzi glyphs + - Japanese-native Kanji glyphs + - Hangul glyph set + - Thanks again to samblenny for all the hard work to make a slick new set of glyphs and a smooth new API! +- Japanese locale +- AZERTY and QWERTZ layouts +- Auto word-wrapping in the TextView objects +- Simplified graphical abstractions + - Modal server: create notifications, checkboxes, progress bars, radio boxes, and text entry boxes with validators using a single API call + - Simplified menu API +- Modular application programs + - manifest.json file to specify application integration parameters, such as the localized name and app launcher menu name + - Build-time command line selection of which apps you want baked into the Xous image +- Many bug fixes and improvements +- Improved libstd support +- Improved Renode and Hosted mode support + +## New in 0.9.7 +- `pddb` has salamanders fixed (https://eprint.iacr.org/2020/1456.pdf). This changes the root basis record storage, causing all prior versions to be unrecognized. +- `betrusted-soc` was updated to the latest Litex in prep for some work optimizing CPU performance and USB cores + ## Roadmap to 1.0 The items that are still missing before we can hit a 1.0 release include: -- PDDB (plausibly deniable database): a key/value store that is the equivalent of a "filesystem" for Xous -- Networking capabilities: a simple (think UDP-only) network stack +- [x] PDDB (plausibly deniable database): a key/value store that is the equivalent of a "filesystem" for Xous +- [x] Networking capabilities: a simple (think UDP-only) network stack - Password changes in the `rootkey` context -- Post-boot loadable applications (currently we have a kernel, there is no notion of a separate "application" file from the kernel code base; although this might be a 1.1-release feature as it depends on the PDDB, which is a major item in and of itself) +- Post-boot loadable applications. We currently have modularized integrated applications, but no notion of a disk-loadable application. Still not sure if this is a feature we want, though, given that Xous is supposed to be a single-purpose tool and not a general OS. +- Further integration of drivers into `libstd` +- Maybe a functional USB device stack?? - Lots of testing and bug fixes diff --git a/precursors/rom.db b/precursors/rom.db index abddc1960..5ee2bcaa6 100644 --- a/precursors/rom.db +++ b/precursors/rom.db @@ -1,128 +1,128 @@ -KEYROM 0 A SLICE_X36Y50 b'9ef6357db6226d0e' -KEYROM 0 B SLICE_X36Y50 b'857bf13e102b0681' -KEYROM 0 C SLICE_X36Y50 b'aad6a906ab393811' -KEYROM 0 D SLICE_X36Y50 b'6ec6bfdb8d6fbd65' -KEYROM 1 A SLICE_X37Y50 b'a99aa62192ee61da' -KEYROM 1 B SLICE_X37Y50 b'97360cfacd820d44' -KEYROM 1 C SLICE_X37Y50 b'cd9ae5284b4d98ec' -KEYROM 1 D SLICE_X37Y50 b'70955ec116272bfb' -KEYROM 2 A SLICE_X36Y51 b'ae878525409d6b22' -KEYROM 2 B SLICE_X36Y51 b'5c99f991d1911581' -KEYROM 2 C SLICE_X36Y51 b'f57e22302f205446' -KEYROM 2 D SLICE_X36Y51 b'6b8daf0f91dda5b0' -KEYROM 3 A SLICE_X37Y51 b'b1fb75c8c802d491' -KEYROM 3 B SLICE_X37Y51 b'b72013478d7d359c' -KEYROM 3 C SLICE_X37Y51 b'61b03aa98db8bee4' -KEYROM 3 D SLICE_X37Y51 b'517377c40a490c79' -KEYROM 4 A SLICE_X36Y52 b'ad8e8d566566373c' -KEYROM 4 B SLICE_X36Y52 b'f3ecbeddae2bcc1b' -KEYROM 4 C SLICE_X36Y52 b'84a9d40dc73d2b75' -KEYROM 4 D SLICE_X36Y52 b'a7346f299dd4bcfb' -KEYROM 5 A SLICE_X37Y52 b'c58a7fbd9312e425' -KEYROM 5 B SLICE_X37Y52 b'4193bc567380d7ab' -KEYROM 5 C SLICE_X37Y52 b'3fddafb15e88c94a' -KEYROM 5 D SLICE_X37Y52 b'f971220e9effc8c3' -KEYROM 6 A SLICE_X36Y53 b'c5e1f45f69384ca0' -KEYROM 6 B SLICE_X36Y53 b'77392ea867709b2c' -KEYROM 6 C SLICE_X36Y53 b'e879f1d549363de3' -KEYROM 6 D SLICE_X36Y53 b'623810d581154b27' -KEYROM 7 A SLICE_X37Y53 b'c6bca1c31aca5b3e' -KEYROM 7 B SLICE_X37Y53 b'd165beb68eee55bf' -KEYROM 7 C SLICE_X37Y53 b'2e9c486617209c20' -KEYROM 7 D SLICE_X37Y53 b'9ca132868a29916e' -KEYROM 8 A SLICE_X36Y54 b'11af473725837d0f' -KEYROM 8 B SLICE_X36Y54 b'c106aa6f9ad81a47' -KEYROM 8 C SLICE_X36Y54 b'aeab5ed2e0611ecc' -KEYROM 8 D SLICE_X36Y54 b'c2adcbc3ec813af2' -KEYROM 9 A SLICE_X37Y54 b'85c02942ec4ca55f' -KEYROM 9 B SLICE_X37Y54 b'72170e8ac0b022ba' -KEYROM 9 C SLICE_X37Y54 b'9f14cf16aaf00045' -KEYROM 9 D SLICE_X37Y54 b'd704155a669a8e47' -KEYROM 10 A SLICE_X36Y55 b'5e874e761cc5580b' -KEYROM 10 B SLICE_X36Y55 b'd0b190ca5b3dfce3' -KEYROM 10 C SLICE_X36Y55 b'4cf7de830c1ac97d' -KEYROM 10 D SLICE_X36Y55 b'8931d69a3b34e64d' -KEYROM 11 A SLICE_X37Y55 b'c22f5d6656c80775' -KEYROM 11 B SLICE_X37Y55 b'0313dd10a00df31b' -KEYROM 11 C SLICE_X37Y55 b'75e334a494e76dd2' -KEYROM 11 D SLICE_X37Y55 b'5378ded61921fffb' -KEYROM 12 A SLICE_X36Y56 b'1006b8877f36119a' -KEYROM 12 B SLICE_X36Y56 b'e624708638b294c8' -KEYROM 12 C SLICE_X36Y56 b'cdfa06516a984301' -KEYROM 12 D SLICE_X36Y56 b'f75415fd4ad88045' -KEYROM 13 A SLICE_X37Y56 b'd774ba30fe1779a7' -KEYROM 13 B SLICE_X37Y56 b'c2a8612bc03935f9' -KEYROM 13 C SLICE_X37Y56 b'b33eeacc096027bf' -KEYROM 13 D SLICE_X37Y56 b'27cdd4d0549d33cb' -KEYROM 14 A SLICE_X36Y57 b'3ff622a9f1951b1f' -KEYROM 14 B SLICE_X36Y57 b'7fe25942fc80c481' -KEYROM 14 C SLICE_X36Y57 b'c6efc1b3965c0a5b' -KEYROM 14 D SLICE_X36Y57 b'63ca59ac8a335a61' -KEYROM 15 A SLICE_X37Y57 b'deab4f42991af725' -KEYROM 15 B SLICE_X37Y57 b'b660723310d171be' -KEYROM 15 C SLICE_X37Y57 b'84fa18ed1ee2785e' -KEYROM 15 D SLICE_X37Y57 b'57eb698ba0497ac3' -KEYROM 16 A SLICE_X36Y58 b'92cf6b960f327018' -KEYROM 16 B SLICE_X36Y58 b'1bd25fb610a9ca2e' -KEYROM 16 C SLICE_X36Y58 b'2800b9f9b38a1fc2' -KEYROM 16 D SLICE_X36Y58 b'4564f3ae5ec7e2ef' -KEYROM 17 A SLICE_X37Y58 b'fe57626288702039' -KEYROM 17 B SLICE_X37Y58 b'9be854aea71e6306' -KEYROM 17 C SLICE_X37Y58 b'c7e4339a88dfa50a' -KEYROM 17 D SLICE_X37Y58 b'9d8464d69d495642' -KEYROM 18 A SLICE_X36Y59 b'6c67028bac778bc3' -KEYROM 18 B SLICE_X36Y59 b'cd6d5338d324a957' -KEYROM 18 C SLICE_X36Y59 b'039c930c96f67bd2' -KEYROM 18 D SLICE_X36Y59 b'09208ef08751a9ee' -KEYROM 19 A SLICE_X37Y59 b'9b7eb1ac7f9cf881' -KEYROM 19 B SLICE_X37Y59 b'a7f4668df275705e' -KEYROM 19 C SLICE_X37Y59 b'055ee2f5b84aeb04' -KEYROM 19 D SLICE_X37Y59 b'ec94695d6d3e4ff1' -KEYROM 20 A SLICE_X36Y60 b'a8da023b9cc0686c' -KEYROM 20 B SLICE_X36Y60 b'beb8707f46f58f18' -KEYROM 20 C SLICE_X36Y60 b'8f6fcffbd6762f54' -KEYROM 20 D SLICE_X36Y60 b'2c971d08f627b14a' -KEYROM 21 A SLICE_X37Y60 b'e79f3b3422d0bd97' -KEYROM 21 B SLICE_X37Y60 b'9b103158162c1fbe' -KEYROM 21 C SLICE_X37Y60 b'e40f0e2681bc671d' -KEYROM 21 D SLICE_X37Y60 b'7fbf49fbcf5091d1' -KEYROM 22 A SLICE_X36Y61 b'da6b6bd12c21ac65' -KEYROM 22 B SLICE_X36Y61 b'dfb684d30dda1d6b' -KEYROM 22 C SLICE_X36Y61 b'40d644b5ca08ac97' -KEYROM 22 D SLICE_X36Y61 b'61aafa2a2a3dd165' -KEYROM 23 A SLICE_X37Y61 b'2292ddb3325db476' -KEYROM 23 B SLICE_X37Y61 b'64ff0d80c373d0cc' -KEYROM 23 C SLICE_X37Y61 b'791536e5d8bb63bd' -KEYROM 23 D SLICE_X37Y61 b'86e930c308efcd8e' -KEYROM 24 A SLICE_X36Y62 b'884f15066623a286' -KEYROM 24 B SLICE_X36Y62 b'eb231df71090da2b' -KEYROM 24 C SLICE_X36Y62 b'0c0c12923bf3412b' -KEYROM 24 D SLICE_X36Y62 b'0b62a24163097e2e' -KEYROM 25 A SLICE_X37Y62 b'8b0c83eb6458563b' -KEYROM 25 B SLICE_X37Y62 b'b437a803c66d86cb' -KEYROM 25 C SLICE_X37Y62 b'882c3eb829382962' -KEYROM 25 D SLICE_X37Y62 b'514789d38eba7737' -KEYROM 26 A SLICE_X36Y63 b'880e318e3a3524d2' -KEYROM 26 B SLICE_X36Y63 b'de2ba44039606212' -KEYROM 26 C SLICE_X36Y63 b'6563c5b3b59c0cfd' -KEYROM 26 D SLICE_X36Y63 b'e0afebdba480792e' -KEYROM 27 A SLICE_X37Y63 b'75faeb7cdabed533' -KEYROM 27 B SLICE_X37Y63 b'0a4ab62dd34dff60' -KEYROM 27 C SLICE_X37Y63 b'04d3aa5ffcfccdcc' -KEYROM 27 D SLICE_X37Y63 b'1d8cc3dbe71bd1ef' -KEYROM 28 A SLICE_X36Y64 b'00d41840d9a957eb' -KEYROM 28 B SLICE_X36Y64 b'3389c742a0378433' -KEYROM 28 C SLICE_X36Y64 b'058f15c7fec3862b' -KEYROM 28 D SLICE_X36Y64 b'90fb604ce31f85f1' -KEYROM 29 A SLICE_X37Y64 b'1c829c30b5423fc4' -KEYROM 29 B SLICE_X37Y64 b'e869d464731f8561' -KEYROM 29 C SLICE_X37Y64 b'058f450e1f271547' -KEYROM 29 D SLICE_X37Y64 b'f1ac853786955262' -KEYROM 30 A SLICE_X36Y65 b'7e3e71f7e3a5019d' -KEYROM 30 B SLICE_X36Y65 b'e813d5dc7cc402cd' -KEYROM 30 C SLICE_X36Y65 b'450b410355320ab2' -KEYROM 30 D SLICE_X36Y65 b'cce7edc5daad2a84' -KEYROM 31 A SLICE_X37Y65 b'35e1cffa2a3cf8b4' -KEYROM 31 B SLICE_X37Y65 b'0988d15e58b77079' -KEYROM 31 C SLICE_X37Y65 b'ef69ea2cac65d5b7' -KEYROM 31 D SLICE_X37Y65 b'f714904698275521' +KEYROM 0 A SLICE_X36Y50 b'fd6cceca4e93c55f' +KEYROM 0 B SLICE_X36Y50 b'cc2d4c7aaa94602a' +KEYROM 0 C SLICE_X36Y50 b'262e3aac2e32b59b' +KEYROM 0 D SLICE_X36Y50 b'dd159c10f00ab72f' +KEYROM 1 A SLICE_X37Y50 b'20336e5611a125ab' +KEYROM 1 B SLICE_X37Y50 b'fc3d4ad57c2ab4cb' +KEYROM 1 C SLICE_X37Y50 b'35a7872666ffb066' +KEYROM 1 D SLICE_X37Y50 b'192d384d2be85592' +KEYROM 2 A SLICE_X36Y51 b'1165b243449daec5' +KEYROM 2 B SLICE_X36Y51 b'93c20a96996b04f5' +KEYROM 2 C SLICE_X36Y51 b'fa9bef7292809be3' +KEYROM 2 D SLICE_X36Y51 b'4dc615bde563f447' +KEYROM 3 A SLICE_X37Y51 b'b600c4bc91cd71e8' +KEYROM 3 B SLICE_X37Y51 b'94d35eba9193ca45' +KEYROM 3 C SLICE_X37Y51 b'c60c850b2122e2ff' +KEYROM 3 D SLICE_X37Y51 b'8b12c1f464b36165' +KEYROM 4 A SLICE_X36Y52 b'ad3ac7f6a04b0079' +KEYROM 4 B SLICE_X36Y52 b'e093325b6688075b' +KEYROM 4 C SLICE_X36Y52 b'2468d8b96df86777' +KEYROM 4 D SLICE_X36Y52 b'e774238941b04f9b' +KEYROM 5 A SLICE_X37Y52 b'703c68a01c4a47e7' +KEYROM 5 B SLICE_X37Y52 b'd3758e86c336dbc7' +KEYROM 5 C SLICE_X37Y52 b'baeabdd7c313d66f' +KEYROM 5 D SLICE_X37Y52 b'06290000816003cc' +KEYROM 6 A SLICE_X36Y53 b'e814f3ac73813485' +KEYROM 6 B SLICE_X36Y53 b'302b680d0ea005ae' +KEYROM 6 C SLICE_X36Y53 b'78f7aca1157d4a19' +KEYROM 6 D SLICE_X36Y53 b'f8d5ace4a60c422a' +KEYROM 7 A SLICE_X37Y53 b'a7e681664f577690' +KEYROM 7 B SLICE_X37Y53 b'c7b3ea62bc792d87' +KEYROM 7 C SLICE_X37Y53 b'b092134f948345d0' +KEYROM 7 D SLICE_X37Y53 b'8dfb70220a299bf5' +KEYROM 8 A SLICE_X36Y54 b'bca4ae74aa646ee8' +KEYROM 8 B SLICE_X36Y54 b'927c25f41c5468f8' +KEYROM 8 C SLICE_X36Y54 b'4e818234dd790f5e' +KEYROM 8 D SLICE_X36Y54 b'42045264cca36484' +KEYROM 9 A SLICE_X37Y54 b'20771c4844191daf' +KEYROM 9 B SLICE_X37Y54 b'0ac5694e1275e9a0' +KEYROM 9 C SLICE_X37Y54 b'a634bc74b90b9a71' +KEYROM 9 D SLICE_X37Y54 b'f523d81ba9d9216c' +KEYROM 10 A SLICE_X36Y55 b'fd2ff13a5000391b' +KEYROM 10 B SLICE_X36Y55 b'e93dcbbd702e9c86' +KEYROM 10 C SLICE_X36Y55 b'21e23ad498022d23' +KEYROM 10 D SLICE_X36Y55 b'08f8f8e2e4e74cbc' +KEYROM 11 A SLICE_X37Y55 b'32b9a3da4a48f700' +KEYROM 11 B SLICE_X37Y55 b'f694b0221488cf08' +KEYROM 11 C SLICE_X37Y55 b'cbadacf332abb536' +KEYROM 11 D SLICE_X37Y55 b'88ce136a7eca86ab' +KEYROM 12 A SLICE_X36Y56 b'2f4bbced6d24a3fc' +KEYROM 12 B SLICE_X36Y56 b'fe3f9c6472065bc9' +KEYROM 12 C SLICE_X36Y56 b'a4fb722e8f0e64f8' +KEYROM 12 D SLICE_X36Y56 b'ff7cc8debb8a9eb9' +KEYROM 13 A SLICE_X37Y56 b'b31169591d54a4f9' +KEYROM 13 B SLICE_X37Y56 b'0b0bc3e577d9729a' +KEYROM 13 C SLICE_X37Y56 b'cba7dd24ec3a78d9' +KEYROM 13 D SLICE_X37Y56 b'44a8800c654b3f72' +KEYROM 14 A SLICE_X36Y57 b'48d075aca60872ab' +KEYROM 14 B SLICE_X36Y57 b'8cd56a01965b28e3' +KEYROM 14 C SLICE_X36Y57 b'163930349876193b' +KEYROM 14 D SLICE_X36Y57 b'a7a8dc0d21c78c2c' +KEYROM 15 A SLICE_X37Y57 b'b75ab434826b5eba' +KEYROM 15 B SLICE_X37Y57 b'33ded10ef97362af' +KEYROM 15 C SLICE_X37Y57 b'5ecc1a3f47c2f980' +KEYROM 15 D SLICE_X37Y57 b'ba57d888d1f8a52e' +KEYROM 16 A SLICE_X36Y58 b'7b81b41fb75bc0e6' +KEYROM 16 B SLICE_X36Y58 b'71e364c8e0208a18' +KEYROM 16 C SLICE_X36Y58 b'ae293b0bf103aaa0' +KEYROM 16 D SLICE_X36Y58 b'd06f234087632ea6' +KEYROM 17 A SLICE_X37Y58 b'15bb04d2c9781dce' +KEYROM 17 B SLICE_X37Y58 b'efb553e298f0e843' +KEYROM 17 C SLICE_X37Y58 b'3b915ef3d08ab845' +KEYROM 17 D SLICE_X37Y58 b'35d33e0c2a87c23e' +KEYROM 18 A SLICE_X36Y59 b'b3006d7308c6c90d' +KEYROM 18 B SLICE_X36Y59 b'9cb61b11f20babac' +KEYROM 18 C SLICE_X36Y59 b'ff959540b452b398' +KEYROM 18 D SLICE_X36Y59 b'bc5fe2a26d99c55a' +KEYROM 19 A SLICE_X37Y59 b'09d7a438fce56b2b' +KEYROM 19 B SLICE_X37Y59 b'650c1dba8971f396' +KEYROM 19 C SLICE_X37Y59 b'ed0b25f3639daadc' +KEYROM 19 D SLICE_X37Y59 b'0052cf44cc5cafaf' +KEYROM 20 A SLICE_X36Y60 b'5446e67d71abe10a' +KEYROM 20 B SLICE_X36Y60 b'2de7e173416e43f2' +KEYROM 20 C SLICE_X36Y60 b'bcb4e0e889134ed8' +KEYROM 20 D SLICE_X36Y60 b'53916327f0e8859b' +KEYROM 21 A SLICE_X37Y60 b'e62f3070dd02ac1e' +KEYROM 21 B SLICE_X37Y60 b'086da9c713098d3c' +KEYROM 21 C SLICE_X37Y60 b'5a3cad1b45aba3ed' +KEYROM 21 D SLICE_X37Y60 b'302675eba1886ede' +KEYROM 22 A SLICE_X36Y61 b'e79af85248b968f9' +KEYROM 22 B SLICE_X36Y61 b'a22fd863f5786979' +KEYROM 22 C SLICE_X36Y61 b'25481858eee2d33c' +KEYROM 22 D SLICE_X36Y61 b'3073fb6ad4c2f50c' +KEYROM 23 A SLICE_X37Y61 b'4be3a8c189882ba9' +KEYROM 23 B SLICE_X37Y61 b'ad233624c17613f5' +KEYROM 23 C SLICE_X37Y61 b'3d97de713b8fe907' +KEYROM 23 D SLICE_X37Y61 b'47d0ce71b8309e6f' +KEYROM 24 A SLICE_X36Y62 b'7e57cfcdcc837e9a' +KEYROM 24 B SLICE_X36Y62 b'9df9bb032fe5c74f' +KEYROM 24 C SLICE_X36Y62 b'ed13aab9735bb963' +KEYROM 24 D SLICE_X36Y62 b'a6b46fce5143bc7d' +KEYROM 25 A SLICE_X37Y62 b'53f2d83cdf137246' +KEYROM 25 B SLICE_X37Y62 b'8926891fa58d224b' +KEYROM 25 C SLICE_X37Y62 b'313b44a200b762c5' +KEYROM 25 D SLICE_X37Y62 b'9f51cb45bca773ea' +KEYROM 26 A SLICE_X36Y63 b'd23b76eaed9615ff' +KEYROM 26 B SLICE_X36Y63 b'8c14b0759dfc3a6a' +KEYROM 26 C SLICE_X36Y63 b'67eca51fc778e5be' +KEYROM 26 D SLICE_X36Y63 b'19e4450cedd462a1' +KEYROM 27 A SLICE_X37Y63 b'b35e4ca890a8ec1c' +KEYROM 27 B SLICE_X37Y63 b'4c955d175a8a9cc4' +KEYROM 27 C SLICE_X37Y63 b'8c71158986d0b616' +KEYROM 27 D SLICE_X37Y63 b'966be57391799479' +KEYROM 28 A SLICE_X36Y64 b'f0b20991ade19a3b' +KEYROM 28 B SLICE_X36Y64 b'53f3470cf0634e0d' +KEYROM 28 C SLICE_X36Y64 b'925834ef3e5ea5cc' +KEYROM 28 D SLICE_X36Y64 b'f6310e83a8b155f5' +KEYROM 29 A SLICE_X37Y64 b'bb48c1bad57730b0' +KEYROM 29 B SLICE_X37Y64 b'4a1bc4c228293c6d' +KEYROM 29 C SLICE_X37Y64 b'1b784a54e3061303' +KEYROM 29 D SLICE_X37Y64 b'a8a4d24f26c729c5' +KEYROM 30 A SLICE_X36Y65 b'4d1505a0b92c34da' +KEYROM 30 B SLICE_X36Y65 b'54ef48143e640961' +KEYROM 30 C SLICE_X36Y65 b'a30975b7e7e91a83' +KEYROM 30 D SLICE_X36Y65 b'17afb4894134dd26' +KEYROM 31 A SLICE_X37Y65 b'fb3781e53d689766' +KEYROM 31 B SLICE_X37Y65 b'61af4482205b8287' +KEYROM 31 C SLICE_X37Y65 b'9feb924c771c04e4' +KEYROM 31 D SLICE_X37Y65 b'80eaeb4109ad4a69' diff --git a/precursors/soc.svd b/precursors/soc.svd index 38b7bbb07..623312969 100644 --- a/precursors/soc.svd +++ b/precursors/soc.svd @@ -3,7 +3,7 @@ litex SOC - + 8 32 @@ -1190,7 +1190,7 @@ register to disable individual events.]]> GIT_MAJOR +``v0.9.7``, so this value is ``0``.]]> 0x0008 0x00 32 @@ -1206,7 +1206,7 @@ register to disable individual events.]]> GIT_MINOR +``v0.9.7``, so this value is ``9``.]]> 0x000c 0x09 32 @@ -1222,9 +1222,9 @@ register to disable individual events.]]> GIT_REVISION +``v0.9.7``, so this value is ``7``.]]> 0x0010 - 0x06 + 0x07 32 @@ -1238,10 +1238,10 @@ register to disable individual events.]]> GIT_GITREV 0x0014 - 0x3b0081ea + 0xa5d09b97 32 @@ -1258,7 +1258,7 @@ the exact git version used to build this firmware.]]> is ``1``, then the repository this was built from has one additional commit beyond the tag indicated in `MAJOR`, `MINOR`, and `REVISION`.]]> 0x0018 - 0x01 + 0x00 32 @@ -3593,7 +3593,7 @@ inject too fast.]]> SEED1 0x0000 - 0x5cb15120 + 0x3c7c0635 32 @@ -3608,7 +3608,7 @@ inject too fast.]]> SEED0 0x0004 - 0x259f731c + 0x4c01b544 32 diff --git a/precursors/soc_csr.bin b/precursors/soc_csr.bin index 004e7cc82..6d1d3bf42 100644 Binary files a/precursors/soc_csr.bin and b/precursors/soc_csr.bin differ diff --git a/services/pddb/Cargo.toml b/services/pddb/Cargo.toml index 099634370..97c4e6257 100644 --- a/services/pddb/Cargo.toml +++ b/services/pddb/Cargo.toml @@ -27,6 +27,7 @@ cipher = "0.3.0" bitfield = "0.13.2" aes-gcm-siv = "0.10.3" llio = {path="../llio"} +subtle = {version = "2.4.1", default-features = false} # passwords sha2 = {path = "../engine-sha512"} diff --git a/services/pddb/src/api.rs b/services/pddb/src/api.rs index 936391cb5..865d86176 100644 --- a/services/pddb/src/api.rs +++ b/services/pddb/src/api.rs @@ -22,7 +22,7 @@ pub(crate) const PASSWORD_LEN: usize = 72; // this is actually set by bcrypt #[allow(dead_code)] pub(crate) const PDDB_MAGIC: [u8; 4] = [0x50, 0x44, 0x44, 0x42]; #[allow(dead_code)] -pub(crate) const PDDB_VERSION: u32 = 0x00_00_00_01; +pub(crate) const PDDB_VERSION: u32 = 0x00_00_01_01; #[allow(dead_code)] // PDDB_A_LEN may be shorter than xous::PDDB_LEN, to speed up testing. #[allow(dead_code)] diff --git a/services/pddb/src/backend/basis.rs b/services/pddb/src/backend/basis.rs index 7ab8345bd..00f889b71 100644 --- a/services/pddb/src/backend/basis.rs +++ b/services/pddb/src/backend/basis.rs @@ -659,8 +659,12 @@ impl BasisCache { } // refetch the basis here to avoid the re-borrow problem, now that all the potential dict cache mutations are done let basis = &mut self.cache[basis_index]; - basis.age = basis.age.saturating_add(1); - basis.clean = false; + + // bumping this every key update affects performance *a lot* -- don't think this is worth it. + // the bases should only "age" when dicts or keys are modified, not when any data in it is updated for any reason. + // basis.age = basis.age.saturating_add(1); + // basis.clean = false; + // now do the sync if let Some(dict_entry) = basis.dicts.get_mut(dict) { let updated_ptr = dict_entry.key_update(hw, &mut basis.v2p_map, @@ -785,10 +789,9 @@ impl BasisCache { policy: BasisRetentionPolicy) -> Option { let basis_key = hw.basis_derive_key(name, password); if let Some(basis_map) = hw.pt_scan_key(&basis_key, name) { - let cipher = Aes256GcmSiv::new(Key::from_slice(&basis_key)); let aad = hw.data_aad(name); if let Some(root_page) = basis_map.get(&VirtAddr::new(VPAGE_SIZE as u64).unwrap()) { - let vpage = match hw.data_decrypt_page(&cipher, &aad, root_page) { + let vpage = match hw.data_decrypt_page_with_commit(&basis_key, &aad, root_page) { Some(data) => data, None => {log::error!("Could not find basis {} root", name); return None;}, }; @@ -856,12 +859,11 @@ impl BasisCache { let slice_iter = journal_bytes.iter() // journal rev .chain(basis_root.as_ref().iter()); - let mut block = [0 as u8; VPAGE_SIZE + size_of::()]; + let mut block = [0 as u8; KCOM_CT_LEN]; for (&src, dst) in slice_iter.zip(block.iter_mut()) { *dst = src; } - let key = Key::clone_from_slice(&basis_key); - hw.data_encrypt_and_patch_page(&Aes256GcmSiv::new(&key), &aad, &mut block, &pp); + hw.data_encrypt_and_patch_page_with_commit(&basis_key, &aad, &mut block, &pp); let cipher = Aes256::new(GenericArray::from_slice(&basis_key)); for (&virt, phys) in basis_v2p_map.iter_mut() { @@ -983,6 +985,8 @@ pub(crate) struct BasisCacheEntry { pub cipher: Aes256GcmSiv, /// derived cipher for encrypting PTEs -- cache it, so we can save the time cost of constructing the cipher key schedule pub cipher_ecb: Aes256, + /// raw AES key -- needed because we have to use this to derive commitment keys for the basis root record, to work around AES-GCM-SIV salamanders + pub key: GenericArray, /// the AAD associated with this Basis pub aad: Vec::, /// modification count @@ -1009,7 +1013,7 @@ impl BasisCacheEntry { let aad = hw.data_aad(name); // get the first page, where the basis root is guaranteed to be if let Some(root_page) = basis_map.get(&VirtAddr::new(VPAGE_SIZE as u64).unwrap()) { - let vpage = match hw.data_decrypt_page(&cipher, &aad, root_page) { + let vpage = match hw.data_decrypt_page_with_commit(key, &aad, root_page) { Some(data) => data, None => {log::error!("System basis decryption did not authenticate. Unrecoverable error."); return None;}, }; @@ -1040,6 +1044,7 @@ impl BasisCacheEntry { dicts: HashMap::::new(), cipher, cipher_ecb: Aes256::new(GenericArray::from_slice(key)), + key: GenericArray::clone_from_slice(key), aad, age: basis_root.age, free_dict_offset: None, @@ -1492,14 +1497,14 @@ impl BasisCacheEntry { let slice_iter = journal_bytes.iter() // journal rev .chain(basis_root.as_ref().iter()); - let mut block = [0 as u8; VPAGE_SIZE + size_of::()]; + let mut block = [0 as u8; KCOM_CT_LEN]; for (&src, dst) in (hw.trng_u32() % JOURNAL_RAND_RANGE).to_le_bytes().iter().zip(block[..size_of::()].iter_mut()) { *dst = src; } for (&src, dst) in slice_iter.zip(block.iter_mut()) { *dst = src; } - hw.data_encrypt_and_patch_page(&self.cipher, &self.aad, &mut block, &pp); + hw.data_encrypt_and_patch_page_with_commit(self.key.as_slice(), &self.aad, &mut block, &pp); self.clean = true; } } diff --git a/services/pddb/src/backend/hosted.rs b/services/pddb/src/backend/hosted.rs index 5b0b2b977..c40e76191 100644 --- a/services/pddb/src/backend/hosted.rs +++ b/services/pddb/src/backend/hosted.rs @@ -94,6 +94,7 @@ impl HostedSpinor { } } pub fn patch(&self, _region: &[u8], _region_base: u32, data: &[u8], offset: u32) -> Result<(), xous::Error> { + // println!("patch at {:x}+{}", offset, data.len()); for (&src, dst) in data.iter().zip( flashmem().memory.as_mut_slice()[offset as usize..offset as usize + data.len()].iter_mut() ) { diff --git a/services/pddb/src/backend/hw.rs b/services/pddb/src/backend/hw.rs index 3db914457..67bd64d3d 100644 --- a/services/pddb/src/backend/hw.rs +++ b/services/pddb/src/backend/hw.rs @@ -7,6 +7,7 @@ use aes::{Aes256, Block, BLOCK_SIZE}; use aes::cipher::{BlockDecrypt, BlockEncrypt, NewBlockCipher, generic_array::GenericArray}; use root_keys::api::AesRootkeyType; use spinor::SPINOR_BULK_ERASE_SIZE; +use subtle::ConstantTimeEq; use core::ops::{Deref, DerefMut}; use core::mem::size_of; @@ -33,6 +34,11 @@ pub const PAGE_SIZE: usize = spinor::SPINOR_ERASE_SIZE as usize; /// size of a virtual page -- after the AES encryption and journaling overhead is subtracted pub const VPAGE_SIZE: usize = PAGE_SIZE - size_of::() - size_of::() - size_of::(); +/// length of the ciphertext in an AES-GCM-SIV page with key commitments +/// equal to the total plaintext to be encrypted, including the journal number +/// does not include the MAC overhead +pub const KCOM_CT_LEN: usize = 4004; + const WRAPPED_AES_KEYSIZE: usize = AES_KEYSIZE + 8; const SCD_VERSION: u32 = 1; #[repr(C)] // this can map directly into Flash @@ -1113,6 +1119,77 @@ impl PddbOs { } } } + + /// returns a decrypted page that also encodes a key commitments. In this case, a raw key is passed, + /// instead of the generic AES-GCM-SIV cipher, because we need to derive the key commitment. + /// Key commitments are a patch to work-around the salamander problem in AES-GCM-SIV see https://eprint.iacr.org/2020/1456.pdf + /// + /// The structure of a page with commit key storage is as follows: + /// - Nonce - 12 bytes + /// - ciphertext - 4004 bytes (includes the journal number) + /// - kcomm_nonce - 32 bytes + /// - kcomm - 32 bytes + /// - MAC - 16 bytes + /// We stripe the MAC at the end just in case the MAC has some arithmetic property that can betray the existence + /// of a basis root record with key commitment. The committed key and the nonce both should be indistinguishable + /// from ciphertext. + pub(crate) fn data_decrypt_page_with_commit(&mut self, key: &[u8], aad: &[u8], page: &PhysPage) -> Option> { + const KCOM_NONCE_LEN: usize = 32; + const KCOM_LEN: usize = 32; + const MAC_LEN: usize = 16; + let ct_slice = &self.pddb_mr.as_slice()[ + self.data_phys_base.as_usize() + page.page_number() as usize * PAGE_SIZE .. + self.data_phys_base.as_usize() + (page.page_number() as usize + 1) * PAGE_SIZE]; + log::debug!("commit data at 0x{:x}", self.data_phys_base.as_usize() + page.page_number() as usize * PAGE_SIZE); + let nonce = &ct_slice[..size_of::()]; + let ct_total = &ct_slice[size_of::()..]; + + // extract the regions of the stored data and place them into their respective buffers + let mut ct_plus_mac = [0u8; KCOM_CT_LEN + MAC_LEN]; + let mut nonce_comm = [0u8; KCOM_NONCE_LEN]; + let mut key_comm_stored = [0u8; KCOM_LEN]; + let mut ct_pos = 0; + + for (&src, dst) in ct_total[ct_pos..].iter().zip(ct_plus_mac[..KCOM_CT_LEN].iter_mut()) { + *dst = src; + ct_pos += 1; + } + for (&src, dst) in ct_total[ct_pos..].iter().zip(nonce_comm.iter_mut()) { + *dst = src; + ct_pos += 1; + } + for (&src, dst) in ct_total[ct_pos..].iter().zip(key_comm_stored.iter_mut()) { + *dst = src; + ct_pos += 1; + } + for (&src, dst) in ct_total[ct_pos..].iter().zip(ct_plus_mac[KCOM_CT_LEN..].iter_mut()) { + *dst = src; + ct_pos += 1; + } + assert!(ct_pos == PAGE_SIZE - size_of::(), "struct sizing error in unpacking page with key commit"); + log::debug!("found nonce of {:x?}", nonce); + log::debug!("found kcom_nonce of {:x?}", nonce_comm); + + let (kenc, kcom) = self.kcom_func(key.try_into().unwrap(), &nonce_comm); + let cipher = Aes256GcmSiv::new(Key::from_slice(&kenc)); + + // Attempt decryption. This is None on failure + let plaintext = cipher.decrypt( + Nonce::from_slice(nonce), + Payload { + aad, + msg: &ct_plus_mac, + } + ).ok(); + + // Only return the plaintext if the stored key commitment agrees with the computed one + if kcom.ct_eq(&key_comm_stored).into() { + plaintext + } else { + None + } + } + /// `data` includes the journal entry on top. The data passed in must be exactly one vpage plus the journal entry pub(crate) fn data_encrypt_and_patch_page(&mut self, cipher: &Aes256GcmSiv, aad: &[u8], data: &mut [u8], pp: &PhysPage) { assert!(data.len() == VPAGE_SIZE + size_of::(), "did not get a page-sized region to patch"); @@ -1129,6 +1206,74 @@ impl PddbOs { self.patch_data(&[nonce.as_slice(), &ciphertext].concat(), pp.page_number() * PAGE_SIZE as u32); } + /// `data` includes the journal entry on top. + /// The data passed in must be exactly one vpage plus the journal entry minus the length of the commit structure (64 bytes), + /// which is 4004 bytes total + pub(crate) fn data_encrypt_and_patch_page_with_commit(&mut self, key: &[u8], aad: &[u8], data: &mut [u8], pp: &PhysPage) { + assert!(data.len() == KCOM_CT_LEN, "did not get a key-commit sized region to patch"); + // updates the journal type + let j = JournalType::from_le_bytes(data[..size_of::()].try_into().unwrap()).saturating_add(1); + for (&src, dst) in j.to_le_bytes().iter().zip(data[..size_of::()].iter_mut()) { *dst = src; } + // gets the AES-GCM-SIV nonce + let nonce = self.nonce_gen(); + // makes a nonce for the key commit + let mut kcom_nonce = [0u8; 32]; + self.trng_slice(&mut kcom_nonce); + // generates the encryption and commit keys + let (kenc, kcom) = self.kcom_func(key.try_into().unwrap(), &kcom_nonce); + let cipher = Aes256GcmSiv::new(Key::from_slice(&kenc)); + let ciphertext = cipher.encrypt( + &nonce, + Payload { + aad, + msg: &data, + } + ).expect("couldn't encrypt data"); + let mut dest_page = [0u8; PAGE_SIZE]; + + let mut written = 0; // used as a sanity check on the insane iterator chain constructed below + for (&src, dst) in + nonce.as_slice().iter() + .chain(ciphertext[..KCOM_CT_LEN].iter()) + .chain(kcom_nonce.iter()) + .chain(kcom.iter()) + .chain(ciphertext[KCOM_CT_LEN..].iter()) + .zip(dest_page.iter_mut()) { + *dst = src; + written += 1; + } + assert!(written == 4096, "data sizing error in encryption with key commit"); + log::trace!("nonce: {:x?}", &nonce); + log::debug!("dest_page[kcom_nonce]: {:x?}", &dest_page[12+4004..12+4004+32]); + self.patch_data(&dest_page, pp.page_number() * PAGE_SIZE as u32); + } + + /// Derive a key commitment. This takes in a base `key`, which is 256 bits; + /// a `nonce` which is the 96-bit nonce used in the AES-GCM-SIV for a given block; + /// and `nonce_com` which is the commitment nonce, set at 256 bits. + /// The result is two tuples, (kenc, kcom). + fn kcom_func(&self, + key: &[u8; 32], + nonce_com: &[u8; 32]) -> ([u8; 32], [u8; 32]) { + use sha2::{FallbackStrategy, Sha512Trunc256}; + use digest::Digest; + + let mut h_enc = Sha512Trunc256::new_with_strategy(FallbackStrategy::SoftwareOnly); + h_enc.update(key); + // per https://eprint.iacr.org/2020/1456.pdf Table 4 on page 13 Type I Lenc + h_enc.update([0x43, 0x6f, 0x6, 0xd6, 0xd, 0x69, 0x74, 0x01, 0x01]); + h_enc.update(nonce_com); + let k_enc = h_enc.finalize(); + + let mut h_com = Sha512Trunc256::new_with_strategy(FallbackStrategy::SoftwareOnly); + h_com.update(key); + // per https://eprint.iacr.org/2020/1456.pdf Table 4 on page 13 Type I Lcom. Note one-bit difference in last byte. + h_com.update([0x43, 0x6f, 0x6, 0xd6, 0xd, 0x69, 0x74, 0x01, 0x02]); + h_com.update(nonce_com); + let k_com = h_com.finalize(); + (k_enc.into(), k_com.into()) + } + /// Meant to be called on boot. This will read the FastSpace record, and then attempt to load /// in the system basis. pub(crate) fn pddb_mount(&mut self) -> Option { @@ -1136,11 +1281,10 @@ impl PddbOs { self.syskey_ensure(); if let Some(syskey) = self.system_basis_key { if let Some(sysbasis_map) = self.pt_scan_key(&syskey, PDDB_DEFAULT_SYSTEM_BASIS) { - let cipher = Aes256GcmSiv::new(Key::from_slice(&syskey)); let aad = self.data_aad(PDDB_DEFAULT_SYSTEM_BASIS); // get the first page, where the basis root is guaranteed to be if let Some(root_page) = sysbasis_map.get(&VirtAddr::new(VPAGE_SIZE as u64).unwrap()) { - let vpage = match self.data_decrypt_page(&cipher, &aad, root_page) { + let vpage = match self.data_decrypt_page_with_commit(&syskey, &aad, root_page) { Some(data) => data, None => {log::error!("System basis decryption did not authenticate. Unrecoverable error."); return None;}, }; @@ -1448,12 +1592,13 @@ impl PddbOs { let slice_iter = journal_bytes.iter() // journal rev .chain(basis_root.as_ref().iter()); - let mut block = [0 as u8; VPAGE_SIZE + size_of::()]; + let mut block = [0 as u8; KCOM_CT_LEN]; for (&src, dst) in slice_iter.zip(block.iter_mut()) { *dst = src; } - let key = Key::clone_from_slice(self.system_basis_key.as_ref().unwrap()); - self.data_encrypt_and_patch_page(&Aes256GcmSiv::new(&key), &aad, &mut block, &pp); + let syskey = self.system_basis_key.unwrap(); // take the key out + self.data_encrypt_and_patch_page_with_commit(&syskey, &aad, &mut block, &pp); + self.system_basis_key = Some(syskey); // put the key back if let Some(modals) = progress { modals.update_progress(66).expect("couldn't update progress bar"); self.tt.sleep_ms(100).unwrap(); diff --git a/services/pddb/src/tests.rs b/services/pddb/src/tests.rs index 5fdf240f9..38a2f692b 100644 --- a/services/pddb/src/tests.rs +++ b/services/pddb/src/tests.rs @@ -111,6 +111,7 @@ pub(crate) fn delete_add_dict_consistency(hw: &mut PddbOs, basis_cache: &mut Bas let dict_start_index = dict_list.len(); for (evicted, evict_dict) in dict_list.iter().enumerate() { if evicted < evict_count { + log::debug!("evicting dict {}", evict_dict); match basis_cache.dict_remove(hw, evict_dict, basis_name, false) { Ok(_) => {}, Err(e) => log::error!("Error evicting dictionary {}: {:?}", evict_dict, e), @@ -124,6 +125,7 @@ pub(crate) fn delete_add_dict_consistency(hw: &mut PddbOs, basis_cache: &mut Bas for dictnum in 1..=evict_count { let dictname = format!("dict{}", dictnum + dict_start_index); let (keyname, keydata) = gen_key(&dictname, keynum, key_lower_bound, key_upper_bound); + log::debug!("adding {}:{}", dictname, keyname); // now we're ready to write it out if maybe_extra_reserved.is_none() { // we do this slightly funky way instead of just passing Some(0) because we want to test the "None" path explicitly @@ -169,6 +171,7 @@ pub(crate) fn patch_test(hw: &mut PddbOs, basis_cache: &mut BasisCache, #[cfg(not(feature = "deterministic"))] let key_list = key_list_unord; for key in key_list.iter() { + log::debug!("updating {}:{}", dict, key); // this actually does something a bit more complicated on a multi-basis system than you'd think: // it will get the union of all key names, and then patch the *latest open basis* only with new data. // note: if the key didn't already exist in the latest open basis, it's added, with just that patch data in it. @@ -182,14 +185,11 @@ pub(crate) fn patch_test(hw: &mut PddbOs, basis_cache: &mut BasisCache, } } - log::debug!("bef readback"); // now fix the CI checksum. structured as two separate patches. not because it's efficient, // but because it exercises the code harder. let mut patchbuf = [0u8; UPPER_BOUND]; let readlen = basis_cache.key_read(hw, dict, key, &mut patchbuf, Some(0), None).unwrap(); - log::debug!("bef no extend"); if !extend { - log::debug!("bef no extend"); // now re-compute the checksum let mut checkdata = Vec::::new(); for &b in &patchbuf[..readlen-4] { @@ -202,7 +202,6 @@ pub(crate) fn patch_test(hw: &mut PddbOs, basis_cache: &mut BasisCache, let checksum = murmur3_32(&checkdata, 0); basis_cache.key_update(hw, dict, key, &checksum.to_le_bytes(), Some(readlen-4), None, None, false)?; } else { - log::debug!("extend"); // this gloms a new checksum onto the existing record, adding 4 new bytes. let mut checkdata = Vec::::new(); for &b in &patchbuf[..readlen] { @@ -408,7 +407,6 @@ pub(crate) fn ci_tests(pddb_os: &mut PddbOs) -> Result<()> { None, None, Some(32))?; log::info!("Saving `basecase1e` to local host"); pddb_os.dbg_dump(Some("basecase1e".to_string()), None); - let extra_basis_key = pddb_os.basis_derive_key(EXTRA_BASIS, EXTRA_BASIS_PW); let mut name = [0 as u8; 64]; for (&src, dst) in EXTRA_BASIS.as_bytes().iter().zip(name.iter_mut()) { diff --git a/services/skeleton/src/main.rs b/services/skeleton/src/main.rs index 190d472d0..574cb3457 100644 --- a/services/skeleton/src/main.rs +++ b/services/skeleton/src/main.rs @@ -86,7 +86,7 @@ fn xmain() -> ! { info!("my PID is {}", xous::process::id()); let xns = xous_names::XousNames::new().unwrap(); - let codec_sid = xns.register_name(api::SERVER_NAME_CODEC).expect("can't register server"); + let codec_sid = xns.register_name(api::SERVER_NAME_CODEC, None).expect("can't register server"); log::trace!("registered with NS -- {:?}", codec_sid); let mut codec = Codec::new(); diff --git a/services/status/src/main.rs b/services/status/src/main.rs index 03ccf0e48..c4de445ab 100644 --- a/services/status/src/main.rs +++ b/services/status/src/main.rs @@ -309,6 +309,7 @@ fn xmain() -> ! { } }); }; + sec_notes.lock().unwrap().insert("current_app".to_string(), format!("Running: Shellchat").to_string()); // this is the default app on boot let mut stats_phase: usize = 0; @@ -727,11 +728,26 @@ fn xmain() -> ! { }), Some(StatusOpcode::SwitchToShellchat) => { ticktimer.sleep_ms(100).ok(); + sec_notes.lock().unwrap().remove(&"current_app".to_string()); + sec_notes.lock().unwrap().insert("current_app".to_string(), format!("Running: Shellchat").to_string()); gam.switch_to_app(gam::APP_NAME_SHELLCHAT, security_tv.token.unwrap()).expect("couldn't raise shellchat"); + secnotes_force_redraw = true; + send_message( + cb_cid, + Message::new_scalar(StatusOpcode::Pump.to_usize().unwrap(), 0, 0, 0, 0), + ).expect("couldn't trigger status update"); }, Some(StatusOpcode::SwitchToApp) => msg_scalar_unpack!(msg, index, _, _, _, { ticktimer.sleep_ms(100).ok(); - app_autogen::app_dispatch(&gam, security_tv.token.unwrap(), index); + let app_name = app_autogen::app_index_to_name(index).expect("app index not found"); + app_autogen::app_dispatch(&gam, security_tv.token.unwrap(), index).expect("cannot switch to app"); + sec_notes.lock().unwrap().remove(&"current_app".to_string()); + sec_notes.lock().unwrap().insert("current_app".to_string(), format!("Running: {}", app_name).to_string()); + secnotes_force_redraw = true; + send_message( + cb_cid, + Message::new_scalar(StatusOpcode::Pump.to_usize().unwrap(), 0, 0, 0, 0), + ).expect("couldn't trigger status update"); }), Some(StatusOpcode::TrySuspend) => { if ((llio.adc_vbus().unwrap() as f64) * 0.005033) > 1.5 { diff --git a/tools/pddbdbg.py b/tools/pddbdbg.py index 1641535c6..d6541ebec 100755 --- a/tools/pddbdbg.py +++ b/tools/pddbdbg.py @@ -4,6 +4,8 @@ import sys from Crypto.Cipher import AES from rfc8452 import AES_GCM_SIV +from Crypto.Hash import SHA512 +import binascii import logging @@ -99,6 +101,41 @@ def mm3_hash( key, seed = 0x0 ): else: return -( (unsigned_val ^ 0xFFFFFFFF) + 1 ) +def keycommit_decrypt(key, aad, pp_data): + # print([hex(d) for d in pp_data[:32]]) + nonce = pp_data[:12] + ct = pp_data[12:12+4004] + kcom_nonce = pp_data[12+4004:12+4004+32] + kcom = pp_data[12+4004+32:12+4004+32+32] + mac = pp_data[-16:] + + #print([hex(d) for d in kcom_nonce]) + # print([hex(d) for d in kcom]) + #h_test = SHA512.new(truncate="256") # just something to make sure our hash functions are sane + #h_test.update(bytes([0x43, 0x6f, 0x6, 0xd6, 0xd, 0x69, 0x74, 0x01, 0x01])) + #print(h_test.hexdigest()) + + h_enc = SHA512.new(truncate="256") + h_enc.update(key) + h_enc.update(bytes([0x43, 0x6f, 0x6, 0xd6, 0xd, 0x69, 0x74, 0x01, 0x01])) + h_enc.update(kcom_nonce) + k_enc = h_enc.digest() + + h_com = SHA512.new(truncate="256") + h_com.update(key) + h_com.update(bytes([0x43, 0x6f, 0x6, 0xd6, 0xd, 0x69, 0x74, 0x01, 0x02])) + h_com.update(kcom_nonce) + k_com_derived = h_com.digest() + print('kcom_stored: ' + binascii.hexlify(kcom).decode('utf-8')) + print('kcom_derived: ' + binascii.hexlify(k_com_derived).decode('utf-8')) + + cipher = AES_GCM_SIV(k_enc, nonce) + pt_data = cipher.decrypt(ct + mac, aad) + if k_com_derived != kcom: + print("basis failed key commit test") + raise Exception(ValueError) + return pt_data + def main(): parser = argparse.ArgumentParser(description="Debug PDDB Images") @@ -191,11 +228,10 @@ def main(): basis_data = bytearray() pp_start = v2p_table[VPAGE_SIZE] - # print("pp_start: {}, vp: {}".format(pp_start, vp)) + # print("pp_start: {:x}".format(pp_start)) pp_data = data[pp_start:pp_start + PAGE_SIZE] try: - cipher = AES_GCM_SIV(key, pp_data[:12]) - pt_data = cipher.decrypt(pp_data[12:], basis_aad(name)) + pt_data = keycommit_decrypt(key, basis_aad(name), pp_data) basis_data.extend(bytearray(pt_data)) logging.debug("decrypted vpage @ {:x} ppage @ {:x}".format(VPAGE_SIZE, v2p_table[VPAGE_SIZE])) # print([hex(x) for x in basis_data[:256]]) @@ -535,7 +571,7 @@ class Basis: #desc += ' DictPtr: {:x}\n'.format(self.dict_ptr) return desc -def basis_aad(name, version=1, dna=0): +def basis_aad(name, version=0x01_01, dna=0): name_bytes = bytearray(name, 'utf-8') # name_bytes += bytearray(([0] * (Basis.MAX_NAME_LEN - len(name)))) name_bytes += version.to_bytes(4, 'little') @@ -703,7 +739,7 @@ class Fscb: self.free_space[pp.page_number() * 4096] = pp # this is the "AAD" used to encrypt the FastSpace - def aad(version=1, dna=0): + def aad(version=0x01_01, dna=0): return bytearray([46, 70, 97, 115, 116, 83, 112, 97, 99, 101]) + version.to_bytes(4, 'little') + dna.to_bytes(8, 'little') class SpaceUpdate: diff --git a/tools/update_ci.ps1 b/tools/update_ci.ps1 new file mode 100644 index 000000000..f9f246f1c --- /dev/null +++ b/tools/update_ci.ps1 @@ -0,0 +1,47 @@ +Write-Output "This script will update Xous and stage gateware and EC firmware for self-provisioning. No secrets will be erased." +Write-Output "This script will use the bleeding edge CI build." +$title = 'Update to bleeding edge CI' +$question = 'Are you sure you want to proceed?' +$choices = '&Yes', '&No' + +$decision = $Host.UI.PromptForChoice($title, $question, $choices, 1) +if ($decision -eq 0) { + Write-Host 'confirmed' +} else { + Exit +} + +Invoke-WebRequest https://ci.betrusted.io/latest-ci/loader.bin -OutFile loader.bin +python usb_update.py -l loader.bin +Remove-Item loader.bin + +Write-Output "waiting for device to reboot" +Start-Sleep 5 + +Invoke-WebRequest https://ci.betrusted.io/latest-ci/xous.img -OutFile xous.img +python usb_update.py -k xous.img +Remove-Item xous.img + +Write-Output "waiting for device to reboot" +Start-Sleep 5 + +Invoke-WebRequest https://ci.betrusted.io/latest-ci/soc_csr.bin -OutFile soc_csr.bin +python usb_update.py -s soc_csr.bin +Remove-Item soc_csr.bin + +Write-Output "waiting for device to reboot" +Start-Sleep 5 + +Invoke-WebRequest https://ci.betrusted.io/latest-ci/ec_fw.bin -OutFile ec_fw.bin +python usb_update.py -e ec_fw.bin +Remove-Item ec_fw.bin + +Write-Output "waiting for device to reboot" +Start-Sleep 5 + +Invoke-WebRequest https://ci.betrusted.io/latest-ci/wf200_fw.bin -OutFile wf200_fw.bin +python usb_update.py -w wf200_fw.bin +Remove-Item wf200_fw.bin + +Write-Output "IMPORTANT: you must select 'Install gateware update' on the Precursor device to update the SoC." +Write-Output "IMPORTANT: you must also run 'ecup auto' to update the EC with the staged firmware objects." diff --git a/tools/update_release.ps1 b/tools/update_release.ps1 index 8f1b2c97b..a72cd391b 100644 --- a/tools/update_release.ps1 +++ b/tools/update_release.ps1 @@ -1,4 +1,5 @@ Write-Output "This script will update Xous and stage gateware and EC firmware for self-provisioning. No secrets will be erased." +Write-Output "This script will use the latest release." $title = 'Update to latest release' $question = 'Are you sure you want to proceed?' $choices = '&Yes', '&No' diff --git a/xtask/src/main.rs b/xtask/src/main.rs index cbd868126..324360e7d 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -166,11 +166,35 @@ fn main() -> Result<(), Box> { let kkey = args.nth(4); match task.as_deref() { Some("renode-image") => { - generate_app_menus(&vec!["ball".to_string()]); + let mut args = env::args(); + args.nth(1); + let mut pkgs = hw_pkgs.to_vec(); + let mut apps: Vec = args.collect(); + if apps.len() == 0 { // add the standard demo apps if none are specified + println!("No apps specified, adding default apps..."); + apps.push("ball".to_string()); + apps.push("repl".to_string()); + } + for app in &apps { + pkgs.push(app); + } + generate_app_menus(&apps); renode_image(false, &hw_pkgs, &[])? }, Some("renode-test") => { - generate_app_menus(&vec!["ball".to_string()]); + let mut args = env::args(); + args.nth(1); + let mut pkgs = hw_pkgs.to_vec(); + let mut apps: Vec = args.collect(); + if apps.len() == 0 { // add the standard demo apps if none are specified + println!("No apps specified, adding default apps..."); + apps.push("ball".to_string()); + apps.push("repl".to_string()); + } + for app in &apps { + pkgs.push(app); + } + generate_app_menus(&apps); renode_image(false, &cbtest_pkgs, &[])? }, Some("libstd-test") => { @@ -1279,16 +1303,49 @@ fn generate_app_menus(apps: &Vec::) { use gam::{{MenuItem, MenuPayload}}; use locales::t; use num_traits::*; +use std::{{error::Error, fmt}}; -pub(crate) fn app_dispatch(gam: &gam::Gam, token: [u32; 4], index: usize) {{ +#[derive(Debug)] +pub enum AppDispatchError {{ + IndexNotFound(usize), +}} + +impl Error for AppDispatchError {{}} + +impl fmt::Display for AppDispatchError {{ + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {{ + match self {{ + AppDispatchError::IndexNotFound(app_index) => write!(f, "Index {{}} not found", app_index), + }} + }} +}} + +pub(crate) fn app_dispatch(gam: &gam::Gam, token: [u32; 4], index: usize) -> Result<(), AppDispatchError> {{ match index {{"####).unwrap(); for (index, (app_name, _manifest)) in working_set.iter().enumerate() { - writeln!(menu, " {} => gam.switch_to_app(gam::APP_NAME_{}, token).expect(\"couldn't raise app\"),", + writeln!(menu, " {} => {{ + gam.switch_to_app(gam::APP_NAME_{}, token).expect(\"couldn't raise app\"); + Ok(()) + }},", index, app_name.to_uppercase() ).unwrap(); } - writeln!(menu, r####" _ => log::error!("Invalid index for app dispatch: {{}}. Ignoring!", index), + writeln!(menu, r####" _ => Err(AppDispatchError::IndexNotFound(index)), + }} +}} + +pub(crate) fn app_index_to_name(index: usize) -> Result<&'static str, AppDispatchError> {{ + match index {{"####).unwrap(); + for (index, (_, _manifest)) in working_set.iter().enumerate() { + for name in _manifest.menu_name.keys() { + writeln!(menu, " {} => Ok(t!(\"{}\", xous::LANG)),", + index, + name, + ).unwrap(); + } + } + writeln!(menu, r####" _ => Err(AppDispatchError::IndexNotFound(index)), }} }}