File Coverage

blib/lib/Crypt/Eksblowfish.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             =head1 NAME
2              
3             Crypt::Eksblowfish - the Eksblowfish block cipher
4              
5             =head1 SYNOPSIS
6              
7             use Crypt::Eksblowfish;
8              
9             $block_size = Crypt::Eksblowfish->blocksize;
10              
11             $cipher = Crypt::Eksblowfish->new(8, $salt, $key);
12              
13             $block_size = $cipher->blocksize;
14             $ciphertext = $cipher->encrypt($plaintext);
15             $plaintext = $cipher->decrypt($ciphertext);
16              
17             $p_array = $cipher->p_array;
18             $s_boxes = $cipher->s_boxes;
19             if($cipher->is_weak) { ...
20              
21             =head1 DESCRIPTION
22              
23             An object of this type encapsulates a keyed instance of the Eksblowfish
24             block cipher, ready to encrypt and decrypt.
25              
26             Eksblowfish is a variant of the Blowfish cipher, modified to make
27             the key setup very expensive. ("Eks" stands for "expensive key
28             schedule".) This doesn't make it significantly cryptographically
29             stronger, but is intended to hinder brute-force attacks. It also
30             makes it unsuitable for any application requiring key agility. It was
31             designed by Niels Provos and David Mazieres for password hashing in
32             OpenBSD. See L for the hash algorithm.
33             See L for the unmodified Blowfish cipher.
34              
35             Eksblowfish is a parameterised (family-keyed) cipher. It takes a cost
36             parameter that controls how expensive the key scheduling is. It also
37             takes a family key, known as the "salt". Cost and salt parameters
38             together define a cipher family. Within each family, a key determines an
39             encryption function in the usual way. See L
40             for a way to encapsulate an Eksblowfish cipher family.
41              
42             =cut
43              
44             package Crypt::Eksblowfish;
45              
46 6     6   96434 { use 5.006; }
  6         22  
  6         257  
47 6     6   32 use warnings;
  6         10  
  6         190  
48 6     6   29 use strict;
  6         11  
  6         298  
49              
50             our $VERSION = "0.009";
51              
52 6     6   6524 use parent "Crypt::Eksblowfish::Subkeyed";
  6         2864  
  6         35  
53              
54             die "mismatched versions of Crypt::Eksblowfish modules"
55             unless $Crypt::Eksblowfish::Subkeyed::VERSION eq $VERSION;
56              
57             =head1 CLASS METHODS
58              
59             =over
60              
61             =item Crypt::Eksblowfish->blocksize
62              
63             Returns 8, indicating the Eksblowfish block size of 8 octets. This method
64             may be called on either the class or an instance.
65              
66             =back
67              
68             =head1 CONSTRUCTOR
69              
70             =over
71              
72             =item Crypt::Eksblowfish->new(COST, SALT, KEY)
73              
74             Performs key setup on a new instance of the Eksblowfish algorithm,
75             returning the keyed state. The KEY may be any length from 1 octet to
76             72 octets inclusive. The SALT is a family key, and must be exactly
77             16 octets. COST is an integer parameter controlling the expense of
78             keying: the number of operations in key setup is proportional to 2^COST.
79             All three parameters influence all the subkeys; changing any of them
80             produces a different encryption function.
81              
82             Due to the mandatory family-keying parameters (COST and SALT), this
83             constructor does not match the interface expected by C
84             and similar crypto plumbing modules. To
85             use Eksblowfish with them it is necessary to have an object that
86             encapsulates a cipher family and provides a constructor that takes only a
87             key argument. That facility is supplied by C.
88              
89             =back
90              
91             =head1 METHODS
92              
93             =over
94              
95             =item $cipher->blocksize
96              
97             Returns 8, indicating the Eksblowfish block size of 8 octets. This method
98             may be called on either the class or an instance.
99              
100             =item $cipher->encrypt(PLAINTEXT)
101              
102             PLAINTEXT must be exactly eight octets. The block is encrypted, and
103             the ciphertext is returned.
104              
105             =item $cipher->decrypt(CIPHERTEXT)
106              
107             CIPHERTEXT must be exactly eight octets. The block is decrypted, and
108             the plaintext is returned.
109              
110             =item $cipher->p_array
111              
112             =item $cipher->s_boxes
113              
114             These methods extract the subkeys from the keyed cipher.
115             This is not required in ordinary operation. See the superclass
116             L for details.
117              
118             =item $cipher->is_weak
119              
120             This method checks whether the cipher has been keyed with a weak key.
121             It may be desired to avoid using weak keys. See the superclass
122             L for details.
123              
124             =back
125              
126             =head1 SEE ALSO
127              
128             L,
129             L,
130             L,
131             L,
132             L
133              
134             =head1 AUTHOR
135              
136             Eksblowfish guts originally by Solar Designer (solar at openwall.com).
137              
138             Modifications and Perl interface by Andrew Main (Zefram)
139             .
140              
141             =head1 COPYRIGHT
142              
143             Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
144             Andrew Main (Zefram)
145              
146             The original Eksblowfish code (in the form of crypt()) from which
147             this module is derived is in the public domain. It may be found at
148             L.
149              
150             =head1 LICENSE
151              
152             This module is free software; you can redistribute it and/or modify it
153             under the same terms as Perl itself.
154              
155             =cut
156              
157             1;