feat(libSceLibreSsl): implement BN_print #15480

Merged
JaceTheBlu merged 1 commit from upstream-pr/15480 into main 2026-11-10 04:53:05 +00:00
JaceTheBlu commented 2026-11-03 14:44:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JaceTheBlu on 2026-11-03T14:44:51Z.


What

Implements BN_print in libSceLibreSsl. It was the last BN_ export left throwing, kept back in #9446 because there was no BIO yet; the memory BIO is on main now.

It follows LibreSSL 2.5.4 bn_print.c:

  • a - for a negative BIGNUM, then 0 when top is 0, so a negative zero prints -0;
  • otherwise the limbs from the top, in uppercase hex, without leading zeros, even when the top limbs are zero;
  • one BIO_write per character, returning 0 on the first write that does not write 1 byte, and 1 otherwise.

A null BIGNUM throws, like the other BN_ calls; LibreSSL dereferences it. A null BIO returns 0, as BIO_write does there.

The debt entry drops the sentence saying BN_print throws, and the pending count goes down by one.

Tested

  • GuestLibreSslBn: 0, -1A, 00F, a two-limb value, a 128-bit value, a non-normalized BIGNUM whose top limb is zero, a negative zero, a read-only BIO and a null BIO. The expected strings and return values come from a small program linked against the LibreSSL 2.5.4 libcrypto.a built by the oracle.
  • All 52 libressl|crypto_memcmp tests pass on Linux. Not run on Windows or macOS.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5139224107 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15480). Originally posted by [JaceTheBlu](https://github.com/JaceTheBlu) on 2026-11-03T14:44:51Z. --- ### What Implements `BN_print` in libSceLibreSsl. It was the last `BN_` export left throwing, kept back in #9446 because there was no `BIO` yet; the memory `BIO` is on `main` now. It follows LibreSSL 2.5.4 `bn_print.c`: - a `-` for a negative `BIGNUM`, then `0` when `top` is 0, so a negative zero prints `-0`; - otherwise the limbs from the top, in uppercase hex, without leading zeros, even when the top limbs are zero; - one `BIO_write` per character, returning 0 on the first write that does not write 1 byte, and 1 otherwise. A null `BIGNUM` throws, like the other `BN_` calls; LibreSSL dereferences it. A null `BIO` returns 0, as `BIO_write` does there. The debt entry drops the sentence saying `BN_print` throws, and the pending count goes down by one. ### Tested - `GuestLibreSslBn`: `0`, `-1A`, `00F`, a two-limb value, a 128-bit value, a non-normalized `BIGNUM` whose top limb is zero, a negative zero, a read-only `BIO` and a null `BIO`. The expected strings and return values come from a small program linked against the LibreSSL 2.5.4 `libcrypto.a` built by the oracle. - All 52 `libressl|crypto_memcmp` tests pass on Linux. Not run on Windows or macOS. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!15480
No description provided.