Repository navigation
feat(libSceLibreSsl3): implement the EVP ChaCha20 and ChaCha20-Poly1305 ciphers - #16249
Merged
oneandonlydean merged 9 commits intoNov 9, 2026
Merged
Conversation
Contributor
|
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. |
Progress report (df088d6 → 84caebd)📈 System libraries: 33.27% (+0.02%, +8 implemented functions) ✅ 8 implemented
Changed libraries (implemented exports)
|
12 tasks done
Ducengarth
force-pushed
the
feat/libressl3-chacha20-ciphers
branch
from
November 6, 2026 01:23
7cd1d96 to
ec51479
Compare
12 tasks done
Ducengarth
force-pushed
the
feat/libressl3-chacha20-ciphers
branch
from
November 7, 2026 00:59
f0a27c2 to
c85e2fa
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.
|
…05 ciphers Implement EVP_chacha20 and EVP_chacha20_poly1305 after LibreSSL 4.0.0 e_chacha.c and e_chacha20poly1305.c: the 64-bit counter IV layout, the streaming keystream, the left-padded AEAD nonce and the AEAD controls, with Poly1305 from mbedtls. They run inside the forwarded libSceLibreSsl EVP_Cipher* functions, which now zero the cipher data as LibreSSL 4.0.0 does. Record the unverified console behaviour and the zero-length update gap as debt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ducengarth
force-pushed
the
feat/libressl3-chacha20-ciphers
branch
from
November 7, 2026 11:14
04ceab7 to
d3f99bf
Compare
12 tasks done
12 tasks done
12 tasks done
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
12 tasks done
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…/libressl3-chacha20-ciphers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…/libressl3-chacha20-ciphers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…/libressl3-chacha20-ciphers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…/libressl3-chacha20-ciphers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…/libressl3-chacha20-ciphers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
12 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Implement
EVP_chacha20andEVP_chacha20_poly1305inlibSceLibreSsl3, replacing their parameterless throwing placeholders inAdditionalExports.cpp. Source: LibreSSL 4.0.0 atce488b78, the revision the library's debt file already uses:evp/e_chacha.c,evp/e_chacha20poly1305.c,chacha/chacha.candchacha/chacha-merged.c.EVP_chacha20(NID 937): stream cipher, 32-byte key, 16-byte IV. As in LibreSSL, IV bytes 0 to 7 are a 64-bit little-endian block counter and bytes 8 to 15 the nonce, which differs from the IETF layout. The keystream left over from a partial block carries across updates, and the counter carries from the low word into the high word. A key-only init keeps the counter, and an IV-only init restarts the keystream.EVP_chacha20_poly1305(NID 967): RFC 8439 AEAD through the EVP cipher interface, as LibreSSL 3.6 and later provide it. A null output means AAD, a null input means final, and AAD after text is rejected. A nonce of 1 to 11 bytes is left-padded with zeros to 12. The controls areEVP_CTRL_INIT,AEAD_GET_IVLEN,AEAD_SET_IVLEN,AEAD_SET_TAG(decrypt only, 1 to 16 bytes, so truncated tags work),AEAD_GET_TAG(encrypt only) andAEAD_SET_IV_FIXED, with the same return values. The tag check is constant-time. After a final, the Poly1305 state is zeroed as LibreSSL'sCRYPTO_poly1305_finishleaves it.ctx_size132 and 384, the LP64 sizes ofChaCha_ctxandstruct chacha20_poly1305_ctx. They use libSceLibreSsl's 88-byteEVP_CIPHER, whose first 80 bytes are the 4.0.0 layout libSceLibreSsl3'sCipher.cppreads, so the existingEVP_CIPHER_key_lengthandEVP_CIPHER_iv_lengthwork on them.mbedcrypto, already linked by libSceLibreSsl). libSceLibreSsl3 links it with--exclude-libs,ALLon MinGW and Linux, as libSceLibreSsl does; without that flag, 21mbedtls_*symbols would become guest-visible exports.Both ciphers run inside libSceLibreSsl's
EVP_CipherInit_ex,EVP_*UpdateandEVP_*Final_ex, which libSceLibreSsl3 forwards. One change there:EVP_CipherInit_exnow takes the cipher data fromcallocinstead ofmalloc. LibreSSL 4.0.0 zeroes it, and a ChaCha20 init with a key and no IV relies on that for a zero counter and nonce. In 2.5.4 the contents were unspecified, so this is still valid for libSceLibreSsl's own ciphers.Known gap, recorded in
docs/dev/debt/libSceLibreSsl3.md: the forwarded 2.5.4 update hands a zero-length update to the cipher, where LibreSSL 4.0.0'sEVP_EncryptUpdateandEVP_DecryptUpdatereturn 1 without calling it. Inside the cipher, a zero-length update with a null input looks exactly like the final call. SoEVP_EncryptUpdate(ctx, out, &n, NULL, 0)onEVP_chacha20_poly1305finishes the message early. The same already happens with AES-GCM through libSceLibreSsl3. A zero-length update with an input, or a negative length, now leaves the state alone and returns as 4.0.0 does. A full fix means giving libSceLibreSsl3 its ownEVP_EncryptUpdate,EVP_DecryptUpdateandEVP_CipherUpdatewith the 4.0.0 prologue. That changes how a NID shared with libSceLibreSsl is resolved on each platform, so it belongs in its own PR.EVP_aes_128_ccmand theEVP_aes_*_wrapciphers stay as they are. The wrap ciphers build onAES_wrap_keyandAES_unwrap_key(#15854, #14612) and onEVP_CIPHER_CTX_set_flags(#15163).No title's trace or disassembly was used, and neither export was measured on a PS5.
pr_overlapreports no pull request with the same exports or new files. The "same exports" it lists (Allocate,Align,Calloc,Free,PosixAlign,Realign,Reallocate) are the test's file-local guest-heap callbacks, which other tests also define. The remaining hits are line conflicts:libSceLibreSsl3.hpp.CMakeLists.txt.Whichever merges second resolves them; I will rebase this one as needed. 62 pull requests that conflict with
maincould not be compared by the tool. I scanned all of them, and every open pull request that toucheslibSceLibreSsl3orEvpCipherCtx.cpp. None addsEVP_chacha20,EVP_chacha20_poly1305or ChaCha code, or changes the cipher-data allocation line.Tested
Windows 11, MinGW-w64 GCC (WinLibs), Release build. No title or homebrew, and not built on Linux or macOS.
guest_libressl3_chacha(new) passes. It drives both ciphers through the forwarded EVP functions and compares them with mbedtls's independent IETF ChaCha20 and ChaCha20-Poly1305:1ae10b59…).0xffffffff.SET_IV_FIXED, every control's in-range and out-of-range return values, and AAD after text on both sides.EVP_CIPHER_key_lengthandEVP_CIPHER_iv_length.guest_libressl*andguest_crypto_memcmptests pass, including libSceLibreSsl's after thecallocchange.objdump -ponlibSceLibreSsl3.prxlists both names and nombedtls_*symbol.python3 tools/check_conventions.py --base upstream/mainpasses.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