Skip to content

PS4 auth: wire by USB output + web-config key upload#172

Merged
RobertDaleSmith merged 4 commits into
mainfrom
ps4-auth-webconfig
Jul 11, 2026
Merged

PS4 auth: wire by USB output + web-config key upload#172
RobertDaleSmith merged 4 commits into
mainfrom
ps4-auth-webconfig

Conversation

@RobertDaleSmith

Copy link
Copy Markdown
Member

Follow-up to #171 (DS4 local RSA auth). Two changes that make PS4 auth a
first-class, runtime-selectable option on any USB-output app.

1. Attach PS4 local auth by USB output, not BTstack

The merge wired joypad_add_ps4_local_auth() into joypad_add_btstack(), which
is the wrong axis:

  • Console-output apps (usb2gc/dc/pce) link BTstack for BT input and were
    paying the mbedTLS cost despite never presenting a PS4 USB device.
  • Native-input USB-output apps (snes2usb, gc2usb, n642usb, …) that don't use
    BTstack never got PS4 auth at all.

Now it attaches to every target that compiles ps4_mode.c (part of
USB_DEVICE_SOURCES) — i.e. every USB-gamepad-output app — via a single
post-definition loop over BUILDSYSTEM_TARGETS. New USB-output apps get it
automatically; tight console-only apps like usb2dc never link mbedTLS.
Activation stays runtime-gated on uploaded key material.

2. PS4 auth key upload in the in-repo web config

Instead of the standalone tools/ps4-auth-upload page, key material can now be
installed from tools/web-config over CDC, on any device that supports it:

  • New Ps4AuthCard: key.prm / serial.txt / sig.bin inputs, client-side RSA-2048
    parsing via WebCrypto (extracts N/E/P/Q, verifies P×Q=N), and
    PS4AUTH.SET/STATUS/CLEAR + PS4LOG.* over the existing CDC protocol.
  • Nav link is hidden unless the firmware answers PS4AUTH.STATUS, so it only
    appears on supported builds.
  • RSA-parsing logic ported from the standalone tool (kept as reference); only
    N/E/P/Q are transmitted, never the PEM.
  • npm run build verified (vite single-file bundle); dist/ rebuilt.

Notes

🤖 Generated with Claude Code

The fork wired joypad_add_ps4_local_auth() into joypad_add_btstack(), which
is the wrong axis: console-output apps (usb2gc/dc/pce) link BTstack for BT
*input* and were paying the mbedTLS cost despite never presenting a PS4 USB
device, while native-input USB-output apps (snes2usb, gc2usb, n642usb, …) that
don't use BTstack never got PS4 auth at all.

Attach it instead to every target that compiles ps4_mode.c (part of
USB_DEVICE_SOURCES) — i.e. every USB-gamepad-output app — via a single
post-definition loop. New USB-output apps get PS4 auth automatically; tight
console-only apps like usb2dc never link mbedTLS. Activation remains runtime-
gated on uploaded key material (PS4AUTH.SET).
Adds a PS4 Auth page to the in-repo web config so DS4 local RSA key material
can be installed from any USB-output device over CDC — no separate upload tool.

- New Ps4AuthCard component: three file inputs (key.prm / serial.txt / sig.bin),
  client-side RSA-2048 parsing via WebCrypto (extracts N/E/P/Q, verifies P×Q=N),
  and PS4AUTH.SET / STATUS / CLEAR + PS4LOG.* over the existing CDC protocol.
- Nav link is hidden unless the firmware answers PS4AUTH.STATUS, so it only
  appears on builds that support it.
- Reuses the RSA-parsing logic from tools/ps4-auth-upload (kept as reference);
  the standalone tool is now redundant with the config app.

Only N/E/P/Q are transmitted, never the PEM.
@RobertDaleSmith
RobertDaleSmith merged commit b292005 into main Jul 11, 2026
66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant