v3_info.c
Go to the documentation of this file.
1 /* v3_info.c */
2 /*
3  * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
4  * 1999.
5  */
6 /* ====================================================================
7  * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in
18  * the documentation and/or other materials provided with the
19  * distribution.
20  *
21  * 3. All advertising materials mentioning features or use of this
22  * software must display the following acknowledgment:
23  * "This product includes software developed by the OpenSSL Project
24  * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25  *
26  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27  * endorse or promote products derived from this software without
28  * prior written permission. For written permission, please contact
29  * licensing@OpenSSL.org.
30  *
31  * 5. Products derived from this software may not be called "OpenSSL"
32  * nor may "OpenSSL" appear in their names without prior written
33  * permission of the OpenSSL Project.
34  *
35  * 6. Redistributions of any form whatsoever must retain the following
36  * acknowledgment:
37  * "This product includes software developed by the OpenSSL Project
38  * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39  *
40  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51  * OF THE POSSIBILITY OF SUCH DAMAGE.
52  * ====================================================================
53  *
54  * This product includes cryptographic software written by Eric Young
55  * (eay@cryptsoft.com). This product includes software written by Tim
56  * Hudson (tjh@cryptsoft.com).
57  *
58  */
59 
60 #include <stdio.h>
61 #include <string.h>
62 
63 #include <openssl/asn1.h>
64 #include <openssl/asn1t.h>
65 #include <openssl/conf.h>
66 #include <openssl/err.h>
67 #include <openssl/mem.h>
68 #include <openssl/obj.h>
69 #include <openssl/x509v3.h>
70 
71 static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD
72  *method, AUTHORITY_INFO_ACCESS
73  *ainfo, STACK_OF(CONF_VALUE)
74  *ret);
75 static AUTHORITY_INFO_ACCESS *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD
76  *method,
77  X509V3_CTX *ctx,
79  *nval);
80 
82  ASN1_ITEM_ref(AUTHORITY_INFO_ACCESS),
83  0, 0, 0, 0,
84  0, 0,
85  (X509V3_EXT_I2V) i2v_AUTHORITY_INFO_ACCESS,
86  (X509V3_EXT_V2I)v2i_AUTHORITY_INFO_ACCESS,
87  0, 0,
88  NULL
89 };
90 
92  ASN1_ITEM_ref(AUTHORITY_INFO_ACCESS),
93  0, 0, 0, 0,
94  0, 0,
95  (X509V3_EXT_I2V) i2v_AUTHORITY_INFO_ACCESS,
96  (X509V3_EXT_V2I)v2i_AUTHORITY_INFO_ACCESS,
97  0, 0,
98  NULL
99 };
100 
105 
107 
108 ASN1_ITEM_TEMPLATE(AUTHORITY_INFO_ACCESS) =
110 ASN1_ITEM_TEMPLATE_END(AUTHORITY_INFO_ACCESS)
111 
112 IMPLEMENT_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS)
113 
114 static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(
115  X509V3_EXT_METHOD *method, AUTHORITY_INFO_ACCESS *ainfo,
117 {
119  size_t i;
120  int nlen;
121  char objtmp[80], *ntmp;
122  CONF_VALUE *vtmp;
123  STACK_OF(CONF_VALUE) *tret = ret;
124 
125  for (i = 0; i < sk_ACCESS_DESCRIPTION_num(ainfo); i++) {
127 
128  desc = sk_ACCESS_DESCRIPTION_value(ainfo, i);
129  tmp = i2v_GENERAL_NAME(method, desc->location, tret);
130  if (tmp == NULL)
131  goto err;
132  tret = tmp;
133  vtmp = sk_CONF_VALUE_value(tret, i);
134  i2t_ASN1_OBJECT(objtmp, sizeof objtmp, desc->method);
135  nlen = strlen(objtmp) + strlen(vtmp->name) + 5;
136  ntmp = OPENSSL_malloc(nlen);
137  if (ntmp == NULL)
138  goto err;
139  OPENSSL_strlcpy(ntmp, objtmp, nlen);
140  OPENSSL_strlcat(ntmp, " - ", nlen);
141  OPENSSL_strlcat(ntmp, vtmp->name, nlen);
142  OPENSSL_free(vtmp->name);
143  vtmp->name = ntmp;
144 
145  }
146  if (ret == NULL && tret == NULL)
147  return sk_CONF_VALUE_new_null();
148 
149  return tret;
150  err:
152  if (ret == NULL && tret != NULL)
153  sk_CONF_VALUE_pop_free(tret, X509V3_conf_free);
154  return NULL;
155 }
156 
157 static AUTHORITY_INFO_ACCESS *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD
158  *method,
159  X509V3_CTX *ctx,
161  *nval)
162 {
163  AUTHORITY_INFO_ACCESS *ainfo = NULL;
164  CONF_VALUE *cnf, ctmp;
165  ACCESS_DESCRIPTION *acc;
166  size_t i;
167  int objlen;
168  char *objtmp, *ptmp;
169  if (!(ainfo = sk_ACCESS_DESCRIPTION_new_null())) {
171  return NULL;
172  }
173  for (i = 0; i < sk_CONF_VALUE_num(nval); i++) {
174  cnf = sk_CONF_VALUE_value(nval, i);
175  if (!(acc = ACCESS_DESCRIPTION_new())
176  || !sk_ACCESS_DESCRIPTION_push(ainfo, acc)) {
178  goto err;
179  }
180  ptmp = strchr(cnf->name, ';');
181  if (!ptmp) {
183  goto err;
184  }
185  objlen = ptmp - cnf->name;
186  ctmp.name = ptmp + 1;
187  ctmp.value = cnf->value;
188  if (!v2i_GENERAL_NAME_ex(acc->location, method, ctx, &ctmp, 0))
189  goto err;
190  if (!(objtmp = OPENSSL_malloc(objlen + 1))) {
192  goto err;
193  }
194  OPENSSL_strlcpy(objtmp, cnf->name, objlen + 1);
195  acc->method = OBJ_txt2obj(objtmp, 0);
196  if (!acc->method) {
198  ERR_add_error_data(2, "value=", objtmp);
199  OPENSSL_free(objtmp);
200  goto err;
201  }
202  OPENSSL_free(objtmp);
203 
204  }
205  return ainfo;
206  err:
207  sk_ACCESS_DESCRIPTION_pop_free(ainfo, ACCESS_DESCRIPTION_free);
208  return NULL;
209 }
210 
212 {
213  i2a_ASN1_OBJECT(bp, a->method);
214 #ifdef UNDEF
215  i2a_GENERAL_NAME(bp, a->location);
216 #endif
217  return 2;
218 }
v2i_GENERAL_NAME_ex
#define v2i_GENERAL_NAME_ex
Definition: boringssl_prefix_symbols.h:3399
GENERAL_NAME_st
Definition: x509v3.h:173
ctx
Definition: benchmark-async.c:30
v3_ext_ctx
Definition: x509v3.h:136
bio_st
Definition: bio.h:822
ACCESS_DESCRIPTION_st
Definition: x509v3.h:211
i2t_ASN1_OBJECT
#define i2t_ASN1_OBJECT
Definition: boringssl_prefix_symbols.h:3309
OPENSSL_PUT_ERROR
#define OPENSSL_PUT_ERROR(library, reason)
Definition: err.h:423
string.h
error_ref_leak.err
err
Definition: error_ref_leak.py:35
ACCESS_DESCRIPTION_new
#define ACCESS_DESCRIPTION_new
Definition: boringssl_prefix_symbols.h:593
x509v3.h
ASN1_ITEM_ref
#define ASN1_ITEM_ref(name)
Definition: asn1.h:312
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
STACK_OF
static STACK_OF(CONF_VALUE)
Definition: v3_info.c:71
ACCESS_DESCRIPTION_free
#define ACCESS_DESCRIPTION_free
Definition: boringssl_prefix_symbols.h:591
IMPLEMENT_ASN1_FUNCTIONS
#define IMPLEMENT_ASN1_FUNCTIONS(stname)
Definition: asn1t.h:636
asn1_object_st
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:102
ASN1_TFLG_SEQUENCE_OF
#define ASN1_TFLG_SEQUENCE_OF
Definition: asn1t.h:393
OPENSSL_malloc
#define OPENSSL_malloc
Definition: boringssl_prefix_symbols.h:1885
i2v_GENERAL_NAME
#define i2v_GENERAL_NAME
Definition: boringssl_prefix_symbols.h:3311
i2a_ACCESS_DESCRIPTION
OPENSSL_EXPORT int i2a_ACCESS_DESCRIPTION(BIO *bp, const ACCESS_DESCRIPTION *a)
ASN1_ITEM_TEMPLATE
ASN1_ITEM_TEMPLATE(CERTIFICATEPOLICIES)
conf_value_st::value
char * value
Definition: conf.h:85
OBJ_txt2obj
#define OBJ_txt2obj
Definition: boringssl_prefix_symbols.h:1861
X509V3_conf_free
#define X509V3_conf_free
Definition: boringssl_prefix_symbols.h:2238
v3_sinfo
const X509V3_EXT_METHOD v3_sinfo
Definition: v3_info.c:91
err.h
ASN1_SEQUENCE
#define ASN1_SEQUENCE(tname)
Definition: asn1t.h:130
asn1t.h
conf.h
v3_info
const X509V3_EXT_METHOD v3_info
OPENSSL_strlcat
#define OPENSSL_strlcat
Definition: boringssl_prefix_symbols.h:1893
ASN1_EX_TEMPLATE_TYPE
#define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type)
Definition: asn1t.h:235
ASN1_SEQUENCE_END
ASN1_SEQUENCE_END(X509_NAME_ENTRY)
Definition: x_name.c:103
X509V3_R_INVALID_SYNTAX
#define X509V3_R_INVALID_SYNTAX
Definition: x509v3.h:989
i2a_ASN1_OBJECT
#define i2a_ASN1_OBJECT
Definition: boringssl_prefix_symbols.h:3172
X509V3_EXT_MULTILINE
#define X509V3_EXT_MULTILINE
Definition: x509v3.h:155
OPENSSL_strlcpy
#define OPENSSL_strlcpy
Definition: boringssl_prefix_symbols.h:1894
ret
UniquePtr< SSL_SESSION > ret
Definition: ssl_x509.cc:1029
NID_sinfo_access
#define NID_sinfo_access
Definition: nid.h:1845
ERR_add_error_data
#define ERR_add_error_data
Definition: boringssl_prefix_symbols.h:1411
desc
#define desc
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:338
ACCESS_DESCRIPTION_st::location
GENERAL_NAME * location
Definition: x509v3.h:213
obj.h
v3_ext_method
Definition: x509v3.h:102
mem.h
X509V3_EXT_V2I
void *(* X509V3_EXT_V2I)(const struct v3_ext_method *method, struct v3_ext_ctx *ctx, STACK_OF(CONF_VALUE) *values)
Definition: x509v3.h:89
autogen_x86imm.tmp
tmp
Definition: autogen_x86imm.py:12
method
NSString * method
Definition: ProtoMethod.h:28
NID_info_access
#define NID_info_access
Definition: nid.h:887
ACCESS_DESCRIPTION_st::method
ASN1_OBJECT * method
Definition: x509v3.h:212
OPENSSL_free
#define OPENSSL_free
Definition: boringssl_prefix_symbols.h:1869
X509V3_R_BAD_OBJECT
#define X509V3_R_BAD_OBJECT
Definition: x509v3.h:955
ASN1_ITEM_TEMPLATE_END
#define ASN1_ITEM_TEMPLATE_END(tname)
Definition: asn1t.h:95
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
asn1.h
ERR_R_MALLOC_FAILURE
#define ERR_R_MALLOC_FAILURE
Definition: err.h:371
conf_value_st
Definition: conf.h:82
conf_value_st::name
char * name
Definition: conf.h:84
ASN1_SIMPLE
#define ASN1_SIMPLE(stname, field, type)
Definition: asn1t.h:265


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:50