line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Directly copied from LemonLDAP::NG project (http://lemonldap-ng.org/) |
2
|
|
|
|
|
|
|
package Apache::Session::Generate::SHA256; |
3
|
|
|
|
|
|
|
|
4
|
5
|
|
|
5
|
|
43
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
173
|
|
5
|
5
|
|
|
5
|
|
60
|
use vars qw($VERSION); |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
245
|
|
6
|
5
|
|
|
5
|
|
2839
|
use Digest::SHA qw(sha256 sha256_hex sha256_base64); |
|
5
|
|
|
|
|
16594
|
|
|
5
|
|
|
|
|
1564
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$VERSION = '1.2.2'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub generate { |
11
|
57
|
|
|
57
|
0
|
576
|
my $session = shift; |
12
|
57
|
|
|
|
|
139
|
my $length = 64; |
13
|
|
|
|
|
|
|
|
14
|
57
|
50
|
|
|
|
201
|
if ( exists $session->{args}->{IDLength} ) { |
15
|
0
|
|
|
|
|
0
|
$length = $session->{args}->{IDLength}; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
57
|
|
|
|
|
1691
|
$session->{data}->{_session_id} = substr( |
19
|
|
|
|
|
|
|
Digest::SHA::sha256_hex( |
20
|
|
|
|
|
|
|
Digest::SHA::sha256_hex( time() . {} . rand() . $$ ) |
21
|
|
|
|
|
|
|
), |
22
|
|
|
|
|
|
|
0, $length |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub validate { |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
#This routine checks to ensure that the session ID is in the form |
30
|
|
|
|
|
|
|
#we expect. This must be called before we start diddling around |
31
|
|
|
|
|
|
|
#in the database or the disk. |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
1
|
0
|
21
|
my $session = shift; |
34
|
|
|
|
|
|
|
|
35
|
1
|
50
|
|
|
|
22
|
if ( $session->{data}->{_session_id} =~ /^([a-fA-F0-9]+)$/ ) { |
36
|
1
|
|
|
|
|
8
|
$session->{data}->{_session_id} = $1; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
0
|
|
|
|
|
|
die "Invalid session ID: " . $session->{data}->{_session_id}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |