all: fix errors reported by vet, golint
None are "wrong" per se, but there are a lot of good suggestions and in one case a docstring that was not present in godoc due to the presence of an extra newline. Changed "Id" in struct properties to "ID" in some non-exported structs. Removed a trailing period from some error messages; I believe the exact contents of error strings are not covered by the Go compatibility promise. Change-Id: I7c620582dc247396f72c52d38c909ccc0ec87b83 Reviewed-on: https://go-review.googlesource.com/80145 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
48a5a650cf
commit
e8f229864d
+2
-2
@@ -241,11 +241,11 @@ func (p *hashed) Hash() []byte {
|
|||||||
n = 3
|
n = 3
|
||||||
}
|
}
|
||||||
arr[n] = '$'
|
arr[n] = '$'
|
||||||
n += 1
|
n++
|
||||||
copy(arr[n:], []byte(fmt.Sprintf("%02d", p.cost)))
|
copy(arr[n:], []byte(fmt.Sprintf("%02d", p.cost)))
|
||||||
n += 2
|
n += 2
|
||||||
arr[n] = '$'
|
arr[n] = '$'
|
||||||
n += 1
|
n++
|
||||||
copy(arr[n:], p.salt)
|
copy(arr[n:], p.salt)
|
||||||
n += encodedSaltSize
|
n += encodedSaltSize
|
||||||
copy(arr[n:], p.hash)
|
copy(arr[n:], p.hash)
|
||||||
|
|||||||
+8
-8
@@ -49,8 +49,8 @@ func RandomG1(r io.Reader) (*big.Int, *G1, error) {
|
|||||||
return k, new(G1).ScalarBaseMult(k), nil
|
return k, new(G1).ScalarBaseMult(k), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *G1) String() string {
|
func (e *G1) String() string {
|
||||||
return "bn256.G1" + g.p.String()
|
return "bn256.G1" + e.p.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScalarBaseMult sets e to g*k where g is the generator of the group and
|
// ScalarBaseMult sets e to g*k where g is the generator of the group and
|
||||||
@@ -92,11 +92,11 @@ func (e *G1) Neg(a *G1) *G1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Marshal converts n to a byte slice.
|
// Marshal converts n to a byte slice.
|
||||||
func (n *G1) Marshal() []byte {
|
func (e *G1) Marshal() []byte {
|
||||||
n.p.MakeAffine(nil)
|
e.p.MakeAffine(nil)
|
||||||
|
|
||||||
xBytes := new(big.Int).Mod(n.p.x, p).Bytes()
|
xBytes := new(big.Int).Mod(e.p.x, p).Bytes()
|
||||||
yBytes := new(big.Int).Mod(n.p.y, p).Bytes()
|
yBytes := new(big.Int).Mod(e.p.y, p).Bytes()
|
||||||
|
|
||||||
// Each value is a 256-bit number.
|
// Each value is a 256-bit number.
|
||||||
const numBytes = 256 / 8
|
const numBytes = 256 / 8
|
||||||
@@ -166,8 +166,8 @@ func RandomG2(r io.Reader) (*big.Int, *G2, error) {
|
|||||||
return k, new(G2).ScalarBaseMult(k), nil
|
return k, new(G2).ScalarBaseMult(k), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *G2) String() string {
|
func (e *G2) String() string {
|
||||||
return "bn256.G2" + g.p.String()
|
return "bn256.G2" + e.p.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScalarBaseMult sets e to g*k where g is the generator of the group and
|
// ScalarBaseMult sets e to g*k where g is the generator of the group and
|
||||||
|
|||||||
+1
-2
@@ -325,9 +325,8 @@ func ReadEntity(packets *packet.Reader) (*Entity, error) {
|
|||||||
if e.PrivateKey, ok = p.(*packet.PrivateKey); !ok {
|
if e.PrivateKey, ok = p.(*packet.PrivateKey); !ok {
|
||||||
packets.Unread(p)
|
packets.Unread(p)
|
||||||
return nil, errors.StructuralError("first packet was not a public/private key")
|
return nil, errors.StructuralError("first packet was not a public/private key")
|
||||||
} else {
|
|
||||||
e.PrimaryKey = &e.PrivateKey.PublicKey
|
|
||||||
}
|
}
|
||||||
|
e.PrimaryKey = &e.PrivateKey.PublicKey
|
||||||
}
|
}
|
||||||
|
|
||||||
if !e.PrimaryKey.PubKeyAlgo.CanSign() {
|
if !e.PrimaryKey.PubKeyAlgo.CanSign() {
|
||||||
|
|||||||
+6
-6
@@ -98,7 +98,7 @@ const (
|
|||||||
agentAddIdentity = 17
|
agentAddIdentity = 17
|
||||||
agentRemoveIdentity = 18
|
agentRemoveIdentity = 18
|
||||||
agentRemoveAllIdentities = 19
|
agentRemoveAllIdentities = 19
|
||||||
agentAddIdConstrained = 25
|
agentAddIDConstrained = 25
|
||||||
|
|
||||||
// 3.3 Key-type independent requests from client to agent
|
// 3.3 Key-type independent requests from client to agent
|
||||||
agentAddSmartcardKey = 20
|
agentAddSmartcardKey = 20
|
||||||
@@ -515,7 +515,7 @@ func (c *client) insertKey(s interface{}, comment string, constraints []byte) er
|
|||||||
|
|
||||||
// if constraints are present then the message type needs to be changed.
|
// if constraints are present then the message type needs to be changed.
|
||||||
if len(constraints) != 0 {
|
if len(constraints) != 0 {
|
||||||
req[0] = agentAddIdConstrained
|
req[0] = agentAddIDConstrained
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := c.call(req)
|
resp, err := c.call(req)
|
||||||
@@ -577,11 +577,11 @@ func (c *client) Add(key AddedKey) error {
|
|||||||
constraints = append(constraints, agentConstrainConfirm)
|
constraints = append(constraints, agentConstrainConfirm)
|
||||||
}
|
}
|
||||||
|
|
||||||
if cert := key.Certificate; cert == nil {
|
cert := key.Certificate
|
||||||
|
if cert == nil {
|
||||||
return c.insertKey(key.PrivateKey, key.Comment, constraints)
|
return c.insertKey(key.PrivateKey, key.Comment, constraints)
|
||||||
} else {
|
|
||||||
return c.insertCert(key.PrivateKey, cert, key.Comment, constraints)
|
|
||||||
}
|
}
|
||||||
|
return c.insertCert(key.PrivateKey, cert, key.Comment, constraints)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *client) insertCert(s interface{}, cert *ssh.Certificate, comment string, constraints []byte) error {
|
func (c *client) insertCert(s interface{}, cert *ssh.Certificate, comment string, constraints []byte) error {
|
||||||
@@ -633,7 +633,7 @@ func (c *client) insertCert(s interface{}, cert *ssh.Certificate, comment string
|
|||||||
|
|
||||||
// if constraints are present then the message type needs to be changed.
|
// if constraints are present then the message type needs to be changed.
|
||||||
if len(constraints) != 0 {
|
if len(constraints) != 0 {
|
||||||
req[0] = agentAddIdConstrained
|
req[0] = agentAddIDConstrained
|
||||||
}
|
}
|
||||||
|
|
||||||
signer, err := ssh.NewSignerFromKey(s)
|
signer, err := ssh.NewSignerFromKey(s)
|
||||||
|
|||||||
+1
-1
@@ -148,7 +148,7 @@ func (s *server) processRequest(data []byte) (interface{}, error) {
|
|||||||
}
|
}
|
||||||
return rep, nil
|
return rep, nil
|
||||||
|
|
||||||
case agentAddIdConstrained, agentAddIdentity:
|
case agentAddIDConstrained, agentAddIdentity:
|
||||||
return nil, s.insertIdentity(data)
|
return nil, s.insertIdentity(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+71
-71
@@ -205,32 +205,32 @@ type channel struct {
|
|||||||
|
|
||||||
// writePacket sends a packet. If the packet is a channel close, it updates
|
// writePacket sends a packet. If the packet is a channel close, it updates
|
||||||
// sentClose. This method takes the lock c.writeMu.
|
// sentClose. This method takes the lock c.writeMu.
|
||||||
func (c *channel) writePacket(packet []byte) error {
|
func (ch *channel) writePacket(packet []byte) error {
|
||||||
c.writeMu.Lock()
|
ch.writeMu.Lock()
|
||||||
if c.sentClose {
|
if ch.sentClose {
|
||||||
c.writeMu.Unlock()
|
ch.writeMu.Unlock()
|
||||||
return io.EOF
|
return io.EOF
|
||||||
}
|
}
|
||||||
c.sentClose = (packet[0] == msgChannelClose)
|
ch.sentClose = (packet[0] == msgChannelClose)
|
||||||
err := c.mux.conn.writePacket(packet)
|
err := ch.mux.conn.writePacket(packet)
|
||||||
c.writeMu.Unlock()
|
ch.writeMu.Unlock()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *channel) sendMessage(msg interface{}) error {
|
func (ch *channel) sendMessage(msg interface{}) error {
|
||||||
if debugMux {
|
if debugMux {
|
||||||
log.Printf("send(%d): %#v", c.mux.chanList.offset, msg)
|
log.Printf("send(%d): %#v", ch.mux.chanList.offset, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := Marshal(msg)
|
p := Marshal(msg)
|
||||||
binary.BigEndian.PutUint32(p[1:], c.remoteId)
|
binary.BigEndian.PutUint32(p[1:], ch.remoteId)
|
||||||
return c.writePacket(p)
|
return ch.writePacket(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteExtended writes data to a specific extended stream. These streams are
|
// WriteExtended writes data to a specific extended stream. These streams are
|
||||||
// used, for example, for stderr.
|
// used, for example, for stderr.
|
||||||
func (c *channel) WriteExtended(data []byte, extendedCode uint32) (n int, err error) {
|
func (ch *channel) WriteExtended(data []byte, extendedCode uint32) (n int, err error) {
|
||||||
if c.sentEOF {
|
if ch.sentEOF {
|
||||||
return 0, io.EOF
|
return 0, io.EOF
|
||||||
}
|
}
|
||||||
// 1 byte message type, 4 bytes remoteId, 4 bytes data length
|
// 1 byte message type, 4 bytes remoteId, 4 bytes data length
|
||||||
@@ -241,16 +241,16 @@ func (c *channel) WriteExtended(data []byte, extendedCode uint32) (n int, err er
|
|||||||
opCode = msgChannelExtendedData
|
opCode = msgChannelExtendedData
|
||||||
}
|
}
|
||||||
|
|
||||||
c.writeMu.Lock()
|
ch.writeMu.Lock()
|
||||||
packet := c.packetPool[extendedCode]
|
packet := ch.packetPool[extendedCode]
|
||||||
// We don't remove the buffer from packetPool, so
|
// We don't remove the buffer from packetPool, so
|
||||||
// WriteExtended calls from different goroutines will be
|
// WriteExtended calls from different goroutines will be
|
||||||
// flagged as errors by the race detector.
|
// flagged as errors by the race detector.
|
||||||
c.writeMu.Unlock()
|
ch.writeMu.Unlock()
|
||||||
|
|
||||||
for len(data) > 0 {
|
for len(data) > 0 {
|
||||||
space := min(c.maxRemotePayload, len(data))
|
space := min(ch.maxRemotePayload, len(data))
|
||||||
if space, err = c.remoteWin.reserve(space); err != nil {
|
if space, err = ch.remoteWin.reserve(space); err != nil {
|
||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
if want := headerLength + space; uint32(cap(packet)) < want {
|
if want := headerLength + space; uint32(cap(packet)) < want {
|
||||||
@@ -262,13 +262,13 @@ func (c *channel) WriteExtended(data []byte, extendedCode uint32) (n int, err er
|
|||||||
todo := data[:space]
|
todo := data[:space]
|
||||||
|
|
||||||
packet[0] = opCode
|
packet[0] = opCode
|
||||||
binary.BigEndian.PutUint32(packet[1:], c.remoteId)
|
binary.BigEndian.PutUint32(packet[1:], ch.remoteId)
|
||||||
if extendedCode > 0 {
|
if extendedCode > 0 {
|
||||||
binary.BigEndian.PutUint32(packet[5:], uint32(extendedCode))
|
binary.BigEndian.PutUint32(packet[5:], uint32(extendedCode))
|
||||||
}
|
}
|
||||||
binary.BigEndian.PutUint32(packet[headerLength-4:], uint32(len(todo)))
|
binary.BigEndian.PutUint32(packet[headerLength-4:], uint32(len(todo)))
|
||||||
copy(packet[headerLength:], todo)
|
copy(packet[headerLength:], todo)
|
||||||
if err = c.writePacket(packet); err != nil {
|
if err = ch.writePacket(packet); err != nil {
|
||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,14 +276,14 @@ func (c *channel) WriteExtended(data []byte, extendedCode uint32) (n int, err er
|
|||||||
data = data[len(todo):]
|
data = data[len(todo):]
|
||||||
}
|
}
|
||||||
|
|
||||||
c.writeMu.Lock()
|
ch.writeMu.Lock()
|
||||||
c.packetPool[extendedCode] = packet
|
ch.packetPool[extendedCode] = packet
|
||||||
c.writeMu.Unlock()
|
ch.writeMu.Unlock()
|
||||||
|
|
||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *channel) handleData(packet []byte) error {
|
func (ch *channel) handleData(packet []byte) error {
|
||||||
headerLen := 9
|
headerLen := 9
|
||||||
isExtendedData := packet[0] == msgChannelExtendedData
|
isExtendedData := packet[0] == msgChannelExtendedData
|
||||||
if isExtendedData {
|
if isExtendedData {
|
||||||
@@ -303,7 +303,7 @@ func (c *channel) handleData(packet []byte) error {
|
|||||||
if length == 0 {
|
if length == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if length > c.maxIncomingPayload {
|
if length > ch.maxIncomingPayload {
|
||||||
// TODO(hanwen): should send Disconnect?
|
// TODO(hanwen): should send Disconnect?
|
||||||
return errors.New("ssh: incoming packet exceeds maximum payload size")
|
return errors.New("ssh: incoming packet exceeds maximum payload size")
|
||||||
}
|
}
|
||||||
@@ -313,21 +313,21 @@ func (c *channel) handleData(packet []byte) error {
|
|||||||
return errors.New("ssh: wrong packet length")
|
return errors.New("ssh: wrong packet length")
|
||||||
}
|
}
|
||||||
|
|
||||||
c.windowMu.Lock()
|
ch.windowMu.Lock()
|
||||||
if c.myWindow < length {
|
if ch.myWindow < length {
|
||||||
c.windowMu.Unlock()
|
ch.windowMu.Unlock()
|
||||||
// TODO(hanwen): should send Disconnect with reason?
|
// TODO(hanwen): should send Disconnect with reason?
|
||||||
return errors.New("ssh: remote side wrote too much")
|
return errors.New("ssh: remote side wrote too much")
|
||||||
}
|
}
|
||||||
c.myWindow -= length
|
ch.myWindow -= length
|
||||||
c.windowMu.Unlock()
|
ch.windowMu.Unlock()
|
||||||
|
|
||||||
if extended == 1 {
|
if extended == 1 {
|
||||||
c.extPending.write(data)
|
ch.extPending.write(data)
|
||||||
} else if extended > 0 {
|
} else if extended > 0 {
|
||||||
// discard other extended data.
|
// discard other extended data.
|
||||||
} else {
|
} else {
|
||||||
c.pending.write(data)
|
ch.pending.write(data)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -384,31 +384,31 @@ func (c *channel) close() {
|
|||||||
// responseMessageReceived is called when a success or failure message is
|
// responseMessageReceived is called when a success or failure message is
|
||||||
// received on a channel to check that such a message is reasonable for the
|
// received on a channel to check that such a message is reasonable for the
|
||||||
// given channel.
|
// given channel.
|
||||||
func (c *channel) responseMessageReceived() error {
|
func (ch *channel) responseMessageReceived() error {
|
||||||
if c.direction == channelInbound {
|
if ch.direction == channelInbound {
|
||||||
return errors.New("ssh: channel response message received on inbound channel")
|
return errors.New("ssh: channel response message received on inbound channel")
|
||||||
}
|
}
|
||||||
if c.decided {
|
if ch.decided {
|
||||||
return errors.New("ssh: duplicate response received for channel")
|
return errors.New("ssh: duplicate response received for channel")
|
||||||
}
|
}
|
||||||
c.decided = true
|
ch.decided = true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *channel) handlePacket(packet []byte) error {
|
func (ch *channel) handlePacket(packet []byte) error {
|
||||||
switch packet[0] {
|
switch packet[0] {
|
||||||
case msgChannelData, msgChannelExtendedData:
|
case msgChannelData, msgChannelExtendedData:
|
||||||
return c.handleData(packet)
|
return ch.handleData(packet)
|
||||||
case msgChannelClose:
|
case msgChannelClose:
|
||||||
c.sendMessage(channelCloseMsg{PeersId: c.remoteId})
|
ch.sendMessage(channelCloseMsg{PeersID: ch.remoteId})
|
||||||
c.mux.chanList.remove(c.localId)
|
ch.mux.chanList.remove(ch.localId)
|
||||||
c.close()
|
ch.close()
|
||||||
return nil
|
return nil
|
||||||
case msgChannelEOF:
|
case msgChannelEOF:
|
||||||
// RFC 4254 is mute on how EOF affects dataExt messages but
|
// RFC 4254 is mute on how EOF affects dataExt messages but
|
||||||
// it is logical to signal EOF at the same time.
|
// it is logical to signal EOF at the same time.
|
||||||
c.extPending.eof()
|
ch.extPending.eof()
|
||||||
c.pending.eof()
|
ch.pending.eof()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -419,24 +419,24 @@ func (c *channel) handlePacket(packet []byte) error {
|
|||||||
|
|
||||||
switch msg := decoded.(type) {
|
switch msg := decoded.(type) {
|
||||||
case *channelOpenFailureMsg:
|
case *channelOpenFailureMsg:
|
||||||
if err := c.responseMessageReceived(); err != nil {
|
if err := ch.responseMessageReceived(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
c.mux.chanList.remove(msg.PeersId)
|
ch.mux.chanList.remove(msg.PeersID)
|
||||||
c.msg <- msg
|
ch.msg <- msg
|
||||||
case *channelOpenConfirmMsg:
|
case *channelOpenConfirmMsg:
|
||||||
if err := c.responseMessageReceived(); err != nil {
|
if err := ch.responseMessageReceived(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if msg.MaxPacketSize < minPacketLength || msg.MaxPacketSize > 1<<31 {
|
if msg.MaxPacketSize < minPacketLength || msg.MaxPacketSize > 1<<31 {
|
||||||
return fmt.Errorf("ssh: invalid MaxPacketSize %d from peer", msg.MaxPacketSize)
|
return fmt.Errorf("ssh: invalid MaxPacketSize %d from peer", msg.MaxPacketSize)
|
||||||
}
|
}
|
||||||
c.remoteId = msg.MyId
|
ch.remoteId = msg.MyID
|
||||||
c.maxRemotePayload = msg.MaxPacketSize
|
ch.maxRemotePayload = msg.MaxPacketSize
|
||||||
c.remoteWin.add(msg.MyWindow)
|
ch.remoteWin.add(msg.MyWindow)
|
||||||
c.msg <- msg
|
ch.msg <- msg
|
||||||
case *windowAdjustMsg:
|
case *windowAdjustMsg:
|
||||||
if !c.remoteWin.add(msg.AdditionalBytes) {
|
if !ch.remoteWin.add(msg.AdditionalBytes) {
|
||||||
return fmt.Errorf("ssh: invalid window update for %d bytes", msg.AdditionalBytes)
|
return fmt.Errorf("ssh: invalid window update for %d bytes", msg.AdditionalBytes)
|
||||||
}
|
}
|
||||||
case *channelRequestMsg:
|
case *channelRequestMsg:
|
||||||
@@ -444,12 +444,12 @@ func (c *channel) handlePacket(packet []byte) error {
|
|||||||
Type: msg.Request,
|
Type: msg.Request,
|
||||||
WantReply: msg.WantReply,
|
WantReply: msg.WantReply,
|
||||||
Payload: msg.RequestSpecificData,
|
Payload: msg.RequestSpecificData,
|
||||||
ch: c,
|
ch: ch,
|
||||||
}
|
}
|
||||||
|
|
||||||
c.incomingRequests <- &req
|
ch.incomingRequests <- &req
|
||||||
default:
|
default:
|
||||||
c.msg <- msg
|
ch.msg <- msg
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -488,23 +488,23 @@ func (e *extChannel) Read(data []byte) (n int, err error) {
|
|||||||
return e.ch.ReadExtended(data, e.code)
|
return e.ch.ReadExtended(data, e.code)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *channel) Accept() (Channel, <-chan *Request, error) {
|
func (ch *channel) Accept() (Channel, <-chan *Request, error) {
|
||||||
if c.decided {
|
if ch.decided {
|
||||||
return nil, nil, errDecidedAlready
|
return nil, nil, errDecidedAlready
|
||||||
}
|
}
|
||||||
c.maxIncomingPayload = channelMaxPacket
|
ch.maxIncomingPayload = channelMaxPacket
|
||||||
confirm := channelOpenConfirmMsg{
|
confirm := channelOpenConfirmMsg{
|
||||||
PeersId: c.remoteId,
|
PeersID: ch.remoteId,
|
||||||
MyId: c.localId,
|
MyID: ch.localId,
|
||||||
MyWindow: c.myWindow,
|
MyWindow: ch.myWindow,
|
||||||
MaxPacketSize: c.maxIncomingPayload,
|
MaxPacketSize: ch.maxIncomingPayload,
|
||||||
}
|
}
|
||||||
c.decided = true
|
ch.decided = true
|
||||||
if err := c.sendMessage(confirm); err != nil {
|
if err := ch.sendMessage(confirm); err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return c, c.incomingRequests, nil
|
return ch, ch.incomingRequests, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ch *channel) Reject(reason RejectionReason, message string) error {
|
func (ch *channel) Reject(reason RejectionReason, message string) error {
|
||||||
@@ -512,7 +512,7 @@ func (ch *channel) Reject(reason RejectionReason, message string) error {
|
|||||||
return errDecidedAlready
|
return errDecidedAlready
|
||||||
}
|
}
|
||||||
reject := channelOpenFailureMsg{
|
reject := channelOpenFailureMsg{
|
||||||
PeersId: ch.remoteId,
|
PeersID: ch.remoteId,
|
||||||
Reason: reason,
|
Reason: reason,
|
||||||
Message: message,
|
Message: message,
|
||||||
Language: "en",
|
Language: "en",
|
||||||
@@ -541,7 +541,7 @@ func (ch *channel) CloseWrite() error {
|
|||||||
}
|
}
|
||||||
ch.sentEOF = true
|
ch.sentEOF = true
|
||||||
return ch.sendMessage(channelEOFMsg{
|
return ch.sendMessage(channelEOFMsg{
|
||||||
PeersId: ch.remoteId})
|
PeersID: ch.remoteId})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ch *channel) Close() error {
|
func (ch *channel) Close() error {
|
||||||
@@ -550,7 +550,7 @@ func (ch *channel) Close() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ch.sendMessage(channelCloseMsg{
|
return ch.sendMessage(channelCloseMsg{
|
||||||
PeersId: ch.remoteId})
|
PeersID: ch.remoteId})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extended returns an io.ReadWriter that sends and receives data on the given,
|
// Extended returns an io.ReadWriter that sends and receives data on the given,
|
||||||
@@ -577,7 +577,7 @@ func (ch *channel) SendRequest(name string, wantReply bool, payload []byte) (boo
|
|||||||
}
|
}
|
||||||
|
|
||||||
msg := channelRequestMsg{
|
msg := channelRequestMsg{
|
||||||
PeersId: ch.remoteId,
|
PeersID: ch.remoteId,
|
||||||
Request: name,
|
Request: name,
|
||||||
WantReply: wantReply,
|
WantReply: wantReply,
|
||||||
RequestSpecificData: payload,
|
RequestSpecificData: payload,
|
||||||
@@ -614,11 +614,11 @@ func (ch *channel) ackRequest(ok bool) error {
|
|||||||
var msg interface{}
|
var msg interface{}
|
||||||
if !ok {
|
if !ok {
|
||||||
msg = channelRequestFailureMsg{
|
msg = channelRequestFailureMsg{
|
||||||
PeersId: ch.remoteId,
|
PeersID: ch.remoteId,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
msg = channelRequestSuccessMsg{
|
msg = channelRequestSuccessMsg{
|
||||||
PeersId: ch.remoteId,
|
PeersID: ch.remoteId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ch.sendMessage(msg)
|
return ch.sendMessage(msg)
|
||||||
|
|||||||
+4
-4
@@ -372,7 +372,7 @@ func (c *gcmCipher) readPacket(seqNum uint32, r io.Reader) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
length := binary.BigEndian.Uint32(c.prefix[:])
|
length := binary.BigEndian.Uint32(c.prefix[:])
|
||||||
if length > maxPacket {
|
if length > maxPacket {
|
||||||
return nil, errors.New("ssh: max packet length exceeded.")
|
return nil, errors.New("ssh: max packet length exceeded")
|
||||||
}
|
}
|
||||||
|
|
||||||
if cap(c.buf) < int(length+gcmTagSize) {
|
if cap(c.buf) < int(length+gcmTagSize) {
|
||||||
@@ -548,11 +548,11 @@ func (c *cbcCipher) readPacketLeaky(seqNum uint32, r io.Reader) ([]byte, error)
|
|||||||
c.packetData = c.packetData[:entirePacketSize]
|
c.packetData = c.packetData[:entirePacketSize]
|
||||||
}
|
}
|
||||||
|
|
||||||
if n, err := io.ReadFull(r, c.packetData[firstBlockLength:]); err != nil {
|
n, err := io.ReadFull(r, c.packetData[firstBlockLength:])
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
c.oracleCamouflage -= uint32(n)
|
|
||||||
}
|
}
|
||||||
|
c.oracleCamouflage -= uint32(n)
|
||||||
|
|
||||||
remainingCrypted := c.packetData[firstBlockLength:macStart]
|
remainingCrypted := c.packetData[firstBlockLength:macStart]
|
||||||
c.decrypter.CryptBlocks(remainingCrypted, remainingCrypted)
|
c.decrypter.CryptBlocks(remainingCrypted, remainingCrypted)
|
||||||
|
|||||||
+2
-2
@@ -242,7 +242,7 @@ func (c *Config) SetDefaults() {
|
|||||||
|
|
||||||
// buildDataSignedForAuth returns the data that is signed in order to prove
|
// buildDataSignedForAuth returns the data that is signed in order to prove
|
||||||
// possession of a private key. See RFC 4252, section 7.
|
// possession of a private key. See RFC 4252, section 7.
|
||||||
func buildDataSignedForAuth(sessionId []byte, req userAuthRequestMsg, algo, pubKey []byte) []byte {
|
func buildDataSignedForAuth(sessionID []byte, req userAuthRequestMsg, algo, pubKey []byte) []byte {
|
||||||
data := struct {
|
data := struct {
|
||||||
Session []byte
|
Session []byte
|
||||||
Type byte
|
Type byte
|
||||||
@@ -253,7 +253,7 @@ func buildDataSignedForAuth(sessionId []byte, req userAuthRequestMsg, algo, pubK
|
|||||||
Algo []byte
|
Algo []byte
|
||||||
PubKey []byte
|
PubKey []byte
|
||||||
}{
|
}{
|
||||||
sessionId,
|
sessionID,
|
||||||
msgUserAuthRequest,
|
msgUserAuthRequest,
|
||||||
req.User,
|
req.User,
|
||||||
req.Service,
|
req.Service,
|
||||||
|
|||||||
+12
-12
@@ -119,7 +119,7 @@ func (group *dhGroup) Client(c packetConn, randSource io.Reader, magics *handsha
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
kInt, err := group.diffieHellman(kexDHReply.Y, x)
|
ki, err := group.diffieHellman(kexDHReply.Y, x)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -129,8 +129,8 @@ func (group *dhGroup) Client(c packetConn, randSource io.Reader, magics *handsha
|
|||||||
writeString(h, kexDHReply.HostKey)
|
writeString(h, kexDHReply.HostKey)
|
||||||
writeInt(h, X)
|
writeInt(h, X)
|
||||||
writeInt(h, kexDHReply.Y)
|
writeInt(h, kexDHReply.Y)
|
||||||
K := make([]byte, intLength(kInt))
|
K := make([]byte, intLength(ki))
|
||||||
marshalInt(K, kInt)
|
marshalInt(K, ki)
|
||||||
h.Write(K)
|
h.Write(K)
|
||||||
|
|
||||||
return &kexResult{
|
return &kexResult{
|
||||||
@@ -164,7 +164,7 @@ func (group *dhGroup) Server(c packetConn, randSource io.Reader, magics *handsha
|
|||||||
}
|
}
|
||||||
|
|
||||||
Y := new(big.Int).Exp(group.g, y, group.p)
|
Y := new(big.Int).Exp(group.g, y, group.p)
|
||||||
kInt, err := group.diffieHellman(kexDHInit.X, y)
|
ki, err := group.diffieHellman(kexDHInit.X, y)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -177,8 +177,8 @@ func (group *dhGroup) Server(c packetConn, randSource io.Reader, magics *handsha
|
|||||||
writeInt(h, kexDHInit.X)
|
writeInt(h, kexDHInit.X)
|
||||||
writeInt(h, Y)
|
writeInt(h, Y)
|
||||||
|
|
||||||
K := make([]byte, intLength(kInt))
|
K := make([]byte, intLength(ki))
|
||||||
marshalInt(K, kInt)
|
marshalInt(K, ki)
|
||||||
h.Write(K)
|
h.Write(K)
|
||||||
|
|
||||||
H := h.Sum(nil)
|
H := h.Sum(nil)
|
||||||
@@ -462,9 +462,9 @@ func (kex *curve25519sha256) Client(c packetConn, rand io.Reader, magics *handsh
|
|||||||
writeString(h, kp.pub[:])
|
writeString(h, kp.pub[:])
|
||||||
writeString(h, reply.EphemeralPubKey)
|
writeString(h, reply.EphemeralPubKey)
|
||||||
|
|
||||||
kInt := new(big.Int).SetBytes(secret[:])
|
ki := new(big.Int).SetBytes(secret[:])
|
||||||
K := make([]byte, intLength(kInt))
|
K := make([]byte, intLength(ki))
|
||||||
marshalInt(K, kInt)
|
marshalInt(K, ki)
|
||||||
h.Write(K)
|
h.Write(K)
|
||||||
|
|
||||||
return &kexResult{
|
return &kexResult{
|
||||||
@@ -510,9 +510,9 @@ func (kex *curve25519sha256) Server(c packetConn, rand io.Reader, magics *handsh
|
|||||||
writeString(h, kexInit.ClientPubKey)
|
writeString(h, kexInit.ClientPubKey)
|
||||||
writeString(h, kp.pub[:])
|
writeString(h, kp.pub[:])
|
||||||
|
|
||||||
kInt := new(big.Int).SetBytes(secret[:])
|
ki := new(big.Int).SetBytes(secret[:])
|
||||||
K := make([]byte, intLength(kInt))
|
K := make([]byte, intLength(ki))
|
||||||
marshalInt(K, kInt)
|
marshalInt(K, ki)
|
||||||
h.Write(K)
|
h.Write(K)
|
||||||
|
|
||||||
H := h.Sum(nil)
|
H := h.Sum(nil)
|
||||||
|
|||||||
+22
-22
@@ -363,7 +363,7 @@ func (r *rsaPublicKey) CryptoPublicKey() crypto.PublicKey {
|
|||||||
|
|
||||||
type dsaPublicKey dsa.PublicKey
|
type dsaPublicKey dsa.PublicKey
|
||||||
|
|
||||||
func (r *dsaPublicKey) Type() string {
|
func (k *dsaPublicKey) Type() string {
|
||||||
return "ssh-dss"
|
return "ssh-dss"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -481,12 +481,12 @@ func (k *dsaPrivateKey) Sign(rand io.Reader, data []byte) (*Signature, error) {
|
|||||||
|
|
||||||
type ecdsaPublicKey ecdsa.PublicKey
|
type ecdsaPublicKey ecdsa.PublicKey
|
||||||
|
|
||||||
func (key *ecdsaPublicKey) Type() string {
|
func (k *ecdsaPublicKey) Type() string {
|
||||||
return "ecdsa-sha2-" + key.nistID()
|
return "ecdsa-sha2-" + k.nistID()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (key *ecdsaPublicKey) nistID() string {
|
func (k *ecdsaPublicKey) nistID() string {
|
||||||
switch key.Params().BitSize {
|
switch k.Params().BitSize {
|
||||||
case 256:
|
case 256:
|
||||||
return "nistp256"
|
return "nistp256"
|
||||||
case 384:
|
case 384:
|
||||||
@@ -499,7 +499,7 @@ func (key *ecdsaPublicKey) nistID() string {
|
|||||||
|
|
||||||
type ed25519PublicKey ed25519.PublicKey
|
type ed25519PublicKey ed25519.PublicKey
|
||||||
|
|
||||||
func (key ed25519PublicKey) Type() string {
|
func (k ed25519PublicKey) Type() string {
|
||||||
return KeyAlgoED25519
|
return KeyAlgoED25519
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -518,23 +518,23 @@ func parseED25519(in []byte) (out PublicKey, rest []byte, err error) {
|
|||||||
return (ed25519PublicKey)(key), w.Rest, nil
|
return (ed25519PublicKey)(key), w.Rest, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (key ed25519PublicKey) Marshal() []byte {
|
func (k ed25519PublicKey) Marshal() []byte {
|
||||||
w := struct {
|
w := struct {
|
||||||
Name string
|
Name string
|
||||||
KeyBytes []byte
|
KeyBytes []byte
|
||||||
}{
|
}{
|
||||||
KeyAlgoED25519,
|
KeyAlgoED25519,
|
||||||
[]byte(key),
|
[]byte(k),
|
||||||
}
|
}
|
||||||
return Marshal(&w)
|
return Marshal(&w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (key ed25519PublicKey) Verify(b []byte, sig *Signature) error {
|
func (k ed25519PublicKey) Verify(b []byte, sig *Signature) error {
|
||||||
if sig.Format != key.Type() {
|
if sig.Format != k.Type() {
|
||||||
return fmt.Errorf("ssh: signature type %s for key type %s", sig.Format, key.Type())
|
return fmt.Errorf("ssh: signature type %s for key type %s", sig.Format, k.Type())
|
||||||
}
|
}
|
||||||
|
|
||||||
edKey := (ed25519.PublicKey)(key)
|
edKey := (ed25519.PublicKey)(k)
|
||||||
if ok := ed25519.Verify(edKey, b, sig.Blob); !ok {
|
if ok := ed25519.Verify(edKey, b, sig.Blob); !ok {
|
||||||
return errors.New("ssh: signature did not verify")
|
return errors.New("ssh: signature did not verify")
|
||||||
}
|
}
|
||||||
@@ -595,9 +595,9 @@ func parseECDSA(in []byte) (out PublicKey, rest []byte, err error) {
|
|||||||
return (*ecdsaPublicKey)(key), w.Rest, nil
|
return (*ecdsaPublicKey)(key), w.Rest, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (key *ecdsaPublicKey) Marshal() []byte {
|
func (k *ecdsaPublicKey) Marshal() []byte {
|
||||||
// See RFC 5656, section 3.1.
|
// See RFC 5656, section 3.1.
|
||||||
keyBytes := elliptic.Marshal(key.Curve, key.X, key.Y)
|
keyBytes := elliptic.Marshal(k.Curve, k.X, k.Y)
|
||||||
// ECDSA publickey struct layout should match the struct used by
|
// ECDSA publickey struct layout should match the struct used by
|
||||||
// parseECDSACert in the x/crypto/ssh/agent package.
|
// parseECDSACert in the x/crypto/ssh/agent package.
|
||||||
w := struct {
|
w := struct {
|
||||||
@@ -605,20 +605,20 @@ func (key *ecdsaPublicKey) Marshal() []byte {
|
|||||||
ID string
|
ID string
|
||||||
Key []byte
|
Key []byte
|
||||||
}{
|
}{
|
||||||
key.Type(),
|
k.Type(),
|
||||||
key.nistID(),
|
k.nistID(),
|
||||||
keyBytes,
|
keyBytes,
|
||||||
}
|
}
|
||||||
|
|
||||||
return Marshal(&w)
|
return Marshal(&w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (key *ecdsaPublicKey) Verify(data []byte, sig *Signature) error {
|
func (k *ecdsaPublicKey) Verify(data []byte, sig *Signature) error {
|
||||||
if sig.Format != key.Type() {
|
if sig.Format != k.Type() {
|
||||||
return fmt.Errorf("ssh: signature type %s for key type %s", sig.Format, key.Type())
|
return fmt.Errorf("ssh: signature type %s for key type %s", sig.Format, k.Type())
|
||||||
}
|
}
|
||||||
|
|
||||||
h := ecHash(key.Curve).New()
|
h := ecHash(k.Curve).New()
|
||||||
h.Write(data)
|
h.Write(data)
|
||||||
digest := h.Sum(nil)
|
digest := h.Sum(nil)
|
||||||
|
|
||||||
@@ -635,7 +635,7 @@ func (key *ecdsaPublicKey) Verify(data []byte, sig *Signature) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if ecdsa.Verify((*ecdsa.PublicKey)(key), digest, ecSig.R, ecSig.S) {
|
if ecdsa.Verify((*ecdsa.PublicKey)(k), digest, ecSig.R, ecSig.S) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return errors.New("ssh: signature did not verify")
|
return errors.New("ssh: signature did not verify")
|
||||||
@@ -758,7 +758,7 @@ func NewPublicKey(key interface{}) (PublicKey, error) {
|
|||||||
return (*rsaPublicKey)(key), nil
|
return (*rsaPublicKey)(key), nil
|
||||||
case *ecdsa.PublicKey:
|
case *ecdsa.PublicKey:
|
||||||
if !supportedEllipticCurve(key.Curve) {
|
if !supportedEllipticCurve(key.Curve) {
|
||||||
return nil, errors.New("ssh: only P-256, P-384 and P-521 EC keys are supported.")
|
return nil, errors.New("ssh: only P-256, P-384 and P-521 EC keys are supported")
|
||||||
}
|
}
|
||||||
return (*ecdsaPublicKey)(key), nil
|
return (*ecdsaPublicKey)(key), nil
|
||||||
case *dsa.PublicKey:
|
case *dsa.PublicKey:
|
||||||
|
|||||||
@@ -108,8 +108,8 @@ func wildcardMatch(pat []byte, str []byte) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *hostPattern) match(a addr) bool {
|
func (p *hostPattern) match(a addr) bool {
|
||||||
return wildcardMatch([]byte(l.addr.host), []byte(a.host)) && l.addr.port == a.port
|
return wildcardMatch([]byte(p.addr.host), []byte(a.host)) && p.addr.port == a.port
|
||||||
}
|
}
|
||||||
|
|
||||||
type keyDBLine struct {
|
type keyDBLine struct {
|
||||||
|
|||||||
+11
-11
@@ -162,7 +162,7 @@ const msgChannelOpen = 90
|
|||||||
|
|
||||||
type channelOpenMsg struct {
|
type channelOpenMsg struct {
|
||||||
ChanType string `sshtype:"90"`
|
ChanType string `sshtype:"90"`
|
||||||
PeersId uint32
|
PeersID uint32
|
||||||
PeersWindow uint32
|
PeersWindow uint32
|
||||||
MaxPacketSize uint32
|
MaxPacketSize uint32
|
||||||
TypeSpecificData []byte `ssh:"rest"`
|
TypeSpecificData []byte `ssh:"rest"`
|
||||||
@@ -173,7 +173,7 @@ const msgChannelData = 94
|
|||||||
|
|
||||||
// Used for debug print outs of packets.
|
// Used for debug print outs of packets.
|
||||||
type channelDataMsg struct {
|
type channelDataMsg struct {
|
||||||
PeersId uint32 `sshtype:"94"`
|
PeersID uint32 `sshtype:"94"`
|
||||||
Length uint32
|
Length uint32
|
||||||
Rest []byte `ssh:"rest"`
|
Rest []byte `ssh:"rest"`
|
||||||
}
|
}
|
||||||
@@ -182,8 +182,8 @@ type channelDataMsg struct {
|
|||||||
const msgChannelOpenConfirm = 91
|
const msgChannelOpenConfirm = 91
|
||||||
|
|
||||||
type channelOpenConfirmMsg struct {
|
type channelOpenConfirmMsg struct {
|
||||||
PeersId uint32 `sshtype:"91"`
|
PeersID uint32 `sshtype:"91"`
|
||||||
MyId uint32
|
MyID uint32
|
||||||
MyWindow uint32
|
MyWindow uint32
|
||||||
MaxPacketSize uint32
|
MaxPacketSize uint32
|
||||||
TypeSpecificData []byte `ssh:"rest"`
|
TypeSpecificData []byte `ssh:"rest"`
|
||||||
@@ -193,7 +193,7 @@ type channelOpenConfirmMsg struct {
|
|||||||
const msgChannelOpenFailure = 92
|
const msgChannelOpenFailure = 92
|
||||||
|
|
||||||
type channelOpenFailureMsg struct {
|
type channelOpenFailureMsg struct {
|
||||||
PeersId uint32 `sshtype:"92"`
|
PeersID uint32 `sshtype:"92"`
|
||||||
Reason RejectionReason
|
Reason RejectionReason
|
||||||
Message string
|
Message string
|
||||||
Language string
|
Language string
|
||||||
@@ -202,7 +202,7 @@ type channelOpenFailureMsg struct {
|
|||||||
const msgChannelRequest = 98
|
const msgChannelRequest = 98
|
||||||
|
|
||||||
type channelRequestMsg struct {
|
type channelRequestMsg struct {
|
||||||
PeersId uint32 `sshtype:"98"`
|
PeersID uint32 `sshtype:"98"`
|
||||||
Request string
|
Request string
|
||||||
WantReply bool
|
WantReply bool
|
||||||
RequestSpecificData []byte `ssh:"rest"`
|
RequestSpecificData []byte `ssh:"rest"`
|
||||||
@@ -212,28 +212,28 @@ type channelRequestMsg struct {
|
|||||||
const msgChannelSuccess = 99
|
const msgChannelSuccess = 99
|
||||||
|
|
||||||
type channelRequestSuccessMsg struct {
|
type channelRequestSuccessMsg struct {
|
||||||
PeersId uint32 `sshtype:"99"`
|
PeersID uint32 `sshtype:"99"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// See RFC 4254, section 5.4.
|
// See RFC 4254, section 5.4.
|
||||||
const msgChannelFailure = 100
|
const msgChannelFailure = 100
|
||||||
|
|
||||||
type channelRequestFailureMsg struct {
|
type channelRequestFailureMsg struct {
|
||||||
PeersId uint32 `sshtype:"100"`
|
PeersID uint32 `sshtype:"100"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// See RFC 4254, section 5.3
|
// See RFC 4254, section 5.3
|
||||||
const msgChannelClose = 97
|
const msgChannelClose = 97
|
||||||
|
|
||||||
type channelCloseMsg struct {
|
type channelCloseMsg struct {
|
||||||
PeersId uint32 `sshtype:"97"`
|
PeersID uint32 `sshtype:"97"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// See RFC 4254, section 5.3
|
// See RFC 4254, section 5.3
|
||||||
const msgChannelEOF = 96
|
const msgChannelEOF = 96
|
||||||
|
|
||||||
type channelEOFMsg struct {
|
type channelEOFMsg struct {
|
||||||
PeersId uint32 `sshtype:"96"`
|
PeersID uint32 `sshtype:"96"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// See RFC 4254, section 4
|
// See RFC 4254, section 4
|
||||||
@@ -263,7 +263,7 @@ type globalRequestFailureMsg struct {
|
|||||||
const msgChannelWindowAdjust = 93
|
const msgChannelWindowAdjust = 93
|
||||||
|
|
||||||
type windowAdjustMsg struct {
|
type windowAdjustMsg struct {
|
||||||
PeersId uint32 `sshtype:"93"`
|
PeersID uint32 `sshtype:"93"`
|
||||||
AdditionalBytes uint32
|
AdditionalBytes uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -278,7 +278,7 @@ func (m *mux) handleChannelOpen(packet []byte) error {
|
|||||||
|
|
||||||
if msg.MaxPacketSize < minPacketLength || msg.MaxPacketSize > 1<<31 {
|
if msg.MaxPacketSize < minPacketLength || msg.MaxPacketSize > 1<<31 {
|
||||||
failMsg := channelOpenFailureMsg{
|
failMsg := channelOpenFailureMsg{
|
||||||
PeersId: msg.PeersId,
|
PeersID: msg.PeersID,
|
||||||
Reason: ConnectionFailed,
|
Reason: ConnectionFailed,
|
||||||
Message: "invalid request",
|
Message: "invalid request",
|
||||||
Language: "en_US.UTF-8",
|
Language: "en_US.UTF-8",
|
||||||
@@ -287,7 +287,7 @@ func (m *mux) handleChannelOpen(packet []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c := m.newChannel(msg.ChanType, channelInbound, msg.TypeSpecificData)
|
c := m.newChannel(msg.ChanType, channelInbound, msg.TypeSpecificData)
|
||||||
c.remoteId = msg.PeersId
|
c.remoteId = msg.PeersID
|
||||||
c.maxRemotePayload = msg.MaxPacketSize
|
c.maxRemotePayload = msg.MaxPacketSize
|
||||||
c.remoteWin.add(msg.PeersWindow)
|
c.remoteWin.add(msg.PeersWindow)
|
||||||
m.incomingChannels <- c
|
m.incomingChannels <- c
|
||||||
@@ -313,7 +313,7 @@ func (m *mux) openChannel(chanType string, extra []byte) (*channel, error) {
|
|||||||
PeersWindow: ch.myWindow,
|
PeersWindow: ch.myWindow,
|
||||||
MaxPacketSize: ch.maxIncomingPayload,
|
MaxPacketSize: ch.maxIncomingPayload,
|
||||||
TypeSpecificData: extra,
|
TypeSpecificData: extra,
|
||||||
PeersId: ch.localId,
|
PeersID: ch.localId,
|
||||||
}
|
}
|
||||||
if err := m.sendMessage(open); err != nil {
|
if err := m.sendMessage(open); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -617,7 +617,7 @@ func writeWithCRLF(w io.Writer, buf []byte) (n int, err error) {
|
|||||||
if _, err = w.Write(crlf); err != nil {
|
if _, err = w.Write(crlf); err != nil {
|
||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
n += 1
|
n++
|
||||||
buf = buf[1:]
|
buf = buf[1:]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -2,6 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// This package contains integration tests for the
|
// Package test contains integration tests for the
|
||||||
// golang.org/x/crypto/ssh package.
|
// golang.org/x/crypto/ssh package.
|
||||||
package test // import "golang.org/x/crypto/ssh/test"
|
package test // import "golang.org/x/crypto/ssh/test"
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import (
|
|||||||
"golang.org/x/crypto/ssh/testdata"
|
"golang.org/x/crypto/ssh/testdata"
|
||||||
)
|
)
|
||||||
|
|
||||||
const sshd_config = `
|
const sshdConfig = `
|
||||||
Protocol 2
|
Protocol 2
|
||||||
Banner {{.Dir}}/banner
|
Banner {{.Dir}}/banner
|
||||||
HostKey {{.Dir}}/id_rsa
|
HostKey {{.Dir}}/id_rsa
|
||||||
@@ -51,7 +51,7 @@ HostbasedAuthentication no
|
|||||||
PubkeyAcceptedKeyTypes=*
|
PubkeyAcceptedKeyTypes=*
|
||||||
`
|
`
|
||||||
|
|
||||||
var configTmpl = template.Must(template.New("").Parse(sshd_config))
|
var configTmpl = template.Must(template.New("").Parse(sshdConfig))
|
||||||
|
|
||||||
type server struct {
|
type server struct {
|
||||||
t *testing.T
|
t *testing.T
|
||||||
@@ -271,7 +271,7 @@ func newServer(t *testing.T) *server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var authkeys bytes.Buffer
|
var authkeys bytes.Buffer
|
||||||
for k, _ := range testdata.PEMBytes {
|
for k := range testdata.PEMBytes {
|
||||||
authkeys.Write(ssh.MarshalAuthorizedKey(testPublicKeys[k]))
|
authkeys.Write(ssh.MarshalAuthorizedKey(testPublicKeys[k]))
|
||||||
}
|
}
|
||||||
writeFile(filepath.Join(dir, "authorized_keys"), authkeys.Bytes())
|
writeFile(filepath.Join(dir, "authorized_keys"), authkeys.Bytes())
|
||||||
|
|||||||
+7
-7
@@ -76,17 +76,17 @@ type connectionState struct {
|
|||||||
// both directions are triggered by reading and writing a msgNewKey packet
|
// both directions are triggered by reading and writing a msgNewKey packet
|
||||||
// respectively.
|
// respectively.
|
||||||
func (t *transport) prepareKeyChange(algs *algorithms, kexResult *kexResult) error {
|
func (t *transport) prepareKeyChange(algs *algorithms, kexResult *kexResult) error {
|
||||||
if ciph, err := newPacketCipher(t.reader.dir, algs.r, kexResult); err != nil {
|
ciph, err := newPacketCipher(t.reader.dir, algs.r, kexResult)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
|
||||||
t.reader.pendingKeyChange <- ciph
|
|
||||||
}
|
}
|
||||||
|
t.reader.pendingKeyChange <- ciph
|
||||||
|
|
||||||
if ciph, err := newPacketCipher(t.writer.dir, algs.w, kexResult); err != nil {
|
ciph, err = newPacketCipher(t.writer.dir, algs.w, kexResult)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
|
||||||
t.writer.pendingKeyChange <- ciph
|
|
||||||
}
|
}
|
||||||
|
t.writer.pendingKeyChange <- ciph
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -139,7 +139,7 @@ func (s *connectionState) readPacket(r *bufio.Reader) ([]byte, error) {
|
|||||||
case cipher := <-s.pendingKeyChange:
|
case cipher := <-s.pendingKeyChange:
|
||||||
s.packetCipher = cipher
|
s.packetCipher = cipher
|
||||||
default:
|
default:
|
||||||
return nil, errors.New("ssh: got bogus newkeys message.")
|
return nil, errors.New("ssh: got bogus newkeys message")
|
||||||
}
|
}
|
||||||
|
|
||||||
case msgDisconnect:
|
case msgDisconnect:
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
// Package tea implements the TEA algorithm, as defined in Needham and
|
// Package tea implements the TEA algorithm, as defined in Needham and
|
||||||
// Wheeler's 1994 technical report, “TEA, a Tiny Encryption Algorithm”. See
|
// Wheeler's 1994 technical report, “TEA, a Tiny Encryption Algorithm”. See
|
||||||
// http://www.cix.co.uk/~klockstone/tea.pdf for details.
|
// http://www.cix.co.uk/~klockstone/tea.pdf for details.
|
||||||
|
|
||||||
package tea
|
package tea
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
+1
-1
@@ -69,7 +69,7 @@ func initCipher(c *Cipher, key []byte) {
|
|||||||
|
|
||||||
// Precalculate the table
|
// Precalculate the table
|
||||||
const delta = 0x9E3779B9
|
const delta = 0x9E3779B9
|
||||||
var sum uint32 = 0
|
var sum uint32
|
||||||
|
|
||||||
// Two rounds of XTEA applied per loop
|
// Two rounds of XTEA applied per loop
|
||||||
for i := 0; i < numRounds; {
|
for i := 0; i < numRounds; {
|
||||||
|
|||||||
Reference in New Issue
Block a user