| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/asn1/x_x509.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | - | |||||||
| 4 | static const ASN1_AUX X509_CINF_aux = { | - | ||||||
| 5 | .flags = 2, | - | ||||||
| 6 | .enc_offset = | - | ||||||
| 7 | __builtin_offsetof ( | - | ||||||
| 8 | X509_CINF | - | ||||||
| 9 | , | - | ||||||
| 10 | enc | - | ||||||
| 11 | ) | - | ||||||
| 12 | , | - | ||||||
| 13 | }; | - | ||||||
| 14 | static const ASN1_TEMPLATE X509_CINF_seq_tt[] = { | - | ||||||
| 15 | { | - | ||||||
| 16 | .flags = (0x2 << 3)|(0x2<<6) | (0x1), | - | ||||||
| 17 | .offset = | - | ||||||
| 18 | __builtin_offsetof ( | - | ||||||
| 19 | X509_CINF | - | ||||||
| 20 | , | - | ||||||
| 21 | version | - | ||||||
| 22 | ) | - | ||||||
| 23 | , | - | ||||||
| 24 | .field_name = "version", | - | ||||||
| 25 | .item = &ASN1_INTEGER_it, | - | ||||||
| 26 | }, | - | ||||||
| 27 | { | - | ||||||
| 28 | .offset = | - | ||||||
| 29 | __builtin_offsetof ( | - | ||||||
| 30 | X509_CINF | - | ||||||
| 31 | , | - | ||||||
| 32 | serialNumber | - | ||||||
| 33 | ) | - | ||||||
| 34 | , | - | ||||||
| 35 | .field_name = "serialNumber", | - | ||||||
| 36 | .item = &ASN1_INTEGER_it, | - | ||||||
| 37 | }, | - | ||||||
| 38 | { | - | ||||||
| 39 | .offset = | - | ||||||
| 40 | __builtin_offsetof ( | - | ||||||
| 41 | X509_CINF | - | ||||||
| 42 | , | - | ||||||
| 43 | signature | - | ||||||
| 44 | ) | - | ||||||
| 45 | , | - | ||||||
| 46 | .field_name = "signature", | - | ||||||
| 47 | .item = &X509_ALGOR_it, | - | ||||||
| 48 | }, | - | ||||||
| 49 | { | - | ||||||
| 50 | .offset = | - | ||||||
| 51 | __builtin_offsetof ( | - | ||||||
| 52 | X509_CINF | - | ||||||
| 53 | , | - | ||||||
| 54 | issuer | - | ||||||
| 55 | ) | - | ||||||
| 56 | , | - | ||||||
| 57 | .field_name = "issuer", | - | ||||||
| 58 | .item = &X509_NAME_it, | - | ||||||
| 59 | }, | - | ||||||
| 60 | { | - | ||||||
| 61 | .offset = | - | ||||||
| 62 | __builtin_offsetof ( | - | ||||||
| 63 | X509_CINF | - | ||||||
| 64 | , | - | ||||||
| 65 | validity | - | ||||||
| 66 | ) | - | ||||||
| 67 | , | - | ||||||
| 68 | .field_name = "validity", | - | ||||||
| 69 | .item = &X509_VAL_it, | - | ||||||
| 70 | }, | - | ||||||
| 71 | { | - | ||||||
| 72 | .offset = | - | ||||||
| 73 | __builtin_offsetof ( | - | ||||||
| 74 | X509_CINF | - | ||||||
| 75 | , | - | ||||||
| 76 | subject | - | ||||||
| 77 | ) | - | ||||||
| 78 | , | - | ||||||
| 79 | .field_name = "subject", | - | ||||||
| 80 | .item = &X509_NAME_it, | - | ||||||
| 81 | }, | - | ||||||
| 82 | { | - | ||||||
| 83 | .offset = | - | ||||||
| 84 | __builtin_offsetof ( | - | ||||||
| 85 | X509_CINF | - | ||||||
| 86 | , | - | ||||||
| 87 | key | - | ||||||
| 88 | ) | - | ||||||
| 89 | , | - | ||||||
| 90 | .field_name = "key", | - | ||||||
| 91 | .item = &X509_PUBKEY_it, | - | ||||||
| 92 | }, | - | ||||||
| 93 | { | - | ||||||
| 94 | .flags = (0x1 << 3)|(0x2<<6) | (0x1), | - | ||||||
| 95 | .tag = 1, | - | ||||||
| 96 | .offset = | - | ||||||
| 97 | __builtin_offsetof ( | - | ||||||
| 98 | X509_CINF | - | ||||||
| 99 | , | - | ||||||
| 100 | issuerUID | - | ||||||
| 101 | ) | - | ||||||
| 102 | , | - | ||||||
| 103 | .field_name = "issuerUID", | - | ||||||
| 104 | .item = &ASN1_BIT_STRING_it, | - | ||||||
| 105 | }, | - | ||||||
| 106 | { | - | ||||||
| 107 | .flags = (0x1 << 3)|(0x2<<6) | (0x1), | - | ||||||
| 108 | .tag = 2, | - | ||||||
| 109 | .offset = | - | ||||||
| 110 | __builtin_offsetof ( | - | ||||||
| 111 | X509_CINF | - | ||||||
| 112 | , | - | ||||||
| 113 | subjectUID | - | ||||||
| 114 | ) | - | ||||||
| 115 | , | - | ||||||
| 116 | .field_name = "subjectUID", | - | ||||||
| 117 | .item = &ASN1_BIT_STRING_it, | - | ||||||
| 118 | }, | - | ||||||
| 119 | { | - | ||||||
| 120 | .flags = (0x2 << 3)|(0x2<<6) | (0x2 << 1) | | - | ||||||
| 121 | (0x1), | - | ||||||
| 122 | .tag = 3, | - | ||||||
| 123 | .offset = | - | ||||||
| 124 | __builtin_offsetof ( | - | ||||||
| 125 | X509_CINF | - | ||||||
| 126 | , | - | ||||||
| 127 | extensions | - | ||||||
| 128 | ) | - | ||||||
| 129 | , | - | ||||||
| 130 | .field_name = "extensions", | - | ||||||
| 131 | .item = &X509_EXTENSION_it, | - | ||||||
| 132 | }, | - | ||||||
| 133 | }; | - | ||||||
| 134 | - | |||||||
| 135 | const ASN1_ITEM X509_CINF_it = { | - | ||||||
| 136 | .itype = 0x1, | - | ||||||
| 137 | .utype = 16, | - | ||||||
| 138 | .templates = X509_CINF_seq_tt, | - | ||||||
| 139 | .tcount = sizeof(X509_CINF_seq_tt) / sizeof(ASN1_TEMPLATE), | - | ||||||
| 140 | .funcs = &X509_CINF_aux, | - | ||||||
| 141 | .size = sizeof(X509_CINF), | - | ||||||
| 142 | .sname = "X509_CINF", | - | ||||||
| 143 | }; | - | ||||||
| 144 | - | |||||||
| 145 | - | |||||||
| 146 | X509_CINF * | - | ||||||
| 147 | d2i_X509_CINF(X509_CINF **a, const unsigned char **in, long len) | - | ||||||
| 148 | { | - | ||||||
| 149 | return never executed: (X509_CINF *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,return (X509_CINF *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &X509_CINF_it);never executed: return (X509_CINF *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &X509_CINF_it); | 0 | ||||||
| 150 | &X509_CINF_it); never executed: return (X509_CINF *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &X509_CINF_it); | 0 | ||||||
| 151 | } | - | ||||||
| 152 | - | |||||||
| 153 | int | - | ||||||
| 154 | i2d_X509_CINF(X509_CINF *a, unsigned char **out) | - | ||||||
| 155 | { | - | ||||||
| 156 | return never executed: ASN1_item_i2d((ASN1_VALUE *)a, out, &X509_CINF_it);return ASN1_item_i2d((ASN1_VALUE *)a, out, &X509_CINF_it);never executed: return ASN1_item_i2d((ASN1_VALUE *)a, out, &X509_CINF_it); | 0 | ||||||
| 157 | } | - | ||||||
| 158 | - | |||||||
| 159 | X509_CINF * | - | ||||||
| 160 | X509_CINF_new(void) | - | ||||||
| 161 | { | - | ||||||
| 162 | return never executed: (X509_CINF *)ASN1_item_new(&X509_CINF_it);return (X509_CINF *)ASN1_item_new(&X509_CINF_it);never executed: return (X509_CINF *)ASN1_item_new(&X509_CINF_it); | 0 | ||||||
| 163 | } | - | ||||||
| 164 | - | |||||||
| 165 | void | - | ||||||
| 166 | X509_CINF_free(X509_CINF *a) | - | ||||||
| 167 | { | - | ||||||
| 168 | ASN1_item_free((ASN1_VALUE *)a, &X509_CINF_it); | - | ||||||
| 169 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||
| 170 | - | |||||||
| 171 | - | |||||||
| 172 | extern void policy_cache_free(X509_POLICY_CACHE *cache); | - | ||||||
| 173 | - | |||||||
| 174 | static int | - | ||||||
| 175 | x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | - | ||||||
| 176 | { | - | ||||||
| 177 | X509 *ret = (X509 *)*pval; | - | ||||||
| 178 | - | |||||||
| 179 | switch (operation) { | - | ||||||
| 180 | - | |||||||
| 181 | case executed 249 times by 8 tests: 1:case 1:Executed by:
executed 249 times by 8 tests: case 1:Executed by:
| 249 | ||||||
| 182 | ret->valid = 0; | - | ||||||
| 183 | ret->name = | - | ||||||
| 184 | ((void *)0) | - | ||||||
| 185 | ; | - | ||||||
| 186 | ret->ex_flags = 0; | - | ||||||
| 187 | ret->ex_pathlen = -1; | - | ||||||
| 188 | ret->skid = | - | ||||||
| 189 | ((void *)0) | - | ||||||
| 190 | ; | - | ||||||
| 191 | ret->akid = | - | ||||||
| 192 | ((void *)0) | - | ||||||
| 193 | ; | - | ||||||
| 194 | ret->aux = | - | ||||||
| 195 | ((void *)0) | - | ||||||
| 196 | ; | - | ||||||
| 197 | ret->crldp = | - | ||||||
| 198 | ((void *)0) | - | ||||||
| 199 | ; | - | ||||||
| 200 | CRYPTO_new_ex_data(10, ret, &ret->ex_data); | - | ||||||
| 201 | break; executed 249 times by 8 tests: break;Executed by:
| 249 | ||||||
| 202 | - | |||||||
| 203 | case executed 219 times by 7 tests: 5:case 5:Executed by:
executed 219 times by 7 tests: case 5:Executed by:
| 219 | ||||||
| 204 | free(ret->name); | - | ||||||
| 205 | ret->name = X509_NAME_oneline(ret->cert_info->subject, | - | ||||||
| 206 | ((void *)0) | - | ||||||
| 207 | , 0); | - | ||||||
| 208 | break; executed 219 times by 7 tests: break;Executed by:
| 219 | ||||||
| 209 | - | |||||||
| 210 | case executed 244 times by 7 tests: 3:case 3:Executed by:
executed 244 times by 7 tests: case 3:Executed by:
| 244 | ||||||
| 211 | CRYPTO_free_ex_data(10, ret, &ret->ex_data); | - | ||||||
| 212 | X509_CERT_AUX_free(ret->aux); | - | ||||||
| 213 | ASN1_OCTET_STRING_free(ret->skid); | - | ||||||
| 214 | AUTHORITY_KEYID_free(ret->akid); | - | ||||||
| 215 | CRL_DIST_POINTS_free(ret->crldp); | - | ||||||
| 216 | policy_cache_free(ret->policy_cache); | - | ||||||
| 217 | GENERAL_NAMES_free(ret->altname); | - | ||||||
| 218 | NAME_CONSTRAINTS_free(ret->nc); | - | ||||||
| 219 | free(ret->name); | - | ||||||
| 220 | ret->name = | - | ||||||
| 221 | ((void *)0) | - | ||||||
| 222 | ; | - | ||||||
| 223 | break; executed 244 times by 7 tests: break;Executed by:
| 244 | ||||||
| 224 | } | - | ||||||
| 225 | - | |||||||
| 226 | return executed 2390 times by 8 tests: 1;return 1;Executed by:
executed 2390 times by 8 tests: return 1;Executed by:
| 2390 | ||||||
| 227 | } | - | ||||||
| 228 | - | |||||||
| 229 | static const ASN1_AUX X509_aux = { | - | ||||||
| 230 | .app_data = | - | ||||||
| 231 | ((void *)0) | - | ||||||
| 232 | , | - | ||||||
| 233 | .flags = 1, | - | ||||||
| 234 | .ref_offset = | - | ||||||
| 235 | __builtin_offsetof ( | - | ||||||
| 236 | X509 | - | ||||||
| 237 | , | - | ||||||
| 238 | references | - | ||||||
| 239 | ) | - | ||||||
| 240 | , | - | ||||||
| 241 | .ref_lock = 3, | - | ||||||
| 242 | .asn1_cb = x509_cb, | - | ||||||
| 243 | }; | - | ||||||
| 244 | static const ASN1_TEMPLATE X509_seq_tt[] = { | - | ||||||
| 245 | { | - | ||||||
| 246 | .offset = | - | ||||||
| 247 | __builtin_offsetof ( | - | ||||||
| 248 | X509 | - | ||||||
| 249 | , | - | ||||||
| 250 | cert_info | - | ||||||
| 251 | ) | - | ||||||
| 252 | , | - | ||||||
| 253 | .field_name = "cert_info", | - | ||||||
| 254 | .item = &X509_CINF_it, | - | ||||||
| 255 | }, | - | ||||||
| 256 | { | - | ||||||
| 257 | .offset = | - | ||||||
| 258 | __builtin_offsetof ( | - | ||||||
| 259 | X509 | - | ||||||
| 260 | , | - | ||||||
| 261 | sig_alg | - | ||||||
| 262 | ) | - | ||||||
| 263 | , | - | ||||||
| 264 | .field_name = "sig_alg", | - | ||||||
| 265 | .item = &X509_ALGOR_it, | - | ||||||
| 266 | }, | - | ||||||
| 267 | { | - | ||||||
| 268 | .offset = | - | ||||||
| 269 | __builtin_offsetof ( | - | ||||||
| 270 | X509 | - | ||||||
| 271 | , | - | ||||||
| 272 | signature | - | ||||||
| 273 | ) | - | ||||||
| 274 | , | - | ||||||
| 275 | .field_name = "signature", | - | ||||||
| 276 | .item = &ASN1_BIT_STRING_it, | - | ||||||
| 277 | }, | - | ||||||
| 278 | }; | - | ||||||
| 279 | - | |||||||
| 280 | const ASN1_ITEM X509_it = { | - | ||||||
| 281 | .itype = 0x1, | - | ||||||
| 282 | .utype = 16, | - | ||||||
| 283 | .templates = X509_seq_tt, | - | ||||||
| 284 | .tcount = sizeof(X509_seq_tt) / sizeof(ASN1_TEMPLATE), | - | ||||||
| 285 | .funcs = &X509_aux, | - | ||||||
| 286 | .size = sizeof(X509), | - | ||||||
| 287 | .sname = "X509", | - | ||||||
| 288 | }; | - | ||||||
| 289 | - | |||||||
| 290 | - | |||||||
| 291 | X509 * | - | ||||||
| 292 | d2i_X509(X509 **a, const unsigned char **in, long len) | - | ||||||
| 293 | { | - | ||||||
| 294 | return executed 216 times by 7 tests: (X509 *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,return (X509 *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &X509_it);Executed by:
executed 216 times by 7 tests: return (X509 *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &X509_it);Executed by:
| 216 | ||||||
| 295 | &X509_it); executed 216 times by 7 tests: return (X509 *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &X509_it);Executed by:
| 216 | ||||||
| 296 | } | - | ||||||
| 297 | - | |||||||
| 298 | int | - | ||||||
| 299 | i2d_X509(X509 *a, unsigned char **out) | - | ||||||
| 300 | { | - | ||||||
| 301 | return executed 217 times by 5 tests: ASN1_item_i2d((ASN1_VALUE *)a, out, &X509_it);return ASN1_item_i2d((ASN1_VALUE *)a, out, &X509_it);Executed by:
executed 217 times by 5 tests: return ASN1_item_i2d((ASN1_VALUE *)a, out, &X509_it);Executed by:
| 217 | ||||||
| 302 | } | - | ||||||
| 303 | - | |||||||
| 304 | X509 * | - | ||||||
| 305 | X509_new(void) | - | ||||||
| 306 | { | - | ||||||
| 307 | return executed 30 times by 2 tests: (X509 *)ASN1_item_new(&X509_it);return (X509 *)ASN1_item_new(&X509_it);Executed by:
executed 30 times by 2 tests: return (X509 *)ASN1_item_new(&X509_it);Executed by:
| 30 | ||||||
| 308 | } | - | ||||||
| 309 | - | |||||||
| 310 | void | - | ||||||
| 311 | X509_free(X509 *a) | - | ||||||
| 312 | { | - | ||||||
| 313 | ASN1_item_free((ASN1_VALUE *)a, &X509_it); | - | ||||||
| 314 | } executed 3519 times by 17 tests: end of blockExecuted by:
| 3519 | ||||||
| 315 | - | |||||||
| 316 | X509 * | - | ||||||
| 317 | X509_dup(X509 *x) | - | ||||||
| 318 | { | - | ||||||
| 319 | return never executed: ASN1_item_dup(&X509_it, x);return ASN1_item_dup(&X509_it, x);never executed: return ASN1_item_dup(&X509_it, x); | 0 | ||||||
| 320 | } | - | ||||||
| 321 | - | |||||||
| 322 | int | - | ||||||
| 323 | X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, | - | ||||||
| 324 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) | - | ||||||
| 325 | { | - | ||||||
| 326 | return never executed: CRYPTO_get_ex_new_index(10, argl, argp,return CRYPTO_get_ex_new_index(10, argl, argp, new_func, dup_func, free_func);never executed: return CRYPTO_get_ex_new_index(10, argl, argp, new_func, dup_func, free_func); | 0 | ||||||
| 327 | new_func, dup_func, free_func); never executed: return CRYPTO_get_ex_new_index(10, argl, argp, new_func, dup_func, free_func); | 0 | ||||||
| 328 | } | - | ||||||
| 329 | - | |||||||
| 330 | int | - | ||||||
| 331 | X509_set_ex_data(X509 *r, int idx, void *arg) | - | ||||||
| 332 | { | - | ||||||
| 333 | return never executed: (CRYPTO_set_ex_data(&r->ex_data, idx, arg));return (CRYPTO_set_ex_data(&r->ex_data, idx, arg));never executed: return (CRYPTO_set_ex_data(&r->ex_data, idx, arg)); | 0 | ||||||
| 334 | } | - | ||||||
| 335 | - | |||||||
| 336 | void * | - | ||||||
| 337 | X509_get_ex_data(X509 *r, int idx) | - | ||||||
| 338 | { | - | ||||||
| 339 | return never executed: (CRYPTO_get_ex_data(&r->ex_data, idx));return (CRYPTO_get_ex_data(&r->ex_data, idx));never executed: return (CRYPTO_get_ex_data(&r->ex_data, idx)); | 0 | ||||||
| 340 | } | - | ||||||
| 341 | X509 * | - | ||||||
| 342 | d2i_X509_AUX(X509 **a, const unsigned char **pp, long length) | - | ||||||
| 343 | { | - | ||||||
| 344 | const unsigned char *q; | - | ||||||
| 345 | X509 *ret; | - | ||||||
| 346 | - | |||||||
| 347 | - | |||||||
| 348 | q = *pp; | - | ||||||
| 349 | ret = d2i_X509( | - | ||||||
| 350 | ((void *)0) | - | ||||||
| 351 | , pp, length); | - | ||||||
| 352 | - | |||||||
| 353 | if (!ret
| 0-8 | ||||||
| 354 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||
| 355 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||
| 356 | ; never executed: return ((void *)0) ; | 0 | ||||||
| 357 | - | |||||||
| 358 | length -= *pp - q; | - | ||||||
| 359 | if (length > 0
| 0-8 | ||||||
| 360 | if (!d2i_X509_CERT_AUX(&ret->aux, pp, length)
| 0 | ||||||
| 361 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||
| 362 | } never executed: end of block | 0 | ||||||
| 363 | if (a !=
| 0-8 | ||||||
| 364 | ((void *)0)
| 0-8 | ||||||
| 365 | ) { | - | ||||||
| 366 | X509_free(*a); | - | ||||||
| 367 | *a = ret; | - | ||||||
| 368 | } never executed: end of block | 0 | ||||||
| 369 | return executed 8 times by 3 tests: ret;return ret;Executed by:
executed 8 times by 3 tests: return ret;Executed by:
| 8 | ||||||
| 370 | - | |||||||
| 371 | err: | - | ||||||
| 372 | X509_free(ret); | - | ||||||
| 373 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||
| 374 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||
| 375 | ; never executed: return ((void *)0) ; | 0 | ||||||
| 376 | } | - | ||||||
| 377 | - | |||||||
| 378 | int | - | ||||||
| 379 | i2d_X509_AUX(X509 *a, unsigned char **pp) | - | ||||||
| 380 | { | - | ||||||
| 381 | int length; | - | ||||||
| 382 | - | |||||||
| 383 | length = i2d_X509(a, pp); | - | ||||||
| 384 | if (a
| 0 | ||||||
| 385 | length += i2d_X509_CERT_AUX(a->aux, pp); never executed: length += i2d_X509_CERT_AUX(a->aux, pp); | 0 | ||||||
| 386 | return never executed: length;return length;never executed: return length; | 0 | ||||||
| 387 | } | - | ||||||
| 388 | - | |||||||
| 389 | void | - | ||||||
| 390 | X509_get0_signature(const ASN1_BIT_STRING **psig, const X509_ALGOR **palg, | - | ||||||
| 391 | const X509 *x) | - | ||||||
| 392 | { | - | ||||||
| 393 | if (psig !=
| 0 | ||||||
| 394 | ((void *)0)
| 0 | ||||||
| 395 | ) | - | ||||||
| 396 | * never executed: psig = x->signature;*psig = x->signature;never executed: *psig = x->signature; | 0 | ||||||
| 397 | if (palg !=
| 0 | ||||||
| 398 | ((void *)0)
| 0 | ||||||
| 399 | ) | - | ||||||
| 400 | * never executed: palg = x->sig_alg;*palg = x->sig_alg;never executed: *palg = x->sig_alg; | 0 | ||||||
| 401 | } never executed: end of block | 0 | ||||||
| 402 | - | |||||||
| 403 | int | - | ||||||
| 404 | X509_get_signature_nid(const X509 *x) | - | ||||||
| 405 | { | - | ||||||
| 406 | return never executed: OBJ_obj2nid(x->sig_alg->algorithm);return OBJ_obj2nid(x->sig_alg->algorithm);never executed: return OBJ_obj2nid(x->sig_alg->algorithm); | 0 | ||||||
| 407 | } | - | ||||||
| Switch to Source code | Preprocessed file |