Skip to content

Encrypted RSA key in OpenSSHKey format results- error in libcrypto #705

@arpoch

Description

@arpoch

I am using sshj library to decrypt an encrypted RSA private key using the code below

        OpenSSHKeyV1KeyFile o = new OpenSSHKeyV1KeyFile();
        o.init(ENCRYPTED_RSA, "", new Pass(arr));
        PrivateKey p = o.getPrivate();
        byte[] c = p.getEncoded();

The above code works great and results in a decrypted private but to use it for git SSH authentication purpose through command line using GIT_SSH_COMMAND environment variable, I am converting the generated PKCS8(from getformat) byte encoded key to PEM and writing it in a temp file using the code below

      PemObject po = new PemObject("PRIVATE KEY", c);
      PemWriter pw = new PemWriter(new OutputStreamWriter(new FileOutputStream(tempFile)));
      pw.writeObject(po);
      pw.flush();
      pw.close();

But I am getting this error message every time I try to perform any git operation which requires authentication sign_and_send_pubkey: signing failed: error in libcrypto only for Encrypted RSA OpenSSH formatted key, I have test over ecdas19 and it works fine.

As I am currently working with
OS- Windows 10
OpenSSH- OpenSSH_for_Windows_8.1p1

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