← Index
NYTProf Performance Profile   « line view »
For t/bug-md-11.t
  Run on Fri Mar 8 13:27:24 2024
Reported on Fri Mar 8 13:30:23 2024

Filename/home/micha/.plenv/versions/5.38.2/lib/perl5/site_perl/5.38.2/x86_64-linux/Crypt/Cipher.pm
StatementsExecuted 11 statements in 169µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111235µs9.43msCrypt::Cipher::::BEGIN@9Crypt::Cipher::BEGIN@9
1118µs9µsCrypt::Cipher::::BEGIN@3Crypt::Cipher::BEGIN@3
1115µs25µsCrypt::Cipher::::BEGIN@7Crypt::Cipher::BEGIN@7
1113µs16µsCrypt::Cipher::::BEGIN@4Crypt::Cipher::BEGIN@4
0000s0sCrypt::Cipher::::CLONE_SKIPCrypt::Cipher::CLONE_SKIP
0000s0sCrypt::Cipher::::keysizeCrypt::Cipher::keysize
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Crypt::Cipher;
2
3215µs210µs
# spent 9µs (8+1) within Crypt::Cipher::BEGIN@3 which was called: # once (8µs+1µs) by Crypt::Mode::CBC::BEGIN@9 at line 3
use strict;
# spent 9µs making 1 call to Crypt::Cipher::BEGIN@3 # spent 1µs making 1 call to strict::import
4218µs230µs
# spent 16µs (3+13) within Crypt::Cipher::BEGIN@4 which was called: # once (3µs+13µs) by Crypt::Mode::CBC::BEGIN@9 at line 4
use warnings;
# spent 16µs making 1 call to Crypt::Cipher::BEGIN@4 # spent 13µs making 1 call to warnings::import
51400nsour $VERSION = '0.080';
6
7219µs245µs
# spent 25µs (5+20) within Crypt::Cipher::BEGIN@7 which was called: # once (5µs+20µs) by Crypt::Mode::CBC::BEGIN@9 at line 7
use Carp;
# spent 25µs making 1 call to Crypt::Cipher::BEGIN@7 # spent 20µs making 1 call to Exporter::import
81500ns$Carp::Internal{(__PACKAGE__)}++;
92114µs29.43ms
# spent 9.43ms (235µs+9.20) within Crypt::Cipher::BEGIN@9 which was called: # once (235µs+9.20ms) by Crypt::Mode::CBC::BEGIN@9 at line 9
use CryptX;
# spent 9.43ms making 1 call to Crypt::Cipher::BEGIN@9 # spent 1µs making 1 call to UNIVERSAL::import
10
11### the following methods/functions are implemented in XS:
12# - new
13# - DESTROY
14# - blocksize
15# - decrypt
16# - default_rounds
17# - encrypt
18# - max_keysize
19# - min_keysize
20
21sub keysize { goto \&max_keysize; } # for Crypt::CBC compatibility
22
23sub CLONE_SKIP { 1 } # prevent cloning
24
2512µs1;
26
27=pod
28
29=head1 NAME
30
31Crypt::Cipher - Generic interface to cipher functions
32
33=head1 SYNOPSIS
34
35 #### example 1 (encrypting single block)
36 use Crypt::Cipher;
37
38 my $key = '...'; # length has to be valid key size for this cipher
39 my $c = Crypt::Cipher->new('AES', $key);
40 my $blocksize = $c->blocksize;
41 my $ciphertext = $c->encrypt('plain text block'); #encrypt 1 block
42 my $plaintext = $c->decrypt($ciphertext); #decrypt 1 block
43
44 ### example 2 (using CBC mode)
45 use Crypt::Mode::CBC;
46
47 my $key = '...'; # length has to be valid key size for this cipher
48 my $iv = '...'; # 16 bytes
49 my $cbc = Crypt::Mode::CBC->new('AES');
50 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
51
52 #### example 3 (compatibility with Crypt::CBC)
53 use Crypt::CBC;
54 use Crypt::Cipher;
55
56 my $key = '...'; # length has to be valid key size for this cipher
57 my $iv = '...'; # 16 bytes
58 my $cipher = Crypt::Cipher('AES', $key);
59 my $cbc = Crypt::CBC->new( -cipher=>$cipher, -iv=>$iv );
60 my $ciphertext = $cbc->encrypt("secret data");
61
62=head1 DESCRIPTION
63
64Provides an interface to various symmetric cipher algorithms.
65
66B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
67encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
68L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
69
70=head1 METHODS
71
72=head2 new
73
74Constructor, returns a reference to the cipher object.
75
76 ## basic scenario
77 $d = Crypt::Cipher->new($name, $key);
78 # $name = one of 'AES', 'Anubis', 'Blowfish', 'CAST5', 'Camellia', 'DES', 'DES_EDE',
79 # 'KASUMI', 'Khazad', 'MULTI2', 'Noekeon', 'RC2', 'RC5', 'RC6',
80 # 'SAFERP', 'SAFER_K128', 'SAFER_K64', 'SAFER_SK128', 'SAFER_SK64',
81 # 'SEED', 'Skipjack', 'Twofish', 'XTEA', 'IDEA', 'Serpent'
82 # simply any <NAME> for which there exists Crypt::Cipher::<NAME>
83 # $key = binary key (keysize should comply with selected cipher requirements)
84
85 ## some of the ciphers (e.g. MULTI2, RC5, SAFER) allow one to set number of rounds
86 $d = Crypt::Cipher->new('MULTI2', $key, $rounds);
87 # $rounds = positive integer (should comply with selected cipher requirements)
88
89=head2 encrypt
90
91Encrypts $plaintext and returns the $ciphertext where $plaintext and $ciphertext should be of B<blocksize> bytes.
92
93 $ciphertext = $d->encrypt($plaintext);
94
95=head2 decrypt
96
97Decrypts $ciphertext and returns the $plaintext where $plaintext and $ciphertext should be of B<blocksize> bytes.
98
99 $plaintext = $d->decrypt($ciphertext);
100
101=head2 keysize
102
103Just an alias for B<max_keysize> (needed for L<Crypt::CBC|Crypt::CBC> compatibility).
104
105=head2 max_keysize
106
107Returns the maximal allowed key size (in bytes) for given cipher.
108
109 $d->max_keysize;
110 #or
111 Crypt::Cipher->max_keysize('AES');
112 #or
113 Crypt::Cipher::max_keysize('AES');
114
115=head2 min_keysize
116
117Returns the minimal allowed key size (in bytes) for given cipher.
118
119 $d->min_keysize;
120 #or
121 Crypt::Cipher->min_keysize('AES');
122 #or
123 Crypt::Cipher::min_keysize('AES');
124
125=head2 blocksize
126
127Returns block size (in bytes) for given cipher.
128
129 $d->blocksize;
130 #or
131 Crypt::Cipher->blocksize('AES');
132 #or
133 Crypt::Cipher::blocksize('AES');
134
135=head2 default_rounds
136
137Returns default number of rounds for given cipher. NOTE: only some ciphers (e.g. MULTI2, RC5, SAFER) allow one to set number of rounds via new().
138
139 $d->default_rounds;
140 #or
141 Crypt::Cipher->default_rounds('AES');
142 #or
143 Crypt::Cipher::default_rounds('AES');
144
145=head1 SEE ALSO
146
147=over
148
149=item * L<CryptX|CryptX>
150
151=item * Check subclasses like L<Crypt::Cipher::AES|Crypt::Cipher::AES>, L<Crypt::Cipher::Blowfish|Crypt::Cipher::Blowfish>, ...
152
153=back
154
155=cut