line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Mode::ECB; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY! |
4
|
|
|
|
|
|
|
|
5
|
17
|
|
|
17
|
|
71590
|
use strict; |
|
17
|
|
|
|
|
40
|
|
|
17
|
|
|
|
|
517
|
|
6
|
17
|
|
|
17
|
|
81
|
use warnings; |
|
17
|
|
|
|
|
32
|
|
|
17
|
|
|
|
|
829
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.079_007'; |
8
|
|
|
|
|
|
|
|
9
|
17
|
|
|
17
|
|
542
|
use Crypt::Cipher; |
|
17
|
|
|
|
|
44
|
|
|
17
|
|
|
|
|
3000
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub encrypt { |
12
|
65
|
|
|
65
|
1
|
78779
|
my ($self, $pt) = (shift, shift); |
13
|
65
|
|
|
|
|
305
|
local $SIG{__DIE__} = \&CryptX::_croak; |
14
|
65
|
|
|
|
|
1288
|
$self->start_encrypt(@_)->add($pt) . $self->finish; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub decrypt { |
18
|
65
|
|
|
65
|
1
|
611
|
my ($self, $ct) = (shift, shift); |
19
|
65
|
|
|
|
|
184
|
local $SIG{__DIE__} = \&CryptX::_croak; |
20
|
65
|
|
|
|
|
603
|
$self->start_decrypt(@_)->add($ct) . $self->finish; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
0
|
|
|
sub CLONE_SKIP { 1 } # prevent cloning |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
1; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=pod |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 NAME |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Crypt::Mode::ECB - Block cipher mode ECB [Electronic codebook] |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SYNOPSIS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
use Crypt::Mode::ECB; |
36
|
|
|
|
|
|
|
my $m = Crypt::Mode::ECB->new('AES'); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
#(en|de)crypt at once |
39
|
|
|
|
|
|
|
my $ciphertext = $m->encrypt($plaintext, $key); |
40
|
|
|
|
|
|
|
my $plaintext = $m->decrypt($ciphertext, $key); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
#encrypt more chunks |
43
|
|
|
|
|
|
|
$m->start_encrypt($key); |
44
|
|
|
|
|
|
|
my $ciphertext = $m->add('some data'); |
45
|
|
|
|
|
|
|
$ciphertext .= $m->add('more data'); |
46
|
|
|
|
|
|
|
$ciphertext .= $m->finish; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
#decrypt more chunks |
49
|
|
|
|
|
|
|
$m->start_decrypt($key); |
50
|
|
|
|
|
|
|
my $plaintext = $m->add($some_ciphertext); |
51
|
|
|
|
|
|
|
$plaintext .= $m->add($more_ciphertext); |
52
|
|
|
|
|
|
|
$plaintext .= $m->finish; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 DESCRIPTION |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
This module implements ECB cipher mode. B it works only with ciphers from L (Crypt::Cipher::NNNN). |
57
|
|
|
|
|
|
|
B, if you are not sure go for L! |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 METHODS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 new |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my $m = Crypt::Mode::ECB->new($name); |
64
|
|
|
|
|
|
|
#or |
65
|
|
|
|
|
|
|
my $m = Crypt::Mode::ECB->new($name, $padding); |
66
|
|
|
|
|
|
|
#or |
67
|
|
|
|
|
|
|
my $m = Crypt::Mode::ECB->new($name, $padding, $cipher_rounds); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# $name ....... one of 'AES', 'Anubis', 'Blowfish', 'CAST5', 'Camellia', 'DES', 'DES_EDE', |
70
|
|
|
|
|
|
|
# 'KASUMI', 'Khazad', 'MULTI2', 'Noekeon', 'RC2', 'RC5', 'RC6', |
71
|
|
|
|
|
|
|
# 'SAFERP', 'SAFER_K128', 'SAFER_K64', 'SAFER_SK128', 'SAFER_SK64', |
72
|
|
|
|
|
|
|
# 'SEED', 'Skipjack', 'Twofish', 'XTEA', 'IDEA', 'Serpent' |
73
|
|
|
|
|
|
|
# simply any for which there exists Crypt::Cipher:: |
74
|
|
|
|
|
|
|
# $padding .... 0 no padding (plaintext size has to be multiple of block length) |
75
|
|
|
|
|
|
|
# 1 PKCS5 padding, Crypt::CBC's "standard" - DEFAULT |
76
|
|
|
|
|
|
|
# 2 Crypt::CBC's "oneandzeroes" |
77
|
|
|
|
|
|
|
# 3 ANSI X.923 padding |
78
|
|
|
|
|
|
|
# 4 zero padding |
79
|
|
|
|
|
|
|
# 5 zero padding (+a block of zeros if the output length is divisible by the blocksize) |
80
|
|
|
|
|
|
|
# $cipher_rounds ... optional num of rounds for given cipher |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 encrypt |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my $ciphertext = $m->encrypt($plaintext, $key); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 decrypt |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my $plaintext = $m->decrypt($ciphertext, $key); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 start_encrypt |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
$m->start_encrypt($key); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 start_decrypt |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
$m->start_decrypt($key); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 add |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# in encrypt mode |
101
|
|
|
|
|
|
|
my $plaintext = $m->add($ciphertext); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# in decrypt mode |
104
|
|
|
|
|
|
|
my $ciphertext = $m->add($plaintext); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 finish |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
#encrypt more chunks |
109
|
|
|
|
|
|
|
$m->start_encrypt($key); |
110
|
|
|
|
|
|
|
my $ciphertext = ''; |
111
|
|
|
|
|
|
|
$ciphertext .= $m->add('some data'); |
112
|
|
|
|
|
|
|
$ciphertext .= $m->add('more data'); |
113
|
|
|
|
|
|
|
$ciphertext .= $m->finish; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
#decrypt more chunks |
116
|
|
|
|
|
|
|
$m->start_decrypt($key); |
117
|
|
|
|
|
|
|
my $plaintext = ''; |
118
|
|
|
|
|
|
|
$plaintext .= $m->add($some_ciphertext); |
119
|
|
|
|
|
|
|
$plaintext .= $m->add($more_ciphertext); |
120
|
|
|
|
|
|
|
$plaintext .= $m->finish; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 SEE ALSO |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=over |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item * L, L |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item * L, L, ... |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item * L |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=back |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |