line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
MODULE = CryptX PACKAGE = Crypt::Mac::PMAC |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY! |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Crypt::Mac::PMAC |
8
|
|
|
|
|
|
|
new(Class, char * cipher_name, SV * key) |
9
|
|
|
|
|
|
|
CODE: |
10
|
|
|
|
|
|
|
{ |
11
|
482
|
|
|
|
|
|
STRLEN k_len=0; |
12
|
482
|
|
|
|
|
|
unsigned char *k=NULL; |
13
|
|
|
|
|
|
|
int rv; |
14
|
|
|
|
|
|
|
int id; |
15
|
|
|
|
|
|
|
|
16
|
482
|
|
|
|
|
|
id = cryptx_internal_find_cipher(cipher_name); |
17
|
482
|
50
|
|
|
|
|
if (id == -1) croak("FATAL: find_cipfer failed for '%s'", cipher_name); |
18
|
|
|
|
|
|
|
|
19
|
482
|
50
|
|
|
|
|
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar"); |
20
|
482
|
50
|
|
|
|
|
k = (unsigned char *) SvPVbyte(key, k_len); |
21
|
|
|
|
|
|
|
|
22
|
482
|
|
|
|
|
|
Newz(0, RETVAL, 1, pmac_state); |
23
|
482
|
50
|
|
|
|
|
if (!RETVAL) croak("FATAL: Newz failed"); |
24
|
|
|
|
|
|
|
|
25
|
482
|
|
|
|
|
|
rv = pmac_init(RETVAL, id, k, (unsigned long)k_len); |
26
|
482
|
50
|
|
|
|
|
if (rv != CRYPT_OK) { |
27
|
0
|
|
|
|
|
|
Safefree(RETVAL); |
28
|
0
|
|
|
|
|
|
croak("FATAL: pmac_init failed: %s", error_to_string(rv)); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
OUTPUT: |
32
|
|
|
|
|
|
|
RETVAL |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
void |
35
|
|
|
|
|
|
|
DESTROY(Crypt::Mac::PMAC self) |
36
|
|
|
|
|
|
|
CODE: |
37
|
482
|
|
|
|
|
|
Safefree(self); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Crypt::Mac::PMAC |
40
|
|
|
|
|
|
|
clone(Crypt::Mac::PMAC self) |
41
|
|
|
|
|
|
|
CODE: |
42
|
0
|
|
|
|
|
|
Newz(0, RETVAL, 1, pmac_state); |
43
|
0
|
0
|
|
|
|
|
if (!RETVAL) croak("FATAL: Newz failed"); |
44
|
0
|
|
|
|
|
|
Copy(self, RETVAL, 1, pmac_state); |
45
|
|
|
|
|
|
|
OUTPUT: |
46
|
|
|
|
|
|
|
RETVAL |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
void |
49
|
|
|
|
|
|
|
add(Crypt::Mac::PMAC self, ...) |
50
|
|
|
|
|
|
|
PPCODE: |
51
|
|
|
|
|
|
|
{ |
52
|
|
|
|
|
|
|
int rv, i; |
53
|
|
|
|
|
|
|
STRLEN in_data_len; |
54
|
|
|
|
|
|
|
unsigned char *in_data; |
55
|
|
|
|
|
|
|
|
56
|
980
|
100
|
|
|
|
|
for(i = 1; i < items; i++) { |
57
|
494
|
100
|
|
|
|
|
in_data = (unsigned char *)SvPVbyte(ST(i), in_data_len); |
58
|
494
|
100
|
|
|
|
|
if (in_data_len > 0) { |
59
|
466
|
|
|
|
|
|
rv = pmac_process(self, in_data, (unsigned long)in_data_len); |
60
|
466
|
50
|
|
|
|
|
if (rv != CRYPT_OK) croak("FATAL: pmac_process failed: %s", error_to_string(rv)); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
486
|
50
|
|
|
|
|
XPUSHs(ST(0)); /* return self */ |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
SV * |
67
|
|
|
|
|
|
|
mac(Crypt::Mac::PMAC self) |
68
|
|
|
|
|
|
|
ALIAS: |
69
|
|
|
|
|
|
|
hexmac = 1 |
70
|
|
|
|
|
|
|
b64mac = 2 |
71
|
|
|
|
|
|
|
b64umac = 3 |
72
|
|
|
|
|
|
|
CODE: |
73
|
|
|
|
|
|
|
{ |
74
|
|
|
|
|
|
|
unsigned char mac[MAXBLOCKSIZE]; |
75
|
|
|
|
|
|
|
unsigned long maclen, outlen; |
76
|
|
|
|
|
|
|
int rv; |
77
|
|
|
|
|
|
|
char out[MAXBLOCKSIZE*2+1]; |
78
|
|
|
|
|
|
|
|
79
|
482
|
|
|
|
|
|
maclen = sizeof(mac); |
80
|
482
|
|
|
|
|
|
rv = pmac_done(self, mac, &maclen); |
81
|
482
|
50
|
|
|
|
|
if (rv != CRYPT_OK) croak("FATAL: pmac_done failed: %s", error_to_string(rv)); |
82
|
482
|
|
|
|
|
|
outlen = sizeof(out); |
83
|
482
|
100
|
|
|
|
|
if (ix == 3) { |
84
|
1
|
|
|
|
|
|
rv = base64url_encode(mac, maclen, out, &outlen); |
85
|
1
|
50
|
|
|
|
|
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); |
86
|
1
|
|
|
|
|
|
RETVAL = newSVpvn(out, outlen); |
87
|
|
|
|
|
|
|
} |
88
|
481
|
100
|
|
|
|
|
else if (ix == 2) { |
89
|
1
|
|
|
|
|
|
rv = base64_encode(mac, maclen, out, &outlen); |
90
|
1
|
50
|
|
|
|
|
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); |
91
|
1
|
|
|
|
|
|
RETVAL = newSVpvn(out, outlen); |
92
|
|
|
|
|
|
|
} |
93
|
480
|
100
|
|
|
|
|
else if (ix == 1) { |
94
|
14
|
|
|
|
|
|
rv = base16_encode(mac, maclen, out, &outlen, 0); |
95
|
14
|
50
|
|
|
|
|
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); |
96
|
14
|
|
|
|
|
|
RETVAL = newSVpvn(out, outlen); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
else { |
99
|
466
|
|
|
|
|
|
RETVAL = newSVpvn((char * )mac, maclen); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
OUTPUT: |
103
|
|
|
|
|
|
|
RETVAL |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
SV * |
106
|
|
|
|
|
|
|
pmac(char * cipher_name, SV * key, ...) |
107
|
|
|
|
|
|
|
ALIAS: |
108
|
|
|
|
|
|
|
pmac_hex = 1 |
109
|
|
|
|
|
|
|
pmac_b64 = 2 |
110
|
|
|
|
|
|
|
pmac_b64u = 3 |
111
|
|
|
|
|
|
|
CODE: |
112
|
|
|
|
|
|
|
{ |
113
|
|
|
|
|
|
|
STRLEN inlen, klen; |
114
|
|
|
|
|
|
|
unsigned char *in; |
115
|
52
|
50
|
|
|
|
|
unsigned char *k = (unsigned char *)SvPVbyte(key, klen); |
116
|
|
|
|
|
|
|
int rv, i; |
117
|
|
|
|
|
|
|
unsigned char mac[MAXBLOCKSIZE]; |
118
|
52
|
|
|
|
|
|
unsigned long len = sizeof(mac), outlen; |
119
|
|
|
|
|
|
|
char out[MAXBLOCKSIZE*2]; |
120
|
|
|
|
|
|
|
pmac_state st; |
121
|
|
|
|
|
|
|
|
122
|
52
|
|
|
|
|
|
int id = cryptx_internal_find_cipher(cipher_name); |
123
|
52
|
50
|
|
|
|
|
if (id == -1) croak("FATAL: find_cipher failed for '%s'", cipher_name); |
124
|
52
|
|
|
|
|
|
rv = pmac_init(&st, id, k, (unsigned long)klen); |
125
|
52
|
50
|
|
|
|
|
if (rv != CRYPT_OK) croak("FATAL: pmac_init failed: %s", error_to_string(rv)); |
126
|
112
|
100
|
|
|
|
|
for (i = 2; i < items; i++) { |
127
|
60
|
100
|
|
|
|
|
in = (unsigned char *)SvPVbyte(ST(i), inlen); |
128
|
60
|
100
|
|
|
|
|
if (inlen > 0) { |
129
|
44
|
|
|
|
|
|
rv = pmac_process(&st, in, (unsigned long)inlen); |
130
|
44
|
50
|
|
|
|
|
if (rv != CRYPT_OK) croak("FATAL: pmac_process failed: %s", error_to_string(rv)); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
} |
133
|
52
|
|
|
|
|
|
rv = pmac_done(&st, mac, &len); |
134
|
52
|
50
|
|
|
|
|
if (rv != CRYPT_OK) croak("FATAL: pmac_done failed: %s", error_to_string(rv)); |
135
|
|
|
|
|
|
|
|
136
|
52
|
|
|
|
|
|
outlen = sizeof(out); |
137
|
52
|
100
|
|
|
|
|
if (ix == 3) { |
138
|
13
|
|
|
|
|
|
rv = base64url_encode(mac, len, out, &outlen); |
139
|
13
|
50
|
|
|
|
|
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); |
140
|
13
|
|
|
|
|
|
RETVAL = newSVpvn((char *) out, outlen); |
141
|
|
|
|
|
|
|
} |
142
|
39
|
100
|
|
|
|
|
else if (ix == 2) { |
143
|
13
|
|
|
|
|
|
rv = base64_encode(mac, len, out, &outlen); |
144
|
13
|
50
|
|
|
|
|
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); |
145
|
13
|
|
|
|
|
|
RETVAL = newSVpvn(out, outlen); |
146
|
|
|
|
|
|
|
} |
147
|
26
|
100
|
|
|
|
|
else if (ix == 1) { |
148
|
13
|
|
|
|
|
|
rv = base16_encode(mac, len, out, &outlen, 0); |
149
|
13
|
50
|
|
|
|
|
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); |
150
|
13
|
|
|
|
|
|
RETVAL = newSVpvn(out, outlen); |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
else { |
153
|
13
|
|
|
|
|
|
RETVAL = newSVpvn((char *) mac, len); |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
OUTPUT: |
157
|
|
|
|
|
|
|
RETVAL |