Fixed handling of ssh pubkey files

This commit is contained in:
Uli Heller 2021-11-19 13:10:30 +01:00
parent 81a6522ee7
commit 43a9f38592

View file

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