line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IO::Stream::Crypt::RC4; |
2
|
2
|
|
|
2
|
|
176582
|
use 5.010001; |
|
2
|
|
|
|
|
14
|
|
3
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
49
|
|
4
|
2
|
|
|
2
|
|
18
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
33
|
|
5
|
2
|
|
|
2
|
|
490
|
use utf8; |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
9
|
|
6
|
2
|
|
|
2
|
|
52
|
use Carp; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
134
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = 'v2.0.1'; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
399
|
use IO::Stream::const; |
|
2
|
|
|
|
|
6578
|
|
|
2
|
|
|
|
|
11
|
|
11
|
2
|
|
|
2
|
|
1045
|
use Crypt::RC4; |
|
2
|
|
|
|
|
1044
|
|
|
2
|
|
|
|
|
796
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
2
|
|
|
2
|
1
|
2041
|
my ($class, $passphrase) = @_; |
16
|
2
|
50
|
|
|
|
7
|
croak 'usage: IO::Stream::Crypt::RC4->new("passphrase")' |
17
|
|
|
|
|
|
|
if !defined $passphrase; |
18
|
2
|
|
|
|
|
10
|
my $self = bless { |
19
|
|
|
|
|
|
|
out_buf => q{}, # modified on: OUT |
20
|
|
|
|
|
|
|
out_pos => undef, # modified on: OUT |
21
|
|
|
|
|
|
|
out_bytes => 0, # modified on: OUT |
22
|
|
|
|
|
|
|
in_buf => q{}, # modified on: IN |
23
|
|
|
|
|
|
|
in_bytes => 0, # modified on: IN |
24
|
|
|
|
|
|
|
ip => undef, # modified on: RESOLVED |
25
|
|
|
|
|
|
|
is_eof => undef, # modified on: EOF |
26
|
|
|
|
|
|
|
_rcrypt => Crypt::RC4->new($passphrase), |
27
|
|
|
|
|
|
|
_wcrypt => Crypt::RC4->new($passphrase), |
28
|
|
|
|
|
|
|
}, $class; |
29
|
2
|
|
|
|
|
2232
|
return $self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub PREPARE { |
33
|
2
|
|
|
2
|
0
|
201
|
my ($self, $fh, $host, $port) = @_; |
34
|
2
|
|
|
|
|
8
|
$self->{_slave}->PREPARE($fh, $host, $port); |
35
|
2
|
|
|
|
|
22
|
return; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub WRITE { |
39
|
5
|
|
|
5
|
|
5218
|
my ($self) = @_; |
40
|
5
|
|
|
|
|
10
|
my $m = $self->{_master}; |
41
|
5
|
|
50
|
|
|
346
|
my $s = substr $m->{out_buf}, $m->{out_pos}||0; |
42
|
5
|
|
|
|
|
12
|
my $n = length $s; |
43
|
5
|
|
|
|
|
21
|
$self->{out_buf} .= $self->{_wcrypt}->RC4($s); |
44
|
5
|
50
|
|
|
|
2179567
|
if (defined $m->{out_pos}) { |
45
|
0
|
|
|
|
|
0
|
$m->{out_pos} += $n; |
46
|
|
|
|
|
|
|
} else { |
47
|
5
|
|
|
|
|
17
|
$m->{out_buf} = q{}; |
48
|
|
|
|
|
|
|
} |
49
|
5
|
|
|
|
|
13
|
$m->{out_bytes} += $n; |
50
|
5
|
|
|
|
|
34
|
$m->EVENT(OUT); |
51
|
5
|
|
|
|
|
97
|
$self->{_slave}->WRITE(); |
52
|
5
|
|
|
|
|
26
|
return; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub EVENT { |
56
|
158
|
|
|
158
|
0
|
11255
|
my ($self, $e, $err) = @_; |
57
|
158
|
|
|
|
|
243
|
my $m = $self->{_master}; |
58
|
158
|
100
|
|
|
|
390
|
if ($e & OUT) { |
59
|
77
|
|
|
|
|
118
|
$e &= ~OUT; |
60
|
77
|
50
|
66
|
|
|
366
|
return if !$e && !$err; |
61
|
|
|
|
|
|
|
} |
62
|
86
|
100
|
|
|
|
167
|
if ($e & IN) { |
63
|
77
|
|
|
|
|
304
|
$m->{in_buf} .= $self->{_rcrypt}->RC4($self->{in_buf}); |
64
|
77
|
|
|
|
|
2238284
|
$m->{in_bytes} += $self->{in_bytes}; |
65
|
77
|
|
|
|
|
201
|
$self->{in_buf} = q{}; |
66
|
77
|
|
|
|
|
138
|
$self->{in_bytes}= 0; |
67
|
|
|
|
|
|
|
} |
68
|
86
|
100
|
|
|
|
232
|
if ($e & RESOLVED) { |
69
|
1
|
|
|
|
|
2
|
$m->{ip} = $self->{ip}; |
70
|
|
|
|
|
|
|
} |
71
|
86
|
100
|
|
|
|
211
|
if ($e & EOF) { |
72
|
2
|
|
|
|
|
7
|
$m->{is_eof} = $self->{is_eof}; |
73
|
|
|
|
|
|
|
} |
74
|
86
|
|
|
|
|
399
|
$m->EVENT($e, $err); |
75
|
85
|
|
|
|
|
3952
|
return; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
80
|
|
|
|
|
|
|
__END__ |