| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
/* |
|
2
|
|
|
|
|
|
|
* Copyright (C) 1995, 1996 Systemics Ltd (http://www.systemics.com/) |
|
3
|
|
|
|
|
|
|
* |
|
4
|
|
|
|
|
|
|
* Code Modfifications Copyright (C) 2000 W3Works, LLC (http://www.w3works.co/) |
|
5
|
|
|
|
|
|
|
* All rights reserved. |
|
6
|
|
|
|
|
|
|
*/ |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
9
|
|
|
|
|
|
|
#include "perl.h" |
|
10
|
|
|
|
|
|
|
#include "XSUB.h" |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#include "blowfish.h" |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
/* thanks to LDS */ |
|
15
|
|
|
|
|
|
|
#ifndef sv_undef |
|
16
|
|
|
|
|
|
|
#define sv_undef PL_sv_undef |
|
17
|
|
|
|
|
|
|
#endif |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
MODULE = Crypt::Blowfish PACKAGE = Crypt::Blowfish PREFIX = blowfish_ |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
char * |
|
25
|
|
|
|
|
|
|
blowfish_init(key) |
|
26
|
|
|
|
|
|
|
unsigned char * key = NO_INIT |
|
27
|
|
|
|
|
|
|
STRLEN key_len = NO_INIT |
|
28
|
|
|
|
|
|
|
CODE: |
|
29
|
|
|
|
|
|
|
{ |
|
30
|
|
|
|
|
|
|
/* |
|
31
|
|
|
|
|
|
|
* What should this length be??? |
|
32
|
|
|
|
|
|
|
*/ |
|
33
|
|
|
|
|
|
|
char ks[8192]; |
|
34
|
|
|
|
|
|
|
|
|
35
|
10013
|
|
|
|
|
|
key = (unsigned char *) SvPV(ST(0), key_len); |
|
36
|
10013
|
|
|
|
|
|
if (key_len < 8 || key_len > 56) |
|
37
|
0
|
|
|
|
|
|
croak("Invalid length key"); |
|
38
|
|
|
|
|
|
|
|
|
39
|
10013
|
|
|
|
|
|
if (blowfish_make_bfkey(key, key_len, ks)) |
|
40
|
0
|
|
|
|
|
|
croak("Error creating key schedule"); |
|
41
|
|
|
|
|
|
|
|
|
42
|
10013
|
|
|
|
|
|
ST(0) = sv_2mortal(newSVpv(ks, sizeof(ks))); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
void |
|
46
|
|
|
|
|
|
|
blowfish_crypt(input, output, ks, dir) |
|
47
|
|
|
|
|
|
|
char * input = NO_INIT |
|
48
|
|
|
|
|
|
|
SV * output |
|
49
|
|
|
|
|
|
|
char * ks = NO_INIT |
|
50
|
|
|
|
|
|
|
STRLEN input_len = NO_INIT |
|
51
|
|
|
|
|
|
|
STRLEN output_len = NO_INIT |
|
52
|
|
|
|
|
|
|
STRLEN ks_len = NO_INIT |
|
53
|
|
|
|
|
|
|
int dir |
|
54
|
|
|
|
|
|
|
CODE: |
|
55
|
|
|
|
|
|
|
{ |
|
56
|
30018
|
|
|
|
|
|
input = (char *) SvPV(ST(0), input_len); |
|
57
|
30018
|
|
|
|
|
|
if (input_len != 8) |
|
58
|
0
|
|
|
|
|
|
croak("input must be 8 bytes long"); |
|
59
|
|
|
|
|
|
|
|
|
60
|
30018
|
|
|
|
|
|
ks = (char *) SvPV(ST(2), ks_len); |
|
61
|
|
|
|
|
|
|
|
|
62
|
30018
|
|
|
|
|
|
if (output == &sv_undef) |
|
63
|
0
|
|
|
|
|
|
output = sv_newmortal(); |
|
64
|
|
|
|
|
|
|
output_len = 8; |
|
65
|
|
|
|
|
|
|
|
|
66
|
30018
|
|
|
|
|
|
if (!SvUPGRADE(output, SVt_PV)) |
|
67
|
0
|
|
|
|
|
|
croak("cannot use output argument as lvalue"); |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
/* blowfish_crypt_8bytes(input, SvGROW(output, 8), ks, dir); */ |
|
70
|
|
|
|
|
|
|
/* HP-UX (HP cc) fix below, thanks Addi! */ |
|
71
|
30018
|
|
|
|
|
|
blowfish_crypt_8bytes( (unsigned char*)input, (unsigned char*)SvGROW(output, 8), ks, (short)dir); |
|
72
|
|
|
|
|
|
|
|
|
73
|
30018
|
|
|
|
|
|
SvCUR_set(output, output_len); |
|
74
|
30018
|
|
|
|
|
|
*SvEND(output) = '\0'; |
|
75
|
30018
|
|
|
|
|
|
(void) SvPOK_only(output); |
|
76
|
30018
|
|
|
|
|
|
SvTAINT(output); |
|
77
|
|
|
|
|
|
|
|
|
78
|
30018
|
|
|
|
|
|
ST(0) = output; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|