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