PuTTY .ppk keys: import and export

- Import PuTTY's private key files, versions 2 and 3 (with their
  passphrase), their comment kept as the key's
- Export as .ppk version 3 (Argon2id, AES-256-CBC, HMAC-SHA-256, as
  PuTTYgen 0.75+ writes them) or version 2 (for older PuTTY and WinSCP),
  with or without a passphrase; chosen in the export dialog beside
  OpenSSH's form
- Imported RSA keys that come without their primes (sshj reads .ppk
  ones so) made whole again from n, e and d: Android's provider
  wouldn't encode them, so they couldn't be kept
- Tested against puttygen: every key type, both versions, with and
  without a passphrase, read by puttygen (MAC and decryption checked)
  and converted back to the same private key; puttygen's own keys
  imported; a wrong passphrase refused. CI installs putty-tools.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172Hejd12i4aYikYW9vgpZs
This commit is contained in:
Claude committed 2026-10-16 19:42:31 +00:00
1 parent a946d5d828
commit 3b8de945bd
6 files changed
+284 -15

No files matched your search

+2 -2
View File
@@ -39,8 +39,8 @@ jobs:
"$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" \
"ndk;$NDK_VERSION" "cmake;$CMAKE_VERSION" "platforms;android-37.0"
- name: OpenSSH (for the SSH interop tests)
run: sudo apt-get install -y -q openssh-client openssh-server && sudo mkdir -p /run/sshd
- name: OpenSSH and PuTTY (for the SSH interop tests)
run: sudo apt-get install -y -q openssh-client openssh-server putty-tools && sudo mkdir -p /run/sshd
- name: Build, unit tests, lint
run: ./gradlew assembleDebug assembleDebugAndroidTest testDebugUnitTest lintDebug