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

   ## Summary
   
   Two changes for the asymmetric side of the software crypto driver:
   
   * **crypto/cryptosoft: pass ECC integers little-endian** - the ECC handlers 
(secp256r1 keygen / sign / verify) used to copy the ioctl parameter buffers 
straight through to the ECC implementation, which reads big-endian, while the 
RSA handlers in the same file explicitly convert and document "cryptodev is 
little-endian". The two paths disagreed. The ECC integers (x, y, r, s, the 
private key and the shared secret) now cross the cryptodev boundary 
little-endian, matching the RSA convention. The only in-tree consumer is the 
ecdsa test, which is a self-consistent generate/sign/verify round trip and does 
not depend on the byte order, so no existing behavior breaks; the new ECDH test 
below pins the convention with fixed vectors.
   * **crypto/cryptodev: add ECDH key agreement commands** - two new kprocess 
commands, `CRK_ECDH_KEYGEN` (generate an ephemeral key pair) and 
`CRK_ECDH_COMPUTE` (compute the shared secret from the peer public key), 
implemented on the secp256r1 curve through the existing ecc code. Integers 
cross the boundary little-endian.
   
   ## Impact
   
   * New CRK_ command ids (next free numbers); no existing command changes. ECC 
byte-order convention changes, but no in-tree consumer depends on the old one.
   
   ## Testing
   
   Board sim:sim/crypto (nuttx master 46aaa10da85), with the companion test PR 
in nuttx-apps:
   
   ```
   nsh> dhm
   test dh compute key ok                       (curve25519, pre-existing)
   test ecdh compute key ok                     (new: fixed vectors dA/dB/QA/QB 
-> shared
                                                 secret Z matches, both 
directions; ephemeral
                                                 key pairs agree both 
directions)
   nsh> ecdsa
   p256 generate key / sign / verify sync success   (round trip, unchanged)
   ```
   
   The ECDH vectors were generated with pure Python affine EC arithmetic and 
cross-checked bidirectionally against the python cryptography package.
   
   Regression: rsa (all 3 cases, seconds - BearSSL path), hmac (35 vectors), 
aescmac (8 vectors incl. 256-bit), hash (7 algorithms, huge-block, unaligned), 
crc32, pbkdf2, poly1305, 3descbc, aescbc, aesctr, aesxts, aesgcm, chacha20, 
chachapoly, castcbc, blfcbc all pass unchanged.
   
   `tools/checkpatch.sh -c -u -m -g <base>..HEAD` passes.
   


-- 
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