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