mirror of
https://gogs.blitter.com/RLabs/xs
synced 2024-08-14 10:26:42 +00:00
De-packetizing-rebuffering of Read() w/HMAC working, yay
This commit is contained in:
parent
3f5db06f16
commit
5ea75e456d
1 changed files with 7 additions and 7 deletions
14
hkexnet.go
14
hkexnet.go
|
@ -299,9 +299,9 @@ func (hl HKExListener) Accept() (hc Conn, err error) {
|
||||||
// See go doc io.Reader
|
// See go doc io.Reader
|
||||||
func (c Conn) Read(b []byte) (n int, err error) {
|
func (c Conn) Read(b []byte) (n int, err error) {
|
||||||
//log.Printf("[Decrypting...]\r\n")
|
//log.Printf("[Decrypting...]\r\n")
|
||||||
log.Printf("Read() requests %d bytes\n", len(b))
|
//log.Printf("Read() requests %d bytes\n", len(b))
|
||||||
for {
|
for {
|
||||||
log.Printf("c.dBuf.Len(): %d\n", c.dBuf.Len())
|
//log.Printf("c.dBuf.Len(): %d\n", c.dBuf.Len())
|
||||||
if c.dBuf.Len() >= 1 /* len(b) */ {
|
if c.dBuf.Len() >= 1 /* len(b) */ {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -322,10 +322,10 @@ func (c Conn) Read(b []byte) (n int, err error) {
|
||||||
if payloadLen > 16384 {
|
if payloadLen > 16384 {
|
||||||
panic("Insane payloadLen")
|
panic("Insane payloadLen")
|
||||||
}
|
}
|
||||||
log.Println("payloadLen:", payloadLen)
|
//log.Println("payloadLen:", payloadLen)
|
||||||
var payloadBytes = make([]byte, payloadLen)
|
var payloadBytes = make([]byte, payloadLen)
|
||||||
n, err = io.ReadFull(c.c, payloadBytes)
|
n, err = io.ReadFull(c.c, payloadBytes)
|
||||||
log.Print(" << Read ", n, " payloadBytes")
|
//log.Print(" << Read ", n, " payloadBytes")
|
||||||
|
|
||||||
// Normal client 'exit' from interactive session will cause
|
// Normal client 'exit' from interactive session will cause
|
||||||
// (on server side) err.Error() == "<iface/addr info ...>: use of closed network connection"
|
// (on server side) err.Error() == "<iface/addr info ...>: use of closed network connection"
|
||||||
|
@ -352,16 +352,16 @@ func (c Conn) Read(b []byte) (n int, err error) {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
c.dBuf.Write(payloadBytes)
|
c.dBuf.Write(payloadBytes)
|
||||||
log.Printf("c.dBuf: %s\n", hex.Dump(c.dBuf.Bytes()))
|
//log.Printf("c.dBuf: %s\n", hex.Dump(c.dBuf.Bytes()))
|
||||||
|
|
||||||
// Re-calculate hmac, compare with received value
|
// Re-calculate hmac, compare with received value
|
||||||
c.rm.Write(payloadBytes)
|
c.rm.Write(payloadBytes)
|
||||||
hTmp := c.rm.Sum(nil)[0]
|
hTmp := c.rm.Sum(nil)[0]
|
||||||
log.Printf("<%04x) HMAC:(i)%02x (c)%02x\r\n", decryptN, hmacIn, hTmp)
|
log.Printf("<%04x) HMAC:(i)%02x (c)%02x\r\n", decryptN, hmacIn, hTmp)
|
||||||
}
|
}
|
||||||
log.Printf("Read() got %d bytes\n", c.dBuf.Len())
|
//log.Printf("Read() got %d bytes\n", c.dBuf.Len())
|
||||||
copy(b, c.dBuf.Next(len(b)))
|
copy(b, c.dBuf.Next(len(b)))
|
||||||
log.Printf("As Read() returns, c.dBuf is %d long: %s\n", c.dBuf.Len(), hex.Dump(c.dBuf.Bytes()))
|
//log.Printf("As Read() returns, c.dBuf is %d long: %s\n", c.dBuf.Len(), hex.Dump(c.dBuf.Bytes()))
|
||||||
return len(b), nil
|
return len(b), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue