OLD | NEW |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package ssh | 5 package ssh |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "encoding/binary" | 9 "encoding/binary" |
10 "io" | 10 "io" |
11 "math/big" | 11 "math/big" |
12 "reflect" | 12 "reflect" |
13 ) | 13 ) |
14 | 14 |
15 // These are SSH message type numbers. They are scattered around several | 15 // These are SSH message type numbers. They are scattered around several |
16 // documents but many were taken from [SSH-PARAMETERS]. | 16 // documents but many were taken from [SSH-PARAMETERS]. |
17 const ( | 17 const ( |
18 msgDisconnect = 1 | 18 msgDisconnect = 1 |
19 msgIgnore = 2 | 19 msgIgnore = 2 |
20 msgUnimplemented = 3 | 20 msgUnimplemented = 3 |
21 msgDebug = 4 | 21 msgDebug = 4 |
22 msgServiceRequest = 5 | 22 msgServiceRequest = 5 |
23 msgServiceAccept = 6 | 23 msgServiceAccept = 6 |
24 | 24 |
25 msgKexInit = 20 | 25 msgKexInit = 20 |
26 msgNewKeys = 21 | 26 msgNewKeys = 21 |
27 | 27 |
| 28 // Diffie-Helman |
28 msgKexDHInit = 30 | 29 msgKexDHInit = 30 |
29 msgKexDHReply = 31 | 30 msgKexDHReply = 31 |
30 | 31 |
| 32 // Standard authentication messages |
31 msgUserAuthRequest = 50 | 33 msgUserAuthRequest = 50 |
32 msgUserAuthFailure = 51 | 34 msgUserAuthFailure = 51 |
33 msgUserAuthSuccess = 52 | 35 msgUserAuthSuccess = 52 |
34 msgUserAuthBanner = 53 | 36 msgUserAuthBanner = 53 |
35 msgUserAuthPubKeyOk = 60 | 37 msgUserAuthPubKeyOk = 60 |
36 | 38 |
| 39 // Method specific messages |
| 40 msgUserAuthInfoRequest = 60 |
| 41 msgUserAuthInfoResponse = 61 |
| 42 |
37 msgGlobalRequest = 80 | 43 msgGlobalRequest = 80 |
38 msgRequestSuccess = 81 | 44 msgRequestSuccess = 81 |
39 msgRequestFailure = 82 | 45 msgRequestFailure = 82 |
40 | 46 |
| 47 // Channel manipulation |
41 msgChannelOpen = 90 | 48 msgChannelOpen = 90 |
42 msgChannelOpenConfirm = 91 | 49 msgChannelOpenConfirm = 91 |
43 msgChannelOpenFailure = 92 | 50 msgChannelOpenFailure = 92 |
44 msgChannelWindowAdjust = 93 | 51 msgChannelWindowAdjust = 93 |
45 msgChannelData = 94 | 52 msgChannelData = 94 |
46 msgChannelExtendedData = 95 | 53 msgChannelExtendedData = 95 |
47 msgChannelEOF = 96 | 54 msgChannelEOF = 96 |
48 msgChannelClose = 97 | 55 msgChannelClose = 97 |
49 msgChannelRequest = 98 | 56 msgChannelRequest = 98 |
50 msgChannelSuccess = 99 | 57 msgChannelSuccess = 99 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 Method string | 117 Method string |
111 Payload []byte `ssh:"rest"` | 118 Payload []byte `ssh:"rest"` |
112 } | 119 } |
113 | 120 |
114 // See RFC 4252, section 5.1 | 121 // See RFC 4252, section 5.1 |
115 type userAuthFailureMsg struct { | 122 type userAuthFailureMsg struct { |
116 Methods []string | 123 Methods []string |
117 PartialSuccess bool | 124 PartialSuccess bool |
118 } | 125 } |
119 | 126 |
| 127 // See RFC 4256, section 3.2 |
| 128 type userAuthInfoRequestMsg struct { |
| 129 User string |
| 130 Instruction string |
| 131 DeprecatedLanguage string |
| 132 NumPrompts uint32 |
| 133 Prompts []byte `ssh:"rest"` |
| 134 } |
| 135 |
120 // See RFC 4254, section 5.1. | 136 // See RFC 4254, section 5.1. |
121 type channelOpenMsg struct { | 137 type channelOpenMsg struct { |
122 ChanType string | 138 ChanType string |
123 PeersId uint32 | 139 PeersId uint32 |
124 PeersWindow uint32 | 140 PeersWindow uint32 |
125 MaxPacketSize uint32 | 141 MaxPacketSize uint32 |
126 TypeSpecificData []byte `ssh:"rest"` | 142 TypeSpecificData []byte `ssh:"rest"` |
127 } | 143 } |
128 | 144 |
129 // See RFC 4254, section 5.1. | 145 // See RFC 4254, section 5.1. |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 case msgChannelFailure: | 631 case msgChannelFailure: |
616 msg = new(channelRequestFailureMsg) | 632 msg = new(channelRequestFailureMsg) |
617 default: | 633 default: |
618 return nil, UnexpectedMessageError{0, packet[0]} | 634 return nil, UnexpectedMessageError{0, packet[0]} |
619 } | 635 } |
620 if err := unmarshal(msg, packet, packet[0]); err != nil { | 636 if err := unmarshal(msg, packet, packet[0]); err != nil { |
621 return nil, err | 637 return nil, err |
622 } | 638 } |
623 return msg, nil | 639 return msg, nil |
624 } | 640 } |
OLD | NEW |