royzah opened a new pull request, #20343:
URL: https://github.com/apache/nuttx/pull/20343

   ## Summary
   
   The i.MX9 ELE driver reaches the mailbox but not the key store the enclave
   offers. This adds it: sessions, key stores, key management, key generation,
   signing by handle, and the storage exchange that lets a key store outlive a
   boot.
   
   A key generated in there is permitted one algorithm and one usage, and export
   can be withheld, so the private half has no command that returns it. That is
   the point: it makes "software cannot read this key" a property of the key
   rather than a claim about an API.
   
   Storage runs the opposite way to every other command. The enclave asks the
   host to write its key store down, and asks for the pieces back, and those
   requests arrive while a command of this side's is still outstanding. The 
reply
   tag is what tells a question from an answer.
   
   Two things a port has to know that neither the reference implementation nor
   the headers say, each of which costs a flash to find and looks from outside
   like "this firmware has no key store":
   
   - Key store commands carry a trailing crc, the exclusive or of every word
     including the header. Without it the enclave answers rating `0xb9`.
   - A persistent key lifetime is a statement of intent. The strict flag on key
     generation is what writes the key to the store; without it a store exported
     around the key comes back without it, and the next signature answers rating
     `0x03`.
   
   Every mailbox wait is now bounded, in both directions. An enclave that stops
   answering must not take the calling thread with it. A reply buffer is a
   kilobyte and no longer sits on the stack of whatever task asked for a
   signature, since NuttX builtin tasks get four.
   
   **Stacked on #20196**, which this needs for the physical-address handling. 
The
   first commit here is that PR; review only the second.
   
   ## Impact
   
   - New feature on i.MX9 only, additive. Existing entry points keep their
     signatures apart from `imx9_ele_key_store_open()`, which was added in this
     series and not yet released.
   - No change to boards that do not call the new functions.
   - Nothing is enabled by default: the driver gains functions, no Kconfig and 
no
     init-time behaviour.
   - The message payload layouts move to file scope as named types, so the wire
     format is readable in one place.
   
   ## Testing
   
   Run on a Saluki NXP93, i.MX93 Cortex-A55, NuttX 12.11.0, PX4 kernel build.
   
   Generate a P-256 key inside the enclave, sign `sha256("")` with it, and 
verify
   the signature against the returned public half on a host:
   
   ```
   ELE: P-256 generated in the enclave, id 0x3fffffff
   ele: pub 0e12f0bac94900dd70cc4d9863e7175c38cfcab8c3d4c99d65d13240d082f1f7
            73bf8f425c25ace0c93ca6f251016291ee32742acf107a2b71975064cd6a4410
   ele: sig 36480dba1545a5b44b86fbf6b08370114f20136c56caf08c4edafbbab6b825d9
            04f16f7605b537919d537ffe13f472467887ceca162b287c388394b3a28cb187
   ```
   
   ```
   $ openssl pkeyutl -verify -pubin -inkey pub.der -keyform DER \
       -sigfile sig.der -in digest -pkeyopt digest:sha256
   Signature Verified Successfully
   ```
   
   Then power the board off, power it back on, and repeat. The key store is
   restored from the pieces the enclave exported, the public half is
   byte-identical, and a fresh signature still verifies:
   
   ```
   ELE: master import 0, response 0x000000d6
   ele: sig f29f413cad527056856c8110f92f1f3f0655fc0badb5bdcb6833ed2d9f3f0433
            856033f7a17420d6a3613e5ae85f84319b21ae40084d128082392cf2f1bddb88
   Signature Verified Successfully
   ```
   
   ECDSA is randomised, so the two signatures differ; verification is the test,
   not comparison.
   
   `tools/checkpatch.sh -f` passes on all three files.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to