inc/CryptX_AuthEnc_OCB.xs.inc

filter: Statementstmt 77.5% 128 / 165 Branchbran 32.4% 74 / 228 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 51.4% 202 / 393 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« inc/CryptX_PK_X448.xs.inc ↑ Summary inc/CryptX_AuthEnc_CCM.xs.inc »
1 MODULE = CryptX PACKAGE = Crypt::AuthEnc::OCB
2  
3 PROTOTYPES: DISABLE
4  
5 Crypt::AuthEnc::OCB
6 new(Class, char * cipher_name, SV * key, SV * nonce, unsigned long taglen)
7 CODE:
8 {
9 37 STRLEN k_len=0;
10 37 unsigned char *k=NULL;
11 37 unsigned char *n=NULL;
12 37 STRLEN n_len=0;
13 int rv, id;
14  
15 37 ▶ if (!SvPOK_spec(key)) croak("FATAL: key must be string/buffer scalar");
Branch: 5 branches
BranchTrueFalseTotal
if (!SvPOK_spec(key)) croak("FATAL: key must be string/buffer scalar"); 37 0 37
if (!SvPOK_spec(key)) croak("FATAL: key must be string/buffer scalar"); 0 37 37
if (!SvPOK_spec(key)) croak("FATAL: key must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(key)) croak("FATAL: key must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(key)) croak("FATAL: key must be string/buffer scalar"); 0 0 0
16 37 k = (unsigned char *) SvPVbyte(key, k_len);
17 37 ▶ if (!SvPOK_spec(nonce)) croak("FATAL: nonce must be string/buffer scalar");
Branch: 5 branches
BranchTrueFalseTotal
if (!SvPOK_spec(nonce)) croak("FATAL: nonce must be string/buffer scalar"); 37 0 37
if (!SvPOK_spec(nonce)) croak("FATAL: nonce must be string/buffer scalar"); 0 37 37
if (!SvPOK_spec(nonce)) croak("FATAL: nonce must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(nonce)) croak("FATAL: nonce must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(nonce)) croak("FATAL: nonce must be string/buffer scalar"); 0 0 0
18 37 n = (unsigned char *) SvPVbyte(nonce, n_len);
19  
20 37 id = cryptx_internal_find_cipher(cipher_name);
21 37 ▶ if (id == -1) croak("FATAL: find_cipher failed for '%s'", cipher_name);
Branch: 1 branch
BranchTrueFalseTotal
if (id == -1) croak("FATAL: find_cipher failed for '%s'", cipher_name); 0 37 37
22  
23 37 Newz(0, RETVAL, 1, struct cryptx_authenc_ocb_struct);
24 37 ▶ if (!RETVAL) croak("FATAL: Newz failed");
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) croak("FATAL: Newz failed"); 0 37 37
25  
26 37 rv = ocb3_init(&RETVAL->state, id, k, (unsigned long)k_len, n, (unsigned long)n_len, taglen);
27 37 ▶ if (rv != CRYPT_OK) {
Branch: 1 branch
BranchTrueFalseTotal
if (rv != CRYPT_OK) { 0 37 37
28 0 zeromem(RETVAL, sizeof(*RETVAL));
29 0 Safefree(RETVAL);
30 0 croak("FATAL: ocb setup failed: %s", error_to_string(rv));
31 }
32 }
33 OUTPUT:
34 RETVAL
35  
36 void
37 DESTROY(Crypt::AuthEnc::OCB self)
38 CODE:
39 38 ▶ if (self) {
Branch: 1 branch
BranchTrueFalseTotal
if (self) { 38 0 38
40 38 zeromem(self, sizeof(*self));
41 38 Safefree(self);
42 }
43  
44 Crypt::AuthEnc::OCB
45 clone(Crypt::AuthEnc::OCB self)
46 CODE:
47 1 Newz(0, RETVAL, 1, struct cryptx_authenc_ocb_struct);
48 1 ▶ if (!RETVAL) croak("FATAL: Newz failed");
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) croak("FATAL: Newz failed"); 0 1 1
49 1 Copy(self, RETVAL, 1, struct cryptx_authenc_ocb_struct);
50 OUTPUT:
51 RETVAL
52  
53 void
54 adata_add(Crypt::AuthEnc::OCB self, SV * data)
55 PPCODE:
56 {
57 int rv;
58 STRLEN in_data_len;
59 unsigned char *in_data;
60  
61 37 ▶ if (self->finalized) croak("FATAL: AEAD object already finalized");
Branch: 1 branch
BranchTrueFalseTotal
if (self->finalized) croak("FATAL: AEAD object already finalized"); 0 37 37
62 37 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
63  
64 37 ▶ if (in_data_len>0) {
Branch: 1 branch
BranchTrueFalseTotal
if (in_data_len>0) { 25 12 37
65 25 rv = ocb3_add_aad(&self->state, in_data, (unsigned long)in_data_len);
66 25 ▶ if (rv != CRYPT_OK) croak("FATAL: ocb3_add_aad failed: %s", error_to_string(rv));
Branch: 1 branch
BranchTrueFalseTotal
if (rv != CRYPT_OK) croak("FATAL: ocb3_add_aad failed: %s", error_to_string(rv)); 0 25 25
67 }
68 37 ▶ XPUSHs(ST(0)); /* return self */
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(ST(0)); /* return self */ 0 37 37
69 }
70  
71 SV *
72 encrypt_add(Crypt::AuthEnc::OCB self, SV * data)
73 CODE:
74 {
75 int rv;
76 STRLEN in_data_len;
77 unsigned char *in_data, *out_data;
78  
79 3 ▶ if (self->finalized) croak("FATAL: AEAD object already finalized");
Branch: 1 branch
BranchTrueFalseTotal
if (self->finalized) croak("FATAL: AEAD object already finalized"); 1 2 3
80 2 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
81 2 ▶ if (in_data_len == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (in_data_len == 0) { 0 2 2
82 0 RETVAL = newSVpvn("", 0);
83 }
84 else {
85 2 ▶ if (in_data_len % 16) {
Branch: 1 branch
BranchTrueFalseTotal
if (in_data_len % 16) { 0 2 2
86 0 croak ("FATAL: sizeof(data) should be multiple of 16");
87 }
88 2 RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
89 2 SvPOK_only(RETVAL);
90 2 SvCUR_set(RETVAL, in_data_len);
91 2 *SvEND(RETVAL) = '\0';
92 2 out_data = (unsigned char *)SvPVX(RETVAL);
93 2 rv = ocb3_encrypt(&self->state, in_data, (unsigned long)in_data_len, out_data);
94 2 ▶ if (rv != CRYPT_OK) {
Branch: 1 branch
BranchTrueFalseTotal
if (rv != CRYPT_OK) { 0 2 2
95 0 SvREFCNT_dec(RETVAL);
96 0 croak("FATAL: ocb3_encrypt failed: %s", error_to_string(rv));
97 }
98 }
99 }
100 OUTPUT:
101 RETVAL
102  
103 SV *
104 encrypt_last(Crypt::AuthEnc::OCB self, SV * data)
105 CODE:
106 {
107 int rv;
108 STRLEN in_data_len;
109 unsigned char *in_data, *out_data;
110  
111 18 ▶ if (self->finalized) croak("FATAL: AEAD object already finalized");
Branch: 1 branch
BranchTrueFalseTotal
if (self->finalized) croak("FATAL: AEAD object already finalized"); 0 18 18
112 18 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
113 18 ▶ if (in_data_len == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (in_data_len == 0) { 6 12 18
114 6 rv = ocb3_encrypt_last(&self->state, in_data, 0, NULL);
115 6 ▶ if (rv != CRYPT_OK) {
Branch: 1 branch
BranchTrueFalseTotal
if (rv != CRYPT_OK) { 0 6 6
116 0 croak("FATAL: ocb3_encrypt_last failed: %s", error_to_string(rv));
117 }
118 6 RETVAL = newSVpvn("", 0);
119 }
120 else {
121 12 RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
122 12 SvPOK_only(RETVAL);
123 12 SvCUR_set(RETVAL, in_data_len);
124 12 *SvEND(RETVAL) = '\0';
125 12 out_data = (unsigned char *)SvPVX(RETVAL);
126 12 rv = ocb3_encrypt_last(&self->state, in_data, (unsigned long)in_data_len, out_data);
127 12 ▶ if (rv != CRYPT_OK) {
Branch: 1 branch
BranchTrueFalseTotal
if (rv != CRYPT_OK) { 0 12 12
128 0 SvREFCNT_dec(RETVAL);
129 0 croak("FATAL: ocb3_encrypt_last failed: %s", error_to_string(rv));
130 }
131 }
132 }
133 OUTPUT:
134 RETVAL
135  
136 SV *
137 decrypt_add(Crypt::AuthEnc::OCB self, SV * data)
138 CODE:
139 {
140 int rv;
141 STRLEN in_data_len;
142 unsigned char *in_data, *out_data;
143  
144 0 ▶ if (self->finalized) croak("FATAL: AEAD object already finalized");
Branch: 1 branch
BranchTrueFalseTotal
if (self->finalized) croak("FATAL: AEAD object already finalized"); 0 0 0
145 0 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
146 0 ▶ if (in_data_len == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (in_data_len == 0) { 0 0 0
147 0 RETVAL = newSVpvn("", 0);
148 }
149 else {
150 0 ▶ if (in_data_len % 16) {
Branch: 1 branch
BranchTrueFalseTotal
if (in_data_len % 16) { 0 0 0
151 0 croak ("FATAL: sizeof(data) should be multiple of 16");
152 }
153 0 RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
154 0 SvPOK_only(RETVAL);
155 0 SvCUR_set(RETVAL, in_data_len);
156 0 *SvEND(RETVAL) = '\0';
157 0 out_data = (unsigned char *)SvPVX(RETVAL);
158 0 rv = ocb3_decrypt(&self->state, in_data, (unsigned long)in_data_len, out_data);
159 0 ▶ if (rv != CRYPT_OK) {
Branch: 1 branch
BranchTrueFalseTotal
if (rv != CRYPT_OK) { 0 0 0
160 0 SvREFCNT_dec(RETVAL);
161 0 croak("FATAL: ocb3_decrypt failed: %s", error_to_string(rv));
162 }
163 }
164 }
165 OUTPUT:
166 RETVAL
167  
168 SV *
169 decrypt_last(Crypt::AuthEnc::OCB self, SV * data)
170 CODE:
171 {
172 int rv;
173 STRLEN in_data_len;
174 unsigned char *in_data, *out_data;
175  
176 18 ▶ if (self->finalized) croak("FATAL: AEAD object already finalized");
Branch: 1 branch
BranchTrueFalseTotal
if (self->finalized) croak("FATAL: AEAD object already finalized"); 0 18 18
177 18 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
178 18 ▶ if (in_data_len == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (in_data_len == 0) { 6 12 18
179 6 rv = ocb3_decrypt_last(&self->state, in_data, 0, NULL);
180 6 ▶ if (rv != CRYPT_OK) {
Branch: 1 branch
BranchTrueFalseTotal
if (rv != CRYPT_OK) { 0 6 6
181 0 croak("FATAL: ocb3_decrypt_last failed: %s", error_to_string(rv));
182 }
183 6 RETVAL = newSVpvn("", 0);
184 }
185 else {
186 12 RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
187 12 SvPOK_only(RETVAL);
188 12 SvCUR_set(RETVAL, in_data_len);
189 12 *SvEND(RETVAL) = '\0';
190 12 out_data = (unsigned char *)SvPVX(RETVAL);
191 12 rv = ocb3_decrypt_last(&self->state, in_data, (unsigned long)in_data_len, out_data);
192 12 ▶ if (rv != CRYPT_OK) {
Branch: 1 branch
BranchTrueFalseTotal
if (rv != CRYPT_OK) { 0 12 12
193 0 SvREFCNT_dec(RETVAL);
194 0 croak("FATAL: ocb3_decrypt_last failed: %s", error_to_string(rv));
195 }
196 }
197 }
198 OUTPUT:
199 RETVAL
200  
201 void
202 encrypt_done(Crypt::AuthEnc::OCB self)
203 PPCODE:
204 {
205 int rv;
206 unsigned char tag[MAXBLOCKSIZE];
207 21 unsigned long tag_len = sizeof(tag);
208  
209 21 ▶ if (self->finalized) croak("FATAL: AEAD object already finalized");
Branch: 1 branch
BranchTrueFalseTotal
if (self->finalized) croak("FATAL: AEAD object already finalized"); 1 20 21
210 20 rv = ocb3_done(&self->state, tag, &tag_len);
211 20 ▶ if (rv != CRYPT_OK) croak("FATAL: ocb3_done_encrypt failed: %s", error_to_string(rv));
Branch: 1 branch
BranchTrueFalseTotal
if (rv != CRYPT_OK) croak("FATAL: ocb3_done_encrypt failed: %s", error_to_string(rv)); 0 20 20
212 20 self->finalized = 1;
213  
214 20 ▶ XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len))); 0 20 20
215 20 zeromem(tag, sizeof(tag));
216 }
217  
218 void
219 decrypt_done(Crypt::AuthEnc::OCB self, ...)
220 PPCODE:
221 {
222 int rv;
223 unsigned char tag[MAXBLOCKSIZE];
224 18 unsigned long tag_len = sizeof(tag);
225 STRLEN expected_tag_len;
226 unsigned char *expected_tag;
227  
228 18 ▶ if (self->finalized) croak("FATAL: AEAD object already finalized");
Branch: 1 branch
BranchTrueFalseTotal
if (self->finalized) croak("FATAL: AEAD object already finalized"); 0 18 18
229 18 rv = ocb3_done(&self->state, tag, &tag_len);
230 18 ▶ if (rv != CRYPT_OK) croak("FATAL: ocb3_done_decrypt failed: %s", error_to_string(rv));
Branch: 1 branch
BranchTrueFalseTotal
if (rv != CRYPT_OK) croak("FATAL: ocb3_done_decrypt failed: %s", error_to_string(rv)); 0 18 18
231 18 self->finalized = 1;
232 18 ▶ if (items == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (items == 1) { 18 0 18
233 18 ▶ XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len))); 0 18 18
234 18 zeromem(tag, sizeof(tag));
235 }
236 else {
237 0 ▶ if (!SvPOK_spec(ST(1))) croak("FATAL: expected_tag must be string/buffer scalar");
Branch: 5 branches
BranchTrueFalseTotal
if (!SvPOK_spec(ST(1))) croak("FATAL: expected_tag must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(ST(1))) croak("FATAL: expected_tag must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(ST(1))) croak("FATAL: expected_tag must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(ST(1))) croak("FATAL: expected_tag must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(ST(1))) croak("FATAL: expected_tag must be string/buffer scalar"); 0 0 0
238 0 expected_tag = (unsigned char *) SvPVbyte(ST(1), expected_tag_len);
239 0 ▶ if (expected_tag_len!=tag_len) {
Branch: 1 branch
BranchTrueFalseTotal
if (expected_tag_len!=tag_len) { 0 0 0
240 0 ▶ XPUSHs(sv_2mortal(newSViv(0))); /* false */
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(0))); /* false */ 0 0 0
241 }
242 0 ▶ else if (mem_neq(expected_tag, tag, tag_len)) {
Branch: 1 branch
BranchTrueFalseTotal
else if (mem_neq(expected_tag, tag, tag_len)) { 0 0 0
243 0 ▶ XPUSHs(sv_2mortal(newSViv(0))); /* false */
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(0))); /* false */ 0 0 0
244 }
245 else {
246 0 ▶ XPUSHs(sv_2mortal(newSViv(1))); /* true */
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(1))); /* true */ 0 0 0
247 }
248 }
249 }
250  
251 void
252 ocb_encrypt_authenticate(char *cipher_name, SV *key, SV *nonce, SV *header, unsigned long tag_len, SV *plaintext)
253 PPCODE:
254 {
255 39 STRLEN k_len = 0, n_len = 0, h_len = 0, pt_len = 0;
256 39 unsigned char *k = NULL, *n = NULL, *h = NULL, *pt = NULL;
257 int rv, id;
258 unsigned char tag[MAXBLOCKSIZE];
259 SV *output;
260  
261 39 ▶ if (!SvPOK_spec(key)) croak("FATAL: key must be string/buffer scalar");
Branch: 5 branches
BranchTrueFalseTotal
if (!SvPOK_spec(key)) croak("FATAL: key must be string/buffer scalar"); 39 0 39
if (!SvPOK_spec(key)) croak("FATAL: key must be string/buffer scalar"); 0 39 39
if (!SvPOK_spec(key)) croak("FATAL: key must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(key)) croak("FATAL: key must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(key)) croak("FATAL: key must be string/buffer scalar"); 0 0 0
262 39 k = (unsigned char *) SvPVbyte(key, k_len);
263 39 ▶ if (!SvPOK_spec(nonce)) croak("FATAL: nonce must be string/buffer scalar");
Branch: 5 branches
BranchTrueFalseTotal
if (!SvPOK_spec(nonce)) croak("FATAL: nonce must be string/buffer scalar"); 39 0 39
if (!SvPOK_spec(nonce)) croak("FATAL: nonce must be string/buffer scalar"); 0 39 39
if (!SvPOK_spec(nonce)) croak("FATAL: nonce must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(nonce)) croak("FATAL: nonce must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(nonce)) croak("FATAL: nonce must be string/buffer scalar"); 0 0 0
264 39 n = (unsigned char *) SvPVbyte(nonce, n_len);
265 39 ▶ if (!SvPOK_spec(plaintext)) croak("FATAL: plaintext must be string/buffer scalar");
Branch: 5 branches
BranchTrueFalseTotal
if (!SvPOK_spec(plaintext)) croak("FATAL: plaintext must be string/buffer scalar"); 39 0 39
if (!SvPOK_spec(plaintext)) croak("FATAL: plaintext must be string/buffer scalar"); 0 39 39
if (!SvPOK_spec(plaintext)) croak("FATAL: plaintext must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(plaintext)) croak("FATAL: plaintext must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(plaintext)) croak("FATAL: plaintext must be string/buffer scalar"); 0 0 0
266 39 pt = (unsigned char *) SvPVbyte(plaintext, pt_len);
267 39 ▶ if (header && SvOK(header)) {
Branch: 2 branches
BranchTrueFalseTotal
if (header && SvOK(header)) { 39 0 39
if (header && SvOK(header)) { 39 0 39
268 39 ▶ if (!SvPOK_spec(header)) croak("FATAL: header must be string/buffer scalar");
Branch: 5 branches
BranchTrueFalseTotal
if (!SvPOK_spec(header)) croak("FATAL: header must be string/buffer scalar"); 39 0 39
if (!SvPOK_spec(header)) croak("FATAL: header must be string/buffer scalar"); 0 39 39
if (!SvPOK_spec(header)) croak("FATAL: header must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(header)) croak("FATAL: header must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(header)) croak("FATAL: header must be string/buffer scalar"); 0 0 0
269 39 h = (unsigned char *) SvPVbyte(header, h_len);
270 39 zeromem(tag, sizeof(tag));
271 }
272  
273 39 id = cryptx_internal_find_cipher(cipher_name);
274 39 ▶ if(id==-1) croak("FATAL: find_cipher failed for '%s'", cipher_name);
Branch: 1 branch
BranchTrueFalseTotal
if(id==-1) croak("FATAL: find_cipher failed for '%s'", cipher_name); 0 39 39
275 39 ▶ output = NEWSV(0, pt_len > 0 ? pt_len : 1); /* avoid zero! */
Branch: 1 branch
BranchTrueFalseTotal
output = NEWSV(0, pt_len > 0 ? pt_len : 1); /* avoid zero! */ 39 0 39
276 39 SvPOK_only(output);
277 39 SvCUR_set(output, pt_len);
278 39 *SvEND(output) = '\0';
279 39 ▶ if(tag_len < 4 || tag_len > 16) tag_len = 16;
Branch: 2 branches
BranchTrueFalseTotal
if(tag_len < 4 || tag_len > 16) tag_len = 16; 35 4 39
if(tag_len < 4 || tag_len > 16) tag_len = 16; 0 35 35
280  
281 39 rv = ocb3_encrypt_authenticate_memory(id, k, (unsigned long)k_len, n, (unsigned long)n_len,
282 h, (unsigned long)h_len, pt, (unsigned long)pt_len,
283 39 (unsigned char *)SvPVX(output), tag, &tag_len);
284  
285 39 ▶ if (rv != CRYPT_OK) {
Branch: 1 branch
BranchTrueFalseTotal
if (rv != CRYPT_OK) { 0 39 39
286 0 SvREFCNT_dec(output);
287 0 croak("FATAL: ocb3_encrypt_authenticate_memory failed: %s", error_to_string(rv));
288 }
289 39 ▶ XPUSHs(sv_2mortal(output));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(output)); 0 39 39
290 39 ▶ XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len))); 0 39 39
291 }
292  
293 void
294 ocb_decrypt_verify(char *cipher_name, SV *key, SV *nonce, SV *header, SV *ciphertext, SV *tagsv)
295 PPCODE:
296 {
297 31 STRLEN k_len = 0, n_len = 0, h_len = 0, ct_len = 0, t_len = 0;
298 31 unsigned char *k = NULL, *n = NULL, *h = NULL, *ct = NULL, *t = NULL;
299 31 int rv, id, stat = 0;
300 SV *output;
301  
302 31 ▶ if (!SvPOK_spec(key)) croak("FATAL: key must be string/buffer scalar");
Branch: 5 branches
BranchTrueFalseTotal
if (!SvPOK_spec(key)) croak("FATAL: key must be string/buffer scalar"); 31 0 31
if (!SvPOK_spec(key)) croak("FATAL: key must be string/buffer scalar"); 0 31 31
if (!SvPOK_spec(key)) croak("FATAL: key must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(key)) croak("FATAL: key must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(key)) croak("FATAL: key must be string/buffer scalar"); 0 0 0
303 31 k = (unsigned char *) SvPVbyte(key, k_len);
304 31 ▶ if (!SvPOK_spec(nonce)) croak("FATAL: nonce must be string/buffer scalar");
Branch: 5 branches
BranchTrueFalseTotal
if (!SvPOK_spec(nonce)) croak("FATAL: nonce must be string/buffer scalar"); 31 0 31
if (!SvPOK_spec(nonce)) croak("FATAL: nonce must be string/buffer scalar"); 0 31 31
if (!SvPOK_spec(nonce)) croak("FATAL: nonce must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(nonce)) croak("FATAL: nonce must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(nonce)) croak("FATAL: nonce must be string/buffer scalar"); 0 0 0
305 31 n = (unsigned char *) SvPVbyte(nonce, n_len);
306 31 ▶ if (!SvPOK_spec(ciphertext)) croak("FATAL: ciphertext must be string/buffer scalar");
Branch: 5 branches
BranchTrueFalseTotal
if (!SvPOK_spec(ciphertext)) croak("FATAL: ciphertext must be string/buffer scalar"); 31 0 31
if (!SvPOK_spec(ciphertext)) croak("FATAL: ciphertext must be string/buffer scalar"); 0 31 31
if (!SvPOK_spec(ciphertext)) croak("FATAL: ciphertext must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(ciphertext)) croak("FATAL: ciphertext must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(ciphertext)) croak("FATAL: ciphertext must be string/buffer scalar"); 0 0 0
307 31 ct = (unsigned char *) SvPVbyte(ciphertext, ct_len);
308 31 ▶ if (!SvPOK_spec(tagsv)) croak("FATAL: tag must be string/buffer scalar");
Branch: 5 branches
BranchTrueFalseTotal
if (!SvPOK_spec(tagsv)) croak("FATAL: tag must be string/buffer scalar"); 31 0 31
if (!SvPOK_spec(tagsv)) croak("FATAL: tag must be string/buffer scalar"); 0 31 31
if (!SvPOK_spec(tagsv)) croak("FATAL: tag must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(tagsv)) croak("FATAL: tag must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(tagsv)) croak("FATAL: tag must be string/buffer scalar"); 0 0 0
309 31 t = (unsigned char *) SvPVbyte(tagsv, t_len);
310 31 ▶ if (header && SvOK(header)) {
Branch: 2 branches
BranchTrueFalseTotal
if (header && SvOK(header)) { 31 0 31
if (header && SvOK(header)) { 31 0 31
311 31 ▶ if (!SvPOK_spec(header)) croak("FATAL: header must be string/buffer scalar");
Branch: 5 branches
BranchTrueFalseTotal
if (!SvPOK_spec(header)) croak("FATAL: header must be string/buffer scalar"); 31 0 31
if (!SvPOK_spec(header)) croak("FATAL: header must be string/buffer scalar"); 0 31 31
if (!SvPOK_spec(header)) croak("FATAL: header must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(header)) croak("FATAL: header must be string/buffer scalar"); 0 0 0
if (!SvPOK_spec(header)) croak("FATAL: header must be string/buffer scalar"); 0 0 0
312 31 h = (unsigned char *) SvPVbyte(header, h_len);
313 }
314  
315 31 id = cryptx_internal_find_cipher(cipher_name);
316 31 ▶ if(id==-1) croak("FATAL: find_cipher failed for '%s'", cipher_name);
Branch: 1 branch
BranchTrueFalseTotal
if(id==-1) croak("FATAL: find_cipher failed for '%s'", cipher_name); 0 31 31
317 31 ▶ output = NEWSV(0, ct_len > 0 ? ct_len : 1); /* avoid zero! */
Branch: 1 branch
BranchTrueFalseTotal
output = NEWSV(0, ct_len > 0 ? ct_len : 1); /* avoid zero! */ 31 0 31
318 31 SvPOK_only(output);
319 31 SvCUR_set(output, ct_len);
320 31 *SvEND(output) = '\0';
321  
322 31 rv = ocb3_decrypt_verify_memory(id, k, (unsigned long)k_len, n, (unsigned long)n_len,
323 h, (unsigned long)h_len, ct, (unsigned long)ct_len,
324 31 (unsigned char *)SvPVX(output), t, (unsigned long)t_len, &stat);
325  
326 31 ▶ if (rv != CRYPT_OK || stat != 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (rv != CRYPT_OK || stat != 1) { 31 0 31
if (rv != CRYPT_OK || stat != 1) { 2 29 31
327 2 SvREFCNT_dec(output);
328 2 ▶ XPUSHs(sv_2mortal(newSVpvn(NULL,0))); /* undef */
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpvn(NULL,0))); /* undef */ 0 2 2
329 }
330 else {
331 29 ▶ XPUSHs(sv_2mortal(output));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(output)); 0 29 29
332 }
333 }
« inc/CryptX_PK_X448.xs.inc ↑ Summary inc/CryptX_AuthEnc_CCM.xs.inc »