Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/x509v3/v3_extku.c |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | /* | - | ||||||
2 | * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. | - | ||||||
3 | * | - | ||||||
4 | * Licensed under the OpenSSL license (the "License"). You may not use | - | ||||||
5 | * this file except in compliance with the License. You can obtain a copy | - | ||||||
6 | * in the file LICENSE in the source distribution or at | - | ||||||
7 | * https://www.openssl.org/source/license.html | - | ||||||
8 | */ | - | ||||||
9 | - | |||||||
10 | #include <stdio.h> | - | ||||||
11 | #include "internal/cryptlib.h" | - | ||||||
12 | #include <openssl/asn1t.h> | - | ||||||
13 | #include <openssl/conf.h> | - | ||||||
14 | #include <openssl/x509v3.h> | - | ||||||
15 | #include "ext_dat.h" | - | ||||||
16 | - | |||||||
17 | static void *v2i_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, | - | ||||||
18 | X509V3_CTX *ctx, | - | ||||||
19 | STACK_OF(CONF_VALUE) *nval); | - | ||||||
20 | static STACK_OF(CONF_VALUE) *i2v_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD | - | ||||||
21 | *method, void *eku, STACK_OF(CONF_VALUE) | - | ||||||
22 | *extlist); | - | ||||||
23 | - | |||||||
24 | const X509V3_EXT_METHOD v3_ext_ku = { | - | ||||||
25 | NID_ext_key_usage, 0, | - | ||||||
26 | ASN1_ITEM_ref(EXTENDED_KEY_USAGE), | - | ||||||
27 | 0, 0, 0, 0, | - | ||||||
28 | 0, 0, | - | ||||||
29 | i2v_EXTENDED_KEY_USAGE, | - | ||||||
30 | v2i_EXTENDED_KEY_USAGE, | - | ||||||
31 | 0, 0, | - | ||||||
32 | NULL | - | ||||||
33 | }; | - | ||||||
34 | - | |||||||
35 | /* NB OCSP acceptable responses also is a SEQUENCE OF OBJECT */ | - | ||||||
36 | const X509V3_EXT_METHOD v3_ocsp_accresp = { | - | ||||||
37 | NID_id_pkix_OCSP_acceptableResponses, 0, | - | ||||||
38 | ASN1_ITEM_ref(EXTENDED_KEY_USAGE), | - | ||||||
39 | 0, 0, 0, 0, | - | ||||||
40 | 0, 0, | - | ||||||
41 | i2v_EXTENDED_KEY_USAGE, | - | ||||||
42 | v2i_EXTENDED_KEY_USAGE, | - | ||||||
43 | 0, 0, | - | ||||||
44 | NULL | - | ||||||
45 | }; | - | ||||||
46 | - | |||||||
47 | ASN1_ITEM_TEMPLATE(EXTENDED_KEY_USAGE) = | - | ||||||
48 | ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, EXTENDED_KEY_USAGE, ASN1_OBJECT) | - | ||||||
49 | ASN1_ITEM_TEMPLATE_END(EXTENDED_KEY_USAGE) | - | ||||||
50 | - | |||||||
51 | IMPLEMENT_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE) never executed: end of block never executed: return (EXTENDED_KEY_USAGE *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(EXTENDED_KEY_USAGE_it))); never executed: return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(EXTENDED_KEY_USAGE_it))); never executed: return (EXTENDED_KEY_USAGE *)ASN1_item_new((&(EXTENDED_KEY_USAGE_it))); | 0 | ||||||
52 | - | |||||||
53 | static STACK_OF(CONF_VALUE) *i2v_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD | - | ||||||
54 | *method, void *a, STACK_OF(CONF_VALUE) | - | ||||||
55 | *ext_list) | - | ||||||
56 | { | - | ||||||
57 | EXTENDED_KEY_USAGE *eku = a; | - | ||||||
58 | int i; | - | ||||||
59 | ASN1_OBJECT *obj; | - | ||||||
60 | char obj_tmp[80]; | - | ||||||
61 | for (i = 0; i < sk_ASN1_OBJECT_num(eku); i++) {
| 2093-2257 | ||||||
62 | obj = sk_ASN1_OBJECT_value(eku, i); | - | ||||||
63 | i2t_ASN1_OBJECT(obj_tmp, 80, obj); | - | ||||||
64 | X509V3_add_value(NULL, obj_tmp, &ext_list); | - | ||||||
65 | } executed 2257 times by 1 test: end of block Executed by:
| 2257 | ||||||
66 | return ext_list; executed 2093 times by 1 test: return ext_list; Executed by:
| 2093 | ||||||
67 | } | - | ||||||
68 | - | |||||||
69 | static void *v2i_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, | - | ||||||
70 | X509V3_CTX *ctx, | - | ||||||
71 | STACK_OF(CONF_VALUE) *nval) | - | ||||||
72 | { | - | ||||||
73 | EXTENDED_KEY_USAGE *extku; | - | ||||||
74 | char *extval; | - | ||||||
75 | ASN1_OBJECT *objtmp; | - | ||||||
76 | CONF_VALUE *val; | - | ||||||
77 | const int num = sk_CONF_VALUE_num(nval); | - | ||||||
78 | int i; | - | ||||||
79 | - | |||||||
80 | extku = sk_ASN1_OBJECT_new_reserve(NULL, num); | - | ||||||
81 | if (extku == NULL) {
| 0 | ||||||
82 | X509V3err(X509V3_F_V2I_EXTENDED_KEY_USAGE, ERR_R_MALLOC_FAILURE); | - | ||||||
83 | sk_ASN1_OBJECT_free(extku); | - | ||||||
84 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||
85 | } | - | ||||||
86 | - | |||||||
87 | for (i = 0; i < num; i++) {
| 0 | ||||||
88 | val = sk_CONF_VALUE_value(nval, i); | - | ||||||
89 | if (val->value)
| 0 | ||||||
90 | extval = val->value; never executed: extval = val->value; | 0 | ||||||
91 | else | - | ||||||
92 | extval = val->name; never executed: extval = val->name; | 0 | ||||||
93 | if ((objtmp = OBJ_txt2obj(extval, 0)) == NULL) {
| 0 | ||||||
94 | sk_ASN1_OBJECT_pop_free(extku, ASN1_OBJECT_free); | - | ||||||
95 | X509V3err(X509V3_F_V2I_EXTENDED_KEY_USAGE, | - | ||||||
96 | X509V3_R_INVALID_OBJECT_IDENTIFIER); | - | ||||||
97 | X509V3_conf_err(val); | - | ||||||
98 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||
99 | } | - | ||||||
100 | sk_ASN1_OBJECT_push(extku, objtmp); /* no failure as it was reserved */ | - | ||||||
101 | } never executed: end of block | 0 | ||||||
102 | return extku; never executed: return extku; | 0 | ||||||
103 | } | - | ||||||
Source code | Switch to Preprocessed file |