rouse-context/work/src
Jason Monk 135269faec Fix #87: Implement FirebaseRenewalAuthProvider with AndroidKeystore EC signing
Replaces the TODO stub that always returned null, unblocking the
expired-cert renewal branch of CertRenewalWorker.

The provider now bridges FirebaseAuth (fresh ID token via getIdToken)
and the Android Keystore (SHA256withECDSA signature over the raw DER
bytes of the renewal CSR) using the P-256 key minted by
FileCertificateStore under the 'rouse_device_key' alias. Returning null
on any transient failure (no signed-in user, Keystore locked, empty
token) keeps the worker retry-safe.

To make the signature actually verify at the relay, this plumbs the CSR
DER through to the provider. CsrResult now carries csrDer alongside the
PEM; CertRenewalFlow.renewWithFirebase grows an overload that receives
a FirebaseRenewalCredentialsProvider, generates the CSR first, and then
asks the provider to sign those exact bytes before submitting to the
relay. The previous (token, signature) overload is retained as a
delegator for the existing tunnel tests.

The old RenewalAuthProvider interface took no arguments and therefore
could not know which CSR to sign. It now receives the csrDer bytes,
which required touching CertRenewer / CertRenewalFlowRenewer so the
worker invokes the provider through the renewer (flow owns the CSR
lifecycle). A new RenewalResult.FirebaseAuthUnavailable preserves the
EXPIRED_NO_AUTH outcome that signalled 'no creds, retry later'.

DeviceKeystoreSigner is a thin interface; AndroidKeystoreSigner is the
production Keystore-backed impl. The provider takes a FirebaseIdTokenSource
seam as well so unit tests can exercise the decision logic without
Robolectric-initialising Firebase. Robolectric is used only to no-op
android.util.Log; no real Keystore or Firebase is exercised by the
provider tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 22:42:22 -04:00
..
main Fix #87: Implement FirebaseRenewalAuthProvider with AndroidKeystore EC signing 2026-04-13 22:42:22 -04:00
test Fix #87: Implement FirebaseRenewalAuthProvider with AndroidKeystore EC signing 2026-04-13 22:42:22 -04:00