| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
2
|
|
|
|
|
|
|
#include "perl.h" |
|
3
|
|
|
|
|
|
|
#include "XSUB.h" |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
MODULE = Crypt::OpenSSL::PBKDF2 PACKAGE = Crypt::OpenSSL::PBKDF2 |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#include |
|
8
|
|
|
|
|
|
|
#include |
|
9
|
|
|
|
|
|
|
#include |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
SV * |
|
12
|
|
|
|
|
|
|
derive(pass, salt, saltlen, iter, hlen, ...) |
|
13
|
|
|
|
|
|
|
const char * pass |
|
14
|
|
|
|
|
|
|
unsigned char * salt |
|
15
|
|
|
|
|
|
|
int saltlen |
|
16
|
|
|
|
|
|
|
int iter |
|
17
|
|
|
|
|
|
|
int hlen |
|
18
|
|
|
|
|
|
|
PREINIT: |
|
19
|
10
|
|
|
|
|
|
const char * alg = "sha1"; |
|
20
|
|
|
|
|
|
|
INIT: |
|
21
|
10
|
|
|
|
|
|
unsigned char * hash = NULL; |
|
22
|
10
|
|
|
|
|
|
int plen = strlen(pass); |
|
23
|
|
|
|
|
|
|
const EVP_MD *md; |
|
24
|
|
|
|
|
|
|
CODE: |
|
25
|
10
|
100
|
|
|
|
|
if( items > 5 ) |
|
26
|
3
|
|
|
|
|
|
alg = (const char *)SvPV_nolen(ST(5)); |
|
27
|
10
|
100
|
|
|
|
|
if ((md = EVP_get_digestbyname(alg)) == NULL) |
|
28
|
2
|
|
|
|
|
|
croak("invalid hashing algorithm"); |
|
29
|
|
|
|
|
|
|
|
|
30
|
8
|
50
|
|
|
|
|
if ( Newxz(hash, hlen, unsigned char) == NULL ) |
|
31
|
0
|
|
|
|
|
|
croak("unable to allocate buffer for hash"); |
|
32
|
8
|
|
|
|
|
|
SSL_library_init(); |
|
33
|
8
|
|
|
|
|
|
ERR_load_crypto_strings(); |
|
34
|
8
|
50
|
|
|
|
|
if (PKCS5_PBKDF2_HMAC(pass, plen, salt, saltlen, iter, md, hlen, hash) != 1) |
|
35
|
0
|
|
|
|
|
|
croak("an error occurred: %s", ERR_error_string(ERR_get_error(), NULL)); |
|
36
|
8
|
|
|
|
|
|
RETVAL = newSVpv((char *)hash, hlen); |
|
37
|
8
|
|
|
|
|
|
ERR_free_strings(); |
|
38
|
8
|
|
|
|
|
|
Safefree(hash); |
|
39
|
|
|
|
|
|
|
OUTPUT: |
|
40
|
|
|
|
|
|
|
RETVAL |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
SV * |
|
43
|
|
|
|
|
|
|
derive_bin(pass, passlen, salt, saltlen, iter, hlen, ...) |
|
44
|
|
|
|
|
|
|
unsigned char * pass |
|
45
|
|
|
|
|
|
|
int passlen |
|
46
|
|
|
|
|
|
|
unsigned char * salt |
|
47
|
|
|
|
|
|
|
int saltlen |
|
48
|
|
|
|
|
|
|
int iter |
|
49
|
|
|
|
|
|
|
int hlen |
|
50
|
|
|
|
|
|
|
PREINIT: |
|
51
|
8
|
|
|
|
|
|
const char * alg = "sha1"; |
|
52
|
|
|
|
|
|
|
INIT: |
|
53
|
8
|
|
|
|
|
|
unsigned char * hash = NULL; |
|
54
|
|
|
|
|
|
|
const EVP_MD *md; |
|
55
|
|
|
|
|
|
|
CODE: |
|
56
|
8
|
100
|
|
|
|
|
if( items > 6 ) |
|
57
|
1
|
|
|
|
|
|
alg = (const char *)SvPV_nolen(ST(6)); |
|
58
|
8
|
50
|
|
|
|
|
if ((md = EVP_get_digestbyname(alg)) == NULL) |
|
59
|
0
|
|
|
|
|
|
croak("invalid hashing algorithm"); |
|
60
|
|
|
|
|
|
|
|
|
61
|
8
|
50
|
|
|
|
|
if ( Newxz(hash, hlen, unsigned char) == NULL ) |
|
62
|
0
|
|
|
|
|
|
croak ("unable to allocate buffer for hash"); |
|
63
|
8
|
|
|
|
|
|
SSL_library_init(); |
|
64
|
8
|
|
|
|
|
|
ERR_load_crypto_strings(); |
|
65
|
8
|
50
|
|
|
|
|
if (PKCS5_PBKDF2_HMAC((const char *)pass, passlen, salt, saltlen, iter, md, hlen, hash) != 1) |
|
66
|
0
|
|
|
|
|
|
croak ("an error occurred: %s", ERR_error_string(ERR_get_error(), NULL)); |
|
67
|
8
|
|
|
|
|
|
RETVAL = newSVpv((char *)hash, hlen); |
|
68
|
8
|
|
|
|
|
|
ERR_free_strings(); |
|
69
|
8
|
|
|
|
|
|
Safefree(hash); |
|
70
|
|
|
|
|
|
|
OUTPUT: |
|
71
|
|
|
|
|
|
|
RETVAL |