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