From 9edcc5110cb3dcaf63bd46b299ad05fe9df0f8a1 Mon Sep 17 00:00:00 2001 From: Russ Magee Date: Wed, 4 Jul 2018 22:06:07 -0700 Subject: [PATCH] Fixed syntax errors from re-org --- herradurakex/herradurakex.go | 2 +- hkexnet/hkexnet.go | 4 ++-- hkexsh/hkexsh.go | 5 +++-- hkexsh/termsize_linux.go | 6 +++--- hkexshd/hkexshd.go | 7 ++++--- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/herradurakex/herradurakex.go b/herradurakex/herradurakex.go index 4e2c0ff..8abe99d 100644 --- a/herradurakex/herradurakex.go +++ b/herradurakex/herradurakex.go @@ -159,7 +159,7 @@ func (h HerraduraKEx) PeerD() *big.Int { // SetPeerD stores the received peer's D value (contents, not ptr) func (h *HerraduraKEx) SetPeerD(pd *big.Int) { - *h.peerD = *pd + h.peerD = new(big.Int).Set(pd) } // ComputeFA computes the FA value, which must be sent to peer for KEx. diff --git a/hkexnet/hkexnet.go b/hkexnet/hkexnet.go index 1eb0c6f..dad88a4 100644 --- a/hkexnet/hkexnet.go +++ b/hkexnet/hkexnet.go @@ -327,9 +327,9 @@ func (hl HKExListener) Accept() (hc Conn, err error) { hc.h.SetPeerD(d) log.Printf("** D:%s\n", hc.h.D().Text(16)) log.Printf("**(s)** peerD:%s\n", hc.h.PeerD().Text(16)) - hc.h.FA() + hc.h.ComputeFA() log.Printf("**(s)** FA:%s\n", hc.h.FA()) - + // Send D and cipheropts/conn_opts to peer fmt.Fprintf(c, "0x%s\n%08x:%08x\n", hc.h.D().Text(16), hc.cipheropts, hc.opts) diff --git a/hkexsh/hkexsh.go b/hkexsh/hkexsh.go index e2fd07b..daca62b 100644 --- a/hkexsh/hkexsh.go +++ b/hkexsh/hkexsh.go @@ -21,6 +21,7 @@ import ( "sync" hkexsh "blitter.com/go/hkexsh" + "blitter.com/go/hkexsh/hkexnet" isatty "github.com/mattn/go-isatty" ) @@ -105,7 +106,7 @@ func main() { log.SetOutput(ioutil.Discard) } - conn, err := hkexsh.Dial("tcp", server, cAlg, hAlg) + conn, err := hkexnet.Dial("tcp", server, cAlg, hAlg) if err != nil { fmt.Println("Err!") panic(err) @@ -237,7 +238,7 @@ func main() { // Copy() expects EOF so this will // exit with outerr == nil //!_, outerr := io.Copy(conn, os.Stdin) - _, outerr := func(conn *hkexsh.Conn, r io.Reader) (w int64, e error) { + _, outerr := func(conn *hkexnet.Conn, r io.Reader) (w int64, e error) { return io.Copy(conn, r) }(conn, os.Stdin) diff --git a/hkexsh/termsize_linux.go b/hkexsh/termsize_linux.go index f583110..0ab5c86 100644 --- a/hkexsh/termsize_linux.go +++ b/hkexsh/termsize_linux.go @@ -8,11 +8,11 @@ import ( "os/signal" "syscall" - hkexsh "blitter.com/go/hkexsh" + "blitter.com/go/hkexsh/hkexnet" ) // Handle pty resizes (notify server side) -func handleTermResizes(conn *hkexsh.Conn) { +func handleTermResizes(conn *hkexnet.Conn) { ch := make(chan os.Signal, 1) signal.Notify(ch, syscall.SIGWINCH) wg.Add(1) @@ -28,7 +28,7 @@ func handleTermResizes(conn *hkexsh.Conn) { log.Println(err) } termSzPacket := fmt.Sprintf("%d %d", rows, cols) - conn.WritePacket([]byte(termSzPacket), hkexsh.CSOTermSize) + conn.WritePacket([]byte(termSzPacket), hkexnet.CSOTermSize) } }() ch <- syscall.SIGWINCH // Initial resize. diff --git a/hkexshd/hkexshd.go b/hkexshd/hkexshd.go index a77452e..0c2aae0 100644 --- a/hkexshd/hkexshd.go +++ b/hkexshd/hkexshd.go @@ -21,6 +21,7 @@ import ( "blitter.com/go/goutmp" hkexsh "blitter.com/go/hkexsh" + "blitter.com/go/hkexsh/hkexnet" "blitter.com/go/hkexsh/spinsult" "github.com/kr/pty" ) @@ -80,7 +81,7 @@ func runCmdAs(who string, cmd string, conn hkex.Conn) (err error) { // Run a command (via default shell) as a specific user // // Uses ptys to support commands which expect a terminal. -func runShellAs(who string, cmd string, interactive bool, conn hkexsh.Conn, chaffing bool) (err error, exitStatus int) { +func runShellAs(who string, cmd string, interactive bool, conn hkexnet.Conn, chaffing bool) (err error, exitStatus int) { u, _ := user.Lookup(who) var uid, gid uint32 fmt.Sscanf(u.Uid, "%d", &uid) @@ -227,7 +228,7 @@ func main() { // Listen on TCP port 2000 on all available unicast and // anycast IP addresses of the local system. - l, err := hkexsh.Listen("tcp", laddr) + l, err := hkexnet.Listen("tcp", laddr) if err != nil { log.Fatal(err) } @@ -252,7 +253,7 @@ func main() { // Handle the connection in a new goroutine. // The loop then returns to accepting, so that // multiple connections may be served concurrently. - go func(hc hkexsh.Conn) (e error) { + go func(hc hkexnet.Conn) (e error) { defer hc.Close() //We use io.ReadFull() here to guarantee we consume