Branch Coverage

inc/CryptX_Mode_CBC.xs.inc
Criterion Covered Total %
branch 100 148 67.5


line true false branch
12 0 144 if (!RETVAL) croak("FATAL: Newz failed");
18 0 144 if (RETVAL->cipher_id == -1) {
43 0 339 if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
44 339 0 k = (unsigned char *) SvPVbyte(key, k_len);
46 0 339 if (!SvPOK(iv)) croak("FATAL: iv must be string/buffer scalar");
47 339 0 i = (unsigned char *) SvPVbyte(iv, i_len);
48 0 339 if (i_len != (STRLEN)cipher_descriptor[self->cipher_id].block_length) {
52 0 339 if (rv != CRYPT_OK) {
56 153 186 self->direction = ix == 1 ? 1 : -1;
58 0 339 XPUSHs(ST(0)); /* return self */
71 3505 3505 for (j = 1; j < items; j++) {
72 141 3364 in_data = (unsigned char *)SvPVbyte(ST(j), in_data_len);
76 3505 0 if (in_data_len > 0) {
77 1681 1824 if (self->direction == 1) {
79 1360 321 if (self->padlen > 0) {
81 585 775 if (in_data_len >= i) { /* enough data to fill pad */
86 0 585 if (rv != CRYPT_OK) {
101 758 923 if (in_data_len > 0 && i > 0) { /* save tail of data into pad */
671 87 if (in_data_len > 0 && i > 0) { /* save tail of data into pad */
107 246 1435 if (in_data_len > 0) {
108 96 150 i = (unsigned long)(has_tmp_block ? in_data_len + blen : in_data_len);
109 246 0 out_data = (unsigned char*)SvGROW(RETVAL, out_len + i + 1) + out_len;
246 0 out_data = (unsigned char*)SvGROW(RETVAL, out_len + i + 1) + out_len;
111 96 150 if (has_tmp_block) {
116 0 246 if (rv != CRYPT_OK) {
121 489 946 else if (has_tmp_block) {
122 489 0 out_data = (unsigned char*)SvGROW(RETVAL, out_len + blen + 1) + out_len;
489 0 out_data = (unsigned char*)SvGROW(RETVAL, out_len + blen + 1) + out_len;
127 1824 0 else if (self->direction == -1) {
128 116 1708 if (self->padlen == blen) {
130 0 116 if (rv != CRYPT_OK) {
137 1470 238 else if (self->padlen > 0) {
139 633 837 if (in_data_len >= i) { /* enough data to fill pad */
144 196 437 if (in_data_len>0 || self->padding_mode == 0) {
64 132 if (in_data_len>0 || self->padding_mode == 0) {
146 0 501 if (rv != CRYPT_OK) {
162 791 1033 if (in_data_len>0) {
164 633 158 if (i>0) { /* save tail of data into pad */
171 297 1527 if (in_data_len>0) {
172 158 139 if (self->padlen == 0 && self->padding_mode !=0) {
107 51 if (self->padlen == 0 && self->padding_mode !=0) {
178 142 155 i = (unsigned long)(has_tmp_block ? in_data_len + blen : in_data_len);
179 295 2 if (i > 0) {
180 295 0 out_data = (unsigned char*)SvGROW(RETVAL, out_len + i + 1) + out_len;
295 0 out_data = (unsigned char*)SvGROW(RETVAL, out_len + i + 1) + out_len;
182 142 153 if (has_tmp_block) {
187 0 295 if (rv != CRYPT_OK) {
193 475 1052 else if (has_tmp_block) {
194 475 0 out_data = (unsigned char*)SvGROW(RETVAL, out_len + blen + 1) + out_len;
475 0 out_data = (unsigned char*)SvGROW(RETVAL, out_len + blen + 1) + out_len;
205 1505 2000 if (out_len > 0) SvCUR_set(RETVAL, out_len);
219 153 186 if (self->direction == 1) {
220 153 0 if (self->padlen < 0 || self->padlen >= (int)blen) croak("FATAL: invalid padlen");
0 153 if (self->padlen < 0 || self->padlen >= (int)blen) croak("FATAL: invalid padlen");
221 90 63 if (self->padding_mode != 0) {
222 45 45 if (self->padding_mode == 1) { padmode = LTC_PAD_PKCS7 | (&self->state)->blocklen; }
223 45 0 else if (self->padding_mode == 2) { padmode = LTC_PAD_ONE_AND_ZERO | (&self->state)->blocklen; }
224 0 0 else if (self->padding_mode == 3) { padmode = LTC_PAD_ANSI_X923 | (&self->state)->blocklen; }
225 0 0 else if (self->padding_mode == 4) { padmode = LTC_PAD_ZERO | (&self->state)->blocklen; }
226 0 0 else if (self->padding_mode == 5) { padmode = LTC_PAD_ZERO_ALWAYS | (&self->state)->blocklen; }
230 0 90 if (rv != CRYPT_OK) croak("FATAL: padding_pad failed: %s", error_to_string(rv));
232 0 90 if (rv != CRYPT_OK) croak("FATAL: cbc_encrypt failed: %s", error_to_string(rv));
235 0 63 if (self->padlen > 0) croak("FATAL: cbc_encrypt, input data length not multiple of %d", (int)blen);
239 186 0 else if (self->direction == -1) {
240 123 63 if (self->padlen > 0) {
241 0 123 if (self->padlen != (int)blen) croak("FATAL: cipher text length has to be multiple of %d (%d)", (int)blen, self->padlen);
243 0 123 if (rv != CRYPT_OK) croak("FATAL: cbc_decrypt failed: %s", error_to_string(rv));
244 123 0 if (self->padding_mode != 0) {
245 78 45 if (self->padding_mode == 1) { padmode = LTC_PAD_PKCS7 | (&self->state)->blocklen; }
246 45 0 else if (self->padding_mode == 2) { padmode = LTC_PAD_ONE_AND_ZERO | (&self->state)->blocklen; }
247 0 0 else if (self->padding_mode == 3) { padmode = LTC_PAD_ANSI_X923 | (&self->state)->blocklen; }
248 0 0 else if (self->padding_mode == 4) { padmode = LTC_PAD_ZERO | (&self->state)->blocklen; }
249 0 0 else if (self->padding_mode == 5) { padmode = LTC_PAD_ZERO_ALWAYS | (&self->state)->blocklen; }
252 0 123 if (rv != CRYPT_OK) croak("FATAL: padding_depad failed: %s", error_to_string(rv));