Skip to content

Fix SK Ed25519 detection#470

Open
nindanaoto wants to merge 2 commits intoconnectbot:mainfrom
nindanaoto:fix_sk
Open

Fix SK Ed25519 detection#470
nindanaoto wants to merge 2 commits intoconnectbot:mainfrom
nindanaoto:fix_sk

Conversation

@nindanaoto
Copy link
Contributor

@nindanaoto nindanaoto commented Feb 23, 2026

If I should write a PR based on connectbot/connectbot#1931, let me know.

  • Move the instanceof SkPublicKey check before the isEd25519Key() check in AuthenticationManager.authenticatePublicKey().
  • SkEd25519PublicKey.getAlgorithm() returns "Ed25519", which matches PublicKeyUtils.isEd25519Key(). This caused SK Ed25519 keys to enter the generic Ed25519 code path, where Ed25519Verify.encodePublicKey() attempted DER decoding on an SSH wire-format key and failed with InvalidKeySpecException: Expected DER Sequence, but found type 0.
  • Add regression tests using realistic algorithm names ("Ed25519" and "EC") that reproduce the bug. The existing tests used the SSH key type string as the algorithm, which didn't trigger the incorrect dispatch.

nindanaoto and others added 2 commits February 23, 2026 15:17
Move the `instanceof SkPublicKey` check before the `isEd25519Key()`
check in AuthenticationManager.authenticatePublicKey(). SK Ed25519
keys (sk-ssh-ed25519@openssh.com) match isEd25519Key() because their
algorithm is "Ed25519", causing them to enter the generic Ed25519 path
which tries DER encoding and fails with InvalidKeySpecException.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add tests that use realistic algorithm names ("Ed25519" and "EC")
matching what real SkEd25519PublicKey and SkEcdsaPublicKey return.
These reproduce the bug where isEd25519Key() matched SK Ed25519 keys
before the instanceof SkPublicKey check, causing DER encoding failure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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