cederom commented on PR #22054:
URL: https://github.com/apache/nuttx/pull/22054#issuecomment-7040987717

   Okay so I am testing that Claude stuff, here are the remarks ;-)
   
   * No check on the peer public key. The handler never calls 
ecc_point_is_on_curve or any other validity check on the peer X,Y. It 
compresses them directly, in swcr_ecdh256_compute_shared. The only rejection is 
if (ecdh_shared_secret(...) == 0) ret = -EINVAL;. Since ecdh_shared_secret() in 
ecc.c doesn’t validate the point either, this stands.
   * Output sizes aren’t checked. This covers genkey params 0–2, sign params 2 
and 3, and the ECDH secret written to krp_param[3]. Each writes a fixed 32 
bytes without looking at the destination’s crp_nbits. The return value of the 
final ECDH copy is also ignored. The kernel buffer is sized from the caller’s 
crp_nbits, so the overflow point stands.
   * The byte-order change isn’t flagged. Code comments state the new 
little-endian convention, but the PR summary says “so no existing behavior 
breaks.” No comment in the diff flags this as an ABI change for existing ECDSA 
callers. Stored keys: keys are reversed before storing (swcr_reverse(priv, 
secp256r1); and so on), and this runs before swkey_write(...). The load path is 
not in the diff. So my question to the author stands: do keys written by the 
old code still load correctly?
   * Unused 4th output. The count check really is in == 0 && out == 4, but the 
handler delegates to swcr_ecc256_genkey, which writes only param[0]=d, 
param[1]=x, param[2]=y. 
   Bits rounded down. Every caller uses floor division, e.g. 
krp->krp_param[0].crp_nbits / 8, while cryptodev.c rounds up. 
   * Private key not wiped on early return. explicit_bzero(d, sizeof(d)); 
appears only on the success path before return OK;. The early return -EINVAL; 
visible in the genkey hunk does not wipe d. Sign and verify are fine, since the 
out: label does wipe d. One more small thing: the genkey code also ignores 
swcr_ecc_copy return values. 


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