line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
MODULE = CryptX PACKAGE = Crypt::Digest::SHAKE |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Crypt::Digest::SHAKE |
6
|
|
|
|
|
|
|
new(Class, int num) |
7
|
|
|
|
|
|
|
CODE: |
8
|
|
|
|
|
|
|
{ |
9
|
|
|
|
|
|
|
int rv; |
10
|
|
|
|
|
|
|
|
11
|
14
|
|
|
|
|
|
Newz(0, RETVAL, 1, struct digest_shake_struct); |
12
|
14
|
50
|
|
|
|
|
if (!RETVAL) croak("FATAL: Newz failed"); |
13
|
|
|
|
|
|
|
|
14
|
14
|
|
|
|
|
|
RETVAL->num = num; |
15
|
14
|
|
|
|
|
|
rv = sha3_shake_init(&RETVAL->state, RETVAL->num); |
16
|
14
|
50
|
|
|
|
|
if (rv != CRYPT_OK) { |
17
|
0
|
|
|
|
|
|
Safefree(RETVAL); |
18
|
0
|
|
|
|
|
|
croak("FATAL: sha3_shake_init failed: %s", error_to_string(rv)); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
OUTPUT: |
22
|
|
|
|
|
|
|
RETVAL |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
void |
25
|
|
|
|
|
|
|
DESTROY(Crypt::Digest::SHAKE self) |
26
|
|
|
|
|
|
|
CODE: |
27
|
14
|
|
|
|
|
|
Safefree(self); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
void |
30
|
|
|
|
|
|
|
reset(Crypt::Digest::SHAKE self) |
31
|
|
|
|
|
|
|
PPCODE: |
32
|
|
|
|
|
|
|
{ |
33
|
|
|
|
|
|
|
int rv; |
34
|
0
|
|
|
|
|
|
rv = sha3_shake_init(&self->state, self->num); |
35
|
0
|
0
|
|
|
|
|
if (rv != CRYPT_OK) croak("FATAL: sha3_shake_init failed: %s", error_to_string(rv)); |
36
|
0
|
0
|
|
|
|
|
XPUSHs(ST(0)); /* return self */ |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Crypt::Digest::SHAKE |
40
|
|
|
|
|
|
|
clone(Crypt::Digest::SHAKE self) |
41
|
|
|
|
|
|
|
CODE: |
42
|
0
|
|
|
|
|
|
Newz(0, RETVAL, 1, struct digest_shake_struct); |
43
|
0
|
0
|
|
|
|
|
if (!RETVAL) croak("FATAL: Newz failed"); |
44
|
0
|
|
|
|
|
|
Copy(&self->state, &RETVAL->state, 1, struct digest_shake_struct); |
45
|
|
|
|
|
|
|
OUTPUT: |
46
|
|
|
|
|
|
|
RETVAL |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
void |
49
|
|
|
|
|
|
|
add(Crypt::Digest::SHAKE self, ...) |
50
|
|
|
|
|
|
|
PPCODE: |
51
|
|
|
|
|
|
|
{ |
52
|
|
|
|
|
|
|
STRLEN inlen; |
53
|
|
|
|
|
|
|
int rv, i; |
54
|
|
|
|
|
|
|
unsigned char *in; |
55
|
|
|
|
|
|
|
|
56
|
38
|
100
|
|
|
|
|
for(i=1; i
|
57
|
19
|
50
|
|
|
|
|
in = (unsigned char *)SvPVbyte(ST(i), inlen); |
58
|
19
|
100
|
|
|
|
|
if (inlen>0) { |
59
|
17
|
|
|
|
|
|
rv = sha3_shake_process(&self->state, in, (unsigned long)inlen); |
60
|
17
|
50
|
|
|
|
|
if (rv != CRYPT_OK) croak("FATAL: sha3_shake_process failed: %s", error_to_string(rv)); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
19
|
50
|
|
|
|
|
XPUSHs(ST(0)); /* return self */ |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
SV * |
67
|
|
|
|
|
|
|
done(Crypt::Digest::SHAKE self, STRLEN out_len) |
68
|
|
|
|
|
|
|
CODE: |
69
|
|
|
|
|
|
|
{ |
70
|
|
|
|
|
|
|
int rv; |
71
|
|
|
|
|
|
|
unsigned char *out_data; |
72
|
|
|
|
|
|
|
|
73
|
17
|
50
|
|
|
|
|
if (out_len == 0) { |
74
|
0
|
|
|
|
|
|
RETVAL = newSVpvn("", 0); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
else { |
77
|
17
|
|
|
|
|
|
RETVAL = NEWSV(0, out_len); /* avoid zero! */ |
78
|
17
|
|
|
|
|
|
SvPOK_only(RETVAL); |
79
|
17
|
|
|
|
|
|
SvCUR_set(RETVAL, out_len); |
80
|
17
|
|
|
|
|
|
out_data = (unsigned char *)SvPVX(RETVAL); |
81
|
17
|
|
|
|
|
|
rv = sha3_shake_done(&self->state, out_data, (unsigned long)out_len); |
82
|
17
|
50
|
|
|
|
|
if (rv != CRYPT_OK) { |
83
|
0
|
|
|
|
|
|
SvREFCNT_dec(RETVAL); |
84
|
0
|
|
|
|
|
|
croak("FATAL: sha3_shake_done failed: %s", error_to_string(rv)); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
OUTPUT: |
89
|
|
|
|
|
|
|
RETVAL |