Repository navigation
feat(libSceLibreSsl): implement EC points, key generation, ECDSA and ECDH - #15827
Conversation
|
Test run on this exact head 100% tests passed, 0 tests failed out of 120 |
Progress report (508ec40 → 6e04d09)📈 System libraries: 29.11% (+0.01%, +6 implemented, -1 reverted functions) ✅ 6 implemented
|
| Library | Name |
|---|---|
| libSceLibreSsl | EC_KEY_set_group_nid_postfix |
Changed libraries (implemented exports)
| Library | Before | After | Change |
|---|---|---|---|
| libSceLibreSsl | 265/446 (59.42%) | 270/446 (60.54%) | +1.12% |
|
On the progress report:
Their other paths are implemented and tested. |
bc70076 to
441d06a
Compare
|
Rebased onto current On this exact head (Linux, Ubuntu 24.04 container, GCC 13.3, Release, One build note unrelated to this PR: on this 100% tests passed, 0 tests failed out of 120 |
441d06a to
81a6e5b
Compare
|
Rebased onto current
100% tests passed, 0 tests failed out of 121 |
81a6e5b to
107fc6a
Compare
|
Rebased onto current On this exact head (Linux, Ubuntu 24.04 container, GCC 13.3, Release, 100% tests passed, 0 tests failed out of 122 |
|
Windows data point for
Not tested: Linux, macOS, a title. |
107fc6a to
9de837b
Compare
|
Rebased onto current On this exact head (Linux, Ubuntu 24.04 container, GCC 13.3, Release, 100% tests passed, 0 tests failed out of 124 |
9de837b to
1f8aaef
Compare
|
Rebased onto current On this exact head (Linux, Ubuntu 24.04 container, GCC 13.3, Release, 100% tests passed, 0 tests failed out of 124 |
1f8aaef to
3f044cb
Compare
|
Rebased onto current On this exact head (Linux, Ubuntu 24.04 container, GCC 13.3, Release, 100% tests passed, 0 tests failed out of 125 |
3f044cb to
94e8bdf
Compare
|
Rebased onto current On this exact head (Linux, Ubuntu 24.04 container, GCC 13.3, Release, 100% tests passed, 0 tests failed out of 127 |
94e8bdf to
ca9ef8a
Compare
|
Rebased onto current On this exact head (Linux, Ubuntu 24.04 container, GCC 13.3, Release, 100% tests passed, 0 tests failed out of 128 |
ca9ef8a to
f7c08cf
Compare
d565a5d to
ef179ba
Compare
ef179ba to
646599b
Compare
646599b to
56b994c
Compare
…ECDH EC_POINT_new, EC_POINT_free, EC_POINT_point2oct, EC_POINT_oct2point, EC_KEY_generate_key, EC_KEY_check_key, EC_KEY_get0_public_key, EC_KEY_set_public_key, ECDSA_sign, ECDSA_verify and ECDH_compute_key follow LibreSSL 2.5.4 on top of mbedtls's named curves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
56b994c to
6e04d09
Compare
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
@AdnanKhan-ak47, @puridanish284: the overlap comment lists #12729, #12730 and #16079 against this PR. None of them adds the same exports. The shared lines are neighbouring stub removals in I propose #15827 first: it is one commit, merges cleanly into |
|
@MarrasFederico: the overlap comment now also lists #16389, which adds the |
|
@janzezno: the overlap comment now lists #14212 here, for the place in |
|
@MarrasFederico: #16719 supersedes #16389 and the overlap comment now lists it at the same debt-file lines, so my proposal above stands: #15827 first, or |
|
No objection to #15827 going first. The PRs share no exports, and merging both into Generated by Claude Code |
|
Windows check of head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.
AI-assisted: yes. |
What
Implements eleven libSceLibreSsl exports that were throwing
NotImplemented:EC_POINT_new,EC_POINT_free,EC_POINT_point2oct,EC_POINT_oct2point,EC_KEY_generate_key,EC_KEY_check_key,EC_KEY_get0_public_key,EC_KEY_set_public_key,ECDSA_sign,ECDSA_verifyandECDH_compute_key.Replaces #10407, which the open PR limit closed while #10395 was open; GitHub no longer reopens it. MarcZX10's review there asked for this stack to be refreshed onto current
mainafter #10395 and its LibreSSL tests rerun on the composed head; this is that head, with only this commit left on top ofmain.ec/ec_lib.c,ec/ec_key.c,ec/ec_oct.c,ec/ecp_oct.c,ecdsa/ecs_sign.c,ecdsa/ecs_vrf.c,ecdsa/ecs_ossl.candecdh/ech_key.c.EC_POINTis a host object holding anmbedtls_ecp_pointand its curve; anEC_KEYnow also holds its public point and private scalar.Api.hppdeclaresEcPointas opaque next toEcGroupandEcKey, with the exports' signatures; the layouts stay in the internalinclude/Ec.hpp. The three exports that take or return aBIGNUM(EC_POINT_mul,EC_KEY_get0_private_key,EC_KEY_set_private_key) still throw: feat(libSceLibreSsl): implement the BN_ BIGNUM, BN_CTX, conversion, word, BN_mul and BN_mod_inverse functions #9446'sBIGNUMlanded after this branch was written, so they are left for a follow-up.EC_POINT_point2octandEC_POINT_oct2pointhandle the compressed, uncompressed and hybrid forms and the single zero octet for infinity, with LibreSSL's checks: form and y bit, exact length, coordinates below the prime, hybrid parity and the X9.62 on-curve test. A point that fails only the on-curve test keeps the decoded coordinates, as in LibreSSL, soEC_KEY_check_keycan reject it later.EC_KEY_generate_keydraws the scalar in [1, n-1] from host entropy and reuses the key's existing point object, as LibreSSL does.EC_KEY_check_keychecks infinity, the curve equation and, with a private key, that it gives the public key; the order test always passes because all 11 curves have cofactor 1.ECDSA_signsigns through mbedtls with a random nonce and writes LibreSSL's DER (unsigned INTEGERs, 0x00 pad when the top bit is set); a null buffer only returns the length.ECDSA_verifyreturns -1 unless the signature is canonical DER with nothing after it (what LibreSSL's decode and re-encode comparison accepts), 0 for r or s outside [1, n-1] or a mismatch, and -1 when u1·G + u2·Q is at infinity. Digests longer than the order are truncated to its bit length, likeecdsa_do_signandecdsa_do_verify.ECDH_compute_keyreturns the x coordinate padded to the field size: -1 without a private key, group or peer key, for a peer at infinity, for a length aboveINT_MAXor a buffer shorter than the secret without a KDF; a larger buffer is zero-filled. A KDF is called through the guest ABI and its output length is returned.Ec.cppstarts with the copyright notices, licence conditions and disclaimers of LibreSSL 2.5.4'sec/ecp_oct.c,ec/ec_key.c,ecdsa/ecs_ossl.candecdh/ech_key.c, verbatim from 2e2c612, becauseEC_POINT_point2oct,EC_POINT_oct2point,EC_KEY_check_key,ECDSA_verifyandECDH_compute_keyfollow their control flow.Gaps, in the debt file: no error is queued; a point used with a group of another curve throws, since LibreSSL's result depends on the EC methods its build picks; so does
EC_KEY_set_groupto another curve on a key that already has a public or private key; compressed points on secp224k1 and secp224r1 throw (mbedtls only decompresses for primes that are 3 mod 4);ECDSA_verifywith a public key at infinity or off the curve andECDH_compute_keywith a peer key off the curve throw, where LibreSSL computes with them. The EC debt entry is split in two to stay under 1000 characters.Export.cppgoes from 121 to 110NotImplemented_nid_no_patchstubs; since #11553 the debt file no longer states that count.Tested
Linux (Ubuntu 24.04 container, GCC 13.3), full configure with
-DBUILD_TESTING=ON, Release: builtlibSceLibreSsl,libSceLibreSsl3, their patched.prxfiles and the eighty-eight LibreSSL tests;ctest -R 'libressl|crypto_memcmp|public_headers'passes 153 of 153 (the eighty-eight LibreSSL tests,public_headersand its 64 compile checks) on head6e04d09675, based onmain06a9092274; the newguest_libressl_ec_keystakes 0.6 s. Built with AddressSanitizer and leak detection,guest_libressl_ec_keys,guest_libressl_ecandguest_libressl3_key_referenceare clean. It checks:EC_KEY_check_key, encoded sizes, sign and verify (another key, a changed signature, another digest, an empty digest), ECDH agreement on both sides and regeneration keeping the point object;cryptography46, and a secp224k1 signature from a Python reference implementation whose 225-bit order makes the truncation drop seven bits; ten non-DER signatures return -1 and five out-of-range ones return 0;EC_KEY_set_public_keycopies, own key, null, infinity and off-curve points, andEC_KEY_set_groupwith and without keys; null arguments throw. Unimplemented paths that throw (other curves, 224-bit compressed points, verify and ECDH with an off-curve or infinite key) are in the debt file and not tested.Windows: JJenkx ran
guest_libressl_ec_keyson head6e04d09675merged ontomain(Windows 11, WinLibs GCC 15.2 UCRT, Release); it passes in 3 of 3 runs (comment).The test fails when the truncation shift, the hybrid y bit, the DER minimal-integer check or the ECDH zero fill is removed.
nm -Don the patchedlibSceLibreSsl.prxlists the eleven NIDs.tools/check_conventions.py --base origin/mainpasses; The overlap comment on6e04d09675lists no open PR with the same exports. #12729 and #12730, stacked on it, remove neighbouring stubs inExport.cppandApi.hpp, #16079 edits the EVP debt entry next to the EC entries, and #16719 adds anEVP_DigestVerifyFinalentry at the same place. I proposed this PR first and offered to rebase after theirs instead (comment). For #16079 the order is agreed: this PR first, with noDepends onon either side (reply). #12729, #12730 and #16719 have not answered yet. #14212 adds a blank line between debt entries across the repository; if it lands first, the rebase separates the two EC entries. #11146 depends on this PR and #11466 on #11146. 40 PRs that share these files conflict withmain, so they could not be compared. No title tested.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code