Filename | /usr/lib/perl/5.14/Digest/SHA.pm |
Statements | Executed 23 statements in 2.02ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 196µs | 196µs | bootstrap (xsub) | Digest::SHA::
1 | 1 | 1 | 50µs | 219µs | BEGIN@6 | Digest::SHA::
1 | 1 | 1 | 26µs | 34µs | BEGIN@5 | Digest::SHA::
1 | 1 | 1 | 21µs | 1.01ms | BEGIN@7 | Digest::SHA::
1 | 1 | 1 | 17µs | 23µs | BEGIN@8 | Digest::SHA::
0 | 0 | 0 | 0s | 0s | Addfile | Digest::SHA::
0 | 0 | 0 | 0s | 0s | DESTROY | Digest::SHA::
0 | 0 | 0 | 0s | 0s | _addfile | Digest::SHA::
0 | 0 | 0 | 0s | 0s | _bail | Digest::SHA::
0 | 0 | 0 | 0s | 0s | add_bits | Digest::SHA::
0 | 0 | 0 | 0s | 0s | clone | Digest::SHA::
0 | 0 | 0 | 0s | 0s | dump | Digest::SHA::
0 | 0 | 0 | 0s | 0s | load | Digest::SHA::
0 | 0 | 0 | 0s | 0s | new | Digest::SHA::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Digest::SHA; | ||||
2 | |||||
3 | 1 | 23µs | require 5.003000; | ||
4 | |||||
5 | 2 | 59µs | 2 | 42µs | # spent 34µs (26+8) within Digest::SHA::BEGIN@5 which was called:
# once (26µs+8µs) by Foswiki::Users::HtPasswdUser::BEGIN@2 at line 5 # spent 34µs making 1 call to Digest::SHA::BEGIN@5
# spent 8µs making 1 call to strict::import |
6 | 2 | 81µs | 2 | 388µs | # spent 219µs (50+169) within Digest::SHA::BEGIN@6 which was called:
# once (50µs+169µs) by Foswiki::Users::HtPasswdUser::BEGIN@2 at line 6 # spent 219µs making 1 call to Digest::SHA::BEGIN@6
# spent 169µs making 1 call to vars::import |
7 | 2 | 45µs | 2 | 2.01ms | # spent 1.01ms (21µs+992µs) within Digest::SHA::BEGIN@7 which was called:
# once (21µs+992µs) by Foswiki::Users::HtPasswdUser::BEGIN@2 at line 7 # spent 1.01ms making 1 call to Digest::SHA::BEGIN@7
# spent 992µs making 1 call to Exporter::import |
8 | 2 | 1.46ms | 2 | 30µs | # spent 23µs (17+6) within Digest::SHA::BEGIN@8 which was called:
# once (17µs+6µs) by Foswiki::Users::HtPasswdUser::BEGIN@2 at line 8 # spent 23µs making 1 call to Digest::SHA::BEGIN@8
# spent 6µs making 1 call to integer::import |
9 | |||||
10 | 1 | 2µs | $VERSION = '5.61'; | ||
11 | |||||
12 | 1 | 2µs | require Exporter; | ||
13 | 1 | 137µs | require DynaLoader; | ||
14 | 1 | 12µs | @ISA = qw(Exporter DynaLoader); | ||
15 | 1 | 9µs | @EXPORT_OK = qw( | ||
16 | hmac_sha1 hmac_sha1_base64 hmac_sha1_hex | ||||
17 | hmac_sha224 hmac_sha224_base64 hmac_sha224_hex | ||||
18 | hmac_sha256 hmac_sha256_base64 hmac_sha256_hex | ||||
19 | hmac_sha384 hmac_sha384_base64 hmac_sha384_hex | ||||
20 | hmac_sha512 hmac_sha512_base64 hmac_sha512_hex | ||||
21 | hmac_sha512224 hmac_sha512224_base64 hmac_sha512224_hex | ||||
22 | hmac_sha512256 hmac_sha512256_base64 hmac_sha512256_hex | ||||
23 | sha1 sha1_base64 sha1_hex | ||||
24 | sha224 sha224_base64 sha224_hex | ||||
25 | sha256 sha256_base64 sha256_hex | ||||
26 | sha384 sha384_base64 sha384_hex | ||||
27 | sha512 sha512_base64 sha512_hex | ||||
28 | sha512224 sha512224_base64 sha512224_hex | ||||
29 | sha512256 sha512256_base64 sha512256_hex); | ||||
30 | |||||
31 | # If possible, inherit from Digest::base (which depends on MIME::Base64) | ||||
32 | |||||
33 | 1 | 3µs | *addfile = \&Addfile; | ||
34 | |||||
35 | 4 | 145µs | eval { | ||
36 | require MIME::Base64; | ||||
37 | require Digest::base; | ||||
38 | push(@ISA, 'Digest::base'); | ||||
39 | }; | ||||
40 | 1 | 1µs | if ($@) { | ||
41 | *hexdigest = \&Hexdigest; | ||||
42 | *b64digest = \&B64digest; | ||||
43 | } | ||||
44 | |||||
45 | # The following routines aren't time-critical, so they can be left in Perl | ||||
46 | |||||
47 | sub new { | ||||
48 | my($class, $alg) = @_; | ||||
49 | $alg =~ s/\D+//g if defined $alg; | ||||
50 | if (ref($class)) { # instance method | ||||
51 | unless (defined($alg) && ($alg != $class->algorithm)) { | ||||
52 | sharewind($$class); | ||||
53 | return($class); | ||||
54 | } | ||||
55 | shaclose($$class) if $$class; | ||||
56 | $$class = shaopen($alg) || return; | ||||
57 | return($class); | ||||
58 | } | ||||
59 | $alg = 1 unless defined $alg; | ||||
60 | my $state = shaopen($alg) || return; | ||||
61 | my $self = \$state; | ||||
62 | bless($self, $class); | ||||
63 | return($self); | ||||
64 | } | ||||
65 | |||||
66 | sub DESTROY { | ||||
67 | my $self = shift; | ||||
68 | shaclose($$self) if $$self; | ||||
69 | } | ||||
70 | |||||
71 | sub clone { | ||||
72 | my $self = shift; | ||||
73 | my $state = shadup($$self) || return; | ||||
74 | my $copy = \$state; | ||||
75 | bless($copy, ref($self)); | ||||
76 | return($copy); | ||||
77 | } | ||||
78 | |||||
79 | 1 | 2µs | *reset = \&new; | ||
80 | |||||
81 | sub add_bits { | ||||
82 | my($self, $data, $nbits) = @_; | ||||
83 | unless (defined $nbits) { | ||||
84 | $nbits = length($data); | ||||
85 | $data = pack("B*", $data); | ||||
86 | } | ||||
87 | shawrite($data, $nbits, $$self); | ||||
88 | return($self); | ||||
89 | } | ||||
90 | |||||
91 | sub _bail { | ||||
92 | my $msg = shift; | ||||
93 | |||||
94 | require Carp; | ||||
95 | Carp::croak("$msg: $!"); | ||||
96 | } | ||||
97 | |||||
98 | sub _addfile { # this is "addfile" from Digest::base 1.00 | ||||
99 | my ($self, $handle) = @_; | ||||
100 | |||||
101 | my $n; | ||||
102 | my $buf = ""; | ||||
103 | |||||
104 | while (($n = read($handle, $buf, 4096))) { | ||||
105 | $self->add($buf); | ||||
106 | } | ||||
107 | _bail("Read failed") unless defined $n; | ||||
108 | |||||
109 | $self; | ||||
110 | } | ||||
111 | |||||
112 | sub Addfile { | ||||
113 | my ($self, $file, $mode) = @_; | ||||
114 | |||||
115 | return(_addfile($self, $file)) unless ref(\$file) eq 'SCALAR'; | ||||
116 | |||||
117 | $mode = defined($mode) ? $mode : ""; | ||||
118 | my ($binary, $portable) = map { $_ eq $mode } ("b", "p"); | ||||
119 | |||||
120 | ## Always interpret "-" to mean STDIN; otherwise use | ||||
121 | ## sysopen to handle full range of POSIX file names | ||||
122 | local *FH; | ||||
123 | $file eq '-' and open(FH, '< -') | ||||
124 | or sysopen(FH, $file, O_RDONLY) | ||||
125 | or _bail('Open failed'); | ||||
126 | binmode(FH) if $binary || $portable; | ||||
127 | |||||
128 | unless ($portable && -T $file) { | ||||
129 | $self->_addfile(*FH); | ||||
130 | close(FH); | ||||
131 | return($self); | ||||
132 | } | ||||
133 | |||||
134 | my ($n1, $n2); | ||||
135 | my ($buf1, $buf2) = ("", ""); | ||||
136 | |||||
137 | while (($n1 = read(FH, $buf1, 4096))) { | ||||
138 | while (substr($buf1, -1) eq "\015") { | ||||
139 | $n2 = read(FH, $buf2, 4096); | ||||
140 | _bail("Read failed") unless defined $n2; | ||||
141 | last unless $n2; | ||||
142 | $buf1 .= $buf2; | ||||
143 | } | ||||
144 | $buf1 =~ s/\015?\015\012/\012/g; # DOS/Windows | ||||
145 | $buf1 =~ s/\015/\012/g; # early MacOS | ||||
146 | $self->add($buf1); | ||||
147 | } | ||||
148 | _bail("Read failed") unless defined $n1; | ||||
149 | close(FH); | ||||
150 | |||||
151 | $self; | ||||
152 | } | ||||
153 | |||||
154 | sub dump { | ||||
155 | my $self = shift; | ||||
156 | my $file = shift || ""; | ||||
157 | |||||
158 | shadump($file, $$self) || return; | ||||
159 | return($self); | ||||
160 | } | ||||
161 | |||||
162 | sub load { | ||||
163 | my $class = shift; | ||||
164 | my $file = shift || ""; | ||||
165 | if (ref($class)) { # instance method | ||||
166 | shaclose($$class) if $$class; | ||||
167 | $$class = shaload($file) || return; | ||||
168 | return($class); | ||||
169 | } | ||||
170 | my $state = shaload($file) || return; | ||||
171 | my $self = \$state; | ||||
172 | bless($self, $class); | ||||
173 | return($self); | ||||
174 | } | ||||
175 | |||||
176 | 1 | 14µs | 1 | 562µs | Digest::SHA->bootstrap($VERSION); # spent 562µs making 1 call to DynaLoader::bootstrap |
177 | |||||
178 | 1 | 28µs | 1; | ||
179 | __END__ | ||||
# spent 196µs within Digest::SHA::bootstrap which was called:
# once (196µs+0s) by DynaLoader::bootstrap at line 207 of DynaLoader.pm |