asn1.h
Go to the documentation of this file.
1 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
2  * All rights reserved.
3  *
4  * This package is an SSL implementation written
5  * by Eric Young (eay@cryptsoft.com).
6  * The implementation was written so as to conform with Netscapes SSL.
7  *
8  * This library is free for commercial and non-commercial use as long as
9  * the following conditions are aheared to. The following conditions
10  * apply to all code found in this distribution, be it the RC4, RSA,
11  * lhash, DES, etc., code; not just the SSL code. The SSL documentation
12  * included with this distribution is covered by the same copyright terms
13  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
14  *
15  * Copyright remains Eric Young's, and as such any Copyright notices in
16  * the code are not to be removed.
17  * If this package is used in a product, Eric Young should be given attribution
18  * as the author of the parts of the library used.
19  * This can be in the form of a textual message at program startup or
20  * in documentation (online or textual) provided with the package.
21  *
22  * Redistribution and use in source and binary forms, with or without
23  * modification, are permitted provided that the following conditions
24  * are met:
25  * 1. Redistributions of source code must retain the copyright
26  * notice, this list of conditions and the following disclaimer.
27  * 2. Redistributions in binary form must reproduce the above copyright
28  * notice, this list of conditions and the following disclaimer in the
29  * documentation and/or other materials provided with the distribution.
30  * 3. All advertising materials mentioning features or use of this software
31  * must display the following acknowledgement:
32  * "This product includes cryptographic software written by
33  * Eric Young (eay@cryptsoft.com)"
34  * The word 'cryptographic' can be left out if the rouines from the library
35  * being used are not cryptographic related :-).
36  * 4. If you include any Windows specific code (or a derivative thereof) from
37  * the apps directory (application code) you must include an acknowledgement:
38  * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
39  *
40  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
41  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
44  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50  * SUCH DAMAGE.
51  *
52  * The licence and distribution terms for any publically available version or
53  * derivative of this code cannot be changed. i.e. this code cannot simply be
54  * copied and put under another distribution licence
55  * [including the GNU Public Licence.]
56  */
57 
58 #ifndef HEADER_ASN1_H
59 #define HEADER_ASN1_H
60 
61 #include <openssl/base.h>
62 
63 #include <time.h>
64 
65 #include <openssl/bio.h>
66 #include <openssl/bn.h>
67 #include <openssl/stack.h>
68 
69 #if defined(__cplusplus)
70 extern "C" {
71 #endif
72 
73 
74 // Legacy ASN.1 library.
75 //
76 // This header is part of OpenSSL's ASN.1 implementation. It is retained for
77 // compatibility but should not be used by new code. The functions are difficult
78 // to use correctly, and have buggy or non-standard behaviors. They are thus
79 // particularly prone to behavior changes and API removals, as BoringSSL
80 // iterates on these issues.
81 //
82 // Use the new |CBS| and |CBB| library in <openssl/bytestring.h> instead.
83 
84 
85 // Tag constants.
86 //
87 // These constants are used in various APIs to specify ASN.1 types and tag
88 // components. See the specific API's documentation for details on which values
89 // are used and how.
90 
91 // The following constants are tag classes.
92 #define V_ASN1_UNIVERSAL 0x00
93 #define V_ASN1_APPLICATION 0x40
94 #define V_ASN1_CONTEXT_SPECIFIC 0x80
95 #define V_ASN1_PRIVATE 0xc0
96 
97 // V_ASN1_CONSTRUCTED indicates an element is constructed, rather than
98 // primitive.
99 #define V_ASN1_CONSTRUCTED 0x20
100 
101 // V_ASN1_PRIMITIVE_TAG is the highest tag number which can be encoded in a
102 // single byte. Note this is unrelated to whether an element is constructed or
103 // primitive.
104 //
105 // TODO(davidben): Make this private.
106 #define V_ASN1_PRIMITIVE_TAG 0x1f
107 
108 // V_ASN1_MAX_UNIVERSAL is the highest supported universal tag number. It is
109 // necessary to avoid ambiguity with |V_ASN1_NEG| and |MBSTRING_FLAG|.
110 //
111 // TODO(davidben): Make this private.
112 #define V_ASN1_MAX_UNIVERSAL 0xff
113 
114 // V_ASN1_UNDEF is used in some APIs to indicate an ASN.1 element is omitted.
115 #define V_ASN1_UNDEF (-1)
116 
117 // V_ASN1_OTHER is used in |ASN1_TYPE| to indicate a non-universal ASN.1 type.
118 #define V_ASN1_OTHER (-3)
119 
120 // V_ASN1_ANY is used by the ASN.1 templates to indicate an ANY type.
121 #define V_ASN1_ANY (-4)
122 
123 // The following constants are tag numbers for universal types.
124 #define V_ASN1_EOC 0
125 #define V_ASN1_BOOLEAN 1
126 #define V_ASN1_INTEGER 2
127 #define V_ASN1_BIT_STRING 3
128 #define V_ASN1_OCTET_STRING 4
129 #define V_ASN1_NULL 5
130 #define V_ASN1_OBJECT 6
131 #define V_ASN1_OBJECT_DESCRIPTOR 7
132 #define V_ASN1_EXTERNAL 8
133 #define V_ASN1_REAL 9
134 #define V_ASN1_ENUMERATED 10
135 #define V_ASN1_UTF8STRING 12
136 #define V_ASN1_SEQUENCE 16
137 #define V_ASN1_SET 17
138 #define V_ASN1_NUMERICSTRING 18
139 #define V_ASN1_PRINTABLESTRING 19
140 #define V_ASN1_T61STRING 20
141 #define V_ASN1_TELETEXSTRING 20
142 #define V_ASN1_VIDEOTEXSTRING 21
143 #define V_ASN1_IA5STRING 22
144 #define V_ASN1_UTCTIME 23
145 #define V_ASN1_GENERALIZEDTIME 24
146 #define V_ASN1_GRAPHICSTRING 25
147 #define V_ASN1_ISO64STRING 26
148 #define V_ASN1_VISIBLESTRING 26
149 #define V_ASN1_GENERALSTRING 27
150 #define V_ASN1_UNIVERSALSTRING 28
151 #define V_ASN1_BMPSTRING 30
152 
153 // The following constants are used for |ASN1_STRING| values that represent
154 // negative INTEGER and ENUMERATED values. See |ASN1_STRING| for more details.
155 #define V_ASN1_NEG 0x100
156 #define V_ASN1_NEG_INTEGER (V_ASN1_INTEGER | V_ASN1_NEG)
157 #define V_ASN1_NEG_ENUMERATED (V_ASN1_ENUMERATED | V_ASN1_NEG)
158 
159 // The following constants are bitmask representations of ASN.1 types.
160 #define B_ASN1_NUMERICSTRING 0x0001
161 #define B_ASN1_PRINTABLESTRING 0x0002
162 #define B_ASN1_T61STRING 0x0004
163 #define B_ASN1_TELETEXSTRING 0x0004
164 #define B_ASN1_VIDEOTEXSTRING 0x0008
165 #define B_ASN1_IA5STRING 0x0010
166 #define B_ASN1_GRAPHICSTRING 0x0020
167 #define B_ASN1_ISO64STRING 0x0040
168 #define B_ASN1_VISIBLESTRING 0x0040
169 #define B_ASN1_GENERALSTRING 0x0080
170 #define B_ASN1_UNIVERSALSTRING 0x0100
171 #define B_ASN1_OCTET_STRING 0x0200
172 #define B_ASN1_BIT_STRING 0x0400
173 #define B_ASN1_BMPSTRING 0x0800
174 #define B_ASN1_UNKNOWN 0x1000
175 #define B_ASN1_UTF8STRING 0x2000
176 #define B_ASN1_UTCTIME 0x4000
177 #define B_ASN1_GENERALIZEDTIME 0x8000
178 #define B_ASN1_SEQUENCE 0x10000
179 
180 // ASN1_tag2bit converts |tag| from the tag number of a universal type to a
181 // corresponding |B_ASN1_*| constant, |B_ASN1_UNKNOWN|, or zero. If the
182 // |B_ASN1_*| constant above is defined, it will map the corresponding
183 // |V_ASN1_*| constant to it. Otherwise, whether it returns |B_ASN1_UNKNOWN| or
184 // zero is ill-defined and callers should not rely on it.
185 //
186 // TODO(https://crbug.com/boringssl/412): Figure out what |B_ASN1_UNNOWN| vs
187 // zero is meant to be. The main impact is what values go in |B_ASN1_PRINTABLE|.
188 // To that end, we must return zero on types that can't go in |ASN1_STRING|.
189 OPENSSL_EXPORT unsigned long ASN1_tag2bit(int tag);
190 
191 // ASN1_tag2str returns a string representation of |tag|, interpret as a tag
192 // number for a universal type, or |V_ASN1_NEG_*|.
193 OPENSSL_EXPORT const char *ASN1_tag2str(int tag);
194 
195 
196 // API conventions.
197 //
198 // The following sample functions document the calling conventions used by
199 // legacy ASN.1 APIs.
200 
201 #if 0 // Sample functions
202 
203 // d2i_SAMPLE parses a structure from up to |len| bytes at |*inp|. On success,
204 // it advances |*inp| by the number of bytes read and returns a newly-allocated
205 // |SAMPLE| object containing the parsed structure. If |out| is non-NULL, it
206 // additionally frees the previous value at |*out| and updates |*out| to the
207 // result. If parsing or allocating the result fails, it returns NULL.
208 //
209 // This function does not reject trailing data in the input. This allows the
210 // caller to parse a sequence of concatenated structures. Callers parsing only
211 // one structure should check for trailing data by comparing the updated |*inp|
212 // with the end of the input.
213 //
214 // Note: If |out| and |*out| are both non-NULL, the object at |*out| is not
215 // updated in-place. Instead, it is freed, and the pointer is updated to the
216 // new object. This differs from OpenSSL, which behaves more like
217 // |d2i_SAMPLE_with_reuse|. Callers are recommended to set |out| to NULL and
218 // instead use the return value.
219 SAMPLE *d2i_SAMPLE(SAMPLE **out, const uint8_t **inp, long len);
220 
221 // d2i_SAMPLE_with_reuse parses a structure from up to |len| bytes at |*inp|. On
222 // success, it advances |*inp| by the number of bytes read and returns a
223 // non-NULL pointer to an object containing the parsed structure. The object is
224 // determined from |out| as follows:
225 //
226 // If |out| is NULL, the function places the result in a newly-allocated
227 // |SAMPLE| object and returns it. This mode is recommended.
228 //
229 // If |out| is non-NULL, but |*out| is NULL, the function also places the result
230 // in a newly-allocated |SAMPLE| object. It sets |*out| to this object and also
231 // returns it.
232 //
233 // If |out| and |*out| are both non-NULL, the function updates the object at
234 // |*out| in-place with the result and returns |*out|.
235 //
236 // If any of the above fail, the function returns NULL.
237 //
238 // This function does not reject trailing data in the input. This allows the
239 // caller to parse a sequence of concatenated structures. Callers parsing only
240 // one structure should check for trailing data by comparing the updated |*inp|
241 // with the end of the input.
242 //
243 // WARNING: Callers should not rely on the in-place update mode. It often
244 // produces the wrong result or breaks the type's internal invariants. Future
245 // revisions of BoringSSL may standardize on the |d2i_SAMPLE| behavior.
246 SAMPLE *d2i_SAMPLE_with_reuse(SAMPLE **out, const uint8_t **inp, long len);
247 
248 // i2d_SAMPLE marshals |in|. On error, it returns a negative value. On success,
249 // it returns the length of the result and outputs it via |outp| as follows:
250 //
251 // If |outp| is NULL, the function writes nothing. This mode can be used to size
252 // buffers.
253 //
254 // If |outp| is non-NULL but |*outp| is NULL, the function sets |*outp| to a
255 // newly-allocated buffer containing the result. The caller is responsible for
256 // releasing |*outp| with |OPENSSL_free|. This mode is recommended for most
257 // callers.
258 //
259 // If |outp| and |*outp| are non-NULL, the function writes the result to
260 // |*outp|, which must have enough space available, and advances |*outp| just
261 // past the output.
262 //
263 // WARNING: In the third mode, the function does not internally check output
264 // bounds. Failing to correctly size the buffer will result in a potentially
265 // exploitable memory error.
266 int i2d_SAMPLE(const SAMPLE *in, uint8_t **outp);
267 
268 #endif // Sample functions
269 
270 // The following typedefs are sometimes used for pointers to functions like
271 // |d2i_SAMPLE| and |i2d_SAMPLE|. Note, however, that these act on |void*|.
272 // Calling a function with a different pointer type is undefined in C, so this
273 // is only valid with a wrapper.
274 typedef void *d2i_of_void(void **, const unsigned char **, long);
275 typedef int i2d_of_void(const void *, unsigned char **);
276 
277 
278 // ASN.1 types.
279 //
280 // An |ASN1_ITEM| represents an ASN.1 type and allows working with ASN.1 types
281 // generically.
282 //
283 // |ASN1_ITEM|s use a different namespace from C types and are accessed via
284 // |ASN1_ITEM_*| macros. So, for example, |ASN1_OCTET_STRING| is both a C type
285 // and the name of an |ASN1_ITEM|, referenced as
286 // |ASN1_ITEM_rptr(ASN1_OCTET_STRING)|.
287 //
288 // Each |ASN1_ITEM| has a corresponding C type, typically with the same name,
289 // which represents values in the ASN.1 type. This type is either a pointer type
290 // or |ASN1_BOOLEAN|. When it is a pointer, NULL pointers represent omitted
291 // values. For example, an OCTET STRING value is declared with the C type
292 // |ASN1_OCTET_STRING*| and uses the |ASN1_ITEM| named |ASN1_OCTET_STRING|. An
293 // OPTIONAL OCTET STRING uses the same C type and represents an omitted value
294 // with a NULL pointer. |ASN1_BOOLEAN| is described in a later section.
295 
296 // DECLARE_ASN1_ITEM declares an |ASN1_ITEM| with name |name|. The |ASN1_ITEM|
297 // may be referenced with |ASN1_ITEM_rptr|. Uses of this macro should document
298 // the corresponding ASN.1 and C types.
299 #define DECLARE_ASN1_ITEM(name) extern OPENSSL_EXPORT const ASN1_ITEM name##_it;
300 
301 // ASN1_ITEM_rptr returns the |const ASN1_ITEM *| named |name|.
302 #define ASN1_ITEM_rptr(name) (&(name##_it))
303 
304 // ASN1_ITEM_EXP is an abstraction for referencing an |ASN1_ITEM| in a
305 // constant-initialized structure, such as a method table. It exists because, on
306 // some OpenSSL platforms, |ASN1_ITEM| references are indirected through
307 // functions. Structures reference the |ASN1_ITEM| by declaring a field like
308 // |ASN1_ITEM_EXP *item| and initializing it with |ASN1_ITEM_ref|.
309 typedef const ASN1_ITEM ASN1_ITEM_EXP;
310 
311 // ASN1_ITEM_ref returns an |ASN1_ITEM_EXP*| for the |ASN1_ITEM| named |name|.
312 #define ASN1_ITEM_ref(name) (&(name##_it))
313 
314 // ASN1_ITEM_ptr converts |iptr|, which must be an |ASN1_ITEM_EXP*| to a
315 // |const ASN1_ITEM*|.
316 #define ASN1_ITEM_ptr(iptr) (iptr)
317 
318 // ASN1_VALUE_st (aka |ASN1_VALUE|) is an opaque type used as a placeholder for
319 // the C type corresponding to an |ASN1_ITEM|.
320 typedef struct ASN1_VALUE_st ASN1_VALUE;
321 
322 // ASN1_item_new allocates a new value of the C type corresponding to |it|, or
323 // NULL on error. On success, the caller must release the value with
324 // |ASN1_item_free|, or the corresponding C type's free function, when done. The
325 // new value will initialize fields of the value to some default state, such as
326 // an empty string. Note, however, that this default state sometimes omits
327 // required values, such as with CHOICE types.
328 //
329 // This function may not be used with |ASN1_ITEM|s whose C type is
330 // |ASN1_BOOLEAN|.
331 //
332 // WARNING: Casting the result of this function to the wrong type is a
333 // potentially exploitable memory error. Callers must ensure the value is used
334 // consistently with |it|. Prefer using type-specific functions such as
335 // |ASN1_OCTET_STRING_new|.
337 
338 // ASN1_item_free releases memory associated with |val|, which must be an object
339 // of the C type corresponding to |it|.
340 //
341 // This function may not be used with |ASN1_ITEM|s whose C type is
342 // |ASN1_BOOLEAN|.
343 //
344 // WARNING: Passing a pointer of the wrong type into this function is a
345 // potentially exploitable memory error. Callers must ensure |val| is consistent
346 // with |it|. Prefer using type-specific functions such as
347 // |ASN1_OCTET_STRING_free|.
349 
350 // ASN1_item_d2i parses the ASN.1 type |it| from up to |len| bytes at |*inp|.
351 // It behaves like |d2i_SAMPLE_with_reuse|, except that |out| and the return
352 // value are cast to |ASN1_VALUE| pointers.
353 //
354 // TODO(https://crbug.com/boringssl/444): C strict aliasing forbids type-punning
355 // |T*| and |ASN1_VALUE*| the way this function signature does. When that bug is
356 // resolved, we will need to pick which type |*out| is (probably |T*|). Do not
357 // use a non-NULL |out| to avoid ending up on the wrong side of this question.
358 //
359 // This function may not be used with |ASN1_ITEM|s whose C type is
360 // |ASN1_BOOLEAN|.
361 //
362 // WARNING: Casting the result of this function to the wrong type, or passing a
363 // pointer of the wrong type into this function, are potentially exploitable
364 // memory errors. Callers must ensure |out| is consistent with |it|. Prefer
365 // using type-specific functions such as |d2i_ASN1_OCTET_STRING|.
367  const unsigned char **inp, long len,
368  const ASN1_ITEM *it);
369 
370 // ASN1_item_i2d marshals |val| as the ASN.1 type associated with |it|, as
371 // described in |i2d_SAMPLE|.
372 //
373 // This function may not be used with |ASN1_ITEM|s whose C type is
374 // |ASN1_BOOLEAN|.
375 //
376 // WARNING: Passing a pointer of the wrong type into this function is a
377 // potentially exploitable memory error. Callers must ensure |val| is consistent
378 // with |it|. Prefer using type-specific functions such as
379 // |i2d_ASN1_OCTET_STRING|.
380 OPENSSL_EXPORT int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **outp,
381  const ASN1_ITEM *it);
382 
383 // ASN1_item_dup returns a newly-allocated copy of |x|, or NULL on error. |x|
384 // must be an object of |it|'s C type.
385 //
386 // This function may not be used with |ASN1_ITEM|s whose C type is
387 // |ASN1_BOOLEAN|.
388 //
389 // WARNING: Casting the result of this function to the wrong type, or passing a
390 // pointer of the wrong type into this function, are potentially exploitable
391 // memory errors. Prefer using type-specific functions such as
392 // |ASN1_STRING_dup|.
393 OPENSSL_EXPORT void *ASN1_item_dup(const ASN1_ITEM *it, void *x);
394 
395 // The following functions behave like |ASN1_item_d2i| but read from |in|
396 // instead. |out| is the same parameter as in |ASN1_item_d2i|, but written with
397 // |void*| instead. The return values similarly match.
398 //
399 // These functions may not be used with |ASN1_ITEM|s whose C type is
400 // |ASN1_BOOLEAN|.
401 //
402 // WARNING: These functions do not bound how much data is read from |in|.
403 // Parsing an untrusted input could consume unbounded memory.
404 OPENSSL_EXPORT void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *out);
405 OPENSSL_EXPORT void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *out);
406 
407 // The following functions behave like |ASN1_item_i2d| but write to |out|
408 // instead. |in| is the same parameter as in |ASN1_item_i2d|, but written with
409 // |void*| instead.
410 //
411 // These functions may not be used with |ASN1_ITEM|s whose C type is
412 // |ASN1_BOOLEAN|.
413 OPENSSL_EXPORT int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *in);
414 OPENSSL_EXPORT int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *in);
415 
416 // ASN1_item_unpack parses |oct|'s contents as |it|'s ASN.1 type. It returns a
417 // newly-allocated instance of |it|'s C type on success, or NULL on error.
418 //
419 // This function may not be used with |ASN1_ITEM|s whose C type is
420 // |ASN1_BOOLEAN|.
421 //
422 // WARNING: Casting the result of this function to the wrong type is a
423 // potentially exploitable memory error. Callers must ensure the value is used
424 // consistently with |it|.
426  const ASN1_ITEM *it);
427 
428 // ASN1_item_pack marshals |obj| as |it|'s ASN.1 type. If |out| is NULL, it
429 // returns a newly-allocated |ASN1_STRING| with the result, or NULL on error.
430 // If |out| is non-NULL, but |*out| is NULL, it does the same but additionally
431 // sets |*out| to the result. If both |out| and |*out| are non-NULL, it writes
432 // the result to |*out| and returns |*out| on success or NULL on error.
433 //
434 // This function may not be used with |ASN1_ITEM|s whose C type is
435 // |ASN1_BOOLEAN|.
436 //
437 // WARNING: Passing a pointer of the wrong type into this function is a
438 // potentially exploitable memory error. Callers must ensure |val| is consistent
439 // with |it|.
441  ASN1_STRING **out);
442 
443 
444 // Booleans.
445 //
446 // This library represents ASN.1 BOOLEAN values with |ASN1_BOOLEAN|, which is an
447 // integer type. FALSE is zero, TRUE is 0xff, and an omitted OPTIONAL BOOLEAN is
448 // -1.
449 
450 // d2i_ASN1_BOOLEAN parses a DER-encoded ASN.1 BOOLEAN from up to |len| bytes at
451 // |*inp|. On success, it advances |*inp| by the number of bytes read and
452 // returns the result. If |out| is non-NULL, it additionally writes the result
453 // to |*out|. On error, it returns -1.
454 //
455 // This function does not reject trailing data in the input. This allows the
456 // caller to parse a sequence of concatenated structures. Callers parsing only
457 // one structure should check for trailing data by comparing the updated |*inp|
458 // with the end of the input.
459 //
460 // WARNING: This function's is slightly different from other |d2i_*| functions
461 // because |ASN1_BOOLEAN| is not a pointer type.
462 //
463 // TODO(https://crbug.com/boringssl/354): This function currently also accepts
464 // BER, but this will be removed in the future.
466  const unsigned char **inp,
467  long len);
468 
469 // i2d_ASN1_BOOLEAN marshals |a| as a DER-encoded ASN.1 BOOLEAN, as described in
470 // |i2d_SAMPLE|.
471 OPENSSL_EXPORT int i2d_ASN1_BOOLEAN(ASN1_BOOLEAN a, unsigned char **outp);
472 
473 // The following |ASN1_ITEM|s have ASN.1 type BOOLEAN and C type |ASN1_BOOLEAN|.
474 // |ASN1_TBOOLEAN| and |ASN1_FBOOLEAN| must be marked OPTIONAL. When omitted,
475 // they are parsed as TRUE and FALSE, respectively, rather than -1.
477 DECLARE_ASN1_ITEM(ASN1_TBOOLEAN)
478 DECLARE_ASN1_ITEM(ASN1_FBOOLEAN)
479 
480 
481 // Strings.
482 //
483 // ASN.1 contains a myriad of string types, as well as types that contain data
484 // that may be encoded into a string. This library uses a single type,
485 // |ASN1_STRING|, to represent most values.
486 
487 // An asn1_string_st (aka |ASN1_STRING|) represents a value of a string-like
488 // ASN.1 type. It contains a type field, and a byte string data field with a
489 // type-specific representation.
490 //
491 // When representing a string value, the type field is one of
492 // |V_ASN1_OCTET_STRING|, |V_ASN1_UTF8STRING|, |V_ASN1_NUMERICSTRING|,
493 // |V_ASN1_PRINTABLESTRING|, |V_ASN1_T61STRING|, |V_ASN1_VIDEOTEXSTRING|,
494 // |V_ASN1_IA5STRING|, |V_ASN1_GRAPHICSTRING|, |V_ASN1_ISO64STRING|,
495 // |V_ASN1_VISIBLESTRING|, |V_ASN1_GENERALSTRING|, |V_ASN1_UNIVERSALSTRING|, or
496 // |V_ASN1_BMPSTRING|. The data contains the byte representation of of the
497 // string.
498 //
499 // When representing a BIT STRING value, the type field is |V_ASN1_BIT_STRING|.
500 // See bit string documentation below for how the data and flags are used.
501 //
502 // When representing an INTEGER or ENUMERATED value, the type field is one of
503 // |V_ASN1_INTEGER|, |V_ASN1_NEG_INTEGER|, |V_ASN1_ENUMERATED|, or
504 // |V_ASN1_NEG_ENUMERATED|. See integer documentation below for details.
505 //
506 // When representing a GeneralizedTime or UTCTime value, the type field is
507 // |V_ASN1_GENERALIZEDTIME| or |V_ASN1_UTCTIME|, respectively. The data contains
508 // the DER encoding of the value. For example, the UNIX epoch would be
509 // "19700101000000Z" for a GeneralizedTime and "700101000000Z" for a UTCTime.
510 //
511 // |ASN1_STRING|, when stored in an |ASN1_TYPE|, may also represent an element
512 // with tag not directly supported by this library. See |ASN1_TYPE| for details.
513 //
514 // |ASN1_STRING| additionally has the following typedefs: |ASN1_BIT_STRING|,
515 // |ASN1_BMPSTRING|, |ASN1_ENUMERATED|, |ASN1_GENERALIZEDTIME|,
516 // |ASN1_GENERALSTRING|, |ASN1_IA5STRING|, |ASN1_INTEGER|, |ASN1_OCTET_STRING|,
517 // |ASN1_PRINTABLESTRING|, |ASN1_T61STRING|, |ASN1_TIME|,
518 // |ASN1_UNIVERSALSTRING|, |ASN1_UTCTIME|, |ASN1_UTF8STRING|, and
519 // |ASN1_VISIBLESTRING|. Other than |ASN1_TIME|, these correspond to universal
520 // ASN.1 types. |ASN1_TIME| represents a CHOICE of UTCTime and GeneralizedTime,
521 // with a cutoff of 2049, as used in Section 4.1.2.5 of RFC 5280.
522 //
523 // For clarity, callers are encouraged to use the appropriate typedef when
524 // available. They are the same type as |ASN1_STRING|, so a caller may freely
525 // pass them into functions expecting |ASN1_STRING|, such as
526 // |ASN1_STRING_length|.
527 //
528 // If a function returns an |ASN1_STRING| where the typedef or ASN.1 structure
529 // implies constraints on the type field, callers may assume that the type field
530 // is correct. However, if a function takes an |ASN1_STRING| as input, callers
531 // must ensure the type field matches. These invariants are not captured by the
532 // C type system and may not be checked at runtime. For example, callers may
533 // assume the output of |X509_get0_serialNumber| has type |V_ASN1_INTEGER| or
534 // |V_ASN1_NEG_INTEGER|. Callers must not pass a string of type
535 // |V_ASN1_OCTET_STRING| to |X509_set_serialNumber|. Doing so may break
536 // invariants on the |X509| object and break the |X509_get0_serialNumber|
537 // invariant.
538 //
539 // TODO(https://crbug.com/boringssl/445): This is very unfriendly. Getting the
540 // type field wrong should not cause memory errors, but it may do strange
541 // things. We should add runtime checks to anything that consumes |ASN1_STRING|s
542 // from the caller.
544  int length;
545  int type;
546  unsigned char *data;
547  long flags;
548 };
549 
550 // ASN1_STRING_FLAG_BITS_LEFT indicates, in a BIT STRING |ASN1_STRING|, that
551 // flags & 0x7 contains the number of padding bits added to the BIT STRING
552 // value. When not set, all trailing zero bits in the last byte are implicitly
553 // treated as padding. This behavior is deprecated and should not be used.
554 #define ASN1_STRING_FLAG_BITS_LEFT 0x08
555 
556 // ASN1_STRING_type_new returns a newly-allocated empty |ASN1_STRING| object of
557 // type |type|, or NULL on error.
559 
560 // ASN1_STRING_new returns a newly-allocated empty |ASN1_STRING| object with an
561 // arbitrary type. Prefer one of the type-specific constructors, such as
562 // |ASN1_OCTET_STRING_new|, or |ASN1_STRING_type_new|.
564 
565 // ASN1_STRING_free releases memory associated with |str|.
567 
568 // ASN1_STRING_copy sets |dst| to a copy of |str|. It returns one on success and
569 // zero on error.
571 
572 // ASN1_STRING_dup returns a newly-allocated copy of |str|, or NULL on error.
574 
575 // ASN1_STRING_type returns the type of |str|. This value will be one of the
576 // |V_ASN1_*| constants.
578 
579 // ASN1_STRING_get0_data returns a pointer to |str|'s contents. Callers should
580 // use |ASN1_STRING_length| to determine the length of the string. The string
581 // may have embedded NUL bytes and may not be NUL-terminated.
582 OPENSSL_EXPORT const unsigned char *ASN1_STRING_get0_data(
583  const ASN1_STRING *str);
584 
585 // ASN1_STRING_data returns a mutable pointer to |str|'s contents. Callers
586 // should use |ASN1_STRING_length| to determine the length of the string. The
587 // string may have embedded NUL bytes and may not be NUL-terminated.
588 //
589 // Prefer |ASN1_STRING_get0_data|.
591 
592 // ASN1_STRING_length returns the length of |str|, in bytes.
594 
595 // ASN1_STRING_cmp compares |a| and |b|'s type and contents. It returns an
596 // integer equal to, less than, or greater than zero if |a| is equal to, less
597 // than, or greater than |b|, respectively. This function compares by length,
598 // then data, then type. Note the data compared is the |ASN1_STRING| internal
599 // representation and the type order is arbitrary. While this comparison is
600 // suitable for sorting, callers should not rely on the exact order when |a|
601 // and |b| are different types.
602 //
603 // Note that, if |a| and |b| are INTEGERs, this comparison does not order the
604 // values numerically. For a numerical comparison, use |ASN1_INTEGER_cmp|.
606 
607 // ASN1_STRING_set sets the contents of |str| to a copy of |len| bytes from
608 // |data|. It returns one on success and zero on error.
609 OPENSSL_EXPORT int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);
610 
611 // ASN1_STRING_set0 sets the contents of |str| to |len| bytes from |data|. It
612 // takes ownership of |data|, which must have been allocated with
613 // |OPENSSL_malloc|.
615 
616 // The following functions call |ASN1_STRING_type_new| with the corresponding
617 // |V_ASN1_*| constant.
627 
628 // The following functions call |ASN1_STRING_free|.
638 
639 // The following functions parse up to |len| bytes from |*inp| as a
640 // DER-encoded ASN.1 value of the corresponding type, as described in
641 // |d2i_SAMPLE_with_reuse|.
642 //
643 // TODO(https://crbug.com/boringssl/354): This function currently also accepts
644 // BER, but this will be removed in the future.
646  const uint8_t **inp,
647  long len);
649  ASN1_GENERALSTRING **out, const uint8_t **inp, long len);
651  const uint8_t **inp,
652  long len);
654  const uint8_t **inp,
655  long len);
657  ASN1_PRINTABLESTRING **out, const uint8_t **inp, long len);
659  const uint8_t **inp,
660  long len);
662  ASN1_UNIVERSALSTRING **out, const uint8_t **inp, long len);
664  const uint8_t **inp,
665  long len);
667  ASN1_VISIBLESTRING **out, const uint8_t **inp, long len);
668 
669 // The following functions marshal |in| as a DER-encoded ASN.1 value of the
670 // corresponding type, as described in |i2d_SAMPLE|.
673  uint8_t **outp);
676  uint8_t **outp);
678  uint8_t **outp);
681  uint8_t **outp);
683  uint8_t **outp);
685  uint8_t **outp);
686 
687 // The following |ASN1_ITEM|s have the ASN.1 type referred to in their name and
688 // C type |ASN1_STRING*|. The C type may also be written as the corresponding
689 // typedef.
699 
700 // ASN1_OCTET_STRING_dup calls |ASN1_STRING_dup|.
702  const ASN1_OCTET_STRING *a);
703 
704 // ASN1_OCTET_STRING_cmp calls |ASN1_STRING_cmp|.
706  const ASN1_OCTET_STRING *b);
707 
708 // ASN1_OCTET_STRING_set calls |ASN1_STRING_set|.
710  const unsigned char *data, int len);
711 
712 // ASN1_STRING_to_UTF8 converts |in| to UTF-8. On success, sets |*out| to a
713 // newly-allocated buffer containing the resulting string and returns the length
714 // of the string. The caller must call |OPENSSL_free| to release |*out| when
715 // done. On error, it returns a negative number.
716 OPENSSL_EXPORT int ASN1_STRING_to_UTF8(unsigned char **out,
717  const ASN1_STRING *in);
718 
719 // The following formats define encodings for use with functions like
720 // |ASN1_mbstring_copy|. Note |MBSTRING_ASC| refers to Latin-1, not ASCII.
721 #define MBSTRING_FLAG 0x1000
722 #define MBSTRING_UTF8 (MBSTRING_FLAG)
723 #define MBSTRING_ASC (MBSTRING_FLAG | 1)
724 #define MBSTRING_BMP (MBSTRING_FLAG | 2)
725 #define MBSTRING_UNIV (MBSTRING_FLAG | 4)
726 
727 // DIRSTRING_TYPE contains the valid string types in an X.509 DirectoryString.
728 #define DIRSTRING_TYPE \
729  (B_ASN1_PRINTABLESTRING | B_ASN1_T61STRING | B_ASN1_BMPSTRING | \
730  B_ASN1_UTF8STRING)
731 
732 // PKCS9STRING_TYPE contains the valid string types in a PKCS9String.
733 #define PKCS9STRING_TYPE (DIRSTRING_TYPE | B_ASN1_IA5STRING)
734 
735 // ASN1_mbstring_copy converts |len| bytes from |in| to an ASN.1 string. If
736 // |len| is -1, |in| must be NUL-terminated and the length is determined by
737 // |strlen|. |in| is decoded according to |inform|, which must be one of
738 // |MBSTRING_*|. |mask| determines the set of valid output types and is a
739 // bitmask containing a subset of |B_ASN1_PRINTABLESTRING|, |B_ASN1_IA5STRING|,
740 // |B_ASN1_T61STRING|, |B_ASN1_BMPSTRING|, |B_ASN1_UNIVERSALSTRING|, and
741 // |B_ASN1_UTF8STRING|, in that preference order. This function chooses the
742 // first output type in |mask| which can represent |in|. It interprets T61String
743 // as Latin-1, rather than T.61.
744 //
745 // If |mask| is zero, |DIRSTRING_TYPE| is used by default.
746 //
747 // On success, this function returns the |V_ASN1_*| constant corresponding to
748 // the selected output type and, if |out| and |*out| are both non-NULL, updates
749 // the object at |*out| with the result. If |out| is non-NULL and |*out| is
750 // NULL, it instead sets |*out| to a newly-allocated |ASN1_STRING| containing
751 // the result. If |out| is NULL, it returns the selected output type without
752 // constructing an |ASN1_STRING|. On error, this function returns -1.
754  int len, int inform, unsigned long mask);
755 
756 // ASN1_mbstring_ncopy behaves like |ASN1_mbstring_copy| but returns an error if
757 // the input is less than |minsize| or greater than |maxsize| codepoints long. A
758 // |maxsize| value of zero is ignored. Note the sizes are measured in
759 // codepoints, not output bytes.
761  int len, int inform, unsigned long mask,
762  long minsize, long maxsize);
763 
764 // ASN1_STRING_set_by_NID behaves like |ASN1_mbstring_ncopy|, but determines
765 // |mask|, |minsize|, and |maxsize| based on |nid|. When |nid| is a recognized
766 // X.509 attribute type, it will pick a suitable ASN.1 string type and bounds.
767 // For most attribute types, it preferentially chooses UTF8String. If |nid| is
768 // unrecognized, it uses UTF8String by default.
769 //
770 // Slightly unlike |ASN1_mbstring_ncopy|, this function interprets |out| and
771 // returns its result as follows: If |out| is NULL, it returns a newly-allocated
772 // |ASN1_STRING| containing the result. If |out| is non-NULL and
773 // |*out| is NULL, it additionally sets |*out| to the result. If both |out| and
774 // |*out| are non-NULL, it instead updates the object at |*out| and returns
775 // |*out|. In all cases, it returns NULL on error.
776 //
777 // This function supports the following NIDs: |NID_countryName|,
778 // |NID_dnQualifier|, |NID_domainComponent|, |NID_friendlyName|,
779 // |NID_givenName|, |NID_initials|, |NID_localityName|, |NID_ms_csp_name|,
780 // |NID_name|, |NID_organizationalUnitName|, |NID_organizationName|,
781 // |NID_pkcs9_challengePassword|, |NID_pkcs9_emailAddress|,
782 // |NID_pkcs9_unstructuredAddress|, |NID_pkcs9_unstructuredName|,
783 // |NID_serialNumber|, |NID_stateOrProvinceName|, and |NID_surname|. Additional
784 // NIDs may be registered with |ASN1_STRING_set_by_NID|, but it is recommended
785 // to call |ASN1_mbstring_ncopy| directly instead.
787  const unsigned char *in,
788  int len, int inform,
789  int nid);
790 
791 // STABLE_NO_MASK causes |ASN1_STRING_TABLE_add| to allow types other than
792 // UTF8String.
793 #define STABLE_NO_MASK 0x02
794 
795 // ASN1_STRING_TABLE_add registers the corresponding parameters with |nid|, for
796 // use with |ASN1_STRING_set_by_NID|. It returns one on success and zero on
797 // error. It is an error to call this function if |nid| is a built-in NID, or
798 // was already registered by a previous call.
799 //
800 // WARNING: This function affects global state in the library. If two libraries
801 // in the same address space register information for the same OID, one call
802 // will fail. Prefer directly passing the desired parametrs to
803 // |ASN1_mbstring_copy| or |ASN1_mbstring_ncopy| instead.
804 OPENSSL_EXPORT int ASN1_STRING_TABLE_add(int nid, long minsize, long maxsize,
805  unsigned long mask,
806  unsigned long flags);
807 
808 
809 // Multi-strings.
810 //
811 // A multi-string, or "MSTRING", is an |ASN1_STRING| that represents a CHOICE of
812 // several string or string-like types, such as X.509's DirectoryString. The
813 // |ASN1_STRING|'s type field determines which type is used.
814 //
815 // Multi-string types are associated with a bitmask, using the |B_ASN1_*|
816 // constants, which defines which types are valid.
817 
818 // B_ASN1_DIRECTORYSTRING is a bitmask of types allowed in an X.509
819 // DirectoryString (RFC 5280).
820 #define B_ASN1_DIRECTORYSTRING \
821  (B_ASN1_PRINTABLESTRING | B_ASN1_TELETEXSTRING | B_ASN1_BMPSTRING | \
822  B_ASN1_UNIVERSALSTRING | B_ASN1_UTF8STRING)
823 
824 // DIRECTORYSTRING_new returns a newly-allocated |ASN1_STRING| with type -1, or
825 // NULL on error. The resulting |ASN1_STRING| is not a valid X.509
826 // DirectoryString until initialized with a value.
828 
829 // DIRECTORYSTRING_free calls |ASN1_STRING_free|.
831 
832 // d2i_DIRECTORYSTRING parses up to |len| bytes from |*inp| as a DER-encoded
833 // X.509 DirectoryString (RFC 5280), as described in |d2i_SAMPLE_with_reuse|.
834 //
835 // TODO(https://crbug.com/boringssl/354): This function currently also accepts
836 // BER, but this will be removed in the future.
837 //
838 // TODO(https://crbug.com/boringssl/449): DirectoryString's non-empty string
839 // requirement is not currently enforced.
841  const uint8_t **inp, long len);
842 
843 // i2d_DIRECTORYSTRING marshals |in| as a DER-encoded X.509 DirectoryString (RFC
844 // 5280), as described in |i2d_SAMPLE|.
846 
847 // DIRECTORYSTRING is an |ASN1_ITEM| whose ASN.1 type is X.509 DirectoryString
848 // (RFC 5280) and C type is |ASN1_STRING*|.
849 DECLARE_ASN1_ITEM(DIRECTORYSTRING)
850 
851 // B_ASN1_DISPLAYTEXT is a bitmask of types allowed in an X.509 DisplayText (RFC
852 // 5280).
853 #define B_ASN1_DISPLAYTEXT \
854  (B_ASN1_IA5STRING | B_ASN1_VISIBLESTRING | B_ASN1_BMPSTRING | \
855  B_ASN1_UTF8STRING)
856 
857 // DISPLAYTEXT_new returns a newly-allocated |ASN1_STRING| with type -1, or NULL
858 // on error. The resulting |ASN1_STRING| is not a valid X.509 DisplayText until
859 // initialized with a value.
861 
862 // DISPLAYTEXT_free calls |ASN1_STRING_free|.
864 
865 // d2i_DISPLAYTEXT parses up to |len| bytes from |*inp| as a DER-encoded X.509
866 // DisplayText (RFC 5280), as described in |d2i_SAMPLE_with_reuse|.
867 //
868 // TODO(https://crbug.com/boringssl/354): This function currently also accepts
869 // BER, but this will be removed in the future.
870 //
871 // TODO(https://crbug.com/boringssl/449): DisplayText's size limits are not
872 // currently enforced.
874  const uint8_t **inp, long len);
875 
876 // i2d_DISPLAYTEXT marshals |in| as a DER-encoded X.509 DisplayText (RFC 5280),
877 // as described in |i2d_SAMPLE|.
879 
880 // DISPLAYTEXT is an |ASN1_ITEM| whose ASN.1 type is X.509 DisplayText (RFC
881 // 5280) and C type is |ASN1_STRING*|.
882 DECLARE_ASN1_ITEM(DISPLAYTEXT)
883 
884 
885 // Bit strings.
886 //
887 // An ASN.1 BIT STRING type represents a string of bits. The string may not
888 // necessarily be a whole number of bytes. BIT STRINGs occur in ASN.1 structures
889 // in several forms:
890 //
891 // Some BIT STRINGs represent a bitmask of named bits, such as the X.509 key
892 // usage extension in RFC 5280, section 4.2.1.3. For such bit strings, DER
893 // imposes an additional restriction that trailing zero bits are removed. Some
894 // functions like |ASN1_BIT_STRING_set_bit| help in maintaining this.
895 //
896 // Other BIT STRINGs are arbitrary strings of bits used as identifiers and do
897 // not have this constraint, such as the X.509 issuerUniqueID field.
898 //
899 // Finally, some structures use BIT STRINGs as a container for byte strings. For
900 // example, the signatureValue field in X.509 and the subjectPublicKey field in
901 // SubjectPublicKeyInfo are defined as BIT STRINGs with a value specific to the
902 // AlgorithmIdentifier. While some unknown algorithm could choose to store
903 // arbitrary bit strings, all supported algorithms use a byte string, with bit
904 // order matching the DER encoding. Callers interpreting a BIT STRING as a byte
905 // string should use |ASN1_BIT_STRING_num_bytes| instead of |ASN1_STRING_length|
906 // and reject bit strings that are not a whole number of bytes.
907 //
908 // This library represents BIT STRINGs as |ASN1_STRING|s with type
909 // |V_ASN1_BIT_STRING|. The data contains the encoded form of the BIT STRING,
910 // including any padding bits added to round to a whole number of bytes, but
911 // excluding the leading byte containing the number of padding bits. If
912 // |ASN1_STRING_FLAG_BITS_LEFT| is set, the bottom three bits contains the
913 // number of padding bits. For example, DER encodes the BIT STRING {1, 0} as
914 // {0x06, 0x80 = 0b10_000000}. The |ASN1_STRING| representation has data of
915 // {0x80} and flags of ASN1_STRING_FLAG_BITS_LEFT | 6. If
916 // |ASN1_STRING_FLAG_BITS_LEFT| is unset, trailing zero bits are implicitly
917 // removed. Callers should not rely this representation when constructing bit
918 // strings. The padding bits in the |ASN1_STRING| data must be zero.
919 
920 // ASN1_BIT_STRING_new calls |ASN1_STRING_type_new| with |V_ASN1_BIT_STRING|.
922 
923 // ASN1_BIT_STRING_free calls |ASN1_STRING_free|.
925 
926 // d2i_ASN1_BIT_STRING parses up to |len| bytes from |*inp| as a DER-encoded
927 // ASN.1 BIT STRING, as described in |d2i_SAMPLE_with_reuse|.
928 //
929 // TODO(https://crbug.com/boringssl/354): This function currently also accepts
930 // BER, but this will be removed in the future.
932  const uint8_t **inp,
933  long len);
934 
935 // i2d_ASN1_BIT_STRING marshals |in| as a DER-encoded ASN.1 BIT STRING, as
936 // described in |i2d_SAMPLE|.
938  uint8_t **outp);
939 
940 // c2i_ASN1_BIT_STRING decodes |len| bytes from |*inp| as the contents of a
941 // DER-encoded BIT STRING, excluding the tag and length. It behaves like
942 // |d2i_SAMPLE_with_reuse| except, on success, it always consumes all |len|
943 // bytes.
944 //
945 // TODO(https://crbug.com/boringssl/354): This function currently also accepts
946 // BER, but this will be removed in the future.
948  const uint8_t **inp,
949  long len);
950 
951 // i2c_ASN1_BIT_STRING encodes |in| as the contents of a DER-encoded BIT STRING,
952 // excluding the tag and length. If |outp| is non-NULL, it writes the result to
953 // |*outp|, advances |*outp| just past the output, and returns the number of
954 // bytes written. |*outp| must have space available for the result. If |outp| is
955 // NULL, it returns the number of bytes without writing anything. On error, it
956 // returns a value <= 0.
957 //
958 // Note this function differs slightly from |i2d_SAMPLE|. If |outp| is non-NULL
959 // and |*outp| is NULL, it does not allocate a new buffer.
960 //
961 // TODO(davidben): This function currently returns zero on error instead of -1,
962 // but it is also mostly infallible. I've currently documented <= 0 to suggest
963 // callers work with both.
965  uint8_t **outp);
966 
967 // ASN1_BIT_STRING is an |ASN1_ITEM| with ASN.1 type BIT STRING and C type
968 // |ASN1_BIT_STRING*|.
970 
971 // ASN1_BIT_STRING_num_bytes computes the length of |str| in bytes. If |str|'s
972 // bit length is a multiple of 8, it sets |*out| to the byte length and returns
973 // one. Otherwise, it returns zero.
974 //
975 // This function may be used with |ASN1_STRING_get0_data| to interpret |str| as
976 // a byte string.
978  size_t *out);
979 
980 // ASN1_BIT_STRING_set calls |ASN1_STRING_set|. It leaves flags unchanged, so
981 // the caller must set the number of unused bits.
982 //
983 // TODO(davidben): Maybe it should? Wrapping a byte string in a bit string is a
984 // common use case.
986  const unsigned char *d, int length);
987 
988 // ASN1_BIT_STRING_set_bit sets bit |n| of |str| to one if |value| is non-zero
989 // and zero if |value| is zero, resizing |str| as needed. It then truncates
990 // trailing zeros in |str| to align with the DER represention for a bit string
991 // with named bits. It returns one on success and zero on error. |n| is indexed
992 // beginning from zero.
994  int value);
995 
996 // ASN1_BIT_STRING_get_bit returns one if bit |n| of |a| is in bounds and set,
997 // and zero otherwise. |n| is indexed beginning from zero.
999 
1000 // ASN1_BIT_STRING_check returns one if |str| only contains bits that are set in
1001 // the |flags_len| bytes pointed by |flags|. Otherwise it returns zero. Bits in
1002 // |flags| are arranged according to the DER representation, so bit 0
1003 // corresponds to the MSB of |flags[0]|.
1005  const unsigned char *flags,
1006  int flags_len);
1007 
1008 
1009 // Integers and enumerated values.
1010 //
1011 // INTEGER and ENUMERATED values are represented as |ASN1_STRING|s where the
1012 // data contains the big-endian encoding of the absolute value of the integer.
1013 // The sign bit is encoded in the type: non-negative values have a type of
1014 // |V_ASN1_INTEGER| or |V_ASN1_ENUMERATED|, while negative values have a type of
1015 // |V_ASN1_NEG_INTEGER| or |V_ASN1_NEG_ENUMERATED|. Note this differs from DER's
1016 // two's complement representation.
1017 
1019 
1020 // ASN1_INTEGER_new calls |ASN1_STRING_type_new| with |V_ASN1_INTEGER|. The
1021 // resulting object has value zero.
1023 
1024 // ASN1_INTEGER_free calls |ASN1_STRING_free|.
1026 
1027 // ASN1_INTEGER_dup calls |ASN1_STRING_dup|.
1029 
1030 // d2i_ASN1_INTEGER parses up to |len| bytes from |*inp| as a DER-encoded
1031 // ASN.1 INTEGER, as described in |d2i_SAMPLE_with_reuse|.
1032 //
1033 // TODO(https://crbug.com/boringssl/354): This function currently also accepts
1034 // BER, but this will be removed in the future.
1036  const uint8_t **inp, long len);
1037 
1038 // i2d_ASN1_INTEGER marshals |in| as a DER-encoded ASN.1 INTEGER, as
1039 // described in |i2d_SAMPLE|.
1041 
1042 // c2i_ASN1_INTEGER decodes |len| bytes from |*inp| as the contents of a
1043 // DER-encoded INTEGER, excluding the tag and length. It behaves like
1044 // |d2i_SAMPLE_with_reuse| except, on success, it always consumes all |len|
1045 // bytes.
1046 //
1047 // TODO(https://crbug.com/boringssl/354): This function currently also accepts
1048 // some invalid inputs, but this will be removed in the future.
1050  const uint8_t **outp, long len);
1051 
1052 // i2c_ASN1_INTEGER encodes |in| as the contents of a DER-encoded INTEGER,
1053 // excluding the tag and length. If |outp| is non-NULL, it writes the result to
1054 // |*outp|, advances |*outp| just past the output, and returns the number of
1055 // bytes written. |*outp| must have space available for the result. If |outp| is
1056 // NULL, it returns the number of bytes without writing anything. On error, it
1057 // returns a value <= 0.
1058 //
1059 // Note this function differs slightly from |i2d_SAMPLE|. If |outp| is non-NULL
1060 // and |*outp| is NULL, it does not allocate a new buffer.
1061 //
1062 // TODO(davidben): This function currently returns zero on error instead of -1,
1063 // but it is also mostly infallible. I've currently documented <= 0 to suggest
1064 // callers work with both.
1066 
1067 // ASN1_INTEGER is an |ASN1_ITEM| with ASN.1 type INTEGER and C type
1068 // |ASN1_INTEGER*|.
1070 
1071 // ASN1_INTEGER_set sets |a| to an INTEGER with value |v|. It returns one on
1072 // success and zero on error.
1074 
1075 // ASN1_INTEGER_set_uint64 sets |a| to an INTEGER with value |v|. It returns one
1076 // on success and zero on error.
1078 
1079 // ASN1_INTEGER_get returns the value of |a| as a |long|, or -1 if |a| is out of
1080 // range or the wrong type.
1082 
1083 // BN_to_ASN1_INTEGER sets |ai| to an INTEGER with value |bn| and returns |ai|
1084 // on success or NULL or error. If |ai| is NULL, it returns a newly-allocated
1085 // |ASN1_INTEGER| on success instead, which the caller must release with
1086 // |ASN1_INTEGER_free|.
1088  ASN1_INTEGER *ai);
1089 
1090 // ASN1_INTEGER_to_BN sets |bn| to the value of |ai| and returns |bn| on success
1091 // or NULL or error. If |bn| is NULL, it returns a newly-allocated |BIGNUM| on
1092 // success instead, which the caller must release with |BN_free|.
1094 
1095 // ASN1_INTEGER_cmp compares the values of |x| and |y|. It returns an integer
1096 // equal to, less than, or greater than zero if |x| is equal to, less than, or
1097 // greater than |y|, respectively.
1099  const ASN1_INTEGER *y);
1100 
1101 // ASN1_ENUMERATED_new calls |ASN1_STRING_type_new| with |V_ASN1_ENUMERATED|.
1102 // The resulting object has value zero.
1104 
1105 // ASN1_ENUMERATED_free calls |ASN1_STRING_free|.
1107 
1108 // d2i_ASN1_ENUMERATED parses up to |len| bytes from |*inp| as a DER-encoded
1109 // ASN.1 ENUMERATED, as described in |d2i_SAMPLE_with_reuse|.
1110 //
1111 // TODO(https://crbug.com/boringssl/354): This function currently also accepts
1112 // BER, but this will be removed in the future.
1114  const uint8_t **inp,
1115  long len);
1116 
1117 // i2d_ASN1_ENUMERATED marshals |in| as a DER-encoded ASN.1 ENUMERATED, as
1118 // described in |i2d_SAMPLE|.
1120  uint8_t **outp);
1121 
1122 // ASN1_ENUMERATED is an |ASN1_ITEM| with ASN.1 type ENUMERATED and C type
1123 // |ASN1_ENUMERATED*|.
1125 
1126 // ASN1_ENUMERATED_set sets |a| to an ENUMERATED with value |v|. It returns one
1127 // on success and zero on error.
1129 
1130 // ASN1_ENUMERATED_get returns the value of |a| as a |long|, or -1 if |a| is out
1131 // of range or the wrong type.
1133 
1134 // BN_to_ASN1_ENUMERATED sets |ai| to an ENUMERATED with value |bn| and returns
1135 // |ai| on success or NULL or error. If |ai| is NULL, it returns a
1136 // newly-allocated |ASN1_INTEGER| on success instead, which the caller must
1137 // release with |ASN1_INTEGER_free|.
1139  ASN1_ENUMERATED *ai);
1140 
1141 // ASN1_ENUMERATED_to_BN sets |bn| to the value of |ai| and returns |bn| on
1142 // success or NULL or error. If |bn| is NULL, it returns a newly-allocated
1143 // |BIGNUM| on success instead, which the caller must release with |BN_free|.
1145  BIGNUM *bn);
1146 
1147 
1148 // Time.
1149 //
1150 // GeneralizedTime and UTCTime values are represented as |ASN1_STRING|s. The
1151 // type field is |V_ASN1_GENERALIZEDTIME| or |V_ASN1_UTCTIME|, respectively. The
1152 // data field contains the DER encoding of the value. For example, the UNIX
1153 // epoch would be "19700101000000Z" for a GeneralizedTime and "700101000000Z"
1154 // for a UTCTime.
1155 //
1156 // ASN.1 does not define how to interpret UTCTime's two-digit year. RFC 5280
1157 // defines it as a range from 1950 to 2049 for X.509. The library uses the
1158 // RFC 5280 interpretation. It does not currently enforce the restrictions from
1159 // BER, and the additional restrictions from RFC 5280, but future versions may.
1160 // Callers should not rely on fractional seconds and non-UTC time zones.
1161 //
1162 // The |ASN1_TIME| typedef is a multi-string representing the X.509 Time type,
1163 // which is a CHOICE of GeneralizedTime and UTCTime, using UTCTime when the
1164 // value is in range.
1165 
1166 // ASN1_UTCTIME_new calls |ASN1_STRING_type_new| with |V_ASN1_UTCTIME|. The
1167 // resulting object contains empty contents and must be initialized to be a
1168 // valid UTCTime.
1170 
1171 // ASN1_UTCTIME_free calls |ASN1_STRING_free|.
1173 
1174 // d2i_ASN1_UTCTIME parses up to |len| bytes from |*inp| as a DER-encoded
1175 // ASN.1 UTCTime, as described in |d2i_SAMPLE_with_reuse|.
1176 //
1177 // TODO(https://crbug.com/boringssl/354): This function currently also accepts
1178 // BER, but this will be removed in the future.
1180  const uint8_t **inp, long len);
1181 
1182 // i2d_ASN1_UTCTIME marshals |in| as a DER-encoded ASN.1 UTCTime, as
1183 // described in |i2d_SAMPLE|.
1185 
1186 // ASN1_UTCTIME is an |ASN1_ITEM| with ASN.1 type UTCTime and C type
1187 // |ASN1_UTCTIME*|.
1189 
1190 // ASN1_UTCTIME_check returns one if |a| is a valid UTCTime and zero otherwise.
1192 
1193 // ASN1_UTCTIME_set represents |t| as a UTCTime and writes the result to |s|. It
1194 // returns |s| on success and NULL on error. If |s| is NULL, it returns a
1195 // newly-allocated |ASN1_UTCTIME| instead.
1196 //
1197 // Note this function may fail if the time is out of range for UTCTime.
1199 
1200 // ASN1_UTCTIME_adj adds |offset_day| days and |offset_sec| seconds to |t| and
1201 // writes the result to |s| as a UTCTime. It returns |s| on success and NULL on
1202 // error. If |s| is NULL, it returns a newly-allocated |ASN1_UTCTIME| instead.
1203 //
1204 // Note this function may fail if the time overflows or is out of range for
1205 // UTCTime.
1207  int offset_day, long offset_sec);
1208 
1209 // ASN1_UTCTIME_set_string sets |s| to a UTCTime whose contents are a copy of
1210 // |str|. It returns one on success and zero on error or if |str| is not a valid
1211 // UTCTime.
1212 //
1213 // If |s| is NULL, this function validates |str| without copying it.
1215 
1216 // ASN1_UTCTIME_cmp_time_t compares |s| to |t|. It returns -1 if |s| < |t|, 0 if
1217 // they are equal, 1 if |s| > |t|, and -2 on error.
1218 OPENSSL_EXPORT int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);
1219 
1220 // ASN1_GENERALIZEDTIME_new calls |ASN1_STRING_type_new| with
1221 // |V_ASN1_GENERALIZEDTIME|. The resulting object contains empty contents and
1222 // must be initialized to be a valid GeneralizedTime.
1224 
1225 // ASN1_GENERALIZEDTIME_free calls |ASN1_STRING_free|.
1227 
1228 // d2i_ASN1_GENERALIZEDTIME parses up to |len| bytes from |*inp| as a
1229 // DER-encoded ASN.1 GeneralizedTime, as described in |d2i_SAMPLE_with_reuse|.
1230 //
1231 // TODO(https://crbug.com/boringssl/354): This function currently also accepts
1232 // BER, but this will be removed in the future.
1234  ASN1_GENERALIZEDTIME **out, const uint8_t **inp, long len);
1235 
1236 // i2d_ASN1_GENERALIZEDTIME marshals |in| as a DER-encoded ASN.1
1237 // GeneralizedTime, as described in |i2d_SAMPLE|.
1239  uint8_t **outp);
1240 
1241 // ASN1_GENERALIZEDTIME is an |ASN1_ITEM| with ASN.1 type GeneralizedTime and C
1242 // type |ASN1_GENERALIZEDTIME*|.
1244 
1245 // ASN1_GENERALIZEDTIME_check returns one if |a| is a valid GeneralizedTime and
1246 // zero otherwise.
1248 
1249 // ASN1_GENERALIZEDTIME_set represents |t| as a GeneralizedTime and writes the
1250 // result to |s|. It returns |s| on success and NULL on error. If |s| is NULL,
1251 // it returns a newly-allocated |ASN1_GENERALIZEDTIME| instead.
1252 //
1253 // Note this function may fail if the time is out of range for GeneralizedTime.
1255  ASN1_GENERALIZEDTIME *s, time_t t);
1256 
1257 // ASN1_GENERALIZEDTIME_adj adds |offset_day| days and |offset_sec| seconds to
1258 // |t| and writes the result to |s| as a GeneralizedTime. It returns |s| on
1259 // success and NULL on error. If |s| is NULL, it returns a newly-allocated
1260 // |ASN1_GENERALIZEDTIME| instead.
1261 //
1262 // Note this function may fail if the time overflows or is out of range for
1263 // GeneralizedTime.
1265  ASN1_GENERALIZEDTIME *s, time_t t, int offset_day, long offset_sec);
1266 
1267 // ASN1_GENERALIZEDTIME_set_string sets |s| to a GeneralizedTime whose contents
1268 // are a copy of |str|. It returns one on success and zero on error or if |str|
1269 // is not a valid GeneralizedTime.
1270 //
1271 // If |s| is NULL, this function validates |str| without copying it.
1273  const char *str);
1274 
1275 // B_ASN1_TIME is a bitmask of types allowed in an X.509 Time.
1276 #define B_ASN1_TIME (B_ASN1_UTCTIME | B_ASN1_GENERALIZEDTIME)
1277 
1278 // ASN1_TIME_new returns a newly-allocated |ASN1_TIME| with type -1, or NULL on
1279 // error. The resulting |ASN1_TIME| is not a valid X.509 Time until initialized
1280 // with a value.
1282 
1283 // ASN1_TIME_free releases memory associated with |str|.
1285 
1286 // d2i_ASN1_TIME parses up to |len| bytes from |*inp| as a DER-encoded X.509
1287 // Time (RFC 5280), as described in |d2i_SAMPLE_with_reuse|.
1288 //
1289 // TODO(https://crbug.com/boringssl/354): This function currently also accepts
1290 // BER, but this will be removed in the future.
1292  long len);
1293 
1294 // i2d_ASN1_TIME marshals |in| as a DER-encoded X.509 Time (RFC 5280), as
1295 // described in |i2d_SAMPLE|.
1296 OPENSSL_EXPORT int i2d_ASN1_TIME(const ASN1_TIME *in, uint8_t **outp);
1297 
1298 // ASN1_TIME is an |ASN1_ITEM| whose ASN.1 type is X.509 Time (RFC 5280) and C
1299 // type is |ASN1_TIME*|.
1301 
1302 // ASN1_TIME_diff computes |to| - |from|. On success, it sets |*out_days| to the
1303 // difference in days, rounded towards zero, sets |*out_seconds| to the
1304 // remainder, and returns one. On error, it returns zero.
1305 //
1306 // If |from| is before |to|, both outputs will be <= 0, with at least one
1307 // negative. If |from| is after |to|, both will be >= 0, with at least one
1308 // positive. If they are equal, ignoring fractional seconds, both will be zero.
1309 //
1310 // Note this function may fail on overflow, or if |from| or |to| cannot be
1311 // decoded.
1312 OPENSSL_EXPORT int ASN1_TIME_diff(int *out_days, int *out_seconds,
1313  const ASN1_TIME *from, const ASN1_TIME *to);
1314 
1315 // ASN1_TIME_set represents |t| as a GeneralizedTime or UTCTime and writes
1316 // the result to |s|. As in RFC 5280, section 4.1.2.5, it uses UTCTime when the
1317 // time fits and GeneralizedTime otherwise. It returns |s| on success and NULL
1318 // on error. If |s| is NULL, it returns a newly-allocated |ASN1_TIME| instead.
1319 //
1320 // Note this function may fail if the time is out of range for GeneralizedTime.
1322 
1323 // ASN1_TIME_adj adds |offset_day| days and |offset_sec| seconds to
1324 // |t| and writes the result to |s|. As in RFC 5280, section 4.1.2.5, it uses
1325 // UTCTime when the time fits and GeneralizedTime otherwise. It returns |s| on
1326 // success and NULL on error. If |s| is NULL, it returns a newly-allocated
1327 // |ASN1_GENERALIZEDTIME| instead.
1328 //
1329 // Note this function may fail if the time overflows or is out of range for
1330 // GeneralizedTime.
1331 OPENSSL_EXPORT ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t, int offset_day,
1332  long offset_sec);
1333 
1334 // ASN1_TIME_check returns one if |t| is a valid UTCTime or GeneralizedTime, and
1335 // zero otherwise. |t|'s type determines which check is performed. This
1336 // function does not enforce that UTCTime was used when possible.
1338 
1339 // ASN1_TIME_to_generalizedtime converts |t| to a GeneralizedTime. If |out| is
1340 // NULL, it returns a newly-allocated |ASN1_GENERALIZEDTIME| on success, or NULL
1341 // on error. If |out| is non-NULL and |*out| is NULL, it additionally sets
1342 // |*out| to the result. If |out| and |*out| are non-NULL, it instead updates
1343 // the object pointed by |*out| and returns |*out| on success or NULL on error.
1345  const ASN1_TIME *t, ASN1_GENERALIZEDTIME **out);
1346 
1347 // ASN1_TIME_set_string behaves like |ASN1_UTCTIME_set_string| if |str| is a
1348 // valid UTCTime, and |ASN1_GENERALIZEDTIME_set_string| if |str| is a valid
1349 // GeneralizedTime. If |str| is neither, it returns zero.
1350 OPENSSL_EXPORT int ASN1_TIME_set_string(ASN1_TIME *s, const char *str);
1351 
1352 // TODO(davidben): Expand and document function prototypes generated in macros.
1353 
1354 
1355 // NULL values.
1356 //
1357 // This library represents the ASN.1 NULL value by a non-NULL pointer to the
1358 // opaque type |ASN1_NULL|. An omitted OPTIONAL ASN.1 NULL value is a NULL
1359 // pointer. Unlike other pointer types, it is not necessary to free |ASN1_NULL|
1360 // pointers, but it is safe to do so.
1361 
1362 // ASN1_NULL_new returns an opaque, non-NULL pointer. It is safe to call
1363 // |ASN1_NULL_free| on the result, but not necessary.
1365 
1366 // ASN1_NULL_free does nothing.
1368 
1369 // d2i_ASN1_NULL parses a DER-encoded ASN.1 NULL value from up to |len| bytes
1370 // at |*inp|, as described in |d2i_SAMPLE|.
1371 //
1372 // TODO(https://crbug.com/boringssl/354): This function currently also accepts
1373 // BER, but this will be removed in the future.
1375  long len);
1376 
1377 // i2d_ASN1_NULL marshals |in| as a DER-encoded ASN.1 NULL value, as described
1378 // in |i2d_SAMPLE|.
1379 OPENSSL_EXPORT int i2d_ASN1_NULL(const ASN1_NULL *in, uint8_t **outp);
1380 
1381 // ASN1_NULL is an |ASN1_ITEM| with ASN.1 type NULL and C type |ASN1_NULL*|.
1383 
1384 
1385 // Object identifiers.
1386 //
1387 // An |ASN1_OBJECT| represents a ASN.1 OBJECT IDENTIFIER. See also obj.h for
1388 // additional functions relating to |ASN1_OBJECT|.
1389 //
1390 // TODO(davidben): What's the relationship between asn1.h and obj.h? Most of
1391 // obj.h deals with the large NID table, but then functions like |OBJ_get0_data|
1392 // or |OBJ_dup| are general |ASN1_OBJECT| functions.
1393 
1395 
1396 // ASN1_OBJECT_create returns a newly-allocated |ASN1_OBJECT| with |len| bytes
1397 // from |data| as the encoded OID, or NULL on error. |data| should contain the
1398 // DER-encoded identifier, excluding the tag and length.
1399 //
1400 // |nid| should be |NID_undef|. Passing a NID value that does not match |data|
1401 // will cause some functions to misbehave. |sn| and |ln| should be NULL. If
1402 // non-NULL, they are stored as short and long names, respectively, but these
1403 // values have no effect for |ASN1_OBJECT|s created through this function.
1404 //
1405 // TODO(davidben): Should we just ignore all those parameters? NIDs and names
1406 // are only relevant for |ASN1_OBJECT|s in the obj.h table.
1408  int len, const char *sn,
1409  const char *ln);
1410 
1411 // ASN1_OBJECT_free releases memory associated with |a|. If |a| is a static
1412 // |ASN1_OBJECT|, returned from |OBJ_nid2obj|, this function does nothing.
1414 
1415 // d2i_ASN1_OBJECT parses a DER-encoded ASN.1 OBJECT IDENTIFIER from up to |len|
1416 // bytes at |*inp|, as described in |d2i_SAMPLE_with_reuse|.
1417 //
1418 // TODO(https://crbug.com/boringssl/354): This function currently also accepts
1419 // BER, but this will be removed in the future.
1421  const uint8_t **inp, long len);
1422 
1423 // i2d_ASN1_OBJECT marshals |in| as a DER-encoded ASN.1 OBJECT IDENTIFIER, as
1424 // described in |i2d_SAMPLE|.
1425 OPENSSL_EXPORT int i2d_ASN1_OBJECT(const ASN1_OBJECT *a, uint8_t **outp);
1426 
1427 // c2i_ASN1_OBJECT decodes |len| bytes from |*inp| as the contents of a
1428 // DER-encoded OBJECT IDENTIFIER, excluding the tag and length. It behaves like
1429 // |d2i_SAMPLE_with_reuse| except, on success, it always consumes all |len|
1430 // bytes.
1432  const uint8_t **inp, long len);
1433 
1434 // ASN1_OBJECT is an |ASN1_ITEM| with ASN.1 type OBJECT IDENTIFIER and C type
1435 // |ASN1_OBJECT*|.
1437 
1438 
1439 // Arbitrary elements.
1440 
1441 // An asn1_type_st (aka |ASN1_TYPE|) represents an arbitrary ASN.1 element,
1442 // typically used for ANY types. It contains a |type| field and a |value| union
1443 // dependent on |type|.
1444 //
1445 // WARNING: This struct has a complex representation. Callers must not construct
1446 // |ASN1_TYPE| values manually. Use |ASN1_TYPE_set| and |ASN1_TYPE_set1|
1447 // instead. Additionally, callers performing non-trivial operations on this type
1448 // are encouraged to use |CBS| and |CBB| from <openssl/bytestring.h>, and
1449 // convert to or from |ASN1_TYPE| with |d2i_ASN1_TYPE| or |i2d_ASN1_TYPE|.
1450 //
1451 // The |type| field corresponds to the tag of the ASN.1 element being
1452 // represented:
1453 //
1454 // If |type| is a |V_ASN1_*| constant for an ASN.1 string-like type, as defined
1455 // by |ASN1_STRING|, the tag matches the constant. |value| contains an
1456 // |ASN1_STRING| pointer (equivalently, one of the more specific typedefs). See
1457 // |ASN1_STRING| for details on the representation. Unlike |ASN1_STRING|,
1458 // |ASN1_TYPE| does not use the |V_ASN1_NEG| flag for negative INTEGER and
1459 // ENUMERATE values. For a negative value, the |ASN1_TYPE|'s |type| will be
1460 // |V_ASN1_INTEGER| or |V_ASN1_ENUMERATED|, but |value| will an |ASN1_STRING|
1461 // whose |type| is |V_ASN1_NEG_INTEGER| or |V_ASN1_NEG_ENUMERATED|.
1462 //
1463 // If |type| is |V_ASN1_OBJECT|, the tag is OBJECT IDENTIFIER and |value|
1464 // contains an |ASN1_OBJECT| pointer.
1465 //
1466 // If |type| is |V_ASN1_NULL|, the tag is NULL. |value| contains a NULL pointer.
1467 //
1468 // If |type| is |V_ASN1_BOOLEAN|, the tag is BOOLEAN. |value| contains an
1469 // |ASN1_BOOLEAN|.
1470 //
1471 // If |type| is |V_ASN1_SEQUENCE|, |V_ASN1_SET|, or |V_ASN1_OTHER|, the tag is
1472 // SEQUENCE, SET, or some non-universal tag, respectively. |value| is an
1473 // |ASN1_STRING| containing the entire element, including the tag and length.
1474 // The |ASN1_STRING|'s |type| field matches the containing |ASN1_TYPE|'s |type|.
1475 //
1476 // Other positive values of |type|, up to |V_ASN1_MAX_UNIVERSAL|, correspond to
1477 // universal primitive tags not directly supported by this library. |value| is
1478 // an |ASN1_STRING| containing the body of the element, excluding the tag
1479 // and length. The |ASN1_STRING|'s |type| field matches the containing
1480 // |ASN1_TYPE|'s |type|.
1482  int type;
1483  union {
1484  char *ptr;
1502  // set and sequence are left complete and still contain the entire element.
1506  } value;
1507 };
1508 
1510 
1511 // ASN1_TYPE_new returns a newly-allocated |ASN1_TYPE|, or NULL on allocation
1512 // failure. The resulting object has type -1 and must be initialized to be
1513 // a valid ANY value.
1515 
1516 // ASN1_TYPE_free releases memory associated with |a|.
1518 
1519 // d2i_ASN1_TYPE parses up to |len| bytes from |*inp| as an ASN.1 value of any
1520 // type, as described in |d2i_SAMPLE_with_reuse|. Note this function only
1521 // validates primitive, universal types supported by this library. Values of
1522 // type |V_ASN1_SEQUENCE|, |V_ASN1_SET|, |V_ASN1_OTHER|, or an unsupported
1523 // primitive type must be validated by the caller when interpreting.
1524 //
1525 // TODO(https://crbug.com/boringssl/354): This function currently also accepts
1526 // BER, but this will be removed in the future.
1528  long len);
1529 
1530 // i2d_ASN1_TYPE marshals |in| as DER, as described in |i2d_SAMPLE|.
1531 OPENSSL_EXPORT int i2d_ASN1_TYPE(const ASN1_TYPE *in, uint8_t **outp);
1532 
1533 // ASN1_ANY is an |ASN1_ITEM| with ASN.1 type ANY and C type |ASN1_TYPE*|. Note
1534 // the |ASN1_ITEM| name and C type do not match.
1535 DECLARE_ASN1_ITEM(ASN1_ANY)
1536 
1537 // ASN1_TYPE_get returns the type of |a|, which will be one of the |V_ASN1_*|
1538 // constants, or zero if |a| is not fully initialized.
1540 
1541 // ASN1_TYPE_set sets |a| to an |ASN1_TYPE| of type |type| and value |value|,
1542 // releasing the previous contents of |a|.
1543 //
1544 // If |type| is |V_ASN1_BOOLEAN|, |a| is set to FALSE if |value| is NULL and
1545 // TRUE otherwise. If setting |a| to TRUE, |value| may be an invalid pointer,
1546 // such as (void*)1.
1547 //
1548 // If |type| is |V_ASN1_NULL|, |value| must be NULL.
1549 //
1550 // For other values of |type|, this function takes ownership of |value|, which
1551 // must point to an object of the corresponding type. See |ASN1_TYPE| for
1552 // details.
1553 OPENSSL_EXPORT void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
1554 
1555 // ASN1_TYPE_set1 behaves like |ASN1_TYPE_set| except it does not take ownership
1556 // of |value|. It returns one on success and zero on error.
1557 OPENSSL_EXPORT int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);
1558 
1559 // ASN1_TYPE_cmp returns zero if |a| and |b| are equal and some non-zero value
1560 // otherwise. Note this function can only be used for equality checks, not an
1561 // ordering.
1562 OPENSSL_EXPORT int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b);
1563 
1564 typedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY;
1565 
1566 // d2i_ASN1_SEQUENCE_ANY parses up to |len| bytes from |*inp| as a DER-encoded
1567 // ASN.1 SEQUENCE OF ANY structure, as described in |d2i_SAMPLE_with_reuse|. The
1568 // resulting |ASN1_SEQUENCE_ANY| owns its contents and thus must be released
1569 // with |sk_ASN1_TYPE_pop_free| and |ASN1_TYPE_free|, not |sk_ASN1_TYPE_free|.
1570 //
1571 // TODO(https://crbug.com/boringssl/354): This function currently also accepts
1572 // BER, but this will be removed in the future.
1573 OPENSSL_EXPORT ASN1_SEQUENCE_ANY *d2i_ASN1_SEQUENCE_ANY(ASN1_SEQUENCE_ANY **out,
1574  const uint8_t **inp,
1575  long len);
1576 
1577 // i2d_ASN1_SEQUENCE_ANY marshals |in| as a DER-encoded SEQUENCE OF ANY
1578 // structure, as described in |i2d_SAMPLE|.
1579 OPENSSL_EXPORT int i2d_ASN1_SEQUENCE_ANY(const ASN1_SEQUENCE_ANY *in,
1580  uint8_t **outp);
1581 
1582 // d2i_ASN1_SET_ANY parses up to |len| bytes from |*inp| as a DER-encoded ASN.1
1583 // SET OF ANY structure, as described in |d2i_SAMPLE_with_reuse|. The resulting
1584 // |ASN1_SEQUENCE_ANY| owns its contents and thus must be released with
1585 // |sk_ASN1_TYPE_pop_free| and |ASN1_TYPE_free|, not |sk_ASN1_TYPE_free|.
1586 //
1587 // TODO(https://crbug.com/boringssl/354): This function currently also accepts
1588 // BER, but this will be removed in the future.
1589 OPENSSL_EXPORT ASN1_SEQUENCE_ANY *d2i_ASN1_SET_ANY(ASN1_SEQUENCE_ANY **out,
1590  const uint8_t **inp,
1591  long len);
1592 
1593 // i2d_ASN1_SET_ANY marshals |in| as a DER-encoded SET OF ANY structure, as
1594 // described in |i2d_SAMPLE|.
1595 OPENSSL_EXPORT int i2d_ASN1_SET_ANY(const ASN1_SEQUENCE_ANY *in,
1596  uint8_t **outp);
1597 
1598 
1599 // Human-readable output.
1600 //
1601 // The following functions output types in some human-readable format. These
1602 // functions may be used for debugging and logging. However, the output should
1603 // not be consumed programmatically. They may be ambiguous or lose information.
1604 
1605 // ASN1_UTCTIME_print writes a human-readable representation of |a| to |out|. It
1606 // returns one on success and zero on error.
1608 
1609 // ASN1_GENERALIZEDTIME_print writes a human-readable representation of |a| to
1610 // |out|. It returns one on success and zero on error.
1612  const ASN1_GENERALIZEDTIME *a);
1613 
1614 // ASN1_TIME_print writes a human-readable representation of |a| to |out|. It
1615 // returns one on success and zero on error.
1617 
1618 // ASN1_STRING_print writes a human-readable representation of |str| to |out|.
1619 // It returns one on success and zero on error. Unprintable characters are
1620 // replaced with '.'.
1622 
1623 // ASN1_STRFLGS_ESC_2253 causes characters to be escaped as in RFC 2253, section
1624 // 2.4.
1625 #define ASN1_STRFLGS_ESC_2253 1
1626 
1627 // ASN1_STRFLGS_ESC_CTRL causes all control characters to be escaped.
1628 #define ASN1_STRFLGS_ESC_CTRL 2
1629 
1630 // ASN1_STRFLGS_ESC_MSB causes all characters above 127 to be escaped.
1631 #define ASN1_STRFLGS_ESC_MSB 4
1632 
1633 // ASN1_STRFLGS_ESC_QUOTE causes the string to be surrounded by quotes, rather
1634 // than using backslashes, when characters are escaped. Fewer characters will
1635 // require escapes in this case.
1636 #define ASN1_STRFLGS_ESC_QUOTE 8
1637 
1638 // ASN1_STRFLGS_UTF8_CONVERT causes the string to be encoded as UTF-8, with each
1639 // byte in the UTF-8 encoding treated as an individual character for purposes of
1640 // escape sequences. If not set, each Unicode codepoint in the string is treated
1641 // as a character, with wide characters escaped as "\Uxxxx" or "\Wxxxxxxxx".
1642 // Note this can be ambiguous if |ASN1_STRFLGS_ESC_*| are all unset. In that
1643 // case, backslashes are not escaped, but wide characters are.
1644 #define ASN1_STRFLGS_UTF8_CONVERT 0x10
1645 
1646 // ASN1_STRFLGS_IGNORE_TYPE causes the string type to be ignored. The
1647 // |ASN1_STRING| in-memory representation will be printed directly.
1648 #define ASN1_STRFLGS_IGNORE_TYPE 0x20
1649 
1650 // ASN1_STRFLGS_SHOW_TYPE causes the string type to be included in the output.
1651 #define ASN1_STRFLGS_SHOW_TYPE 0x40
1652 
1653 // ASN1_STRFLGS_DUMP_ALL causes all strings to be printed as a hexdump, using
1654 // RFC 2253 hexstring notation, such as "#0123456789ABCDEF".
1655 #define ASN1_STRFLGS_DUMP_ALL 0x80
1656 
1657 // ASN1_STRFLGS_DUMP_UNKNOWN behaves like |ASN1_STRFLGS_DUMP_ALL| but only
1658 // applies to values of unknown type. If unset, unknown values will print
1659 // their contents as single-byte characters with escape sequences.
1660 #define ASN1_STRFLGS_DUMP_UNKNOWN 0x100
1661 
1662 // ASN1_STRFLGS_DUMP_DER causes hexdumped strings (as determined by
1663 // |ASN1_STRFLGS_DUMP_ALL| or |ASN1_STRFLGS_DUMP_UNKNOWN|) to print the entire
1664 // DER element as in RFC 2253, rather than only the contents of the
1665 // |ASN1_STRING|.
1666 #define ASN1_STRFLGS_DUMP_DER 0x200
1667 
1668 // ASN1_STRFLGS_RFC2253 causes the string to be escaped as in RFC 2253,
1669 // additionally escaping control characters.
1670 #define ASN1_STRFLGS_RFC2253 \
1671  (ASN1_STRFLGS_ESC_2253 | ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB | \
1672  ASN1_STRFLGS_UTF8_CONVERT | ASN1_STRFLGS_DUMP_UNKNOWN | \
1673  ASN1_STRFLGS_DUMP_DER)
1674 
1675 // ASN1_STRING_print_ex writes a human-readable representation of |str| to
1676 // |out|. It returns the number of bytes written on success and -1 on error. If
1677 // |out| is NULL, it returns the number of bytes it would have written, without
1678 // writing anything.
1679 //
1680 // The |flags| should be a combination of combination of |ASN1_STRFLGS_*|
1681 // constants. See the documentation for each flag for how it controls the
1682 // output. If unsure, use |ASN1_STRFLGS_RFC2253|.
1684  unsigned long flags);
1685 
1686 // ASN1_STRING_print_ex_fp behaves like |ASN1_STRING_print_ex| but writes to a
1687 // |FILE| rather than a |BIO|.
1689  unsigned long flags);
1690 
1691 // i2a_ASN1_INTEGER writes a human-readable representation of |a| to |bp|. It
1692 // returns the number of bytes written on success, or a negative number on
1693 // error. On error, this function may have written a partial output to |bp|.
1695 
1696 // i2a_ASN1_ENUMERATED writes a human-readable representation of |a| to |bp|. It
1697 // returns the number of bytes written on success, or a negative number on
1698 // error. On error, this function may have written a partial output to |bp|.
1700 
1701 // i2a_ASN1_OBJECT writes a human-readable representation of |a| to |bp|. It
1702 // returns the number of bytes written on success, or a negative number on
1703 // error. On error, this function may have written a partial output to |bp|.
1705 
1706 // i2a_ASN1_STRING writes a text representation of |a|'s contents to |bp|. It
1707 // returns the number of bytes written on success, or a negative number on
1708 // error. On error, this function may have written a partial output to |bp|.
1709 // |type| is ignored.
1710 //
1711 // This function does not decode |a| into a Unicode string. It only hex-encodes
1712 // the internal representation of |a|. This is suitable for printing an OCTET
1713 // STRING, but may not be human-readable for any other string type.
1714 OPENSSL_EXPORT int i2a_ASN1_STRING(BIO *bp, const ASN1_STRING *a, int type);
1715 
1716 // i2t_ASN1_OBJECT calls |OBJ_obj2txt| with |always_return_oid| set to zero.
1717 OPENSSL_EXPORT int i2t_ASN1_OBJECT(char *buf, int buf_len,
1718  const ASN1_OBJECT *a);
1719 
1720 
1721 // Low-level encoding functions.
1722 
1723 // ASN1_get_object parses a BER element from up to |max_len| bytes at |*inp|. It
1724 // returns |V_ASN1_CONSTRUCTED| if it successfully parsed a constructed element,
1725 // zero if it successfully parsed a primitive element, and 0x80 on error. On
1726 // success, it additionally advances |*inp| to the element body, sets
1727 // |*out_length|, |*out_tag|, and |*out_class| to the element's length, tag
1728 // number, and tag class, respectively,
1729 //
1730 // Unlike OpenSSL, this function does not support indefinite-length elements.
1731 //
1732 // This function is difficult to use correctly. Use |CBS_get_asn1| and related
1733 // functions from bytestring.h.
1734 //
1735 // TODO(https://crbug.com/boringssl/354): Remove support for non-minimal
1736 // lengths.
1737 OPENSSL_EXPORT int ASN1_get_object(const unsigned char **inp, long *out_length,
1738  int *out_tag, int *out_class, long max_len);
1739 
1740 // ASN1_put_object writes the header for a DER or BER element to |*outp| and
1741 // advances |*outp| by the number of bytes written. The caller is responsible
1742 // for ensuring |*outp| has enough space for the output. The header describes an
1743 // element with length |length|, tag number |tag|, and class |xclass|. |xclass|
1744 // should be one of the |V_ASN1_*| tag class constants. The element is primitive
1745 // if |constructed| is zero and constructed if it is one or two. If
1746 // |constructed| is two, |length| is ignored and the element uses
1747 // indefinite-length encoding.
1748 //
1749 // Use |CBB_add_asn1| instead.
1750 OPENSSL_EXPORT void ASN1_put_object(unsigned char **outp, int constructed,
1751  int length, int tag, int xclass);
1752 
1753 // ASN1_put_eoc writes two zero bytes to |*outp|, advances |*outp| to point past
1754 // those bytes, and returns two.
1755 //
1756 // Use definite-length encoding instead.
1757 OPENSSL_EXPORT int ASN1_put_eoc(unsigned char **outp);
1758 
1759 // ASN1_object_size returns the number of bytes needed to encode a DER or BER
1760 // value with length |length| and tag number |tag|, or -1 on error. |tag| should
1761 // not include the constructed bit or tag class. If |constructed| is zero or
1762 // one, the result uses a definite-length encoding with minimally-encoded
1763 // length, as in DER. If |constructed| is two, the result uses BER
1764 // indefinite-length encoding.
1765 //
1766 // Use |CBB_add_asn1| instead.
1767 OPENSSL_EXPORT int ASN1_object_size(int constructed, int length, int tag);
1768 
1769 
1770 // Function declaration macros.
1771 //
1772 // The following macros declare functions for ASN.1 types. Prefer writing the
1773 // prototypes directly. Particularly when |type|, |itname|, or |name| differ,
1774 // the macros can be difficult to understand.
1775 
1776 #define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type)
1777 
1778 #define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \
1779  DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type)
1780 
1781 #define DECLARE_ASN1_FUNCTIONS_name(type, name) \
1782  DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
1783  DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name)
1784 
1785 #define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \
1786  DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
1787  DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name)
1788 
1789 #define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \
1790  OPENSSL_EXPORT type *d2i_##name(type **a, const unsigned char **in, \
1791  long len); \
1792  OPENSSL_EXPORT int i2d_##name(type *a, unsigned char **out); \
1793  DECLARE_ASN1_ITEM(itname)
1794 
1795 #define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \
1796  OPENSSL_EXPORT type *d2i_##name(type **a, const unsigned char **in, \
1797  long len); \
1798  OPENSSL_EXPORT int i2d_##name(const type *a, unsigned char **out); \
1799  DECLARE_ASN1_ITEM(name)
1800 
1801 #define DECLARE_ASN1_FUNCTIONS_const(name) \
1802  DECLARE_ASN1_ALLOC_FUNCTIONS(name) \
1803  DECLARE_ASN1_ENCODE_FUNCTIONS_const(name, name)
1804 
1805 #define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
1806  OPENSSL_EXPORT type *name##_new(void); \
1807  OPENSSL_EXPORT void name##_free(type *a);
1808 
1809 
1810 // Deprecated functions.
1811 
1812 // ASN1_PRINTABLE_type interprets |len| bytes from |s| as a Latin-1 string. It
1813 // returns the first of |V_ASN1_PRINTABLESTRING|, |V_ASN1_IA5STRING|, or
1814 // |V_ASN1_T61STRING| that can represent every character. If |len| is negative,
1815 // |strlen(s)| is used instead.
1816 //
1817 // TODO(davidben): Remove this once all copies of Conscrypt have been updated
1818 // past https://github.com/google/conscrypt/pull/1032.
1819 OPENSSL_EXPORT int ASN1_PRINTABLE_type(const unsigned char *s, int len);
1820 
1821 // ASN1_STRING_set_default_mask does nothing.
1822 OPENSSL_EXPORT void ASN1_STRING_set_default_mask(unsigned long mask);
1823 
1824 // ASN1_STRING_set_default_mask_asc returns one.
1826 
1827 // ASN1_STRING_get_default_mask returns |B_ASN1_UTF8STRING|.
1828 OPENSSL_EXPORT unsigned long ASN1_STRING_get_default_mask(void);
1829 
1830 // ASN1_STRING_TABLE_cleanup does nothing.
1832 
1833 // M_ASN1_* are legacy aliases for various |ASN1_STRING| functions. Use the
1834 // functions themselves.
1835 #define M_ASN1_STRING_length(x) ASN1_STRING_length(x)
1836 #define M_ASN1_STRING_type(x) ASN1_STRING_type(x)
1837 #define M_ASN1_STRING_data(x) ASN1_STRING_data(x)
1838 #define M_ASN1_BIT_STRING_new() ASN1_BIT_STRING_new()
1839 #define M_ASN1_BIT_STRING_free(a) ASN1_BIT_STRING_free(a)
1840 #define M_ASN1_BIT_STRING_dup(a) ASN1_STRING_dup(a)
1841 #define M_ASN1_BIT_STRING_cmp(a, b) ASN1_STRING_cmp(a, b)
1842 #define M_ASN1_BIT_STRING_set(a, b, c) ASN1_BIT_STRING_set(a, b, c)
1843 #define M_ASN1_INTEGER_new() ASN1_INTEGER_new()
1844 #define M_ASN1_INTEGER_free(a) ASN1_INTEGER_free(a)
1845 #define M_ASN1_INTEGER_dup(a) ASN1_INTEGER_dup(a)
1846 #define M_ASN1_INTEGER_cmp(a, b) ASN1_INTEGER_cmp(a, b)
1847 #define M_ASN1_ENUMERATED_new() ASN1_ENUMERATED_new()
1848 #define M_ASN1_ENUMERATED_free(a) ASN1_ENUMERATED_free(a)
1849 #define M_ASN1_ENUMERATED_dup(a) ASN1_STRING_dup(a)
1850 #define M_ASN1_ENUMERATED_cmp(a, b) ASN1_STRING_cmp(a, b)
1851 #define M_ASN1_OCTET_STRING_new() ASN1_OCTET_STRING_new()
1852 #define M_ASN1_OCTET_STRING_free(a) ASN1_OCTET_STRING_free()
1853 #define M_ASN1_OCTET_STRING_dup(a) ASN1_OCTET_STRING_dup(a)
1854 #define M_ASN1_OCTET_STRING_cmp(a, b) ASN1_OCTET_STRING_cmp(a, b)
1855 #define M_ASN1_OCTET_STRING_set(a, b, c) ASN1_OCTET_STRING_set(a, b, c)
1856 #define M_ASN1_OCTET_STRING_print(a, b) ASN1_STRING_print(a, b)
1857 #define M_ASN1_PRINTABLESTRING_new() ASN1_PRINTABLESTRING_new()
1858 #define M_ASN1_PRINTABLESTRING_free(a) ASN1_PRINTABLESTRING_free(a)
1859 #define M_ASN1_IA5STRING_new() ASN1_IA5STRING_new()
1860 #define M_ASN1_IA5STRING_free(a) ASN1_IA5STRING_free(a)
1861 #define M_ASN1_IA5STRING_dup(a) ASN1_STRING_dup(a)
1862 #define M_ASN1_UTCTIME_new() ASN1_UTCTIME_new()
1863 #define M_ASN1_UTCTIME_free(a) ASN1_UTCTIME_free(a)
1864 #define M_ASN1_UTCTIME_dup(a) ASN1_STRING_dup(a)
1865 #define M_ASN1_T61STRING_new() ASN1_T61STRING_new()
1866 #define M_ASN1_T61STRING_free(a) ASN1_T61STRING_free(a)
1867 #define M_ASN1_GENERALIZEDTIME_new() ASN1_GENERALIZEDTIME_new()
1868 #define M_ASN1_GENERALIZEDTIME_free(a) ASN1_GENERALIZEDTIME_free(a)
1869 #define M_ASN1_GENERALIZEDTIME_dup(a) ASN1_STRING_dup(a)
1870 #define M_ASN1_GENERALSTRING_new() ASN1_GENERALSTRING_new()
1871 #define M_ASN1_GENERALSTRING_free(a) ASN1_GENERALSTRING_free(a)
1872 #define M_ASN1_UNIVERSALSTRING_new() ASN1_UNIVERSALSTRING_new()
1873 #define M_ASN1_UNIVERSALSTRING_free(a) ASN1_UNIVERSALSTRING_free(a)
1874 #define M_ASN1_BMPSTRING_new() ASN1_BMPSTRING_new()
1875 #define M_ASN1_BMPSTRING_free(a) ASN1_BMPSTRING_free(a)
1876 #define M_ASN1_VISIBLESTRING_new() ASN1_VISIBLESTRING_new()
1877 #define M_ASN1_VISIBLESTRING_free(a) ASN1_VISIBLESTRING_free(a)
1878 #define M_ASN1_UTF8STRING_new() ASN1_UTF8STRING_new()
1879 #define M_ASN1_UTF8STRING_free(a) ASN1_UTF8STRING_free(a)
1880 
1881 // B_ASN1_PRINTABLE is a bitmask for an ad-hoc subset of string-like types. Note
1882 // the presence of |B_ASN1_UNKNOWN| means it includes types which |ASN1_tag2bit|
1883 // maps to |B_ASN1_UNKNOWN|.
1884 //
1885 // Do not use this. Despite the name, it has no connection to PrintableString or
1886 // printable characters. See https://crbug.com/boringssl/412.
1887 #define B_ASN1_PRINTABLE \
1888  (B_ASN1_NUMERICSTRING | B_ASN1_PRINTABLESTRING | B_ASN1_T61STRING | \
1889  B_ASN1_IA5STRING | B_ASN1_BIT_STRING | B_ASN1_UNIVERSALSTRING | \
1890  B_ASN1_BMPSTRING | B_ASN1_UTF8STRING | B_ASN1_SEQUENCE | B_ASN1_UNKNOWN)
1891 
1892 // ASN1_PRINTABLE_new returns a newly-allocated |ASN1_STRING| with type -1, or
1893 // NULL on error. The resulting |ASN1_STRING| is not a valid ASN.1 value until
1894 // initialized with a value.
1896 
1897 // ASN1_PRINTABLE_free calls |ASN1_STRING_free|.
1899 
1900 // d2i_ASN1_PRINTABLE parses up to |len| bytes from |*inp| as a DER-encoded
1901 // CHOICE of an ad-hoc subset of string-like types, as described in
1902 // |d2i_SAMPLE_with_reuse|.
1903 //
1904 // Do not use this. Despite, the name it has no connection to PrintableString or
1905 // printable characters. See https://crbug.com/boringssl/412.
1906 //
1907 // TODO(https://crbug.com/boringssl/354): This function currently also accepts
1908 // BER, but this will be removed in the future.
1910  const uint8_t **inp, long len);
1911 
1912 // i2d_ASN1_PRINTABLE marshals |in| as DER, as described in |i2d_SAMPLE|.
1913 //
1914 // Do not use this. Despite the name, it has no connection to PrintableString or
1915 // printable characters. See https://crbug.com/boringssl/412.
1917 
1918 // ASN1_PRINTABLE is an |ASN1_ITEM| whose ASN.1 type is a CHOICE of an ad-hoc
1919 // subset of string-like types, and whose C type is |ASN1_STRING*|.
1920 //
1921 // Do not use this. Despite the name, it has no connection to PrintableString or
1922 // printable characters. See https://crbug.com/boringssl/412.
1923 DECLARE_ASN1_ITEM(ASN1_PRINTABLE)
1924 
1925 
1926 #if defined(__cplusplus)
1927 } // extern C
1928 
1929 extern "C++" {
1930 
1932 
1936 
1938 
1939 } // extern C++
1940 
1941 #endif
1942 
1943 #define ASN1_R_ASN1_LENGTH_MISMATCH 100
1944 #define ASN1_R_AUX_ERROR 101
1945 #define ASN1_R_BAD_GET_ASN1_OBJECT_CALL 102
1946 #define ASN1_R_BAD_OBJECT_HEADER 103
1947 #define ASN1_R_BMPSTRING_IS_WRONG_LENGTH 104
1948 #define ASN1_R_BN_LIB 105
1949 #define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 106
1950 #define ASN1_R_BUFFER_TOO_SMALL 107
1951 #define ASN1_R_CONTEXT_NOT_INITIALISED 108
1952 #define ASN1_R_DECODE_ERROR 109
1953 #define ASN1_R_DEPTH_EXCEEDED 110
1954 #define ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED 111
1955 #define ASN1_R_ENCODE_ERROR 112
1956 #define ASN1_R_ERROR_GETTING_TIME 113
1957 #define ASN1_R_EXPECTING_AN_ASN1_SEQUENCE 114
1958 #define ASN1_R_EXPECTING_AN_INTEGER 115
1959 #define ASN1_R_EXPECTING_AN_OBJECT 116
1960 #define ASN1_R_EXPECTING_A_BOOLEAN 117
1961 #define ASN1_R_EXPECTING_A_TIME 118
1962 #define ASN1_R_EXPLICIT_LENGTH_MISMATCH 119
1963 #define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED 120
1964 #define ASN1_R_FIELD_MISSING 121
1965 #define ASN1_R_FIRST_NUM_TOO_LARGE 122
1966 #define ASN1_R_HEADER_TOO_LONG 123
1967 #define ASN1_R_ILLEGAL_BITSTRING_FORMAT 124
1968 #define ASN1_R_ILLEGAL_BOOLEAN 125
1969 #define ASN1_R_ILLEGAL_CHARACTERS 126
1970 #define ASN1_R_ILLEGAL_FORMAT 127
1971 #define ASN1_R_ILLEGAL_HEX 128
1972 #define ASN1_R_ILLEGAL_IMPLICIT_TAG 129
1973 #define ASN1_R_ILLEGAL_INTEGER 130
1974 #define ASN1_R_ILLEGAL_NESTED_TAGGING 131
1975 #define ASN1_R_ILLEGAL_NULL 132
1976 #define ASN1_R_ILLEGAL_NULL_VALUE 133
1977 #define ASN1_R_ILLEGAL_OBJECT 134
1978 #define ASN1_R_ILLEGAL_OPTIONAL_ANY 135
1979 #define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE 136
1980 #define ASN1_R_ILLEGAL_TAGGED_ANY 137
1981 #define ASN1_R_ILLEGAL_TIME_VALUE 138
1982 #define ASN1_R_INTEGER_NOT_ASCII_FORMAT 139
1983 #define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 140
1984 #define ASN1_R_INVALID_BIT_STRING_BITS_LEFT 141
1985 #define ASN1_R_INVALID_BMPSTRING 142
1986 #define ASN1_R_INVALID_DIGIT 143
1987 #define ASN1_R_INVALID_MODIFIER 144
1988 #define ASN1_R_INVALID_NUMBER 145
1989 #define ASN1_R_INVALID_OBJECT_ENCODING 146
1990 #define ASN1_R_INVALID_SEPARATOR 147
1991 #define ASN1_R_INVALID_TIME_FORMAT 148
1992 #define ASN1_R_INVALID_UNIVERSALSTRING 149
1993 #define ASN1_R_INVALID_UTF8STRING 150
1994 #define ASN1_R_LIST_ERROR 151
1995 #define ASN1_R_MISSING_ASN1_EOS 152
1996 #define ASN1_R_MISSING_EOC 153
1997 #define ASN1_R_MISSING_SECOND_NUMBER 154
1998 #define ASN1_R_MISSING_VALUE 155
1999 #define ASN1_R_MSTRING_NOT_UNIVERSAL 156
2000 #define ASN1_R_MSTRING_WRONG_TAG 157
2001 #define ASN1_R_NESTED_ASN1_ERROR 158
2002 #define ASN1_R_NESTED_ASN1_STRING 159
2003 #define ASN1_R_NON_HEX_CHARACTERS 160
2004 #define ASN1_R_NOT_ASCII_FORMAT 161
2005 #define ASN1_R_NOT_ENOUGH_DATA 162
2006 #define ASN1_R_NO_MATCHING_CHOICE_TYPE 163
2007 #define ASN1_R_NULL_IS_WRONG_LENGTH 164
2008 #define ASN1_R_OBJECT_NOT_ASCII_FORMAT 165
2009 #define ASN1_R_ODD_NUMBER_OF_CHARS 166
2010 #define ASN1_R_SECOND_NUMBER_TOO_LARGE 167
2011 #define ASN1_R_SEQUENCE_LENGTH_MISMATCH 168
2012 #define ASN1_R_SEQUENCE_NOT_CONSTRUCTED 169
2013 #define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG 170
2014 #define ASN1_R_SHORT_LINE 171
2015 #define ASN1_R_STREAMING_NOT_SUPPORTED 172
2016 #define ASN1_R_STRING_TOO_LONG 173
2017 #define ASN1_R_STRING_TOO_SHORT 174
2018 #define ASN1_R_TAG_VALUE_TOO_HIGH 175
2019 #define ASN1_R_TIME_NOT_ASCII_FORMAT 176
2020 #define ASN1_R_TOO_LONG 177
2021 #define ASN1_R_TYPE_NOT_CONSTRUCTED 178
2022 #define ASN1_R_TYPE_NOT_PRIMITIVE 179
2023 #define ASN1_R_UNEXPECTED_EOC 180
2024 #define ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH 181
2025 #define ASN1_R_UNKNOWN_FORMAT 182
2026 #define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 183
2027 #define ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM 184
2028 #define ASN1_R_UNKNOWN_TAG 185
2029 #define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 186
2030 #define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 187
2031 #define ASN1_R_UNSUPPORTED_TYPE 188
2032 #define ASN1_R_WRONG_PUBLIC_KEY_TYPE 189
2033 #define ASN1_R_WRONG_TAG 190
2034 #define ASN1_R_WRONG_TYPE 191
2035 #define ASN1_R_NESTED_TOO_DEEP 192
2036 #define ASN1_R_BAD_TEMPLATE 193
2037 #define ASN1_R_INVALID_BIT_STRING_PADDING 194
2038 
2039 #endif
ASN1_BIT_STRING_set
OPENSSL_EXPORT int ASN1_BIT_STRING_set(ASN1_BIT_STRING *str, const unsigned char *d, int length)
Definition: a_bitstr.c:69
xds_interop_client.str
str
Definition: xds_interop_client.py:487
asn1_type_st::asn1_string
ASN1_STRING * asn1_string
Definition: asn1.h:1486
asn1_type_st::object
ASN1_OBJECT * object
Definition: asn1.h:1487
ASN1_item_pack
OPENSSL_EXPORT ASN1_STRING * ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **out)
Definition: asn_pack.c:63
obj
OPENSSL_EXPORT const ASN1_OBJECT * obj
Definition: x509.h:1671
bn.h
d2i_DISPLAYTEXT
OPENSSL_EXPORT ASN1_STRING * d2i_DISPLAYTEXT(ASN1_STRING **out, const uint8_t **inp, long len)
ASN1_UTCTIME_check
OPENSSL_EXPORT int ASN1_UTCTIME_check(const ASN1_UTCTIME *a)
Definition: a_utctm.c:160
asn1_type_st::sequence
ASN1_STRING * sequence
Definition: asn1.h:1504
dst
static const char dst[]
Definition: test-fs-copyfile.c:37
gen_build_yaml.out
dictionary out
Definition: src/benchmark/gen_build_yaml.py:24
ASN1_OCTET_STRING_set
OPENSSL_EXPORT int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, int len)
Definition: a_octet.c:73
regen-readme.it
it
Definition: regen-readme.py:15
d2i_ASN1_INTEGER
OPENSSL_EXPORT ASN1_INTEGER * d2i_ASN1_INTEGER(ASN1_INTEGER **out, const uint8_t **inp, long len)
ASN1_STRING_set_default_mask_asc
OPENSSL_EXPORT int ASN1_STRING_set_default_mask_asc(const char *p)
Definition: a_strnid.c:86
ASN1_OBJECT_free
OPENSSL_EXPORT void ASN1_OBJECT_free(ASN1_OBJECT *a)
Definition: a_object.c:268
ASN1_IA5STRING_free
OPENSSL_EXPORT void ASN1_IA5STRING_free(ASN1_IA5STRING *str)
asn1_type_st::bmpstring
ASN1_BMPSTRING * bmpstring
Definition: asn1.h:1496
d2i_ASN1_PRINTABLE
OPENSSL_EXPORT ASN1_STRING * d2i_ASN1_PRINTABLE(ASN1_STRING **out, const uint8_t **inp, long len)
d2i_ASN1_UNIVERSALSTRING
OPENSSL_EXPORT ASN1_UNIVERSALSTRING * d2i_ASN1_UNIVERSALSTRING(ASN1_UNIVERSALSTRING **out, const uint8_t **inp, long len)
ASN1_UTCTIME_set_string
OPENSSL_EXPORT int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str)
Definition: a_utctm.c:165
ASN1_VISIBLESTRING_new
OPENSSL_EXPORT ASN1_VISIBLESTRING * ASN1_VISIBLESTRING_new(void)
ASN1_TIME_check
OPENSSL_EXPORT int ASN1_TIME_check(const ASN1_TIME *t)
Definition: a_time.c:103
i2d_ASN1_TYPE
OPENSSL_EXPORT int i2d_ASN1_TYPE(const ASN1_TYPE *in, uint8_t **outp)
bio_st
Definition: bio.h:822
ASN1_UTCTIME_new
OPENSSL_EXPORT ASN1_UTCTIME * ASN1_UTCTIME_new(void)
ASN1_TIME_new
OPENSSL_EXPORT ASN1_TIME * ASN1_TIME_new(void)
d2i_ASN1_IA5STRING
OPENSSL_EXPORT ASN1_IA5STRING * d2i_ASN1_IA5STRING(ASN1_IA5STRING **out, const uint8_t **inp, long len)
asn1_type_st::boolean
ASN1_BOOLEAN boolean
Definition: asn1.h:1485
ASN1_BOOLEAN
int ASN1_BOOLEAN
Definition: base.h:335
ASN1_STRING_dup
OPENSSL_EXPORT ASN1_STRING * ASN1_STRING_dup(const ASN1_STRING *str)
Definition: asn1_lib.c:308
ASN1_INTEGER_to_BN
OPENSSL_EXPORT BIGNUM * ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn)
Definition: a_int.c:411
ASN1_GENERALIZEDTIME_check
OPENSSL_EXPORT int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a)
Definition: a_gentm.c:184
ASN1_GENERALIZEDTIME_set
OPENSSL_EXPORT ASN1_GENERALIZEDTIME * ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, time_t t)
Definition: a_gentm.c:208
ASN1_get_object
OPENSSL_EXPORT int ASN1_get_object(const unsigned char **inp, long *out_length, int *out_tag, int *out_class, long max_len)
Definition: asn1_lib.c:110
ASN1_GENERALIZEDTIME_adj
OPENSSL_EXPORT ASN1_GENERALIZEDTIME * ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, time_t t, int offset_day, long offset_sec)
Definition: a_gentm.c:214
regen-readme.inp
inp
Definition: regen-readme.py:11
ASN1_STRING_set0
OPENSSL_EXPORT void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len)
Definition: asn1_lib.c:356
d2i_ASN1_OCTET_STRING
OPENSSL_EXPORT ASN1_OCTET_STRING * d2i_ASN1_OCTET_STRING(ASN1_OCTET_STRING **out, const uint8_t **inp, long len)
d2i_ASN1_VISIBLESTRING
OPENSSL_EXPORT ASN1_VISIBLESTRING * d2i_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING **out, const uint8_t **inp, long len)
d2i_ASN1_SET_ANY
OPENSSL_EXPORT ASN1_SEQUENCE_ANY * d2i_ASN1_SET_ANY(ASN1_SEQUENCE_ANY **out, const uint8_t **inp, long len)
i2d_ASN1_VISIBLESTRING
OPENSSL_EXPORT int i2d_ASN1_VISIBLESTRING(const ASN1_VISIBLESTRING *in, uint8_t **outp)
y
const double y
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3611
bio.h
DIRECTORYSTRING_free
OPENSSL_EXPORT void DIRECTORYSTRING_free(ASN1_STRING *str)
ASN1_BIT_STRING_num_bytes
OPENSSL_EXPORT int ASN1_BIT_STRING_num_bytes(const ASN1_BIT_STRING *str, size_t *out)
Definition: a_bitstr.c:102
ASN1_GENERALIZEDTIME_new
OPENSSL_EXPORT ASN1_GENERALIZEDTIME * ASN1_GENERALIZEDTIME_new(void)
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
i2a_ASN1_OBJECT
OPENSSL_EXPORT int i2a_ASN1_OBJECT(BIO *bp, const ASN1_OBJECT *a)
Definition: a_object.c:119
i2d_ASN1_GENERALSTRING
OPENSSL_EXPORT int i2d_ASN1_GENERALSTRING(const ASN1_GENERALSTRING *in, uint8_t **outp)
ASN1_STRING_print
OPENSSL_EXPORT int ASN1_STRING_print(BIO *out, const ASN1_STRING *str)
Definition: a_strex.c:476
_gevent_test_main.maxsize
maxsize
Definition: _gevent_test_main.py:26
ASN1_item_dup
OPENSSL_EXPORT void * ASN1_item_dup(const ASN1_ITEM *it, void *x)
Definition: a_dup.c:68
asn1_type_st::asn1_value
ASN1_VALUE * asn1_value
Definition: asn1.h:1505
ASN1_GENERALIZEDTIME_free
OPENSSL_EXPORT void ASN1_GENERALIZEDTIME_free(ASN1_GENERALIZEDTIME *str)
d2i_ASN1_SEQUENCE_ANY
OPENSSL_EXPORT ASN1_SEQUENCE_ANY * d2i_ASN1_SEQUENCE_ANY(ASN1_SEQUENCE_ANY **out, const uint8_t **inp, long len)
i2c_ASN1_BIT_STRING
OPENSSL_EXPORT int i2c_ASN1_BIT_STRING(const ASN1_BIT_STRING *in, uint8_t **outp)
Definition: a_bitstr.c:112
d2i_ASN1_OBJECT
OPENSSL_EXPORT ASN1_OBJECT * d2i_ASN1_OBJECT(ASN1_OBJECT **out, const uint8_t **inp, long len)
Definition: a_object.c:146
asn1_type_st::universalstring
ASN1_UNIVERSALSTRING * universalstring
Definition: asn1.h:1497
ASN1_PRINTABLE_free
OPENSSL_EXPORT void ASN1_PRINTABLE_free(ASN1_STRING *str)
ASN1_OCTET_STRING_cmp
OPENSSL_EXPORT int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a, const ASN1_OCTET_STRING *b)
Definition: a_octet.c:67
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
asn1_type_st::set
ASN1_STRING * set
Definition: asn1.h:1503
to
size_t to
Definition: abseil-cpp/absl/container/internal/layout_test.cc:1385
xds_manager.p
p
Definition: xds_manager.py:60
ASN1_put_eoc
OPENSSL_EXPORT int ASN1_put_eoc(unsigned char **outp)
Definition: asn1_lib.c:237
ASN1_STRING_set
OPENSSL_EXPORT int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len)
Definition: asn1_lib.c:323
ASN1_TIME_free
OPENSSL_EXPORT void ASN1_TIME_free(ASN1_TIME *str)
ASN1_UTCTIME_free
OPENSSL_EXPORT void ASN1_UTCTIME_free(ASN1_UTCTIME *str)
ASN1_BMPSTRING_new
OPENSSL_EXPORT ASN1_BMPSTRING * ASN1_BMPSTRING_new(void)
asn1_type_st::t61string
ASN1_T61STRING * t61string
Definition: asn1.h:1493
i2d_ASN1_OBJECT
OPENSSL_EXPORT int i2d_ASN1_OBJECT(const ASN1_OBJECT *a, uint8_t **outp)
Definition: a_object.c:70
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
ASN1_tag2str
const OPENSSL_EXPORT char * ASN1_tag2str(int tag)
Definition: asn1_par.c:60
ASN1_PRINTABLE_type
OPENSSL_EXPORT int ASN1_PRINTABLE_type(const unsigned char *s, int len)
Definition: a_print.c:64
asn1_type_st::visiblestring
ASN1_VISIBLESTRING * visiblestring
Definition: asn1.h:1500
ASN1_INTEGER_new
OPENSSL_EXPORT ASN1_INTEGER * ASN1_INTEGER_new(void)
ASN1_NULL_new
OPENSSL_EXPORT ASN1_NULL * ASN1_NULL_new(void)
d2i_ASN1_BMPSTRING
OPENSSL_EXPORT ASN1_BMPSTRING * d2i_ASN1_BMPSTRING(ASN1_BMPSTRING **out, const uint8_t **inp, long len)
ASN1_OBJECT_create
OPENSSL_EXPORT ASN1_OBJECT * ASN1_OBJECT_create(int nid, const uint8_t *data, int len, const char *sn, const char *ln)
Definition: a_object.c:286
ASN1_UNIVERSALSTRING_new
OPENSSL_EXPORT ASN1_UNIVERSALSTRING * ASN1_UNIVERSALSTRING_new(void)
asn1_string_st::data
unsigned char * data
Definition: asn1.h:546
ASN1_ENUMERATED_set
OPENSSL_EXPORT int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v)
Definition: a_enum.c:73
ASN1_OCTET_STRING_new
OPENSSL_EXPORT ASN1_OCTET_STRING * ASN1_OCTET_STRING_new(void)
ASN1_ENUMERATED_get
OPENSSL_EXPORT long ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a)
Definition: a_enum.c:111
i2a_ASN1_INTEGER
OPENSSL_EXPORT int i2a_ASN1_INTEGER(BIO *bp, const ASN1_INTEGER *a)
Definition: f_int.c:61
ASN1_ENUMERATED_new
OPENSSL_EXPORT ASN1_ENUMERATED * ASN1_ENUMERATED_new(void)
DISPLAYTEXT_free
OPENSSL_EXPORT void DISPLAYTEXT_free(ASN1_STRING *str)
gen_build_yaml.struct
def struct(**kwargs)
Definition: test/core/end2end/gen_build_yaml.py:30
ASN1_BIT_STRING_check
OPENSSL_EXPORT int ASN1_BIT_STRING_check(const ASN1_BIT_STRING *str, const unsigned char *flags, int flags_len)
Definition: a_bitstr.c:266
base.h
ASN1_TIME_to_generalizedtime
OPENSSL_EXPORT ASN1_GENERALIZEDTIME * ASN1_TIME_to_generalizedtime(const ASN1_TIME *t, ASN1_GENERALIZEDTIME **out)
Definition: a_time.c:113
ASN1_TYPE_set
OPENSSL_EXPORT void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value)
Definition: a_type.c:87
i2t_ASN1_OBJECT
OPENSSL_EXPORT int i2t_ASN1_OBJECT(char *buf, int buf_len, const ASN1_OBJECT *a)
Definition: a_object.c:108
ASN1_BIT_STRING_new
OPENSSL_EXPORT ASN1_BIT_STRING * ASN1_BIT_STRING_new(void)
i2d_of_void
int i2d_of_void(const void *, unsigned char **)
Definition: asn1.h:275
ASN1_INTEGER_get
OPENSSL_EXPORT long ASN1_INTEGER_get(const ASN1_INTEGER *a)
Definition: a_int.c:332
asn1_object_st
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:102
ASN1_STRING_type_new
OPENSSL_EXPORT ASN1_STRING * ASN1_STRING_type_new(int type)
Definition: asn1_lib.c:368
ASN1_TIME_diff
OPENSSL_EXPORT int ASN1_TIME_diff(int *out_days, int *out_seconds, const ASN1_TIME *from, const ASN1_TIME *to)
Definition: a_time.c:203
ASN1_BIT_STRING_get_bit
OPENSSL_EXPORT int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *str, int n)
Definition: a_bitstr.c:249
ASN1_tag2bit
OPENSSL_EXPORT unsigned long ASN1_tag2bit(int tag)
Definition: tasn_dec.c:120
ASN1_TYPE_set1
OPENSSL_EXPORT int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value)
Definition: a_type.c:98
ASN1_NULL_free
OPENSSL_EXPORT void ASN1_NULL_free(ASN1_NULL *null)
asn1_string_st::flags
long flags
Definition: asn1.h:547
from
size_t from
Definition: abseil-cpp/absl/container/internal/layout_test.cc:1384
ASN1_item_i2d_bio
OPENSSL_EXPORT int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *in)
Definition: a_i2d_fp.c:76
i2d_ASN1_UNIVERSALSTRING
OPENSSL_EXPORT int i2d_ASN1_UNIVERSALSTRING(const ASN1_UNIVERSALSTRING *in, uint8_t **outp)
ASN1_INTEGER_dup
OPENSSL_EXPORT ASN1_INTEGER * ASN1_INTEGER_dup(const ASN1_INTEGER *x)
Definition: a_int.c:68
asn1_type_st::printablestring
ASN1_PRINTABLESTRING * printablestring
Definition: asn1.h:1492
in
const char * in
Definition: third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc:391
ASN1_INTEGER_cmp
OPENSSL_EXPORT int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y)
Definition: a_int.c:73
asn1_type_st::type
int type
Definition: asn1.h:1482
asn1_type_st::utf8string
ASN1_UTF8STRING * utf8string
Definition: asn1.h:1501
ASN1_item_d2i_fp
OPENSSL_EXPORT void * ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *out)
Definition: a_d2i_fp.c:81
ASN1_TIME_print
OPENSSL_EXPORT int ASN1_TIME_print(BIO *out, const ASN1_TIME *a)
Definition: a_strex.c:505
BN_to_ASN1_INTEGER
OPENSSL_EXPORT ASN1_INTEGER * BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai)
Definition: a_int.c:371
ASN1_ITEM_st
Definition: asn1t.h:459
ASN1_STRING_type
OPENSSL_EXPORT int ASN1_STRING_type(const ASN1_STRING *str)
Definition: asn1_lib.c:439
asn1_type_st::bit_string
ASN1_BIT_STRING * bit_string
Definition: asn1.h:1490
ASN1_T61STRING_new
OPENSSL_EXPORT ASN1_T61STRING * ASN1_T61STRING_new(void)
ASN1_STRING_TABLE_add
OPENSSL_EXPORT int ASN1_STRING_TABLE_add(int nid, long minsize, long maxsize, unsigned long mask, unsigned long flags)
Definition: a_strnid.c:208
ASN1_GENERALSTRING_new
OPENSSL_EXPORT ASN1_GENERALSTRING * ASN1_GENERALSTRING_new(void)
ASN1_STRING_free
OPENSSL_EXPORT void ASN1_STRING_free(ASN1_STRING *str)
Definition: asn1_lib.c:384
asn1_string_st::length
int length
Definition: asn1.h:544
tag
static void * tag(intptr_t t)
Definition: bad_client.cc:318
d2i_DIRECTORYSTRING
OPENSSL_EXPORT ASN1_STRING * d2i_DIRECTORYSTRING(ASN1_STRING **out, const uint8_t **inp, long len)
d2i_ASN1_PRINTABLESTRING
OPENSSL_EXPORT ASN1_PRINTABLESTRING * d2i_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING **out, const uint8_t **inp, long len)
d2i_ASN1_TIME
OPENSSL_EXPORT ASN1_TIME * d2i_ASN1_TIME(ASN1_TIME **out, const uint8_t **inp, long len)
ASN1_T61STRING_free
OPENSSL_EXPORT void ASN1_T61STRING_free(ASN1_T61STRING *str)
ASN1_TYPE_free
OPENSSL_EXPORT void ASN1_TYPE_free(ASN1_TYPE *a)
ASN1_item_i2d
OPENSSL_EXPORT int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **outp, const ASN1_ITEM *it)
Definition: tasn_enc.c:87
setup.v
v
Definition: third_party/bloaty/third_party/capstone/bindings/python/setup.py:42
DIRECTORYSTRING_new
OPENSSL_EXPORT ASN1_STRING * DIRECTORYSTRING_new(void)
ASN1_ENUMERATED_to_BN
OPENSSL_EXPORT BIGNUM * ASN1_ENUMERATED_to_BN(const ASN1_ENUMERATED *ai, BIGNUM *bn)
Definition: a_enum.c:186
ASN1_STRING_get0_data
const OPENSSL_EXPORT unsigned char * ASN1_STRING_get0_data(const ASN1_STRING *str)
Definition: asn1_lib.c:449
ASN1_STRING_print_ex_fp
OPENSSL_EXPORT int ASN1_STRING_print_ex_fp(FILE *fp, const ASN1_STRING *str, unsigned long flags)
Definition: a_strex.c:435
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
ASN1_BMPSTRING_free
OPENSSL_EXPORT void ASN1_BMPSTRING_free(ASN1_BMPSTRING *str)
ASN1_STRING_set_by_NID
OPENSSL_EXPORT ASN1_STRING * ASN1_STRING_set_by_NID(ASN1_STRING **out, const unsigned char *in, int len, int inform, int nid)
Definition: a_strnid.c:99
BSSL_NAMESPACE_END
#define BSSL_NAMESPACE_END
Definition: base.h:480
ASN1_item_d2i
OPENSSL_EXPORT ASN1_VALUE * ASN1_item_d2i(ASN1_VALUE **out, const unsigned char **inp, long len, const ASN1_ITEM *it)
Definition: tasn_dec.c:140
i2d_DIRECTORYSTRING
OPENSSL_EXPORT int i2d_DIRECTORYSTRING(const ASN1_STRING *in, uint8_t **outp)
d2i_ASN1_TYPE
OPENSSL_EXPORT ASN1_TYPE * d2i_ASN1_TYPE(ASN1_TYPE **out, const uint8_t **inp, long len)
ASN1_UTF8STRING_free
OPENSSL_EXPORT void ASN1_UTF8STRING_free(ASN1_UTF8STRING *str)
ASN1_UTCTIME_adj
OPENSSL_EXPORT ASN1_UTCTIME * ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, int offset_day, long offset_sec)
Definition: a_utctm.c:189
BN_to_ASN1_ENUMERATED
OPENSSL_EXPORT ASN1_ENUMERATED * BN_to_ASN1_ENUMERATED(const BIGNUM *bn, ASN1_ENUMERATED *ai)
Definition: a_enum.c:150
ASN1_BIT_STRING_set_bit
OPENSSL_EXPORT int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *str, int n, int value)
Definition: a_bitstr.c:211
i2d_ASN1_PRINTABLE
OPENSSL_EXPORT int i2d_ASN1_PRINTABLE(const ASN1_STRING *in, uint8_t **outp)
ASN1_STRING_get_default_mask
OPENSSL_EXPORT unsigned long ASN1_STRING_get_default_mask(void)
Definition: a_strnid.c:81
ASN1_INTEGER_set_uint64
OPENSSL_EXPORT int ASN1_INTEGER_set_uint64(ASN1_INTEGER *out, uint64_t v)
Definition: a_int.c:303
d2i_ASN1_T61STRING
OPENSSL_EXPORT ASN1_T61STRING * d2i_ASN1_T61STRING(ASN1_T61STRING **out, const uint8_t **inp, long len)
x
int x
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3610
ASN1_TIME_adj
OPENSSL_EXPORT ASN1_TIME * ASN1_TIME_adj(ASN1_TIME *s, time_t t, int offset_day, long offset_sec)
Definition: a_time.c:83
i2d_ASN1_GENERALIZEDTIME
OPENSSL_EXPORT int i2d_ASN1_GENERALIZEDTIME(const ASN1_GENERALIZEDTIME *in, uint8_t **outp)
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
ASN1_PRINTABLESTRING_free
OPENSSL_EXPORT void ASN1_PRINTABLESTRING_free(ASN1_PRINTABLESTRING *str)
ASN1_INTEGER_free
OPENSSL_EXPORT void ASN1_INTEGER_free(ASN1_INTEGER *str)
ASN1_UNIVERSALSTRING_free
OPENSSL_EXPORT void ASN1_UNIVERSALSTRING_free(ASN1_UNIVERSALSTRING *str)
ASN1_UTCTIME_cmp_time_t
OPENSSL_EXPORT int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t)
Definition: a_utctm.c:241
i2a_ASN1_ENUMERATED
OPENSSL_EXPORT int i2a_ASN1_ENUMERATED(BIO *bp, const ASN1_ENUMERATED *a)
Definition: f_int.c:99
asn1_type_st::utctime
ASN1_UTCTIME * utctime
Definition: asn1.h:1498
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
ASN1_ITEM_EXP
const typedef ASN1_ITEM ASN1_ITEM_EXP
Definition: asn1.h:309
DEFINE_STACK_OF
#define DEFINE_STACK_OF(type)
Definition: stack.h:409
asn1_type_st::ia5string
ASN1_IA5STRING * ia5string
Definition: asn1.h:1494
ASN1_UTCTIME_set
OPENSSL_EXPORT ASN1_UTCTIME * ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
Definition: a_utctm.c:184
d
static const fe d
Definition: curve25519_tables.h:19
n
int n
Definition: abseil-cpp/absl/container/btree_test.cc:1080
d2i_ASN1_NULL
OPENSSL_EXPORT ASN1_NULL * d2i_ASN1_NULL(ASN1_NULL **out, const uint8_t **inp, long len)
i2d_ASN1_INTEGER
OPENSSL_EXPORT int i2d_ASN1_INTEGER(const ASN1_INTEGER *in, uint8_t **outp)
ASN1_mbstring_ncopy
OPENSSL_EXPORT int ASN1_mbstring_ncopy(ASN1_STRING **out, const uint8_t *in, int len, int inform, unsigned long mask, long minsize, long maxsize)
Definition: a_mbstr.c:88
ASN1_item_unpack
OPENSSL_EXPORT void * ASN1_item_unpack(const ASN1_STRING *oct, const ASN1_ITEM *it)
Definition: asn_pack.c:91
STACK_OF
typedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY
ASN1_GENERALSTRING_free
OPENSSL_EXPORT void ASN1_GENERALSTRING_free(ASN1_GENERALSTRING *str)
asn1_type_st::octet_string
ASN1_OCTET_STRING * octet_string
Definition: asn1.h:1491
i2d_ASN1_UTCTIME
OPENSSL_EXPORT int i2d_ASN1_UTCTIME(const ASN1_UTCTIME *in, uint8_t **outp)
ASN1_GENERALIZEDTIME_set_string
OPENSSL_EXPORT int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str)
Definition: a_gentm.c:189
nid
int nid
Definition: cipher_extra.c:71
value
const char * value
Definition: hpack_parser_table.cc:165
ASN1_STRING_length
OPENSSL_EXPORT int ASN1_STRING_length(const ASN1_STRING *str)
Definition: asn1_lib.c:434
ASN1_item_d2i_bio
OPENSSL_EXPORT void * ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *out)
Definition: a_d2i_fp.c:66
c2i_ASN1_INTEGER
OPENSSL_EXPORT ASN1_INTEGER * c2i_ASN1_INTEGER(ASN1_INTEGER **in, const uint8_t **outp, long len)
Definition: a_int.c:190
i2a_ASN1_STRING
OPENSSL_EXPORT int i2a_ASN1_STRING(BIO *bp, const ASN1_STRING *a, int type)
Definition: f_string.c:61
d2i_ASN1_UTF8STRING
OPENSSL_EXPORT ASN1_UTF8STRING * d2i_ASN1_UTF8STRING(ASN1_UTF8STRING **out, const uint8_t **inp, long len)
BSSL_NAMESPACE_BEGIN
Definition: trust_token_test.cc:45
ASN1_STRING_copy
OPENSSL_EXPORT int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str)
Definition: asn1_lib.c:297
benchmark.FILE
FILE
Definition: benchmark.py:21
i2d_ASN1_PRINTABLESTRING
OPENSSL_EXPORT int i2d_ASN1_PRINTABLESTRING(const ASN1_PRINTABLESTRING *in, uint8_t **outp)
ASN1_ENUMERATED_free
OPENSSL_EXPORT void ASN1_ENUMERATED_free(ASN1_ENUMERATED *str)
absl::flags_internal
Definition: abseil-cpp/absl/flags/commandlineflag.h:40
ASN1_OCTET_STRING_dup
OPENSSL_EXPORT ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a)
Definition: a_octet.c:62
ASN1_item_i2d_fp
OPENSSL_EXPORT int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *in)
Definition: a_i2d_fp.c:64
asn1_type_st::ptr
char * ptr
Definition: asn1.h:1484
ASN1_PRINTABLE_new
OPENSSL_EXPORT ASN1_STRING * ASN1_PRINTABLE_new(void)
bignum_st
Definition: bn.h:957
d2i_ASN1_GENERALIZEDTIME
OPENSSL_EXPORT ASN1_GENERALIZEDTIME * d2i_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME **out, const uint8_t **inp, long len)
DISPLAYTEXT_new
OPENSSL_EXPORT ASN1_STRING * DISPLAYTEXT_new(void)
ASN1_STRING_new
OPENSSL_EXPORT ASN1_STRING * ASN1_STRING_new(void)
Definition: asn1_lib.c:363
ASN1_STRING_print_ex
OPENSSL_EXPORT int ASN1_STRING_print_ex(BIO *out, const ASN1_STRING *str, unsigned long flags)
Definition: a_strex.c:357
ASN1_mbstring_copy
OPENSSL_EXPORT int ASN1_mbstring_copy(ASN1_STRING **out, const uint8_t *in, int len, int inform, unsigned long mask)
Definition: a_mbstr.c:78
OPENSSL_EXPORT
#define OPENSSL_EXPORT
Definition: base.h:222
BORINGSSL_MAKE_DELETER
#define BORINGSSL_MAKE_DELETER(type, deleter)
Definition: base.h:506
ASN1_VALUE
struct ASN1_VALUE_st ASN1_VALUE
Definition: asn1.h:320
d2i_ASN1_UTCTIME
OPENSSL_EXPORT ASN1_UTCTIME * d2i_ASN1_UTCTIME(ASN1_UTCTIME **out, const uint8_t **inp, long len)
DECLARE_ASN1_ITEM
#define DECLARE_ASN1_ITEM(name)
Definition: asn1.h:299
ASN1_UTF8STRING_new
OPENSSL_EXPORT ASN1_UTF8STRING * ASN1_UTF8STRING_new(void)
ASN1_UTCTIME_print
OPENSSL_EXPORT int ASN1_UTCTIME_print(BIO *out, const ASN1_UTCTIME *a)
Definition: a_strex.c:599
ASN1_TYPE_new
OPENSSL_EXPORT ASN1_TYPE * ASN1_TYPE_new(void)
ASN1_STRING_to_UTF8
OPENSSL_EXPORT int ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in)
Definition: a_strex.c:452
asn1_string_st::type
int type
Definition: asn1.h:545
i2c_ASN1_INTEGER
OPENSSL_EXPORT int i2c_ASN1_INTEGER(const ASN1_INTEGER *in, uint8_t **outp)
Definition: a_int.c:118
ASN1_STRING_TABLE_cleanup
OPENSSL_EXPORT void ASN1_STRING_TABLE_cleanup(void)
Definition: a_strnid.c:258
i2d_ASN1_BOOLEAN
OPENSSL_EXPORT int i2d_ASN1_BOOLEAN(ASN1_BOOLEAN a, unsigned char **outp)
Definition: a_bool.c:62
asn1_type_st::generalizedtime
ASN1_GENERALIZEDTIME * generalizedtime
Definition: asn1.h:1499
d2i_ASN1_ENUMERATED
OPENSSL_EXPORT ASN1_ENUMERATED * d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **out, const uint8_t **inp, long len)
d2i_of_void
void * d2i_of_void(void **, const unsigned char **, long)
Definition: asn1.h:274
i2d_ASN1_SET_ANY
OPENSSL_EXPORT int i2d_ASN1_SET_ANY(const ASN1_SEQUENCE_ANY *in, uint8_t **outp)
ASN1_STRING_cmp
OPENSSL_EXPORT int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b)
Definition: asn1_lib.c:392
ASN1_object_size
OPENSSL_EXPORT int ASN1_object_size(int constructed, int length, int tag)
Definition: asn1_lib.c:269
i2d_ASN1_OCTET_STRING
OPENSSL_EXPORT int i2d_ASN1_OCTET_STRING(const ASN1_OCTET_STRING *in, uint8_t **outp)
i2d_ASN1_ENUMERATED
OPENSSL_EXPORT int i2d_ASN1_ENUMERATED(const ASN1_ENUMERATED *in, uint8_t **outp)
ASN1_item_free
OPENSSL_EXPORT void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it)
Definition: tasn_fre.c:68
ASN1_TIME_set
OPENSSL_EXPORT ASN1_TIME * ASN1_TIME_set(ASN1_TIME *s, time_t t)
ASN1_TYPE_cmp
OPENSSL_EXPORT int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b)
Definition: a_type.c:120
asn1_type_st::enumerated
ASN1_ENUMERATED * enumerated
Definition: asn1.h:1489
ASN1_GENERALIZEDTIME_print
OPENSSL_EXPORT int ASN1_GENERALIZEDTIME_print(BIO *out, const ASN1_GENERALIZEDTIME *a)
Definition: a_strex.c:520
ASN1_BIT_STRING_free
OPENSSL_EXPORT void ASN1_BIT_STRING_free(ASN1_BIT_STRING *str)
ASN1_IA5STRING_new
OPENSSL_EXPORT ASN1_IA5STRING * ASN1_IA5STRING_new(void)
i2d_ASN1_BMPSTRING
OPENSSL_EXPORT int i2d_ASN1_BMPSTRING(const ASN1_BMPSTRING *in, uint8_t **outp)
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
asn1_type_st
Definition: asn1.h:1481
ASN1_PRINTABLESTRING_new
OPENSSL_EXPORT ASN1_PRINTABLESTRING * ASN1_PRINTABLESTRING_new(void)
ASN1_STRING_data
OPENSSL_EXPORT unsigned char * ASN1_STRING_data(ASN1_STRING *str)
Definition: asn1_lib.c:444
length
std::size_t length
Definition: abseil-cpp/absl/time/internal/test_util.cc:57
d2i_ASN1_BOOLEAN
OPENSSL_EXPORT ASN1_BOOLEAN d2i_ASN1_BOOLEAN(ASN1_BOOLEAN *out, const unsigned char **inp, long len)
Definition: a_bool.c:91
d2i_ASN1_BIT_STRING
OPENSSL_EXPORT ASN1_BIT_STRING * d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **out, const uint8_t **inp, long len)
asn1_type_st::integer
ASN1_INTEGER * integer
Definition: asn1.h:1488
d2i_ASN1_GENERALSTRING
OPENSSL_EXPORT ASN1_GENERALSTRING * d2i_ASN1_GENERALSTRING(ASN1_GENERALSTRING **out, const uint8_t **inp, long len)
ASN1_STRING_set_default_mask
OPENSSL_EXPORT void ASN1_STRING_set_default_mask(unsigned long mask)
ASN1_put_object
OPENSSL_EXPORT void ASN1_put_object(unsigned char **outp, int constructed, int length, int tag, int xclass)
Definition: asn1_lib.c:207
ASN1_VISIBLESTRING_free
OPENSSL_EXPORT void ASN1_VISIBLESTRING_free(ASN1_VISIBLESTRING *str)
i2d_ASN1_NULL
OPENSSL_EXPORT int i2d_ASN1_NULL(const ASN1_NULL *in, uint8_t **outp)
c2i_ASN1_BIT_STRING
OPENSSL_EXPORT ASN1_BIT_STRING * c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **out, const uint8_t **inp, long len)
Definition: a_bitstr.c:136
i2d_ASN1_BIT_STRING
OPENSSL_EXPORT int i2d_ASN1_BIT_STRING(const ASN1_BIT_STRING *in, uint8_t **outp)
ASN1_TIME_set_string
OPENSSL_EXPORT int ASN1_TIME_set_string(ASN1_TIME *s, const char *str)
Definition: a_time.c:163
asn1_string_st
Definition: asn1.h:543
i2d_ASN1_TIME
OPENSSL_EXPORT int i2d_ASN1_TIME(const ASN1_TIME *in, uint8_t **outp)
ASN1_OCTET_STRING_free
OPENSSL_EXPORT void ASN1_OCTET_STRING_free(ASN1_OCTET_STRING *str)
i2d_ASN1_IA5STRING
OPENSSL_EXPORT int i2d_ASN1_IA5STRING(const ASN1_IA5STRING *in, uint8_t **outp)
i2d_ASN1_SEQUENCE_ANY
OPENSSL_EXPORT int i2d_ASN1_SEQUENCE_ANY(const ASN1_SEQUENCE_ANY *in, uint8_t **outp)
i2d_DISPLAYTEXT
OPENSSL_EXPORT int i2d_DISPLAYTEXT(const ASN1_STRING *in, uint8_t **outp)
i2d_ASN1_T61STRING
OPENSSL_EXPORT int i2d_ASN1_T61STRING(const ASN1_T61STRING *in, uint8_t **outp)
i2d_ASN1_UTF8STRING
OPENSSL_EXPORT int i2d_ASN1_UTF8STRING(const ASN1_UTF8STRING *in, uint8_t **outp)
ASN1_item_new
OPENSSL_EXPORT ASN1_VALUE * ASN1_item_new(const ASN1_ITEM *it)
Definition: tasn_new.c:78
stack.h
c2i_ASN1_OBJECT
OPENSSL_EXPORT ASN1_OBJECT * c2i_ASN1_OBJECT(ASN1_OBJECT **out, const uint8_t **inp, long len)
Definition: a_object.c:174
ASN1_INTEGER_set
OPENSSL_EXPORT int ASN1_INTEGER_set(ASN1_INTEGER *a, long v)
Definition: a_int.c:289
ASN1_TYPE_get
OPENSSL_EXPORT int ASN1_TYPE_get(const ASN1_TYPE *a)
Definition: a_type.c:67
asn1_type_st::generalstring
ASN1_GENERALSTRING * generalstring
Definition: asn1.h:1495
ASN1_NULL
struct asn1_null_st ASN1_NULL
Definition: base.h:333


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:34