line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Mode::OFB; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY! |
4
|
|
|
|
|
|
|
|
5
|
17
|
|
|
17
|
|
54886
|
use strict; |
|
17
|
|
|
|
|
40
|
|
|
17
|
|
|
|
|
384
|
|
6
|
17
|
|
|
17
|
|
69
|
use warnings; |
|
17
|
|
|
|
|
22
|
|
|
17
|
|
|
|
|
531
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.080'; |
8
|
|
|
|
|
|
|
|
9
|
17
|
|
|
17
|
|
424
|
use Crypt::Cipher; |
|
17
|
|
|
|
|
30
|
|
|
17
|
|
|
|
|
2127
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub encrypt { |
12
|
51
|
|
|
51
|
1
|
47157
|
my ($self, $pt) = (shift, shift); |
13
|
51
|
|
|
|
|
235
|
local $SIG{__DIE__} = \&CryptX::_croak; |
14
|
51
|
|
|
|
|
444
|
$self->start_encrypt(@_)->add($pt); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub decrypt { |
18
|
51
|
|
|
51
|
1
|
380
|
my ($self, $ct) = (shift, shift); |
19
|
51
|
|
|
|
|
130
|
local $SIG{__DIE__} = \&CryptX::_croak; |
20
|
51
|
|
|
|
|
275
|
$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::OFB - Block cipher mode OFB [Output feedback] |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SYNOPSIS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
use Crypt::Mode::OFB; |
36
|
|
|
|
|
|
|
my $m = Crypt::Mode::OFB->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 OFB 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::OFB->new($name); |
61
|
|
|
|
|
|
|
#or |
62
|
|
|
|
|
|
|
my $m = Crypt::Mode::OFB->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 |