Filename | /usr/lib/x86_64-linux-gnu/perl5/5.20/Crypt/Eksblowfish.pm |
Statements | Executed 12 statements in 198µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 30µs | 30µs | bootstrap (xsub) | Crypt::Eksblowfish::
1 | 1 | 1 | 19µs | 19µs | BEGIN@46 | Crypt::Eksblowfish::
1 | 1 | 1 | 10µs | 18µs | BEGIN@47 | Crypt::Eksblowfish::
1 | 1 | 1 | 7µs | 1.50ms | BEGIN@52 | Crypt::Eksblowfish::
1 | 1 | 1 | 6µs | 17µs | BEGIN@48 | Crypt::Eksblowfish::
Line | State ments |
Time on line |
Calls | Time in subs |
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<Crypt::Eksblowfish::Bcrypt> for the hash algorithm. | ||||
33 | See L<Crypt::Eksblowfish::Blowfish> 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<Crypt::Eksblowfish::Family> | ||||
40 | for a way to encapsulate an Eksblowfish cipher family. | ||||
41 | |||||
42 | =cut | ||||
43 | |||||
44 | package Crypt::Eksblowfish; | ||||
45 | |||||
46 | 3 | 48µs | 1 | 19µs | # spent 19µs within Crypt::Eksblowfish::BEGIN@46 which was called:
# once (19µs+0s) by Crypt::Eksblowfish::Bcrypt::BEGIN@42 at line 46 # spent 19µs making 1 call to Crypt::Eksblowfish::BEGIN@46 |
47 | 2 | 23µs | 2 | 27µs | # spent 18µs (10+9) within Crypt::Eksblowfish::BEGIN@47 which was called:
# once (10µs+9µs) by Crypt::Eksblowfish::Bcrypt::BEGIN@42 at line 47 # spent 18µs making 1 call to Crypt::Eksblowfish::BEGIN@47
# spent 8µs making 1 call to warnings::import |
48 | 2 | 32µs | 2 | 28µs | # spent 17µs (6+11) within Crypt::Eksblowfish::BEGIN@48 which was called:
# once (6µs+11µs) by Crypt::Eksblowfish::Bcrypt::BEGIN@42 at line 48 # spent 17µs making 1 call to Crypt::Eksblowfish::BEGIN@48
# spent 11µs making 1 call to strict::import |
49 | |||||
50 | 1 | 400ns | our $VERSION = "0.009"; | ||
51 | |||||
52 | 2 | 91µs | 2 | 2.99ms | # spent 1.50ms (7µs+1.49) within Crypt::Eksblowfish::BEGIN@52 which was called:
# once (7µs+1.49ms) by Crypt::Eksblowfish::Bcrypt::BEGIN@42 at line 52 # spent 1.50ms making 1 call to Crypt::Eksblowfish::BEGIN@52
# spent 1.49ms making 1 call to parent::import |
53 | |||||
54 | 1 | 400ns | 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<Crypt::CBC> | ||||
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<Crypt::Eksblowfish::Family>. | ||||
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<Crypt::Eksblowfish::Subkeyed> 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<Crypt::Eksblowfish::Subkeyed> for details. | ||||
123 | |||||
124 | =back | ||||
125 | |||||
126 | =head1 SEE ALSO | ||||
127 | |||||
128 | L<Crypt::Eksblowfish::Bcrypt>, | ||||
129 | L<Crypt::Eksblowfish::Blowfish>, | ||||
130 | L<Crypt::Eksblowfish::Family>, | ||||
131 | L<Crypt::Eksblowfish::Subkeyed>, | ||||
132 | L<http://www.usenix.org/events/usenix99/provos/provos_html/node4.html> | ||||
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 | <zefram@fysh.org>. | ||||
140 | |||||
141 | =head1 COPYRIGHT | ||||
142 | |||||
143 | Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 | ||||
144 | Andrew Main (Zefram) <zefram@fysh.org> | ||||
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<http://www.openwall.com/crypt/>. | ||||
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 | 2µs | 1; | ||
# spent 30µs within Crypt::Eksblowfish::bootstrap which was called:
# once (30µs+0s) by DynaLoader::bootstrap at line 210 of DynaLoader.pm |