line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Ctr; |
2
|
1
|
|
|
1
|
|
4859
|
use Crypt::CFB; |
|
1
|
|
|
|
|
9062
|
|
|
1
|
|
|
|
|
81
|
|
3
|
1
|
|
|
1
|
|
13
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
949
|
|
4
|
|
|
|
|
|
|
@ISA = (Crypt::CFB); |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
$VERSION = 0.01; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub _statef; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# Crypt::Ctr implements the Counter Mode for block ciphers. |
12
|
|
|
|
|
|
|
# almost everything is inherited from Crypt::CFB, just the |
13
|
|
|
|
|
|
|
# _statef method is overloaded. |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# XXX the counter is just a perl int. So after roughly two Gigabytes |
16
|
|
|
|
|
|
|
# of cleartext, the keystream will repeat itself. |
17
|
|
|
|
|
|
|
# |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
1
|
|
|
1
|
1
|
1373822
|
my ($proto, $key, $algo) = @_; |
21
|
1
|
|
33
|
|
|
30
|
my $class = ref($proto) || $proto; |
22
|
1
|
|
|
|
|
66
|
my $self = new Crypt::CFB ($key, $algo); |
23
|
1
|
|
|
|
|
399
|
$self->{statef} = \&_statef; |
24
|
1
|
|
|
|
|
10
|
$self->{fill} = "\x0" x ($self->{registerlength} - 4); |
25
|
1
|
|
|
|
|
6
|
bless ($self, $class); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _statef { |
30
|
442
|
|
|
442
|
|
17119
|
my $self = shift; |
31
|
442
|
|
|
|
|
1286
|
my ($c, undef) = unpack "La*", $self->{register}; |
32
|
442
|
|
|
|
|
1022
|
$c++; |
33
|
442
|
|
|
|
|
12971
|
$self->{register} = unpack "a*" , (pack "La*", ($c, $self->{fill})); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
__END__ |