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