Closed
Description
BouncyCastle create PEM files for EC-keys with DEK-Info salt in lowercase, which prevents the PrivateKeyPattern to match the key.
This results in a SshException("Invalid private key file.") when trying to load the private key file.
Example:
-----BEGIN EC PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,d87771503957057a
This could be fixed by changing
DEK-Info: (?<cipherName>[A-Z0-9-]+),(?<salt>[A-F0-9]+)
to
DEK-Info: (?<cipherName>[A-Z0-9-]+),(?<salt>[a-fA-F0-9]+)
Fixed line would be
private const string PrivateKeyPattern = @"^-+ *BEGIN (?<keyName>\w+( \w+)*) *-+\r?\n((Proc-Type: 4,ENCRYPTED\r?\nDEK-Info: (?<cipherName>[A-Z0-9-]+),(?<salt>[a-zA-F0-9]+)\r?\n\r?\n)|(Comment: ""?[^\r\n]*""?\r?\n))?(?<data>([a-zA-Z0-9/+=]{1,80}\r?\n)+)(\r?\n)?-+ *END \k<keyName> *-+";
Metadata
Metadata
Assignees
Labels
No labels