| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
/* |
|
2
|
|
|
|
|
|
|
* Copyright 2001 Abhijit Menon-Sen |
|
3
|
|
|
|
|
|
|
*/ |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
6
|
|
|
|
|
|
|
#include "perl.h" |
|
7
|
|
|
|
|
|
|
#include "XSUB.h" |
|
8
|
|
|
|
|
|
|
#include "ppport.h" |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#include "twofish.h" |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
typedef struct twofish * Crypt__Twofish; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
MODULE = Crypt::Twofish PACKAGE = Crypt::Twofish PREFIX = twofish_ |
|
15
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Crypt::Twofish |
|
18
|
|
|
|
|
|
|
twofish_setup(key) |
|
19
|
|
|
|
|
|
|
char * key = NO_INIT |
|
20
|
|
|
|
|
|
|
STRLEN keylen = NO_INIT |
|
21
|
|
|
|
|
|
|
CODE: |
|
22
|
|
|
|
|
|
|
{ |
|
23
|
20297
|
50
|
|
|
|
|
key = SvPV(ST(0), keylen); |
|
24
|
20297
|
100
|
|
|
|
|
if (keylen != 16 && keylen != 24 && keylen != 32) |
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
croak("key must be 16, 24, or 32 bytes long"); |
|
26
|
|
|
|
|
|
|
|
|
27
|
20297
|
|
|
|
|
|
RETVAL = twofish_setup((unsigned char *)key, keylen); |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
OUTPUT: |
|
30
|
|
|
|
|
|
|
RETVAL |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
void |
|
33
|
|
|
|
|
|
|
twofish_DESTROY(self) |
|
34
|
|
|
|
|
|
|
Crypt::Twofish self |
|
35
|
|
|
|
|
|
|
CODE: |
|
36
|
20297
|
|
|
|
|
|
twofish_free(self); |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
void |
|
39
|
|
|
|
|
|
|
twofish_crypt(self, input, output, decrypt) |
|
40
|
|
|
|
|
|
|
Crypt::Twofish self |
|
41
|
|
|
|
|
|
|
char * input = NO_INIT |
|
42
|
|
|
|
|
|
|
SV * output |
|
43
|
|
|
|
|
|
|
int decrypt |
|
44
|
|
|
|
|
|
|
STRLEN inlen = NO_INIT |
|
45
|
|
|
|
|
|
|
STRLEN outlen = NO_INIT |
|
46
|
|
|
|
|
|
|
CODE: |
|
47
|
|
|
|
|
|
|
{ |
|
48
|
40296
|
50
|
|
|
|
|
input = SvPV(ST(1), inlen); |
|
49
|
40296
|
50
|
|
|
|
|
if (inlen != 16) |
|
50
|
0
|
|
|
|
|
|
croak("input must be 16 bytes long"); |
|
51
|
|
|
|
|
|
|
|
|
52
|
40296
|
50
|
|
|
|
|
if (output == &PL_sv_undef) |
|
53
|
0
|
|
|
|
|
|
output = sv_newmortal(); |
|
54
|
40296
|
|
|
|
|
|
outlen = 16; |
|
55
|
|
|
|
|
|
|
|
|
56
|
40296
|
50
|
|
|
|
|
SvUPGRADE(output, SVt_PV); |
|
57
|
40296
|
50
|
|
|
|
|
if (SvREADONLY(output)) |
|
58
|
0
|
|
|
|
|
|
croak("cannot use output as lvalue"); |
|
59
|
|
|
|
|
|
|
|
|
60
|
80294
|
100
|
|
|
|
|
twofish_crypt(self, |
|
61
|
|
|
|
|
|
|
(unsigned char *)input, |
|
62
|
39998
|
50
|
|
|
|
|
(unsigned char *)SvGROW(output, outlen), |
|
63
|
|
|
|
|
|
|
decrypt); |
|
64
|
|
|
|
|
|
|
|
|
65
|
40296
|
|
|
|
|
|
SvCUR_set(output, outlen); |
|
66
|
40296
|
|
|
|
|
|
*SvEND(output) = '\0'; |
|
67
|
40296
|
|
|
|
|
|
SvPOK_only(output); |
|
68
|
40296
|
50
|
|
|
|
|
SvTAINT(output); |
|
|
|
0
|
|
|
|
|
|
|
69
|
40296
|
|
|
|
|
|
ST(0) = output; |
|
70
|
|
|
|
|
|
|
} |