third_party/boringssl-with-bazel/src/crypto/asn1/internal.h
Go to the documentation of this file.
1 /*
2  * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
3  * 2006.
4  */
5 /* ====================================================================
6  * Copyright (c) 2006 The OpenSSL Project. All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. All advertising materials mentioning features or use of this
21  * software must display the following acknowledgment:
22  * "This product includes software developed by the OpenSSL Project
23  * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24  *
25  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26  * endorse or promote products derived from this software without
27  * prior written permission. For written permission, please contact
28  * licensing@OpenSSL.org.
29  *
30  * 5. Products derived from this software may not be called "OpenSSL"
31  * nor may "OpenSSL" appear in their names without prior written
32  * permission of the OpenSSL Project.
33  *
34  * 6. Redistributions of any form whatsoever must retain the following
35  * acknowledgment:
36  * "This product includes software developed by the OpenSSL Project
37  * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38  *
39  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50  * OF THE POSSIBILITY OF SUCH DAMAGE.
51  * ====================================================================
52  *
53  * This product includes cryptographic software written by Eric Young
54  * (eay@cryptsoft.com). This product includes software written by Tim
55  * Hudson (tjh@cryptsoft.com).
56  *
57  */
58 
59 #ifndef OPENSSL_HEADER_ASN1_ASN1_LOCL_H
60 #define OPENSSL_HEADER_ASN1_ASN1_LOCL_H
61 
62 #include <time.h>
63 
64 #include <openssl/asn1.h>
65 #include <openssl/asn1t.h>
66 
67 #if defined(__cplusplus)
68 extern "C" {
69 #endif
70 
71 
72 /* Wrapper functions for time functions. */
73 
74 /* OPENSSL_gmtime wraps |gmtime_r|. See the manual page for that function. */
75 struct tm *OPENSSL_gmtime(const time_t *time, struct tm *result);
76 
77 /* OPENSSL_gmtime_adj updates |tm| by adding |offset_day| days and |offset_sec|
78  * seconds. */
79 int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec);
80 
81 /* OPENSSL_gmtime_diff calculates the difference between |from| and |to| and
82  * outputs the difference as a number of days and seconds in |*out_days| and
83  * |*out_secs|. */
84 int OPENSSL_gmtime_diff(int *out_days, int *out_secs, const struct tm *from,
85  const struct tm *to);
86 
87 
88 /* Internal ASN1 structures and functions: not for application use */
89 
90 /* These are used internally in the ASN1_OBJECT to keep track of
91  * whether the names and data need to be free()ed */
92 #define ASN1_OBJECT_FLAG_DYNAMIC 0x01 /* internal use */
93 #define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04 /* internal use */
94 #define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08 /* internal use */
95 
96 /* An asn1_object_st (aka |ASN1_OBJECT|) represents an ASN.1 OBJECT IDENTIFIER.
97  * Note: Mutating an |ASN1_OBJECT| is only permitted when initializing it. The
98  * library maintains a table of static |ASN1_OBJECT|s, which may be referenced
99  * by non-const |ASN1_OBJECT| pointers. Code which receives an |ASN1_OBJECT|
100  * pointer externally must assume it is immutable, even if the pointer is not
101  * const. */
103  const char *sn, *ln;
104  int nid;
105  int length;
106  const unsigned char *data; /* data remains const after init */
107  int flags; /* Should we free this one */
108 };
109 
111 
112 // ASN1_ENCODING structure: this is used to save the received
113 // encoding of an ASN1 type. This is useful to get round
114 // problems with invalid encodings which can break signatures.
115 typedef struct ASN1_ENCODING_st {
116  unsigned char *enc; // DER encoding
117  long len; // Length of encoding
118  int modified; // set to 1 if 'enc' is invalid
119  // alias_only is zero if |enc| owns the buffer that it points to
120  // (although |enc| may still be NULL). If one, |enc| points into a
121  // buffer that is owned elsewhere.
122  unsigned alias_only : 1;
123  // alias_only_on_next_parse is one iff the next parsing operation
124  // should avoid taking a copy of the input and rather set
125  // |alias_only|.
127 } ASN1_ENCODING;
128 
129 int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d);
131 
132 void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it,
133  int combine);
134 
135 int UTF8_getc(const unsigned char *str, int len, uint32_t *val);
136 int UTF8_putc(unsigned char *str, int len, uint32_t value);
137 
138 int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
139 void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
140 
141 void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
142 int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
143  const ASN1_ITEM *it, int tag, int aclass, char opt,
144  ASN1_TLC *ctx);
145 
146 /* ASN1_item_ex_i2d encodes |*pval| as a value of type |it| to |out| under the
147  * i2d output convention. It returns a non-zero length on success and -1 on
148  * error. If |tag| is -1. the tag and class come from |it|. Otherwise, the tag
149  * number is |tag| and the class is |aclass|. This is used for implicit tagging.
150  * This function treats a missing value as an error, not an optional field. */
151 int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
152  const ASN1_ITEM *it, int tag, int aclass);
153 
154 void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
155 
156 /* asn1_get_choice_selector returns the CHOICE selector value for |*pval|, which
157  * must of type |it|. */
158 int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it);
159 
160 int asn1_set_choice_selector(ASN1_VALUE **pval, int value, const ASN1_ITEM *it);
161 
162 /* asn1_get_field_ptr returns a pointer to the field in |*pval| corresponding to
163  * |tt|. */
165 
166 /* asn1_do_adb returns the |ASN1_TEMPLATE| for the ANY DEFINED BY field |tt|,
167  * based on the selector INTEGER or OID in |*pval|. If |tt| is not an ADB field,
168  * it returns |tt|. If the selector does not match any value, it returns NULL.
169  * If |nullerr| is non-zero, it will additionally push an error to the error
170  * queue when there is no match. */
171 const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt,
172  int nullerr);
173 
174 void asn1_refcount_set_one(ASN1_VALUE **pval, const ASN1_ITEM *it);
176 
177 void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it);
178 void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
179 
180 /* asn1_enc_restore, if |*pval| has a saved encoding, writes it to |out| under
181  * the i2d output convention, sets |*len| to the length, and returns one. If it
182  * has no saved encoding, it returns zero. */
183 int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval,
184  const ASN1_ITEM *it);
185 
186 int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen,
187  const ASN1_ITEM *it);
188 
189 /* asn1_type_value_as_pointer returns |a|'s value in pointer form. This is
190  * usually the value object but, for BOOLEAN values, is 0 or 0xff cast to
191  * a pointer. */
192 const void *asn1_type_value_as_pointer(const ASN1_TYPE *a);
193 
194 /* asn1_is_printable returns one if |value| is a valid Unicode codepoint for an
195  * ASN.1 PrintableString, and zero otherwise. */
197 
198 /* asn1_bit_string_length returns the number of bytes in |str| and sets
199  * |*out_padding_bits| to the number of padding bits.
200  *
201  * This function should be used instead of |ASN1_STRING_length| to correctly
202  * handle the non-|ASN1_STRING_FLAG_BITS_LEFT| case. */
204  uint8_t *out_padding_bits);
205 
206 typedef struct {
207  int nid;
208  long minsize;
209  long maxsize;
210  unsigned long mask;
211  unsigned long flags;
213 
214 /* asn1_get_string_table_for_testing sets |*out_ptr| and |*out_len| to the table
215  * of built-in |ASN1_STRING_TABLE| values. It is exported for testing. */
217  const ASN1_STRING_TABLE **out_ptr, size_t *out_len);
218 
219 
220 #if defined(__cplusplus)
221 } /* extern C */
222 #endif
223 
224 #endif /* OPENSSL_HEADER_ASN1_ASN1_LOCL_H */
xds_interop_client.str
str
Definition: xds_interop_client.py:487
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
asn1_object_st::length
int length
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:105
asn1_bit_string_length
int asn1_bit_string_length(const ASN1_BIT_STRING *str, uint8_t *out_padding_bits)
Definition: a_bitstr.c:74
gen_build_yaml.out
dictionary out
Definition: src/benchmark/gen_build_yaml.py:24
regen-readme.it
it
Definition: regen-readme.py:15
ASN1_TLC_st
Definition: asn1t.h:520
ctx
Definition: benchmark-async.c:30
ASN1_item_ex_free
void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
Definition: tasn_fre.c:73
asn1_set_choice_selector
int asn1_set_choice_selector(ASN1_VALUE **pval, int value, const ASN1_ITEM *it)
Definition: tasn_utl.c:84
ASN1_STRING_TABLE
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:206
ASN1_ENCODING_st::alias_only_on_next_parse
unsigned alias_only_on_next_parse
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:126
ASN1_primitive_free
void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
Definition: tasn_fre.c:184
ASN1_ENCODING_st::len
long len
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:117
ASN1_item_ex_d2i
int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx)
Definition: tasn_dec.c:464
UTF8_getc
int UTF8_getc(const unsigned char *str, int len, uint32_t *val)
Definition: a_utf8.c:75
ASN1_STRING_TABLE::flags
unsigned long flags
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:211
asn1_enc_restore
int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval, const ASN1_ITEM *it)
Definition: tasn_utl.c:191
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
OPENSSL_gmtime
struct tm * OPENSSL_gmtime(const time_t *time, struct tm *result)
Definition: time_support.c:69
to
size_t to
Definition: abseil-cpp/absl/container/internal/layout_test.cc:1385
OPENSSL_gmtime_adj
int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec)
Definition: time_support.c:144
asn1_utctime_to_tm
int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d)
Definition: a_utctm.c:68
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
asn1_get_string_table_for_testing
OPENSSL_EXPORT void asn1_get_string_table_for_testing(const ASN1_STRING_TABLE **out_ptr, size_t *out_len)
Definition: a_strnid.c:262
asn1_object_st
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:102
asn1_object_st::flags
int flags
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:107
asn1_enc_init
void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it)
Definition: tasn_utl.c:133
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
from
size_t from
Definition: abseil-cpp/absl/container/internal/layout_test.cc:1384
ASN1_OBJECT_new
ASN1_OBJECT * ASN1_OBJECT_new(void)
Definition: a_object.c:250
ASN1_item_ex_new
int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
Definition: tasn_new.c:88
in
const char * in
Definition: third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc:391
ASN1_ENCODING_st::modified
int modified
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:118
ASN1_ITEM_st
Definition: asn1t.h:459
asn1_object_st::nid
int nid
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:104
tag
static void * tag(intptr_t t)
Definition: bad_client.cc:318
asn1_object_st::sn
const char * sn
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:103
asn1_item_combine_free
void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine)
Definition: tasn_fre.c:78
ASN1_STRING_TABLE::nid
int nid
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:207
asn1_generalizedtime_to_tm
int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d)
Definition: a_gentm.c:67
asn1_object_st::data
const unsigned char * data
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:106
asn1_enc_free
void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
Definition: tasn_utl.c:145
asn1_refcount_set_one
void asn1_refcount_set_one(ASN1_VALUE **pval, const ASN1_ITEM *it)
Definition: tasn_utl.c:105
asn1t.h
ASN1_item_ex_i2d
int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass)
Definition: tasn_enc.c:118
asn1_is_printable
int asn1_is_printable(uint32_t value)
Definition: a_mbstr.c:286
ASN1_template_free
void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
Definition: tasn_fre.c:167
ASN1_ENCODING_st::alias_only
unsigned alias_only
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:122
OPENSSL_gmtime_diff
int OPENSSL_gmtime_diff(int *out_days, int *out_secs, const struct tm *from, const struct tm *to)
Definition: time_support.c:174
d
static const fe d
Definition: curve25519_tables.h:19
ASN1_ENCODING_st::enc
unsigned char * enc
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:116
tm
static uv_timer_t tm
Definition: test-tcp-open.c:41
value
const char * value
Definition: hpack_parser_table.cc:165
asn1_do_adb
const ASN1_TEMPLATE * asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt, int nullerr)
Definition: tasn_utl.c:222
ASN1_ENCODING
struct ASN1_ENCODING_st ASN1_ENCODING
asn1_enc_save
int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, const ASN1_ITEM *it)
Definition: tasn_utl.c:160
asn1_get_field_ptr
ASN1_VALUE ** asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
Definition: tasn_utl.c:209
ASN1_STRING_TABLE::minsize
long minsize
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:208
ASN1_ENCODING_st
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:115
ASN1_TEMPLATE_st
Definition: asn1t.h:351
OPENSSL_EXPORT
#define OPENSSL_EXPORT
Definition: base.h:222
ASN1_VALUE
struct ASN1_VALUE_st ASN1_VALUE
Definition: asn1.h:320
ASN1_STRING_TABLE::maxsize
long maxsize
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:209
asn1_type_value_as_pointer
const void * asn1_type_value_as_pointer(const ASN1_TYPE *a)
Definition: a_type.c:76
UTF8_putc
int UTF8_putc(unsigned char *str, int len, uint32_t value)
Definition: a_utf8.c:172
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
asn1_type_st
Definition: asn1.h:1481
ASN1_STRING_TABLE::mask
unsigned long mask
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:210
asn1_get_choice_selector
int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it)
Definition: tasn_utl.c:78
asn1_string_st
Definition: asn1.h:543
asn1.h
asn1_refcount_dec_and_test_zero
int asn1_refcount_dec_and_test_zero(ASN1_VALUE **pval, const ASN1_ITEM *it)
Definition: tasn_utl.c:112
asn1_object_st::ln
const char * ln
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:103


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:07