line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# This code based in part on the Systemics Crypt::CFB. |
2
|
|
|
|
|
|
|
# Parts Copyright (C) 1995, 1996 Systemics Ltd (http://www.systemics.com/) |
3
|
|
|
|
|
|
|
# All rights reserved. |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Net::SSH::Perl::Cipher::CFB; |
6
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
27
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
314
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
6
|
|
|
6
|
0
|
19
|
my($class, $ciph, $iv) = @_; |
11
|
6
|
|
33
|
|
|
24
|
bless { |
12
|
|
|
|
|
|
|
cipher => $ciph, |
13
|
|
|
|
|
|
|
iv => $iv || ("\0" x $ciph->blocksize), |
14
|
|
|
|
|
|
|
}, $class; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub encrypt { |
18
|
3
|
|
|
3
|
0
|
6
|
my $cfb = shift; |
19
|
3
|
|
|
|
|
5
|
my $data = shift; |
20
|
|
|
|
|
|
|
|
21
|
3
|
|
|
|
|
5
|
my $retval = ""; |
22
|
3
|
|
|
|
|
8
|
my $iv = $cfb->{iv}; |
23
|
3
|
|
|
|
|
9
|
my $size = $cfb->{cipher}->blocksize; |
24
|
|
|
|
|
|
|
|
25
|
3
|
|
|
|
|
16
|
while (length $data) { |
26
|
3
|
|
|
|
|
11
|
my $out = $cfb->{cipher}->encrypt($iv); |
27
|
3
|
|
|
|
|
40
|
$iv = substr($data, 0, $size, '') ^ substr($out, 0, $size, ''); |
28
|
3
|
|
|
|
|
9
|
$retval .= $iv; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
3
|
|
|
|
|
6
|
$cfb->{iv} = $iv; |
32
|
3
|
|
|
|
|
7
|
$retval; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub decrypt { |
36
|
3
|
|
|
3
|
0
|
5
|
my $cfb = shift; |
37
|
3
|
|
|
|
|
5
|
my $data = shift; |
38
|
|
|
|
|
|
|
|
39
|
3
|
|
|
|
|
11
|
my $retval = ""; |
40
|
3
|
|
|
|
|
10
|
my $iv = $cfb->{iv}; |
41
|
3
|
|
|
|
|
8
|
my $size = $cfb->{cipher}->blocksize; |
42
|
|
|
|
|
|
|
|
43
|
3
|
|
|
|
|
14
|
while (length $data) { |
44
|
3
|
|
|
|
|
8
|
my $out = $cfb->{cipher}->encrypt($iv); |
45
|
3
|
|
|
|
|
31
|
$iv = substr($data, 0, $size, ''); |
46
|
3
|
|
|
|
|
13
|
$retval .= $iv ^ substr($out, 0, $size); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
3
|
|
|
|
|
9
|
$cfb->{iv} = $iv; |
50
|
3
|
|
|
|
|
7
|
$retval; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
__END__ |