// TestNewSignatureVerifierFromFile tests initializing SignatureVerifier from file func TestNewSignatureVerifierFromFile(t *testing.T) { v, err := NewSignatureVerifierFromAuthorizedKeysFile(authorizedKeysFile) if err != nil { t.Error("failed to read from authorized keys file:", err) } keys := v.pubkeys if bytes.Compare(gossh.MarshalAuthorizedKey(keys[0]), []byte(firstAuthorizedKey)) != 0 { t.Error("wrong first authorized key") } if bytes.Compare(gossh.MarshalAuthorizedKey(keys[1]), []byte(secondAuthorizedKey)) != 0 { t.Error("wrong second authorized key") } }
func renderHostLine(addr string, key gossh.PublicKey) []byte { keyByte := gossh.MarshalAuthorizedKey(key) // allocate line space in advance length := len(addr) + 1 + len(keyByte) line := make([]byte, 0, length) w := bytes.NewBuffer(line) w.Write([]byte(addr)) w.WriteByte(' ') w.Write(keyByte) return w.Bytes() }