| line |
true |
false |
branch |
|
13
|
0 |
3 |
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar"); |
|
14
|
3 |
0 |
k = (unsigned char *) SvPVbyte(key, k_len); |
|
15
|
3 |
0 |
if (nonce) { |
|
16
|
0 |
3 |
if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar"); |
|
17
|
3 |
0 |
iv = (unsigned char *) SvPVbyte(nonce, iv_len); |
|
21
|
0 |
3 |
if (!RETVAL) croak("FATAL: Newz failed"); |
|
24
|
0 |
3 |
if (rv != CRYPT_OK) { |
|
29
|
3 |
0 |
if (iv && iv_len > 0) { |
|
|
3 |
0 |
if (iv && iv_len > 0) { |
|
31
|
0 |
3 |
if (rv != CRYPT_OK) { |
|
49
|
0 |
0 |
if (!RETVAL) croak("FATAL: Newz failed"); |
|
62
|
0 |
0 |
if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar"); |
|
63
|
0 |
0 |
iv = (unsigned char *) SvPVbyte(nonce, iv_len); |
|
65
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_setiv failed: %s", error_to_string(rv)); |
|
66
|
0 |
0 |
XPUSHs(ST(0)); /* return self */; |
|
77
|
0 |
0 |
if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar"); |
|
78
|
0 |
0 |
iv = (unsigned char *) SvPVbyte(nonce, iv_len); |
|
80
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_setiv_rfc7905 failed: %s", error_to_string(rv)); |
|
81
|
0 |
0 |
XPUSHs(ST(0)); /* return self */ |
|
92
|
3 |
0 |
in_data = (unsigned char *)SvPVbyte(data, in_data_len); |
|
94
|
0 |
3 |
if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_add_aad failed: %s", error_to_string(rv)); |
|
95
|
0 |
3 |
XPUSHs(ST(0)); /* return self */ |
|
106
|
1 |
20 |
in_data = (unsigned char *)SvPVbyte(data, in_data_len); |
|
107
|
0 |
21 |
if (in_data_len == 0) { |
|
116
|
0 |
21 |
if (rv != CRYPT_OK) { |
|
133
|
2 |
0 |
in_data = (unsigned char *)SvPVbyte(data, in_data_len); |
|
134
|
0 |
2 |
if (in_data_len == 0) { |
|
143
|
0 |
2 |
if (rv != CRYPT_OK) { |
|
161
|
0 |
1 |
if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_done failed: %s", error_to_string(rv)); |
|
162
|
0 |
1 |
XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len))); |
|
176
|
0 |
2 |
if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_done failed: %s", error_to_string(rv)); |
|
177
|
2 |
0 |
if (items == 1) { |
|
178
|
0 |
2 |
XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len))); |
|
181
|
0 |
0 |
if (!SvPOK(ST(1))) croak("FATAL: expected_tag must be string/buffer scalar"); |
|
182
|
0 |
0 |
expected_tag = (unsigned char *) SvPVbyte(ST(1), expected_tag_len); |
|
183
|
0 |
0 |
if (expected_tag_len!=tag_len) { |
|
184
|
0 |
0 |
XPUSHs(sv_2mortal(newSViv(0))); /* false */ |
|
186
|
0 |
0 |
else if (memNE(expected_tag, tag, tag_len)) { |
|
187
|
0 |
0 |
XPUSHs(sv_2mortal(newSViv(0))); /* false */ |
|
190
|
0 |
0 |
XPUSHs(sv_2mortal(newSViv(1))); /* true */ |
|
206
|
2 |
0 |
if (SvPOK(key)) k = (unsigned char *) SvPVbyte(key, k_len); |
|
|
2 |
0 |
if (SvPOK(key)) k = (unsigned char *) SvPVbyte(key, k_len); |
|
207
|
2 |
0 |
if (SvPOK(nonce)) n = (unsigned char *) SvPVbyte(nonce, n_len); |
|
|
2 |
0 |
if (SvPOK(nonce)) n = (unsigned char *) SvPVbyte(nonce, n_len); |
|
208
|
2 |
0 |
if (SvPOK(plaintext)) pt = (unsigned char *) SvPVbyte(plaintext, pt_len); |
|
|
2 |
0 |
if (SvPOK(plaintext)) pt = (unsigned char *) SvPVbyte(plaintext, pt_len); |
|
209
|
2 |
0 |
if (SvPOK(header)) h = (unsigned char *) SvPVbyte(header, h_len); |
|
|
2 |
0 |
if (SvPOK(header)) h = (unsigned char *) SvPVbyte(header, h_len); |
|
211
|
2 |
0 |
output = NEWSV(0, pt_len > 0 ? pt_len : 1); /* avoid zero! */ |
|
219
|
0 |
2 |
if (rv != CRYPT_OK) { |
|
223
|
0 |
2 |
XPUSHs(sv_2mortal(output)); |
|
224
|
0 |
2 |
XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len))); |
|
238
|
4 |
0 |
if (SvPOK(key)) k = (unsigned char *) SvPVbyte(key, k_len); |
|
|
4 |
0 |
if (SvPOK(key)) k = (unsigned char *) SvPVbyte(key, k_len); |
|
239
|
4 |
0 |
if (SvPOK(nonce)) n = (unsigned char *) SvPVbyte(nonce, n_len); |
|
|
4 |
0 |
if (SvPOK(nonce)) n = (unsigned char *) SvPVbyte(nonce, n_len); |
|
240
|
4 |
0 |
if (SvPOK(ciphertext)) ct = (unsigned char *) SvPVbyte(ciphertext, ct_len); |
|
|
4 |
0 |
if (SvPOK(ciphertext)) ct = (unsigned char *) SvPVbyte(ciphertext, ct_len); |
|
241
|
4 |
0 |
if (SvPOK(tagsv)) t = (unsigned char *) SvPVbyte(tagsv, t_len); |
|
|
4 |
0 |
if (SvPOK(tagsv)) t = (unsigned char *) SvPVbyte(tagsv, t_len); |
|
242
|
4 |
0 |
if (SvPOK(header)) h = (unsigned char *) SvPVbyte(header, h_len); |
|
|
4 |
0 |
if (SvPOK(header)) h = (unsigned char *) SvPVbyte(header, h_len); |
|
244
|
4 |
0 |
output = NEWSV(0, ct_len > 0 ? ct_len : 1); /* avoid zero! */ |
|
254
|
2 |
2 |
if (rv != CRYPT_OK) { |
|
256
|
0 |
2 |
XPUSHs(sv_2mortal(newSVpvn(NULL,0))); /* undef */ |
|
259
|
0 |
2 |
XPUSHs(sv_2mortal(output)); |