line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Mode::CFB; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY! |
4
|
|
|
|
|
|
|
|
5
|
17
|
|
|
17
|
|
68831
|
use strict; |
|
17
|
|
|
|
|
38
|
|
|
17
|
|
|
|
|
473
|
|
6
|
17
|
|
|
17
|
|
83
|
use warnings; |
|
17
|
|
|
|
|
30
|
|
|
17
|
|
|
|
|
696
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.080_001'; |
8
|
|
|
|
|
|
|
|
9
|
17
|
|
|
17
|
|
513
|
use Crypt::Cipher; |
|
17
|
|
|
|
|
42
|
|
|
17
|
|
|
|
|
2788
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub encrypt { |
12
|
51
|
|
|
51
|
1
|
57420
|
my ($self, $pt) = (shift, shift); |
13
|
51
|
|
|
|
|
247
|
local $SIG{__DIE__} = \&CryptX::_croak; |
14
|
51
|
|
|
|
|
515
|
$self->start_encrypt(@_)->add($pt); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub decrypt { |
18
|
51
|
|
|
51
|
1
|
429
|
my ($self, $ct) = (shift, shift); |
19
|
51
|
|
|
|
|
146
|
local $SIG{__DIE__} = \&CryptX::_croak; |
20
|
51
|
|
|
|
|
338
|
$self->start_decrypt(@_)->add($ct); |
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::CFB - Block cipher mode CFB [Cipher feedback] |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SYNOPSIS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
use Crypt::Mode::CFB; |
36
|
|
|
|
|
|
|
my $m = Crypt::Mode::CFB->new('AES'); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
#(en|de)crypt at once |
39
|
|
|
|
|
|
|
my $ciphertext = $m->encrypt($plaintext, $key, $iv); |
40
|
|
|
|
|
|
|
my $plaintext = $m->decrypt($ciphertext, $key, $iv); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
#encrypt more chunks |
43
|
|
|
|
|
|
|
$m->start_encrypt($key, $iv); |
44
|
|
|
|
|
|
|
my $ciphertext = $m->add('some data'); |
45
|
|
|
|
|
|
|
$ciphertext .= $m->add('more data'); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
#decrypt more chunks |
48
|
|
|
|
|
|
|
$m->start_decrypt($key, $iv); |
49
|
|
|
|
|
|
|
my $plaintext = $m->add($some_ciphertext); |
50
|
|
|
|
|
|
|
$plaintext .= $m->add($more_ciphertext); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 DESCRIPTION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This module implements CFB cipher mode. B it works only with ciphers from L (Crypt::Cipher::NNNN). |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 METHODS |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 new |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $m = Crypt::Mode::CFB->new($name); |
61
|
|
|
|
|
|
|
#or |
62
|
|
|
|
|
|
|
my $m = Crypt::Mode::CFB->new($name, $cipher_rounds); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# $name ............ one of 'AES', 'Anubis', 'Blowfish', 'CAST5', 'Camellia', 'DES', 'DES_EDE', |
65
|
|
|
|
|
|
|
# 'KASUMI', 'Khazad', 'MULTI2', 'Noekeon', 'RC2', 'RC5', 'RC6', |
66
|
|
|
|
|
|
|
# 'SAFERP', 'SAFER_K128', 'SAFER_K64', 'SAFER_SK128', 'SAFER_SK64', |
67
|
|
|
|
|
|
|
# 'SEED', 'Skipjack', 'Twofish', 'XTEA', 'IDEA', 'Serpent' |
68
|
|
|
|
|
|
|
# simply any for which there exists Crypt::Cipher:: |
69
|
|
|
|
|
|
|
# $cipher_rounds ... optional num of rounds for given cipher |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 encrypt |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $ciphertext = $m->encrypt($plaintext, $key, $iv); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 decrypt |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $plaintext = $m->decrypt($ciphertext, $key, $iv); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 start_encrypt |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
$m->start_encrypt($key, $iv); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 start_decrypt |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$m->start_decrypt($key, $iv); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 add |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# in encrypt mode |
90
|
|
|
|
|
|
|
my $plaintext = $m->add($ciphertext); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# in decrypt mode |
93
|
|
|
|
|
|
|
my $ciphertext = $m->add($plaintext); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 SEE ALSO |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=over |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item * L, L |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item * L, L, ... |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item * L |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=back |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |