Closed scott-xu closed 1 year ago
There's nothing wrong with current implmentation according to the spec, for example https://www.rfc-editor.org/rfc/rfc5656#section-3.1
However, OpenSSH and PuTTY both are using below format:
{prefix:string} {keydata:base64encoded} {comments:string}
Sorry my bad. The {keydata:base64encoded} includes the prefix according the RFC
The prefix, in below case, "ssh-rsa" should be in text format but not in binary format. However, the test cases and the
EncodePublicKey
method combined the prefix and the public key in byte array, which is not compatible with OpenSsh format.Test cases: https://github.com/bcgit/bc-csharp/blob/636fa069f181f2eb8f7c5c125a980622cc84b4ba/crypto/test/src/crypto/test/OpenSshKeyParsingTest.cs#L322 https://github.com/bcgit/bc-csharp/blob/636fa069f181f2eb8f7c5c125a980622cc84b4ba/crypto/test/src/crypto/test/OpenSshKeyParsingTest.cs#L337 https://github.com/bcgit/bc-csharp/blob/636fa069f181f2eb8f7c5c125a980622cc84b4ba/crypto/test/src/crypto/test/OpenSshKeyParsingTest.cs#L425
EncodePublicKey
method: https://github.com/bcgit/bc-csharp/blob/636fa069f181f2eb8f7c5c125a980622cc84b4ba/crypto/src/crypto/util/OpenSshPublicKeyUtilities.cs#L38-L93Here's a sample output from OpenSSH. Note the public key format.