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

Handle lower-case hex in private key's salt field #179

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

RiJo
Copy link

@RiJo RiJo commented Feb 22, 2017

I'm using BouncyCastle (http://bouncycastle.org/) to produce public/private key pairs. In later versions of SSH.NET an exception is thrown (SshException: "Invalid private key file.") while establishing connection using the private keys previously generated.

It seems to be an issue with the regex matching the private key file data which this commit handles properly. Below is the private key data I've been using for debugging:

`-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,00abc69aea079727973a76b231177bef

FnaHUyvIU4pOvR7RkIQ35KlNDB1HsPmLmGzXBpNKF59ifFw1cxoMIZ1xLbDdHy63
RIGRZAQ2l+unxo7TPgRznHENvj3BzW8X71hu0B1Vkr2DETsNCI5vqI29/U20YzUw
EUzb4UBi9IyAEbQZHEjXKl36Q/FvXTWp/IQxzSzW80rn6GSENj7qJOb4tj0aLCpG
CZEF+lxESCZ+na7IPXrzTeW3sPwDBHjf6IUbPK5biurM+SU9MLYH83cf0IvESq6y
uL7uPWpzQPn4wVjTha15/0qpDD9uXJnzVfz6HENMUSdXDXWYFLCkCJUcmyA7W4X2
UZE9D0mD2TA85/FG4xS/JlWbgJRB/8LHjHQh7IfyCW5EAVA2cGUM1uSZkgIBM7rW
vh0R3GF+FK38Op97EIGvpMmIYAqYwwuNfZqJuoib8J8WhzCIHbWt7VKGMjdwGcsY
ayg1tg0vl/z4A3GobJksrirtvTTymikSitIpBAuARt3GCxj3KRnwqWc1x9lx4s9h
wW7QJnsyPDi4YY0u3XjfRzFhzkpjzNnJjSNyIhLSZSMy8Nn2rks8cXTpYUDkn8JT
C/V9OqjIUT0EFh06ei/uqSyd5c7XoU7IoxURwzP3FQzby+1Ncd9nrJXyHz+rMvMs
VpvwpyOq8ddkhsHrYc39zSe5wZVE9Q7FKJ5KE7Z4eKsmBZg/BDQojJKmkIZfqVK2
Mph+337cLOC78HBWTOIqCCp8pEQtHNjujgeNBsDxJIgbl+g4aGtnI9fMMfl4wzX/
ROnnCbbWQBf/oEAi/2sUcJwt9gh/WHqY8B/DNZ3N69Iw0itslUuidjaTYwWmmkfs
gch9UiBCNMEh0L6Pht/AKMdvbbnokVK8KrMr4mVcyJeBbYanFCzmi8gCcT7xA+2t
K1evV1IZ9r2GCpDM21cWowiy0nsflgqUHOawNLdzJkSL+T2sqHra9MC+pe+YYySS
UTSufiNA/LV31vef0k0x+Jp78uhWsRddw8zY3Tw1KWUlUaBcK8pjLdoHAO3By4+G
5FqVQRFHqdA1B0Zk7NNEllrD31AY5lTpgJKu9w/sDMAuluyzmReVFm2zXEyhQpqb
lxpI3oTIcdlp5T69pgstNp5f1FGryURy/4ABrqUgdvJEjT5JNODR36au5o6gtnbz
n1HyOXBfb4DjOy9lM3OYUgNLPw2pY3kmX4nARJH+0/OCV23nWaO5uB6BzyJKMzCC
fZQPPf3nAA42HtO18VXNXFZ3FX41t4TdKkY0bfCA/offZX1T7DpbJlugiwkio323
93jX/d6ShfrJI2Q6y2OmZhVIBNEWfkK6bWqE4ay012lAsaWKOCXgQlG3V8qcbYoZ
InTJae7SyhWJDV91/KwSsUKAKsBWRR7se/jTTbQTx2j6Hr8UkktC3F8oJVGOIsrl
D4jvNp3QZ/qRFMNAU6hMBrUZhGvxh54ZkcgFuqMg0OVrmu39ngPsifkey60UlH8L
jXs8ZFUKwuAAzKDeCEP073pxq9LSqQkDFtnMOUfzOOowgvEETFRpvbBflit1dT02
nzKtbSerG+wD1U+E93DbrYSLsSKfPYtBj3HMPaYLVzBfPashhZV0/v1gylEN4y3W
-----END RSA PRIVATE KEY-----`

I'm using BouncyCastle (http://bouncycastle.org/) to produce public/private key pairs. In later versions of SSH.NET an exception is thrown (SshException: "Invalid private key file.") while establishing connection using the private keys previously generated.

It seems to be an issue with the regex matching the private key file data which this commit handles properly. Below is the private key data I've been using for debugging:

`-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,00abc69aea079727973a76b231177bef

FnaHUyvIU4pOvR7RkIQ35KlNDB1HsPmLmGzXBpNKF59ifFw1cxoMIZ1xLbDdHy63
RIGRZAQ2l+unxo7TPgRznHENvj3BzW8X71hu0B1Vkr2DETsNCI5vqI29/U20YzUw
EUzb4UBi9IyAEbQZHEjXKl36Q/FvXTWp/IQxzSzW80rn6GSENj7qJOb4tj0aLCpG
CZEF+lxESCZ+na7IPXrzTeW3sPwDBHjf6IUbPK5biurM+SU9MLYH83cf0IvESq6y
uL7uPWpzQPn4wVjTha15/0qpDD9uXJnzVfz6HENMUSdXDXWYFLCkCJUcmyA7W4X2
UZE9D0mD2TA85/FG4xS/JlWbgJRB/8LHjHQh7IfyCW5EAVA2cGUM1uSZkgIBM7rW
vh0R3GF+FK38Op97EIGvpMmIYAqYwwuNfZqJuoib8J8WhzCIHbWt7VKGMjdwGcsY
ayg1tg0vl/z4A3GobJksrirtvTTymikSitIpBAuARt3GCxj3KRnwqWc1x9lx4s9h
wW7QJnsyPDi4YY0u3XjfRzFhzkpjzNnJjSNyIhLSZSMy8Nn2rks8cXTpYUDkn8JT
C/V9OqjIUT0EFh06ei/uqSyd5c7XoU7IoxURwzP3FQzby+1Ncd9nrJXyHz+rMvMs
VpvwpyOq8ddkhsHrYc39zSe5wZVE9Q7FKJ5KE7Z4eKsmBZg/BDQojJKmkIZfqVK2
Mph+337cLOC78HBWTOIqCCp8pEQtHNjujgeNBsDxJIgbl+g4aGtnI9fMMfl4wzX/
ROnnCbbWQBf/oEAi/2sUcJwt9gh/WHqY8B/DNZ3N69Iw0itslUuidjaTYwWmmkfs
gch9UiBCNMEh0L6Pht/AKMdvbbnokVK8KrMr4mVcyJeBbYanFCzmi8gCcT7xA+2t
K1evV1IZ9r2GCpDM21cWowiy0nsflgqUHOawNLdzJkSL+T2sqHra9MC+pe+YYySS
UTSufiNA/LV31vef0k0x+Jp78uhWsRddw8zY3Tw1KWUlUaBcK8pjLdoHAO3By4+G
5FqVQRFHqdA1B0Zk7NNEllrD31AY5lTpgJKu9w/sDMAuluyzmReVFm2zXEyhQpqb
lxpI3oTIcdlp5T69pgstNp5f1FGryURy/4ABrqUgdvJEjT5JNODR36au5o6gtnbz
n1HyOXBfb4DjOy9lM3OYUgNLPw2pY3kmX4nARJH+0/OCV23nWaO5uB6BzyJKMzCC
fZQPPf3nAA42HtO18VXNXFZ3FX41t4TdKkY0bfCA/offZX1T7DpbJlugiwkio323
93jX/d6ShfrJI2Q6y2OmZhVIBNEWfkK6bWqE4ay012lAsaWKOCXgQlG3V8qcbYoZ
InTJae7SyhWJDV91/KwSsUKAKsBWRR7se/jTTbQTx2j6Hr8UkktC3F8oJVGOIsrl
D4jvNp3QZ/qRFMNAU6hMBrUZhGvxh54ZkcgFuqMg0OVrmu39ngPsifkey60UlH8L
jXs8ZFUKwuAAzKDeCEP073pxq9LSqQkDFtnMOUfzOOowgvEETFRpvbBflit1dT02
nzKtbSerG+wD1U+E93DbrYSLsSKfPYtBj3HMPaYLVzBfPashhZV0/v1gylEN4y3W
-----END RSA PRIVATE KEY-----`
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