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 "tea.h" |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
typedef struct tea * Crypt__TEA; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
MODULE = Crypt::TEA PACKAGE = Crypt::TEA PREFIX = tea_ |
15
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Crypt::TEA |
18
|
|
|
|
|
|
|
tea_setup(key, rounds) |
19
|
|
|
|
|
|
|
char * key = NO_INIT |
20
|
|
|
|
|
|
|
int rounds |
21
|
|
|
|
|
|
|
STRLEN keylen = NO_INIT |
22
|
|
|
|
|
|
|
CODE: |
23
|
|
|
|
|
|
|
{ |
24
|
40003
|
50
|
|
|
|
|
key = SvPV(ST(0), keylen); |
25
|
40003
|
50
|
|
|
|
|
if (keylen != 16) |
26
|
0
|
|
|
|
|
|
croak("key must be 16 bytes long"); |
27
|
|
|
|
|
|
|
|
28
|
40003
|
|
|
|
|
|
RETVAL = tea_setup((unsigned char *)key, rounds); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
OUTPUT: |
31
|
|
|
|
|
|
|
RETVAL |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
void |
34
|
|
|
|
|
|
|
tea_DESTROY(self) |
35
|
|
|
|
|
|
|
Crypt::TEA self |
36
|
|
|
|
|
|
|
CODE: |
37
|
40003
|
|
|
|
|
|
tea_free(self); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
void |
40
|
|
|
|
|
|
|
tea_crypt(self, input, output, decrypt) |
41
|
|
|
|
|
|
|
Crypt::TEA self |
42
|
|
|
|
|
|
|
char * input = NO_INIT |
43
|
|
|
|
|
|
|
SV * output |
44
|
|
|
|
|
|
|
int decrypt |
45
|
|
|
|
|
|
|
STRLEN inlen = NO_INIT |
46
|
|
|
|
|
|
|
STRLEN outlen = NO_INIT |
47
|
|
|
|
|
|
|
CODE: |
48
|
|
|
|
|
|
|
{ |
49
|
140002
|
50
|
|
|
|
|
input = SvPV(ST(1), inlen); |
50
|
140002
|
50
|
|
|
|
|
if (inlen != 8) |
51
|
0
|
|
|
|
|
|
croak("input must be 8 bytes long"); |
52
|
|
|
|
|
|
|
|
53
|
140002
|
50
|
|
|
|
|
if (output == &PL_sv_undef) |
54
|
0
|
|
|
|
|
|
output = sv_newmortal(); |
55
|
140002
|
|
|
|
|
|
outlen = 8; |
56
|
|
|
|
|
|
|
|
57
|
140002
|
50
|
|
|
|
|
if (SvREADONLY(output)) |
58
|
0
|
0
|
|
|
|
|
SvUPGRADE(output, SVt_PV); |
59
|
|
|
|
|
|
|
|
60
|
280000
|
100
|
|
|
|
|
tea_crypt(self, |
61
|
|
|
|
|
|
|
(unsigned char *)input, |
62
|
139998
|
50
|
|
|
|
|
(unsigned char *)SvGROW(output, outlen), |
63
|
|
|
|
|
|
|
decrypt); |
64
|
|
|
|
|
|
|
|
65
|
140002
|
|
|
|
|
|
SvCUR_set(output, outlen); |
66
|
140002
|
|
|
|
|
|
*SvEND(output) = '\0'; |
67
|
140002
|
|
|
|
|
|
SvPOK_only(output); |
68
|
140002
|
50
|
|
|
|
|
SvTAINT(output); |
|
|
0
|
|
|
|
|
|
69
|
140002
|
|
|
|
|
|
ST(0) = output; |
70
|
|
|
|
|
|
|
} |