File Coverage

blib/lib/Net/SSH/Perl/Constants.pm
Criterion Covered Total %
statement 27 27 100.0
branch 3 4 75.0
condition n/a
subroutine 7 7 100.0
pod n/a
total 37 38 97.3


line stmt bran cond sub pod time code
1             # $Id: Constants.pm,v 1.24 2008/10/02 20:46:17 turnstep Exp $
2              
3             package Net::SSH::Perl::Constants;
4 4     4   29 use strict;
  4         44  
  4         137  
5 4     4   28 use warnings;
  4         10  
  4         152  
6              
7 4     4   24 use vars qw( %CONSTANTS );
  4         46  
  4         1526  
8             %CONSTANTS = (
9             'PROTOCOL_MAJOR_1' => 1,
10             'PROTOCOL_MINOR_1' => 5,
11             'PROTOCOL_MAJOR_2' => 2,
12             'PROTOCOL_MINOR_2' => 0,
13             'PROTOCOL_SSH1_PREFERRED' => 4,
14             'PROTOCOL_SSH1' => 1,
15             'PROTOCOL_SSH2' => 2,
16              
17             'SSH_MSG_NONE' => 0,
18             'SSH_MSG_DISCONNECT' => 1,
19             'SSH_SMSG_PUBLIC_KEY' => 2,
20             'SSH_CMSG_SESSION_KEY' => 3,
21             'SSH_CMSG_USER' => 4,
22             'SSH_CMSG_AUTH_RHOSTS' => 5,
23             'SSH_CMSG_AUTH_RSA' => 6,
24             'SSH_SMSG_AUTH_RSA_CHALLENGE' => 7,
25             'SSH_CMSG_AUTH_RSA_RESPONSE' => 8,
26             'SSH_CMSG_AUTH_PASSWORD' => 9,
27             'SSH_CMSG_REQUEST_PTY' => 10,
28             'SSH_CMSG_EXEC_SHELL' => 12,
29             'SSH_CMSG_EXEC_CMD' => 13,
30             'SSH_SMSG_SUCCESS' => 14,
31             'SSH_SMSG_FAILURE' => 15,
32             'SSH_CMSG_STDIN_DATA' => 16,
33             'SSH_SMSG_STDOUT_DATA' => 17,
34             'SSH_SMSG_STDERR_DATA' => 18,
35             'SSH_CMSG_EOF' => 19,
36             'SSH_SMSG_EXITSTATUS' => 20,
37             'SSH_MSG_IGNORE' => 32,
38             'SSH_CMSG_EXIT_CONFIRMATION' => 33,
39             'SSH_CMSG_AUTH_RHOSTS_RSA' => 35,
40             'SSH_MSG_DEBUG' => 36,
41             'SSH_CMSG_REQUEST_COMPRESSION' => 37,
42             'SSH_CMSG_AUTH_TIS' => 39,
43             'SSH_SMSG_AUTH_TIS_CHALLENGE' => 40,
44             'SSH_CMSG_AUTH_TIS_RESPONSE' => 41,
45              
46             'SSH_COMPAT_BUG_SIGBLOB' => 0x01,
47             'SSH_COMPAT_BUG_PUBKEYAUTH' => 0x02,
48             'SSH_COMPAT_BUG_HMAC' => 0x04,
49             'SSH_COMPAT_BUG_X11FWD' => 0x08,
50             'SSH_COMPAT_OLD_SESSIONID' => 0x10,
51             'SSH_COMPAT_BUG_PKAUTH' => 0x20,
52             'SSH_COMPAT_BUG_RSASIGMD5' => 0x2000,
53              
54             'SSH2_MSG_DISCONNECT' => 1,
55             'SSH2_MSG_IGNORE' => 2,
56             'SSH2_MSG_UNIMPLEMENTED' => 3,
57             'SSH2_MSG_DEBUG' => 4,
58             'SSH2_MSG_SERVICE_REQUEST' => 5,
59             'SSH2_MSG_SERVICE_ACCEPT' => 6,
60             'SSH2_MSG_EXT_INFO' => 7,
61             'SSH2_MSG_KEXINIT' => 20,
62             'SSH2_MSG_NEWKEYS' => 21,
63             'SSH2_MSG_KEXDH_INIT' => 30,
64             'SSH2_MSG_KEXDH_REPLY' => 31,
65             'SSH2_MSG_KEX_DH_GEX_REQUEST_OLD' => 30,
66             'SSH2_MSG_KEX_DH_GEX_REQUEST' => 34,
67             'SSH2_MSG_KEX_DH_GEX_GROUP' => 31,
68             'SSH2_MSG_KEX_DH_GEX_INIT' => 32,
69             'SSH2_MSG_KEX_DH_GEX_REPLY' => 33,
70             'SSH2_MSG_KEX_ECDH_INIT' => 30,
71             'SSH2_MSG_KEX_ECDH_REPLY' => 31,
72             'SSH2_MSG_USERAUTH_REQUEST' => 50,
73             'SSH2_MSG_USERAUTH_FAILURE' => 51,
74             'SSH2_MSG_USERAUTH_SUCCESS' => 52,
75             'SSH2_MSG_USERAUTH_BANNER' => 53,
76             'SSH2_MSG_USERAUTH_PK_OK' => 60,
77             'SSH2_MSG_USERAUTH_INFO_REQUEST' => 60,
78             'SSH2_MSG_USERAUTH_INFO_RESPONSE' => 61,
79             'SSH2_MSG_GLOBAL_REQUEST' => 80,
80             'SSH2_MSG_REQUEST_SUCCESS' => 81,
81             'SSH2_MSG_REQUEST_FAILURE' => 82,
82             'SSH2_MSG_CHANNEL_OPEN' => 90,
83             'SSH2_MSG_CHANNEL_OPEN_CONFIRMATION' => 91,
84             'SSH2_MSG_CHANNEL_OPEN_FAILURE' => 92,
85             'SSH2_MSG_CHANNEL_WINDOW_ADJUST' => 93,
86             'SSH2_MSG_CHANNEL_DATA' => 94,
87             'SSH2_MSG_CHANNEL_EXTENDED_DATA' => 95,
88             'SSH2_MSG_CHANNEL_EOF' => 96,
89             'SSH2_MSG_CHANNEL_CLOSE' => 97,
90             'SSH2_MSG_CHANNEL_REQUEST' => 98,
91             'SSH2_MSG_CHANNEL_SUCCESS' => 99,
92             'SSH2_MSG_CHANNEL_FAILURE' => 100,
93              
94             'SSH_CHANNEL_OPENING' => 3,
95             'SSH_CHANNEL_OPEN' => 4,
96             'SSH_CHANNEL_INPUT_DRAINING' => 8,
97             'SSH_CHANNEL_OUTPUT_DRAINING' => 9,
98             'SSH_CHANNEL_LARVAL' => 10,
99              
100             'SSH_AGENTC_REQUEST_RSA_IDENTITIES' => 1,
101             'SSH_AGENT_RSA_IDENTITIES_ANSWER' => 2,
102             'SSH_AGENTC_RSA_CHALLENGE' => 3,
103             'SSH_AGENT_RSA_RESPONSE' => 4,
104             'SSH_AGENT_FAILURE' => 5,
105             'SSH_AGENT_SUCCESS' => 6,
106              
107             'SSH2_AGENTC_REQUEST_IDENTITIES' => 11,
108             'SSH2_AGENT_IDENTITIES_ANSWER' => 12,
109             'SSH2_AGENTC_SIGN_REQUEST' => 13,
110             'SSH2_AGENT_SIGN_RESPONSE' => 14,
111              
112             'SSH_COM_AGENT2_FAILURE' => 102,
113              
114             'CHAN_INPUT_OPEN' => 0x01,
115             'CHAN_INPUT_WAIT_DRAIN' => 0x02,
116             'CHAN_INPUT_WAIT_IEOF' => 0x04,
117             'CHAN_INPUT_CLOSED' => 0x08,
118             'CHAN_OUTPUT_OPEN' => 0x10,
119             'CHAN_OUTPUT_WAIT_DRAIN' => 0x20,
120             'CHAN_OUTPUT_WAIT_IEOF' => 0x40,
121             'CHAN_OUTPUT_CLOSED' => 0x80,
122             'CHAN_CLOSE_SENT' => 0x01,
123             'CHAN_CLOSE_RCVD' => 0x02,
124              
125             'KEX_DH1' => 'diffie-hellman-group1-sha1',
126             'KEX_DH14_SHA1' => 'diffie-hellman-group14-sha1',
127             'KEX_DH14_SHA256' => 'diffie-hellman-group14-sha256',
128             'KEX_DH16_SHA512' => 'diffie-hellman-group16-sha512',
129             'KEX_DH18_SHA512' => 'diffie-hellman-group18-sha512',
130             'KEX_DH_GEX_SHA256' => 'diffie-hellman-group-exchange-sha256',
131             'KEX_DH_GEX_SHA1' => 'diffie-hellman-group-exchange-sha1',
132             'KEX_CURVE25519_SHA256' => 'curve25519-sha256@libssh.org',
133             'KEX_CURVE25519_SHA256_ALIAS' => 'curve25519-sha256',
134             'KEX_DEFAULT_KEX' => 'curve25519-sha256@libssh.org,curve25519-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1',
135             'KEX_ALL_KEX' => 'diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,curve25519-sha256@libssh.org,curve25519-sha256',
136             'KEX_DEFAULT_PK_ALG' => 'ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,ssh-rsa',
137             'KEX_ALL_PK_ALG' => 'ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,ssh-rsa,ssh-dss',
138             'KEX_DEFAULT_ENCRYPT' => 'chacha20-poly1305@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr',
139             'KEX_ALL_ENCRYPT' => 'chacha20-poly1305@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-cbc,blowfish-cbc,arcfour',
140             'KEX_DEFAULT_MAC' => 'hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512,hmac-sha2-256',
141             'KEX_ALL_MAC' => 'hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-sha1,hmac-md5',
142             'KEX_DEFAULT_COMP' => 'none,zlib',
143             'KEX_DEFAULT_LANG' => '',
144              
145             'PROPOSAL_KEX_ALGS' => 0,
146             'PROPOSAL_SERVER_HOST_KEY_ALGS' => 1,
147             'PROPOSAL_CIPH_ALGS_CTOS' => 2,
148             'PROPOSAL_CIPH_ALGS_STOC' => 3,
149             'PROPOSAL_MAC_ALGS_CTOS' => 4,
150             'PROPOSAL_MAC_ALGS_STOC' => 5,
151             'PROPOSAL_COMP_ALGS_CTOS' => 6,
152             'PROPOSAL_COMP_ALGS_STOC' => 7,
153             'PROPOSAL_LANG_CTOS' => 8,
154             'PROPOSAL_LANG_STOC' => 9,
155              
156             'HOST_OK' => 1,
157             'HOST_NEW' => 2,
158             'HOST_CHANGED' => 3,
159              
160             'PRIVATE_KEY_ID_STRING' => "SSH PRIVATE KEY FILE FORMAT 1.1\n",
161              
162             'MAX_PACKET_SIZE' => 256000,
163             );
164              
165 4     4   32 use vars qw( %TAGS );
  4         8  
  4         692  
166             my %RULES = (
167             '^SSH_\w?MSG' => 'msg',
168             '^SSH2_\w?MSG' => 'msg2',
169             '^SSH2?_AGENT' => 'agent',
170             '^KEX' => 'kex',
171             '^PROTOCOL' => 'protocol',
172             '^HOST' => 'hosts',
173             '^PROPOSAL' => 'proposal',
174             '^SSH_CHANNEL|^CHAN' => 'channels',
175             '^SSH_COMPAT' => 'compat',
176             );
177              
178             for my $re (keys %RULES) {
179             @{ $TAGS{ $RULES{$re} } } = grep /$re/, keys %CONSTANTS;
180             }
181              
182             sub import {
183 16     16   56 my $class = shift;
184              
185 16         36 my @to_export;
186 16         65 my @args = @_;
187 16         47 for my $item (@args) {
188             push @to_export,
189 60 100       326 $item =~ s/^:// ? @{ $TAGS{$item} } : $item;
  28         447  
190             }
191              
192 4     4   28 no strict 'refs'; ## no critic
  4         15  
  4         656  
193 16         52 my $pkg = caller;
194 16         73 for my $con (@to_export) {
195             warn __PACKAGE__, " does not export the constant '$con'"
196 244 50       866 unless exists $CONSTANTS{$con};
197 244     100   1913 *{"${pkg}::$con"} = sub () { $CONSTANTS{$con} }
  100         491  
198 244         1198 }
199             }
200              
201             1;
202             __END__