Skip to content

feat(libSceLibreSsl3): implement MD5 and SHA1 - #9043

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
HQasper:claude/project-thread-w0s18y-libressl3
Oct 23, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
HQasper:claude/project-thread-w0s18y-libressl3

Conversation

@HQasper

@HQasper HQasper commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What

All 87 libSceLibreSsl3 exports threw. This implements the MD5 and SHA1 one-shots. CRYPTO_memcmp is left to #8956, which implements it first; this PR is built on top of it.

Tested

Linux (Ubuntu 24.04.5 container, GCC 13.3, Release, BUILD_TESTING=ON):

  • New guest_libressl3_digest: passed. It checks MD5 and SHA1 against the RFC 1321 and FIPS 180 values for abc, the empty string and one million a, and that they write only the digest length and return the buffer. It also checks the throwing cases.
  • guest_crypto_memcmp (from feat(libressl3): implement CRYPTO_memcmp #8956), guest_libressl_digest (from feat(libSceLibreSsl): implement the MD4, MD5, SHA-1 and SHA-2 digests #9025) and patched_libraries: passed. The patched libSceLibreSsl3.prx needs libSceLibreSsl.prx, and all six imported NIDs are defined there. Its export set is unchanged (87 names).
  • python3 tools/check_conventions.py --base origin/main: passed.
  • Not tested: Windows, and any title or homebrew.

Note: until #8956 and #9025 merge, this PR also shows their commits. After they merge, I rebase it onto main so only its own commit is left.

Checklist

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Progress report (950388b → 71ce2fe)

📈 System libraries: 42.29% (+0.19%, +21 implemented functions)

✅ 21 implemented
Library Name
libSceLibreSsl MD4_Final_nid_postfix
libSceLibreSsl MD4_Init_nid_postfix
libSceLibreSsl MD4_Update_nid_postfix
libSceLibreSsl MD5_Final_nid_postfix
libSceLibreSsl MD5_Init_nid_postfix
libSceLibreSsl MD5_Update_nid_postfix
libSceLibreSsl SHA1_Final_nid_postfix
libSceLibreSsl SHA1_Init_nid_postfix
libSceLibreSsl SHA1_Update_nid_postfix
libSceLibreSsl SHA224_Final_nid_postfix
libSceLibreSsl SHA224_Init_nid_postfix
libSceLibreSsl SHA224_Update_nid_postfix
libSceLibreSsl SHA256_Final_nid_postfix
libSceLibreSsl SHA256_Init_nid_postfix
libSceLibreSsl SHA256_Update_nid_postfix
libSceLibreSsl SHA384_Final_nid_postfix
libSceLibreSsl SHA384_Init_nid_postfix
libSceLibreSsl SHA384_Update_nid_postfix
libSceLibreSsl SHA512_Init_nid_postfix
libSceLibreSsl SHA512_Update_nid_postfix
libSceLibreSsl3 CRYPTO_memcmp_nid_postfix

@blawesom

Copy link
Copy Markdown
Contributor

Support triage — overlap note: this PR's CRYPTO_memcmp for libSceLibreSsl3 (Export.cpp removal + Digest.cpp implementation, constant-time XOR fold) is the same function #8956 (ynkmyz233, opened earlier) implements in libSceLibreSsl3/Export.cpp with its own test file. Whichever lands first will conflict the other in Export.cpp; please coordinate with the author of #8956 and declare Depends on on the checklist line. Note the two implementations differ subtly: #8956 reads through volatile pointers to defeat compiler optimization of the fold; this one does not — worth aligning on the constant-time property either way.

@blawesom blawesom mentioned this pull request Oct 21, 2026
12 tasks done
HQasper and others added 2 commits October 21, 2026 17:49
MD4, MD5, SHA1, SHA224, SHA256, SHA384 and SHA512 Init/Update/Final and
the SHA256 one-shot threw. They now hash as LibreSSL does, on the
caller's MD4_CTX, MD5_CTX, SHA_CTX, SHA256_CTX and SHA512_CTX laid out as
in LibreSSL's md4.h, md5.h and sha.h, so a context copied or inspected
by the title stays valid: the bit count in Nl/Nh, the partial block in
data with its length in num, and md_len selecting the truncated digest.
Final pads and clears the buffer as LibreSSL's sources do.

Cases that differ between LibreSSL versions throw: SHA256 with a null
digest buffer and SHA512_Final with the SHA-512/224 or SHA-512/256
length. The test checks the RFC 1320, RFC 1321 and FIPS 180 vectors over
several chunk sizes, the context fields, copied contexts and those
cases.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Both one-shots threw. They run Init, Update and Final through
libSceLibreSsl's MD5_* and SHA1_*, which libSceLibreSsl3 now links,
and return the digest buffer. A null digest buffer throws, since
LibreSSL up to 3.8 hashes into a static buffer and later versions do
not check it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ycbuzi

ycbuzi commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Windows run of 352eae4 merged onto main 745b394 (650f732293, clean), the platform the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, BUILD_TESTING=ON.

Built libSceLibreSsl, libSceLibreSsl3, guest_libressl_digest_tests and guest_libressl3_digest_tests with no errors or warnings. ctest --repeat until-fail:2 on guest_libressl_digest and guest_libressl3_digest: both pass on both repeats. Not run: a title.

@HQasper
HQasper force-pushed the claude/project-thread-w0s18y-libressl3 branch from 352eae4 to 71ce2fe Compare October 21, 2026 17:51
@HQasper HQasper changed the title feat(libSceLibreSsl3): implement MD5, SHA1 and CRYPTO_memcmp feat(libSceLibreSsl3): implement MD5 and SHA1 Oct 21, 2026
@HQasper

HQasper commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

@blawesom Thanks for the note. #8956 is older, so it goes first. I have removed CRYPTO_memcmp from this PR and rebuilt it on top of #8956, so it now only implements MD5 and SHA1 and no longer conflicts with #8956. The checklist says Depends on: #8956, #9025. Until both merge, this PR also shows their commits, and I will rebase it onto main after they land.

@ycbuzi Thanks for validating the Windows build and confirming guest_libressl_digest and guest_libressl3_digest pass on repeated runs. Much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants