Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The SSHKeyPair.fromPem method cannot read key files of certain formats. #109

Open
jooy2 opened this issue Aug 29, 2024 · 0 comments
Open

Comments

@jooy2
Copy link

jooy2 commented Aug 29, 2024

Hello, thank you for your continued development of the dartssh2 module!

I've noticed that the SSHKeyPair.fromPem function we use to read the private key fails to parse a few different types of private keys.

I would like to see private keys with these formats supported.

Regards,

The key formats that fail include:

A. Any private key that uses the DSA algorithm

Test private key (no passphrase):

-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABsgAAAAdzc2gtZH
NzAAAAgQCug6Xc8tsj6zVA+4y7pQ1OvdcBh0K5dr89/bqMguSLJ0YzcxPuAvzDTWxFjBpq
9t3nOYvlpjy5Q/rqIZN9jXaSRyocwm4um0k2s7UnqS+jXd4aQ2RbyauZRPMjCousDfEH4g
8B/hS1ibOEIUW60+AeeQsRL7JTTLbxiCJhtKbC3QAAABUA5E6Qv3YhulSUX815/ihA3wZs
8aEAAACAbf6738RCp0xuPcLl2OpwZnGRzPQxC15DK4OYxQSAvxMAE1mWV+nDqOKhmGrTWt
0oYzjJKbwoTxKgKLaB8IDDh2tNFlpFcUPFNDzNaQuCEfN15sH/gxtUJLu+DQV1qfI4gJBJ
X3H8ohRbwlSpX/IdvcAu6gbGMTyyQwXqUC9hs3YAAACBAJj2JjyG1eZt0wUUo4FNhN1Nkv
zZZgGg4InhTI40CFfXG/mR+drDMIgmxvYcMgsKIKxnyVkNvgJOvMFystiBc/Hn2CPQsAsj
9aHHQldUOqQgKeFP5IyvPxeFQ733VwsPQ8GXpHZmdGg6SOMnR9Pjbzo6HrKlHkh5l3PB+h
c+VqHfAAAB6EsoT05LKE9OAAAAB3NzaC1kc3MAAACBAK6D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IbV5m3TBRSjgU2E3U2S/NlmAaDgieFMjjQIV9cb+ZH52sMwiCbG9hwyCwogrGfJWQ2+Ak68wXKy2IFz8efYI9CwCyP1ocdCV1Q6pCAp4U/kjK8/F4VDvfdXCw9DwZekdmZ0aDpI4ydH0+NvOjoesqUeSHmXc8H6Fz5Wod8= dsa 1024-083024

B. Private keys using the ECDSA algorithm with old PEM (SSH-2) format

Test private key (no passphrase):

-----BEGIN EC PRIVATE KEY-----
MIIBaAIBAQQg7TXJD04t4e/CrwIdaxF1FJ+PSF0kTzMQs5TOp9L0MvKggfowgfcC
AQEwLAYHKoZIzj0BAQIhAP////8AAAABAAAAAAAAAAAAAAAA////////////////
MFsEIP////8AAAABAAAAAAAAAAAAAAAA///////////////8BCBaxjXYqjqT57Pr
vVV2mIa8ZR0GsMxTsPY7zjw+J9JgSwMVAMSdNgiG5wSTamZ44ROdJreBn36QBEEE
axfR8uEsQkf4vOblY6RA8ncDfYEt6zOg9KE5RdiYwpZP40Li/hp/m47n60p8D54W
K84zV2sxXs7LtkBoN79R9QIhAP////8AAAAA//////////+85vqtpxeehPO5ysL8
YyVRAgEBoUQDQgAEQ3EUZAOS4yK43BKX5gl1BPUWPN3CsU0xrptfxnItUD34jPc0
ybMM3pZ6HeBa89ariwVsl/wCYzZfgR64JAC1nQ==
-----END EC PRIVATE KEY-----

public key:

ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBENxFGQDkuMiuNwSl+YJdQT1FjzdwrFNMa6bX8ZyLVA9+Iz3NMmzDN6Weh3gWvPWq4sFbJf8AmM2X4EeuCQAtZ0= ecdsa 256-083024

C. A private key with Proc-Type and DEK-Info information. (When using RSA/ECDSA with passphrase)

Test private key (RSA with passphrase):

(passphrase is test.)

-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,74E0BC77BE064544

GDaBoq982V4GgOXxNkefwlFwMYL93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YLIK
FQkW1+GarNyskC9nQQTz0WxUBIeuKNzeWvGw/Oo5ZGLKn/gJAJATXAXf8t3D79rX
0Y58J8bjmpZ3Sor+tgtLYZu75c6btlGZSf0vtU76h3+TFmI+wMVuRRvylhhb6lzo
TV/2/KHqVbDnIVaUil8rNfnhDMSOoMufq0iWlSJyRW8rbypl+ua0Jgy+rpUlpn5G
ZJyJ1vxIZSrPsTxkAFDMc9x3lO4KZlaionZ6IWuhLPb/Ng9J9c1aN523nDKhr5yF
kgMeUGvCf2aoxp6cFkS+CerUyLokQWQqkuJcucreuP1Dy145Gn3eWOxHO+u6AjCV
tv+1aYhVmgX0TG20TWz4vST9MeGKFhTNJI5Gnlh23U65z0r2GhUk4mh35bQ2W4u8
pOwuPiuCX2q8gEaoPXHkcvvUL34cH+ciJUVYZsmJqqCA5GuPdU+ms2lJFdyMaZff
UkBjJZMhH8L+DX5Eq2VJf65rHWP334gpW9QY0kN4vB4ptccs4sjEhg==
-----END RSA PRIVATE KEY-----

public key:

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAuWGdovlg+EG9FqSfGSptc6z8IFs4ufR11vwkI/YosKupjWoJzwzEASsutVZA7I8nsn7kokpiYD1/OEXS4e5yhxL3bxdGy1PjyFiexTGI79S1OgMoi/geaPUQmmABzOTEumDfQTh32M1/5gQ8vXNuuFK4dEAyztad/fuZmSbLhou8qwA2XrWVP8WdDldZdXw6bDoI3Gv5sPVZQI2UUKH2r4LIz6mhcbFzQw4HqwetsOARgNR4uwW0Pjvtnbc560F219C6kj131coT3NzNVkIZuWP4dB7lolSa7vs5VSmCrwQydsmXH/uWYz1pjiJg3N3rlrqOIQIXfXkr4igD57dbnQ== rsa 2048-083024
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

No branches or pull requests

1 participant