Merge pull request #4 from uli-heller/ssh-pubkey
Fixed handling of ssh pubkey files; use regexp to split
This commit is contained in:
commit
460f1cf703
1 changed files with 4 additions and 2 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Reference in a new issue