Filename | /home/micha/.plenv/versions/5.38.2/lib/perl5/site_perl/5.38.2/x86_64-linux/Crypt/Mode/ECB.pm |
Statements | Executed 8 statements in 144µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 11µs | 27µs | BEGIN@6 | Crypt::Mode::ECB::
1 | 1 | 1 | 9µs | 11µs | BEGIN@5 | Crypt::Mode::ECB::
1 | 1 | 1 | 5µs | 6µs | BEGIN@9 | Crypt::Mode::ECB::
0 | 0 | 0 | 0s | 0s | CLONE_SKIP | Crypt::Mode::ECB::
0 | 0 | 0 | 0s | 0s | decrypt | Crypt::Mode::ECB::
0 | 0 | 0 | 0s | 0s | encrypt | Crypt::Mode::ECB::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Crypt::Mode::ECB; | ||||
2 | |||||
3 | ### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY! | ||||
4 | |||||
5 | 2 | 18µs | 2 | 12µs | # spent 11µs (9+2) within Crypt::Mode::ECB::BEGIN@5 which was called:
# once (9µs+2µs) by Spreadsheet::ParseXLSX::Decryptor::BEGIN@11 at line 5 # spent 11µs making 1 call to Crypt::Mode::ECB::BEGIN@5
# spent 2µs making 1 call to strict::import |
6 | 2 | 23µs | 2 | 43µs | # spent 27µs (11+16) within Crypt::Mode::ECB::BEGIN@6 which was called:
# once (11µs+16µs) by Spreadsheet::ParseXLSX::Decryptor::BEGIN@11 at line 6 # spent 27µs making 1 call to Crypt::Mode::ECB::BEGIN@6
# spent 16µs making 1 call to warnings::import |
7 | 1 | 400ns | our $VERSION = '0.080'; | ||
8 | |||||
9 | 2 | 100µs | 2 | 6µs | # spent 6µs (5+600ns) within Crypt::Mode::ECB::BEGIN@9 which was called:
# once (5µs+600ns) by Spreadsheet::ParseXLSX::Decryptor::BEGIN@11 at line 9 # spent 6µs making 1 call to Crypt::Mode::ECB::BEGIN@9
# spent 600ns making 1 call to UNIVERSAL::import |
10 | |||||
11 | sub encrypt { | ||||
12 | my ($self, $pt) = (shift, shift); | ||||
13 | local $SIG{__DIE__} = \&CryptX::_croak; | ||||
14 | $self->start_encrypt(@_)->add($pt) . $self->finish; | ||||
15 | } | ||||
16 | |||||
17 | sub decrypt { | ||||
18 | my ($self, $ct) = (shift, shift); | ||||
19 | local $SIG{__DIE__} = \&CryptX::_croak; | ||||
20 | $self->start_decrypt(@_)->add($ct) . $self->finish; | ||||
21 | } | ||||
22 | |||||
23 | sub CLONE_SKIP { 1 } # prevent cloning | ||||
24 | |||||
25 | 1 | 2µs | 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<NOTE:> it works only with ciphers from L<CryptX> (Crypt::Cipher::NNNN). | ||||
57 | B<BEWARE: ECB is inherently insecure>, if you are not sure go for L<Crypt::Mode::CBC>! | ||||
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 <NAME> for which there exists Crypt::Cipher::<NAME> | ||||
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<CryptX|CryptX>, L<Crypt::Cipher> | ||||
127 | |||||
128 | =item * L<Crypt::Cipher::AES>, L<Crypt::Cipher::Blowfish>, ... | ||||
129 | |||||
130 | =item * L<https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Electronic_codebook_.28ECB.29> | ||||
131 | |||||
132 | =back | ||||
133 | |||||
134 | =cut |