Merge pull request #4 from uli-heller/ssh-pubkey

Fixed handling of ssh pubkey files; use regexp to split
This commit is contained in:
Sudhi Herle 2021-11-19 19:57:55 -08:00 committed by GitHub
commit 460f1cf703
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,6 +26,7 @@ import (
"encoding/binary"
"encoding/pem"
"fmt"
"regexp"
"strings"
"github.com/dchest/bcrypt_pbkdf"
@ -56,12 +57,13 @@ func parseSSHPrivateKey(data []byte, getpw func() ([]byte, error)) (*PrivateKey,
}
func parseSSHPublicKey(in []byte) (*PublicKey, error) {
v := bytes.Split(in, []byte(" \t"))
splitter := regexp.MustCompile("[ \\t]+");
v := splitter.Split(string(in), -1);
if len(v) != 3 {
return nil, ErrBadPublicKey
}
return parseEncPubKey(v[1], string(v[2]))
return parseEncPubKey([]byte(v[1]), v[2])
}
// parse a wire encoded public key