| line |
true |
false |
branch |
|
57
|
196896 |
12306 |
for (i = 0; i < 16; i++) { |
|
63
|
787584 |
12306 |
for (i = 16; i < 80; i++) { |
|
69
|
984480 |
12306 |
for (i = 0; i < 80; i++) { |
|
70
|
246120 |
738360 |
if (i < 20) { |
|
73
|
246120 |
492240 |
} else if (i < 40) { |
|
76
|
246120 |
246120 |
} else if (i < 60) { |
|
100
|
12294 |
24570 |
if (len >= part_len) { |
|
104
|
12 |
12294 |
for (j = part_len; j + 63 < len; j += 64) { |
|
123
|
12288 |
0 |
pad_len = (i < 56) ? (56 - i) : (120 - i); |
|
127
|
98304 |
12288 |
for (j = 0; j < 8; j++) { |
|
132
|
61440 |
12288 |
for (j = 0; j < 5; j++) { |
|
189
|
0 |
4 |
if (S_len == 0) S_len = v; |
|
191
|
0 |
4 |
if (!S) return; |
|
192
|
256 |
4 |
for (i = 0; i < S_len; i++) { |
|
193
|
256 |
0 |
S[i] = salt_len > 0 ? salt[i % salt_len] : 0; |
|
197
|
4 |
0 |
pwd_len = password ? strlen(password) : 0; |
|
200
|
0 |
4 |
if (P_len == 0) P_len = v; |
|
202
|
0 |
4 |
if (!P) { free(S); return; } |
|
204
|
32 |
4 |
for (i = 0; i < pwd_len; i++) { |
|
213
|
184 |
4 |
for (i = P_raw_len; i < P_len; i++) { |
|
220
|
0 |
4 |
if (!I) { free(S); free(P); return; } |
|
230
|
4 |
0 |
if (!A || !B || !DI) { |
|
|
4 |
0 |
if (!A || !B || !DI) { |
|
|
0 |
4 |
if (!A || !B || !DI) { |
|
232
|
0 |
0 |
if (A) free(A); |
|
233
|
0 |
0 |
if (B) free(B); |
|
234
|
0 |
0 |
if (DI) free(DI); |
|
238
|
6 |
0 |
while (produced < output_len) { |
|
244
|
12282 |
6 |
for (j = 1; j < iterations; j++) { |
|
250
|
2 |
4 |
if (to_copy > (size_t)u) to_copy = u; |
|
254
|
4 |
2 |
if (produced >= output_len) break; |
|
257
|
128 |
2 |
for (j = 0; j < v; j++) { |
|
262
|
4 |
2 |
for (jj = 0; jj < I_len; jj += v) { |
|
265
|
256 |
4 |
for (k = v - 1; k >= 0; k--) { |
|
357
|
624384 |
13008 |
for (i = 0; i < 48; i++) { |
|
363
|
78048 |
13008 |
for (i = 0; i < 6; i++) E[i] ^= K[i]; |
|
366
|
104064 |
13008 |
for (i = 0; i < 8; i++) { |
|
374
|
416256 |
13008 |
for (i = 0; i < 32; i++) { |
|
392
|
336 |
6 |
for (i = 0; i < 56; i++) { |
|
400
|
96 |
6 |
for (round = 0; round < 16; round++) { |
|
402
|
168 |
96 |
for (i = 0; i < DES_SHIFTS[round]; i++) { |
|
409
|
4608 |
96 |
for (i = 0; i < 48; i++) { |
|
411
|
2302 |
2306 |
if (bit) { |
|
433
|
52032 |
813 |
for (i = 0; i < 64; i++) { |
|
442
|
13008 |
813 |
for (i = 0; i < 16; i++) { |
|
443
|
8672 |
4336 |
round = decrypt ? (15 - i) : i; |
|
452
|
52032 |
813 |
for (i = 0; i < 64; i++) { |
|
454
|
26041 |
25991 |
if (bit) |
|
492
|
271 |
2 |
for (i = 0; i < len; i += 8) { |
|
500
|
2168 |
271 |
for (j = 0; j < 8; j++) |
|
538
|
0 |
0 |
for (i = 0; i < src_len && out < dst_len; i++) { |
|
|
0 |
0 |
for (i = 0; i < src_len && out < dst_len; i++) { |
|
540
|
0 |
0 |
if (val == -1) continue; |
|
541
|
0 |
0 |
if (val == -2) break; |
|
546
|
0 |
0 |
if (bits >= 8) { |
|
583
|
1 |
0 |
if (!arena || !data || len == 0) return NULL; |
|
|
1 |
0 |
if (!arena || !data || len == 0) return NULL; |
|
|
0 |
1 |
if (!arena || !data || len == 0) return NULL; |
|
587
|
0 |
1 |
if (!pdfmake_asn1_is_sequence(root)) { |
|
601
|
1 |
0 |
if (!version || !alg || !key_data) return NULL; |
|
|
1 |
0 |
if (!version || !alg || !key_data) return NULL; |
|
|
0 |
1 |
if (!version || !alg || !key_data) return NULL; |
|
605
|
0 |
1 |
if (!oid_node) return NULL; |
|
608
|
0 |
1 |
if (!oid) return NULL; |
|
612
|
0 |
1 |
if (!key) return NULL; |
|
617
|
1 |
0 |
if (key->pkcs8_der) { |
|
622
|
1 |
0 |
if (strcmp(oid, OID_RSA_ENCRYPTION) == 0) { |
|
626
|
1 |
0 |
if (key_data->tag == ASN1_TAG_OCTET_STRING) { |
|
631
|
1 |
0 |
if (pdfmake_asn1_is_sequence(rsa_key)) { |
|
642
|
1 |
0 |
if (n && e && d) { |
|
|
1 |
0 |
if (n && e && d) { |
|
|
1 |
0 |
if (n && e && d) { |
|
644
|
1 |
0 |
if (key->rsa.modulus) { |
|
650
|
1 |
0 |
if (key->rsa.public_exponent) { |
|
656
|
1 |
0 |
if (key->rsa.private_exponent) { |
|
661
|
1 |
0 |
if (p) { |
|
663
|
1 |
0 |
if (key->rsa.prime1) { |
|
669
|
1 |
0 |
if (q) { |
|
671
|
1 |
0 |
if (key->rsa.prime2) { |
|
679
|
0 |
0 |
} else if (strcmp(oid, OID_EC_PUBLIC_KEY) == 0) { |
|
684
|
0 |
0 |
if (param && param->tag == ASN1_TAG_OID) { |
|
|
0 |
0 |
if (param && param->tag == ASN1_TAG_OID) { |
|
687
|
0 |
0 |
if (pdfmake_asn1_oid_equals(param, OID_SECP256R1)) { |
|
689
|
0 |
0 |
} else if (pdfmake_asn1_oid_equals(param, OID_SECP384R1)) { |
|
691
|
0 |
0 |
} else if (pdfmake_asn1_oid_equals(param, OID_SECP521R1)) { |
|
697
|
0 |
0 |
if (key_data->tag == ASN1_TAG_OCTET_STRING) { |
|
702
|
0 |
0 |
if (pdfmake_asn1_is_sequence(ec_key)) { |
|
710
|
0 |
0 |
if (priv && priv->tag == ASN1_TAG_OCTET_STRING) { |
|
|
0 |
0 |
if (priv && priv->tag == ASN1_TAG_OCTET_STRING) { |
|
712
|
0 |
0 |
if (key->ecdsa.private_value) { |
|
720
|
0 |
0 |
while (child) { |
|
721
|
0 |
0 |
if ((child->tag & ASN1_CLASS_MASK) == ASN1_CLASS_CONTEXT && |
|
722
|
0 |
0 |
(child->tag & 0x1F) == 1) { |
|
725
|
0 |
0 |
if (pub && pub->tag == ASN1_TAG_BIT_STRING) { |
|
|
0 |
0 |
if (pub && pub->tag == ASN1_TAG_BIT_STRING) { |
|
728
|
0 |
0 |
if (pdfmake_asn1_get_bit_string(pub, &bits, &bit_count) == 0) { |
|
730
|
0 |
0 |
if (key->ecdsa.public_point) { |
|
762
|
0 |
0 |
if (!arena || !pem || len == 0) return NULL; |
|
|
0 |
0 |
if (!arena || !pem || len == 0) return NULL; |
|
|
0 |
0 |
if (!arena || !pem || len == 0) return NULL; |
|
766
|
0 |
0 |
if (!begin) return NULL; |
|
770
|
0 |
0 |
if (!end) return NULL; |
|
774
|
0 |
0 |
if (!content_start) return NULL; |
|
779
|
0 |
0 |
if (strstr(begin, "ENCRYPTED") != NULL) { |
|
784
|
0 |
0 |
while (content_start < end && *content_start != '\n' && |
|
|
0 |
0 |
while (content_start < end && *content_start != '\n' && |
|
785
|
0 |
0 |
(content_start[0] == 'P' || content_start[0] == 'D')) { |
|
|
0 |
0 |
(content_start[0] == 'P' || content_start[0] == 'D')) { |
|
788
|
0 |
0 |
if (content_start) content_start++; |
|
792
|
0 |
0 |
if (content_start && *content_start == '\n') content_start++; |
|
|
0 |
0 |
if (content_start && *content_start == '\n') content_start++; |
|
798
|
0 |
0 |
if (!der) return NULL; |
|
801
|
0 |
0 |
if (der_len == 0) return NULL; |
|
803
|
0 |
0 |
if (is_encrypted && password) { |
|
|
0 |
0 |
if (is_encrypted && password) { |
|
821
|
0 |
0 |
if (!arena || !path) return NULL; |
|
|
0 |
0 |
if (!arena || !path) return NULL; |
|
824
|
0 |
0 |
if (!f) return NULL; |
|
830
|
0 |
0 |
if (size <= 0 || size > 1024 * 1024) { |
|
|
0 |
0 |
if (size <= 0 || size > 1024 * 1024) { |
|
836
|
0 |
0 |
if (!data) { |
|
841
|
0 |
0 |
if (fread(data, 1, size, f) != (size_t)size) { |
|
848
|
0 |
0 |
if (size > 10 && memcmp(data, "-----BEGIN", 10) == 0) { |
|
|
0 |
0 |
if (size > 10 && memcmp(data, "-----BEGIN", 10) == 0) { |
|
886
|
0 |
2 |
if (!pdfmake_asn1_is_sequence(params)) |
|
891
|
2 |
0 |
if (!salt_node || !iter_node) return NULL; |
|
|
0 |
2 |
if (!salt_node || !iter_node) return NULL; |
|
893
|
2 |
0 |
if (pdfmake_asn1_get_int64(iter_node, &iterations) != 0 || iterations <= 0) |
|
|
0 |
2 |
if (pdfmake_asn1_get_int64(iter_node, &iterations) != 0 || iterations <= 0) |
|
903
|
2 |
0 |
if (ct_len == 0 || ct_len % 8 != 0) return NULL; |
|
|
0 |
2 |
if (ct_len == 0 || ct_len % 8 != 0) return NULL; |
|
906
|
0 |
2 |
if (!plain) return NULL; |
|
912
|
2 |
0 |
if (pad == 0 || pad > 8) return NULL; |
|
|
0 |
2 |
if (pad == 0 || pad > 8) return NULL; |
|
913
|
13 |
2 |
for (i = 0; i < pad; i++) { |
|
914
|
0 |
13 |
if (plain[ct_len - 1 - i] != pad) return NULL; |
|
960
|
0 |
0 |
if (!pdfmake_asn1_is_sequence(params)) |
|
965
|
0 |
0 |
if (!kdf || !enc) return NULL; |
|
|
0 |
0 |
if (!kdf || !enc) return NULL; |
|
966
|
0 |
0 |
if (!pdfmake_asn1_is_sequence(kdf)) return NULL; |
|
967
|
0 |
0 |
if (!pdfmake_asn1_is_sequence(enc)) return NULL; |
|
971
|
0 |
0 |
if (!kdf_oid || !pdfmake_asn1_oid_equals(kdf_oid, OID_PBKDF2)) |
|
|
0 |
0 |
if (!kdf_oid || !pdfmake_asn1_oid_equals(kdf_oid, OID_PBKDF2)) |
|
977
|
0 |
0 |
if (!kdf_params) return NULL; |
|
981
|
0 |
0 |
if (!salt_node || !iter_node) return NULL; |
|
|
0 |
0 |
if (!salt_node || !iter_node) return NULL; |
|
983
|
0 |
0 |
if (pdfmake_asn1_get_int64(iter_node, &iterations) != 0) return NULL; |
|
987
|
0 |
0 |
if (!enc_oid) return NULL; |
|
990
|
0 |
0 |
if (!enc_oid_str) return NULL; |
|
992
|
0 |
0 |
if (strcmp(enc_oid_str, OID_AES256_CBC) == 0) key_len = 32; |
|
993
|
0 |
0 |
else if (strcmp(enc_oid_str, OID_AES192_CBC) == 0) key_len = 24; |
|
994
|
0 |
0 |
else if (strcmp(enc_oid_str, OID_AES128_CBC) == 0) key_len = 16; |
|
999
|
0 |
0 |
if (!enc_params || enc_params->tag != ASN1_TAG_OCTET_STRING || enc_params->length != 16) |
|
|
0 |
0 |
if (!enc_params || enc_params->tag != ASN1_TAG_OCTET_STRING || enc_params->length != 16) |
|
|
0 |
0 |
if (!enc_params || enc_params->tag != ASN1_TAG_OCTET_STRING || enc_params->length != 16) |
|
1005
|
0 |
0 |
pwd_len = password ? strlen(password) : 0; |
|
1013
|
0 |
0 |
while (dk_produced < key_len) { |
|
1018
|
0 |
0 |
for (j = 0; j < pwd_len && j < 64; j++) { |
|
|
0 |
0 |
for (j = 0; j < pwd_len && j < 64; j++) { |
|
1022
|
0 |
0 |
if (pwd_len > 64) { |
|
1027
|
0 |
0 |
for (j = 0; j < 20; j++) { |
|
1053
|
0 |
0 |
for (jj = 1; jj < iterations; jj++) { |
|
1066
|
0 |
0 |
for (k = 0; k < 20; k++) |
|
1071
|
0 |
0 |
if (to_copy > 20) to_copy = 20; |
|
1079
|
0 |
0 |
if (ct_len == 0 || ct_len % 16 != 0) return NULL; |
|
|
0 |
0 |
if (ct_len == 0 || ct_len % 16 != 0) return NULL; |
|
1082
|
0 |
0 |
if (!plain) return NULL; |
|
1086
|
0 |
0 |
if (plain_len < 0) return NULL; |
|
1105
|
0 |
2 |
if (!oid_node) return NULL; |
|
1108
|
0 |
2 |
if (!oid) return NULL; |
|
1110
|
0 |
2 |
if (strcmp(oid, OID_PBE_SHA1_3DES) == 0 || |
|
1111
|
0 |
0 |
strcmp(oid, OID_PBE_SHA1_2DES) == 0) { |
|
1114
|
0 |
0 |
} else if (strcmp(oid, OID_PBES2) == 0) { |
|
1146
|
0 |
2 |
if (!pdfmake_asn1_is_sequence(bag)) return; |
|
1150
|
2 |
0 |
if (!bag_oid || !bag_value_wrapper) return; |
|
|
0 |
2 |
if (!bag_oid || !bag_value_wrapper) return; |
|
1153
|
0 |
2 |
if (!oid) return; |
|
1157
|
0 |
2 |
if (!bag_value) return; |
|
1159
|
1 |
1 |
if (strcmp(oid, OID_PKCS12_SHROUDEDKEYBAG) == 0 && !identity->privkey) { |
|
|
1 |
0 |
if (strcmp(oid, OID_PKCS12_SHROUDEDKEYBAG) == 0 && !identity->privkey) { |
|
1163
|
0 |
1 |
if (!pdfmake_asn1_is_sequence(bag_value)) return; |
|
1167
|
1 |
0 |
if (!enc_alg || !enc_data) return; |
|
|
0 |
1 |
if (!enc_alg || !enc_data) return; |
|
1168
|
0 |
1 |
if (enc_data->tag != ASN1_TAG_OCTET_STRING) return; |
|
1173
|
1 |
0 |
if (plain && plain_len > 0) { |
|
|
1 |
0 |
if (plain && plain_len > 0) { |
|
1177
|
0 |
1 |
else if (strcmp(oid, OID_PKCS12_KEYBAG) == 0 && !identity->privkey) { |
|
|
0 |
0 |
else if (strcmp(oid, OID_PKCS12_KEYBAG) == 0 && !identity->privkey) { |
|
1179
|
0 |
0 |
if (pdfmake_asn1_is_sequence(bag_value)) { |
|
1191
|
1 |
0 |
else if (strcmp(oid, OID_PKCS12_CERTBAG) == 0 && !identity->cert) { |
|
|
1 |
0 |
else if (strcmp(oid, OID_PKCS12_CERTBAG) == 0 && !identity->cert) { |
|
1193
|
0 |
1 |
if (!pdfmake_asn1_is_sequence(bag_value)) return; |
|
1197
|
1 |
0 |
if (!cert_id || !cert_val_wrapper) return; |
|
|
0 |
1 |
if (!cert_id || !cert_val_wrapper) return; |
|
1200
|
0 |
1 |
if (!pdfmake_asn1_oid_equals(cert_id, OID_CERT_X509)) return; |
|
1204
|
1 |
0 |
if (!cert_octet || cert_octet->tag != ASN1_TAG_OCTET_STRING) return; |
|
|
0 |
1 |
if (!cert_octet || cert_octet->tag != ASN1_TAG_OCTET_STRING) return; |
|
1225
|
0 |
2 |
if (!pdfmake_asn1_is_sequence(safe_contents)) |
|
1229
|
2 |
2 |
for (bag = safe_contents->children; bag; bag = bag->next) { |
|
1268
|
1 |
0 |
if (!arena || !data || len == 0) return NULL; |
|
|
1 |
0 |
if (!arena || !data || len == 0) return NULL; |
|
|
0 |
1 |
if (!arena || !data || len == 0) return NULL; |
|
1277
|
0 |
1 |
if (!pdfmake_asn1_is_sequence(pfx)) |
|
1282
|
1 |
0 |
if (!version || !auth_safe) return NULL; |
|
|
0 |
1 |
if (!version || !auth_safe) return NULL; |
|
1284
|
1 |
0 |
if (pdfmake_asn1_get_int64(version, &ver) != 0 || ver != 3) |
|
|
0 |
1 |
if (pdfmake_asn1_get_int64(version, &ver) != 0 || ver != 3) |
|
1288
|
0 |
1 |
if (!pdfmake_asn1_is_sequence(auth_safe)) |
|
1293
|
1 |
0 |
if (!content_type || !content) return NULL; |
|
|
0 |
1 |
if (!content_type || !content) return NULL; |
|
1295
|
0 |
1 |
if (!pdfmake_asn1_oid_equals(content_type, OID_PKCS7_DATA)) |
|
1300
|
1 |
0 |
if (!octet_string || octet_string->tag != ASN1_TAG_OCTET_STRING) |
|
|
0 |
1 |
if (!octet_string || octet_string->tag != ASN1_TAG_OCTET_STRING) |
|
1308
|
0 |
1 |
if (!pdfmake_asn1_is_sequence(auth_safe_seq)) |
|
1314
|
0 |
1 |
if (!identity) return NULL; |
|
1319
|
2 |
1 |
for (ci = auth_safe_seq->children; ci; ci = ci->next) { |
|
1320
|
0 |
2 |
if (!pdfmake_asn1_is_sequence(ci)) continue; |
|
1324
|
2 |
0 |
if (!ci_type || !ci_content) continue; |
|
|
0 |
2 |
if (!ci_type || !ci_content) continue; |
|
1327
|
0 |
2 |
if (!ci_oid) continue; |
|
1329
|
1 |
1 |
if (strcmp(ci_oid, OID_PKCS7_DATA) == 0) { |
|
1332
|
1 |
0 |
if (!os || os->tag != ASN1_TAG_OCTET_STRING) continue; |
|
|
0 |
1 |
if (!os || os->tag != ASN1_TAG_OCTET_STRING) continue; |
|
1337
|
1 |
0 |
else if (strcmp(ci_oid, OID_PKCS7_ENCRYPTED) == 0) { |
|
1347
|
0 |
1 |
if (!pdfmake_asn1_is_sequence(ed)) |
|
1353
|
0 |
1 |
if (!pdfmake_asn1_is_sequence(eci)) |
|
1360
|
1 |
0 |
if (!eci_alg || !eci_data) continue; |
|
|
0 |
1 |
if (!eci_alg || !eci_data) continue; |
|
1368
|
1 |
0 |
if (plain && plain_len > 0) { |
|
|
1 |
0 |
if (plain && plain_len > 0) { |
|
1376
|
0 |
1 |
if (!identity->privkey && !identity->cert) |
|
|
0 |
0 |
if (!identity->privkey && !identity->cert) |
|
1391
|
0 |
0 |
if (!arena || !path) return NULL; |
|
|
0 |
0 |
if (!arena || !path) return NULL; |
|
1394
|
0 |
0 |
if (!f) return NULL; |
|
1400
|
0 |
0 |
if (size <= 0 || size > 10 * 1024 * 1024) { /* Max 10MB */ |
|
|
0 |
0 |
if (size <= 0 || size > 10 * 1024 * 1024) { /* Max 10MB */ |
|
1406
|
0 |
0 |
if (!data) { |
|
1411
|
0 |
0 |
if (fread(data, 1, size, f) != (size_t)size) { |
|
1428
|
0 |
0 |
if (!arena || !key || !cert) return NULL; |
|
|
0 |
0 |
if (!arena || !key || !cert) return NULL; |
|
|
0 |
0 |
if (!arena || !key || !cert) return NULL; |
|
1431
|
0 |
0 |
if (!identity) return NULL; |
|
1443
|
0 |
0 |
if (!key) return 0; |
|
1448
|
0 |
0 |
if (key->rsa.modulus && key->rsa.modulus_len > 0) { |
|
|
0 |
0 |
if (key->rsa.modulus && key->rsa.modulus_len > 0) { |
|
1452
|
0 |
0 |
if (len > 0 && mod[0] == 0) { |
|
|
0 |
0 |
if (len > 0 && mod[0] == 0) { |
|
1474
|
0 |
0 |
if (!key || !cert) return 0; |
|
|
0 |
0 |
if (!key || !cert) return 0; |
|
1477
|
0 |
0 |
if (key->algorithm != cert->pubkey.algorithm) return 0; |
|
1482
|
0 |
0 |
if (key->rsa.modulus_len != cert->pubkey.rsa.modulus_len) return 0; |
|
1484
|
0 |
0 |
key->rsa.modulus_len) != 0) return 0; |
|
1489
|
0 |
0 |
if (key->ecdsa.curve_bits != cert->pubkey.ecdsa.curve_bits) return 0; |
|
1502
|
0 |
1 |
if (!key) return; |
|
1505
|
1 |
0 |
if (key->algorithm == PDFMAKE_PK_RSA) { |
|
1506
|
1 |
0 |
if (key->rsa.private_exponent) { |
|
1509
|
1 |
0 |
if (key->rsa.prime1) { |
|
1512
|
1 |
0 |
if (key->rsa.prime2) { |
|
1515
|
0 |
0 |
} else if (key->algorithm == PDFMAKE_PK_ECDSA) { |
|
1516
|
0 |
0 |
if (key->ecdsa.private_value) { |
|
1521
|
1 |
0 |
if (key->pkcs8_der) { |
|
1530
|
0 |
1 |
if (!id) return; |
|
1532
|
1 |
0 |
if (id->privkey) { |