Skip to content

Decrypting PuTTY keys protected by passphrase with umlauts fails #1037

Description

@beth-soptim

Decrypting PuTTY keys protected by passphrase with umlauts fails:

JSch jSch = new JSch();
String prvkey = """
        PuTTY-User-Key-File-3: ecdsa-sha2-nistp256
        Encryption: aes256-cbc
        Comment: ecdsa-key-20260417
        Public-Lines: 3
        AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBGXm6QPAlc2K
        35/WrbOK2BWAJ9rZCt1JZxN2ST4v4C5co6MT8GsGKt0SVc/tzE2sC9w85bZR9rhu
        J5cTdm/fdac=
        Key-Derivation: Argon2id
        Argon2-Memory: 8192
        Argon2-Passes: 34
        Argon2-Parallelism: 1
        Argon2-Salt: 837714b0fd5cd436fe5d5727943fbb21
        Private-Lines: 1
        sijTJ9kQFECRzS/9dHKN8r1iDvRQB4OXWAbLZJjPn+vjCm1HDlO3XcUDEtBMpdwM
        Private-MAC: 25cdb7650f2a829d743b3efa98013f5b1a2415cc4bf945704e794c3dff3d1183
        """;
Path tempFile = Files.createTempFile("test", "test");
Files.writeString(tempFile, prvkey);
jSch.addIdentity(tempFile.toAbsolutePath().toString(), "secret123äöüß");

When changing the charset from UTF-8 to e.g. ISO-8859-1 in Util.str2byte(String) it works.

Not sure what is the correct encoding for a passphrase of a PuTTY private key.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions