| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Crypt::Cipher::Blowfish; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY! |
|
4
|
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
1634
|
use strict; |
|
|
3
|
|
|
|
|
13
|
|
|
|
3
|
|
|
|
|
107
|
|
|
6
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
201
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.089'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
17
|
use base qw(Crypt::Cipher); |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
954
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
|
12
|
11
|
|
|
11
|
1
|
36
|
my ($class, @args) = @_; |
|
13
|
11
|
|
|
|
|
688
|
my $obj = Crypt::Cipher->new('Blowfish', @args); |
|
14
|
11
|
|
|
|
|
88
|
return bless $obj, $class; |
|
15
|
|
|
|
|
|
|
} |
|
16
|
|
|
|
|
|
|
|
|
17
|
3
|
|
|
3
|
1
|
136018
|
sub blocksize { Crypt::Cipher::blocksize('Blowfish') } |
|
18
|
3
|
|
|
3
|
1
|
9
|
sub keysize { Crypt::Cipher::keysize('Blowfish') } |
|
19
|
3
|
|
|
3
|
1
|
24
|
sub max_keysize { Crypt::Cipher::max_keysize('Blowfish') } |
|
20
|
4
|
|
|
4
|
1
|
301
|
sub min_keysize { Crypt::Cipher::min_keysize('Blowfish') } |
|
21
|
3
|
|
|
3
|
1
|
34
|
sub default_rounds { Crypt::Cipher::default_rounds('Blowfish') } |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
1; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=pod |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 NAME |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Crypt::Cipher::Blowfish - Symmetric cipher Blowfish, key size: 64-576 bits |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
### example 1 |
|
34
|
|
|
|
|
|
|
use Crypt::Mode::CBC; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $key = '...'; # length must be a valid key size for this cipher |
|
37
|
|
|
|
|
|
|
my $iv = '...'; # 16 bytes |
|
38
|
|
|
|
|
|
|
my $cbc = Crypt::Mode::CBC->new('Blowfish'); |
|
39
|
|
|
|
|
|
|
my $ciphertext = $cbc->encrypt("secret data", $key, $iv); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
### example 2 (slower) |
|
42
|
|
|
|
|
|
|
use Crypt::CBC; |
|
43
|
|
|
|
|
|
|
use Crypt::Cipher::Blowfish; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $key = '...'; # length must be a valid key size for this cipher |
|
46
|
|
|
|
|
|
|
my $iv = '...'; # 16 bytes |
|
47
|
|
|
|
|
|
|
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::Blowfish', -key=>$key, -iv=>$iv ); |
|
48
|
|
|
|
|
|
|
my $ciphertext = $cbc->encrypt("secret data"); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
This module implements the Blowfish cipher. Its interface is compatible with L. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
B This module only implements single-block encryption and decryption. |
|
55
|
|
|
|
|
|
|
For general data, use a block mode such as |
|
56
|
|
|
|
|
|
|
L, L, or L (which is slower). |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 METHODS |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Unless noted otherwise, assume C<$c> is an existing cipher object created via |
|
61
|
|
|
|
|
|
|
C, for example: |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my $c = Crypt::Cipher::Blowfish->new($key); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 new |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $c = Crypt::Cipher::Blowfish->new($key); |
|
68
|
|
|
|
|
|
|
#or |
|
69
|
|
|
|
|
|
|
my $c = Crypt::Cipher::Blowfish->new($key, $rounds); |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# $key .... [binary string] key of an accepted length (see keysize, min_keysize, max_keysize) |
|
72
|
|
|
|
|
|
|
# $rounds . [integer] optional, number of rounds (if supported by the cipher; croaks on invalid value) |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 encrypt |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Encrypts exactly one block of plaintext. The length of C<$plaintext> must |
|
77
|
|
|
|
|
|
|
equal L; croaks otherwise. An empty string is accepted and |
|
78
|
|
|
|
|
|
|
returned unchanged. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $ciphertext = $c->encrypt($plaintext); |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Returns the encrypted block as a binary string (raw bytes). |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 decrypt |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Decrypts exactly one block of ciphertext. The length of C<$ciphertext> must |
|
87
|
|
|
|
|
|
|
equal L; croaks otherwise. An empty string is accepted and |
|
88
|
|
|
|
|
|
|
returned unchanged. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $plaintext = $c->decrypt($ciphertext); |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Returns the decrypted block as a binary string (raw bytes). |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 keysize |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Just an alias for C. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
$c->keysize; |
|
99
|
|
|
|
|
|
|
#or |
|
100
|
|
|
|
|
|
|
Crypt::Cipher::Blowfish->keysize; |
|
101
|
|
|
|
|
|
|
#or |
|
102
|
|
|
|
|
|
|
Crypt::Cipher::Blowfish::keysize; |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 blocksize |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Returns the cipher block size (in bytes). |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
$c->blocksize; |
|
109
|
|
|
|
|
|
|
#or |
|
110
|
|
|
|
|
|
|
Crypt::Cipher::Blowfish->blocksize; |
|
111
|
|
|
|
|
|
|
#or |
|
112
|
|
|
|
|
|
|
Crypt::Cipher::Blowfish::blocksize; |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 max_keysize |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Returns the maximum key size (in bytes). |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
$c->max_keysize; |
|
119
|
|
|
|
|
|
|
#or |
|
120
|
|
|
|
|
|
|
Crypt::Cipher::Blowfish->max_keysize; |
|
121
|
|
|
|
|
|
|
#or |
|
122
|
|
|
|
|
|
|
Crypt::Cipher::Blowfish::max_keysize; |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 min_keysize |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Returns the minimum key size (in bytes). |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
$c->min_keysize; |
|
129
|
|
|
|
|
|
|
#or |
|
130
|
|
|
|
|
|
|
Crypt::Cipher::Blowfish->min_keysize; |
|
131
|
|
|
|
|
|
|
#or |
|
132
|
|
|
|
|
|
|
Crypt::Cipher::Blowfish::min_keysize; |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 default_rounds |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Returns the cipher's default round count. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
$c->default_rounds; |
|
139
|
|
|
|
|
|
|
#or |
|
140
|
|
|
|
|
|
|
Crypt::Cipher::Blowfish->default_rounds; |
|
141
|
|
|
|
|
|
|
#or |
|
142
|
|
|
|
|
|
|
Crypt::Cipher::Blowfish::default_rounds; |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=over |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item * L, L |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item * L |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=back |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |