line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
MODULE = CryptX PACKAGE = Crypt::Stream::RC4 |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Crypt::Stream::RC4 |
6
|
|
|
|
|
|
|
new(Class, SV * key) |
7
|
|
|
|
|
|
|
CODE: |
8
|
|
|
|
|
|
|
{ |
9
|
|
|
|
|
|
|
int rv; |
10
|
2
|
|
|
|
|
|
STRLEN k_len=0; |
11
|
2
|
|
|
|
|
|
unsigned char *k=NULL; |
12
|
|
|
|
|
|
|
|
13
|
2
|
50
|
|
|
|
|
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar"); |
14
|
2
|
50
|
|
|
|
|
k = (unsigned char *) SvPVbyte(key, k_len); |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
|
|
|
Newz(0, RETVAL, 1, rc4_state); |
17
|
2
|
50
|
|
|
|
|
if (!RETVAL) croak("FATAL: Newz failed"); |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
|
|
|
rv = rc4_stream_setup(RETVAL, k, (unsigned long)k_len); |
20
|
2
|
50
|
|
|
|
|
if (rv != CRYPT_OK) { |
21
|
0
|
|
|
|
|
|
Safefree(RETVAL); |
22
|
0
|
|
|
|
|
|
croak("FATAL: rc4_stream_setup failed: %s", error_to_string(rv)); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
OUTPUT: |
26
|
|
|
|
|
|
|
RETVAL |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
void |
29
|
|
|
|
|
|
|
DESTROY(Crypt::Stream::RC4 self) |
30
|
|
|
|
|
|
|
CODE: |
31
|
2
|
|
|
|
|
|
rc4_stream_done(self); |
32
|
2
|
|
|
|
|
|
Safefree(self); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Crypt::Stream::RC4 |
35
|
|
|
|
|
|
|
clone(Crypt::Stream::RC4 self) |
36
|
|
|
|
|
|
|
CODE: |
37
|
0
|
|
|
|
|
|
Newz(0, RETVAL, 1, rc4_state); |
38
|
0
|
0
|
|
|
|
|
if (!RETVAL) croak("FATAL: Newz failed"); |
39
|
0
|
|
|
|
|
|
Copy(self, RETVAL, 1, rc4_state); |
40
|
|
|
|
|
|
|
OUTPUT: |
41
|
|
|
|
|
|
|
RETVAL |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
SV * |
44
|
|
|
|
|
|
|
keystream(Crypt::Stream::RC4 self, STRLEN out_len) |
45
|
|
|
|
|
|
|
CODE: |
46
|
|
|
|
|
|
|
{ |
47
|
|
|
|
|
|
|
int rv; |
48
|
|
|
|
|
|
|
unsigned char *out_data; |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
if (out_len == 0) { |
51
|
0
|
|
|
|
|
|
RETVAL = newSVpvn("", 0); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
else { |
54
|
0
|
|
|
|
|
|
RETVAL = NEWSV(0, out_len); /* avoid zero! */ |
55
|
0
|
|
|
|
|
|
SvPOK_only(RETVAL); |
56
|
0
|
|
|
|
|
|
SvCUR_set(RETVAL, out_len); |
57
|
0
|
|
|
|
|
|
out_data = (unsigned char *)SvPVX(RETVAL); |
58
|
0
|
|
|
|
|
|
rv = rc4_stream_keystream(self, out_data, (unsigned long)out_len); |
59
|
0
|
0
|
|
|
|
|
if (rv != CRYPT_OK) { |
60
|
0
|
|
|
|
|
|
SvREFCNT_dec(RETVAL); |
61
|
0
|
|
|
|
|
|
croak("FATAL: rc4_stream_keystream failed: %s", error_to_string(rv)); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
OUTPUT: |
66
|
|
|
|
|
|
|
RETVAL |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
SV * |
69
|
|
|
|
|
|
|
crypt(Crypt::Stream::RC4 self, SV * data) |
70
|
|
|
|
|
|
|
CODE: |
71
|
|
|
|
|
|
|
{ |
72
|
|
|
|
|
|
|
int rv; |
73
|
|
|
|
|
|
|
STRLEN in_data_len; |
74
|
|
|
|
|
|
|
unsigned char *in_data, *out_data; |
75
|
|
|
|
|
|
|
|
76
|
2
|
50
|
|
|
|
|
in_data = (unsigned char *)SvPVbyte(data, in_data_len); |
77
|
2
|
50
|
|
|
|
|
if (in_data_len == 0) { |
78
|
0
|
|
|
|
|
|
RETVAL = newSVpvn("", 0); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
else { |
81
|
2
|
|
|
|
|
|
RETVAL = NEWSV(0, in_data_len); /* avoid zero! */ |
82
|
2
|
|
|
|
|
|
SvPOK_only(RETVAL); |
83
|
2
|
|
|
|
|
|
SvCUR_set(RETVAL, in_data_len); |
84
|
2
|
|
|
|
|
|
out_data = (unsigned char *)SvPVX(RETVAL); |
85
|
2
|
|
|
|
|
|
rv = rc4_stream_crypt(self, in_data, (unsigned long)in_data_len, out_data); |
86
|
2
|
50
|
|
|
|
|
if (rv != CRYPT_OK) { |
87
|
0
|
|
|
|
|
|
SvREFCNT_dec(RETVAL); |
88
|
0
|
|
|
|
|
|
croak("FATAL: rc4_stream_crypt failed: %s", error_to_string(rv)); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
OUTPUT: |
93
|
|
|
|
|
|
|
RETVAL |