Skip to content

fix(ssh): replace Android's stripped BC provider for Ed25519 - #158

Merged
CallMeTechie merged 1 commit into
masterfrom
fix/ssh-bouncycastle-ed25519
Apr 21, 2026
Merged

CallMeTechie merged 1 commit into
masterfrom
fix/ssh-bouncycastle-ed25519

Conversation

@CallMeTechie

Copy link
Copy Markdown
Owner

User-reported error after fail2ban unban + sshd reachable:

NoSuchAlgorithmException: no such algorithm: 25519 for provider BC

Classic Android+BouncyCastle bug. Android ships a Security.Provider named BC that is a stripped-down subset of BouncyCastle (no Ed25519). SSHJ asks for BC via name, gets the limited Android provider instead of the full bcprov-jdk18on 1.80 that SSHJ pulls transitively.

Fix: BouncyCastleSetup.install() removes Android's BC and inserts the bundled one at position 1 before the first SSHJ operation. Called from OriDevApplication.onCreate.

User-reported: after the fail2ban unban, the connect error became
'NoSuchAlgorithmException: no such algorithm: 25519 for provider BC'
(modern OpenSSH servers default to Ed25519 host keys).

Root cause: Android ships a Security.Provider named 'BC' that
is a reduced subset of BouncyCastle — without Ed25519. SSHJ calls
Security.getProvider("BC") and gets Android's limited version,
NOT the full bcprov-jdk18on (1.80) that SSHJ brings in as a
transitive dependency.

Fix: BouncyCastleSetup.install() at OriDevApplication.onCreate
removes the Android provider and inserts the bundled one at
position 1, so all subsequent Security.getProvider("BC")
calls get Ed25519 / Curve25519 / ChaCha20-Poly1305 resolvable.

- core-security: new crypto/BouncyCastleSetup.kt + explicit
  bcprov-jdk18on dep (was only transitive via SSHJ).
- libs.versions.toml: bcprov alias pinned to 1.80 to match the
  version sshj 0.40.0 pulls.
- OriDevApplication.onCreate: install() call runs before the
  first SSHJ operation (before the Terminal or Connect screens
  can reach for a session).
@CallMeTechie
CallMeTechie enabled auto-merge (squash) April 21, 2026 14:39
@CallMeTechie
CallMeTechie merged commit ebe2b72 into master Apr 21, 2026
10 of 12 checks passed
@CallMeTechie
CallMeTechie deleted the fix/ssh-bouncycastle-ed25519 branch April 21, 2026 14:55
CallMeTechie added a commit that referenced this pull request Apr 21, 2026
Wear was the first module to hit the bcprov x jspecify OSGI
manifest duplicate (PR #158 pulled bcprov into :core:core-security,
every Android module inheriting :core:core-security now ships the
conflicting resource). :app had already guarded against it; :wear
was fixed in the previous commit on this branch.

But feature-settings' test APK failed with the same error on PR
#160's CI, and tracking down which module transitively gets bcprov
on the next dependency change is operational churn we don't need.

Move the exclude into root build.gradle.kts via a subprojects
plugin-withId block — applies to every com.android.library and
com.android.application subproject without per-module bookkeeping.
Revert the now-redundant wear-only exclude added two commits ago.

Local verify: :app, :wear, :feature-settings:assembleDebugAndroidTest
all green. detekt clean.
CallMeTechie added a commit that referenced this pull request Apr 21, 2026
* fix(wear): exclude OSGI META-INF to unblock bcprov packaging

Release build of v0.33.12 (PR #158) failed at :wear:mergeRelease
JavaResource because bcprov-jdk18on 1.80 and jspecify 1.0.0 both
ship META-INF/versions/9/OSGI-INF/MANIFEST.MF. The :app module
already excluded this path; :wear did not, because wear never
pulled in bcprov before — it does now via the shared
:core:core-security dependency (BouncyCastleSetup lives there).

Add a packaging resources block to wear/build.gradle.kts
mirroring the app exclusion list. OSGI metadata is not used by
Android runtime, so dropping it is safe.

* fix(build): centralise OSGI META-INF exclude in root build.gradle

Wear was the first module to hit the bcprov x jspecify OSGI
manifest duplicate (PR #158 pulled bcprov into :core:core-security,
every Android module inheriting :core:core-security now ships the
conflicting resource). :app had already guarded against it; :wear
was fixed in the previous commit on this branch.

But feature-settings' test APK failed with the same error on PR
#160's CI, and tracking down which module transitively gets bcprov
on the next dependency change is operational churn we don't need.

Move the exclude into root build.gradle.kts via a subprojects
plugin-withId block — applies to every com.android.library and
com.android.application subproject without per-module bookkeeping.
Revert the now-redundant wear-only exclude added two commits ago.

Local verify: :app, :wear, :feature-settings:assembleDebugAndroidTest
all green. detekt clean.
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