chromium/third_party/boringssl/src/include/openssl/asn1t.h

/* Written by Dr Stephen N Henson ([email protected]) for the OpenSSL
 * project 2000.
 */
/* ====================================================================
 * Copyright (c) 2000-2005 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    [email protected].
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * ([email protected]).  This product includes software written by Tim
 * Hudson ([email protected]).
 *
 */
#ifndef OPENSSL_HEADER_ASN1T_H
#define OPENSSL_HEADER_ASN1T_H

#include <openssl/base.h>
#include <openssl/asn1.h>

#if defined(__cplusplus)
extern "C" {
#endif


/* Legacy ASN.1 library template definitions.
 *
 * This header is used to define new types in OpenSSL's ASN.1 implementation. It
 * is deprecated and will be unexported from the library. Use the new |CBS| and
 * |CBB| library in <openssl/bytestring.h> instead. */


ASN1_TEMPLATE;
ASN1_TLC;

/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
#define ASN1_ADB_ptr(iptr)


/* Macros for start and end of ASN1_ITEM definition */

#define ASN1_ITEM_start(itname)

#define ASN1_ITEM_end(itname)

/* Macros to aid ASN1 template writing */

#define ASN1_ITEM_TEMPLATE(tname) 

#define ASN1_ITEM_TEMPLATE_END(tname)


/* This is a ASN1 type which just embeds a template */
 
/* This pair helps declare a SEQUENCE. We can do:
 *
 * 	ASN1_SEQUENCE(stname) = {
 * 		... SEQUENCE components ...
 * 	} ASN1_SEQUENCE_END(stname)
 *
 * 	This will produce an ASN1_ITEM called stname_it
 *	for a structure called stname.
 *
 * 	If you want the same structure but a different
 *	name then use:
 *
 * 	ASN1_SEQUENCE(itname) = {
 * 		... SEQUENCE components ...
 * 	} ASN1_SEQUENCE_END_name(stname, itname)
 *
 *	This will create an item called itname_it using
 *	a structure called stname.
 */

#define ASN1_SEQUENCE(tname) 

#define ASN1_SEQUENCE_END(stname)

#define ASN1_SEQUENCE_END_name(stname, tname)

#define ASN1_SEQUENCE_cb(tname, cb)

#define ASN1_SEQUENCE_ref(tname, cb)

#define ASN1_SEQUENCE_enc(tname, enc, cb)

#define ASN1_SEQUENCE_END_enc(stname, tname)

#define ASN1_SEQUENCE_END_cb(stname, tname)

#define ASN1_SEQUENCE_END_ref(stname, tname)


/* This pair helps declare a CHOICE type. We can do:
 *
 * 	ASN1_CHOICE(chname) = {
 * 		... CHOICE options ...
 * 	ASN1_CHOICE_END(chname)
 *
 * 	This will produce an ASN1_ITEM called chname_it
 *	for a structure called chname. The structure
 *	definition must look like this:
 *	typedef struct {
 *		int type;
 *		union {
 *			ASN1_SOMETHING *opt1;
 *			ASN1_SOMEOTHER *opt2;
 *		} value;
 *	} chname;
 *	
 *	the name of the selector must be 'type'.
 * 	to use an alternative selector name use the
 *      ASN1_CHOICE_END_selector() version.
 */

#define ASN1_CHOICE(tname) 

#define ASN1_CHOICE_cb(tname, cb)

#define ASN1_CHOICE_END(stname)

#define ASN1_CHOICE_END_name(stname, tname)

#define ASN1_CHOICE_END_selector(stname, tname, selname)

#define ASN1_CHOICE_END_cb(stname, tname, selname)

/* This helps with the template wrapper form of ASN1_ITEM */

#define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type)

/* These help with SEQUENCE or CHOICE components */

/* used to declare other types */

#define ASN1_EX_TYPE(flags, tag, stname, field, type)

/* implicit and explicit helper macros */

#define ASN1_IMP_EX(stname, field, type, tag, ex)

#define ASN1_EXP_EX(stname, field, type, tag, ex)

/* Any defined by macros: the field used is in the table itself */

#define ASN1_ADB_OBJECT(tblname)
/* Plain simple type */
#define ASN1_SIMPLE(stname, field, type)

/* OPTIONAL simple type */
#define ASN1_OPT(stname, field, type)

/* IMPLICIT tagged simple type */
#define ASN1_IMP(stname, field, type, tag)

/* IMPLICIT tagged OPTIONAL simple type */
#define ASN1_IMP_OPT(stname, field, type, tag)

/* Same as above but EXPLICIT */

#define ASN1_EXP(stname, field, type, tag)
#define ASN1_EXP_OPT(stname, field, type, tag)

/* SEQUENCE OF type */
#define ASN1_SEQUENCE_OF(stname, field, type)

/* OPTIONAL SEQUENCE OF */
#define ASN1_SEQUENCE_OF_OPT(stname, field, type)

/* Same as above but for SET OF */

#define ASN1_SET_OF(stname, field, type)

#define ASN1_SET_OF_OPT(stname, field, type)

/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */

#define ASN1_IMP_SET_OF(stname, field, type, tag)

#define ASN1_EXP_SET_OF(stname, field, type, tag)

#define ASN1_IMP_SET_OF_OPT(stname, field, type, tag)

#define ASN1_EXP_SET_OF_OPT(stname, field, type, tag)

#define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag)

#define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag)

#define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag)

#define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag)

/* Macros for the ASN1_ADB structure */

#define ASN1_ADB(name) 

#define ASN1_ADB_END(name, flags, field, app_table, def, none)

#define ADB_ENTRY(val, template)

#define ASN1_ADB_TEMPLATE(name) 

/* This is the ASN1 template structure that defines
 * a wrapper round the actual type. It determines the
 * actual position of the field in the value structure,
 * various flags such as OPTIONAL and the field name.
 */

struct ASN1_TEMPLATE_st {};

/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */

#define ASN1_TEMPLATE_item(t)
#define ASN1_TEMPLATE_adb(t)

ASN1_ADB_TABLE;
ASN1_ADB;

ASN1_MUST_BE_NULL;

struct ASN1_ADB_st {};

struct ASN1_ADB_TABLE_st {};

/* template flags */

/* Field is optional */
#define ASN1_TFLG_OPTIONAL

/* Field is a SET OF */
#define ASN1_TFLG_SET_OF

/* Field is a SEQUENCE OF */
#define ASN1_TFLG_SEQUENCE_OF

/* Mask for SET OF or SEQUENCE OF */
#define ASN1_TFLG_SK_MASK

/* These flags mean the tag should be taken from the
 * tag field. If EXPLICIT then the underlying type
 * is used for the inner tag.
 */

/* IMPLICIT tagging */
#define ASN1_TFLG_IMPTAG


/* EXPLICIT tagging, inner tag from underlying type */
#define ASN1_TFLG_EXPTAG

#define ASN1_TFLG_TAG_MASK

/* context specific IMPLICIT */
#define ASN1_TFLG_IMPLICIT

/* context specific EXPLICIT */
#define ASN1_TFLG_EXPLICIT

/* If tagging is in force these determine the
 * type of tag to use. Otherwise the tag is
 * determined by the underlying type. These 
 * values reflect the actual octet format.
 */

/* Universal tag */ 
#define ASN1_TFLG_UNIVERSAL
/* Application tag */ 
#define ASN1_TFLG_APPLICATION
/* Context specific tag */ 
#define ASN1_TFLG_CONTEXT
/* Private tag */ 
#define ASN1_TFLG_PRIVATE

#define ASN1_TFLG_TAG_CLASS

/* These are for ANY DEFINED BY type. In this case
 * the 'item' field points to an ASN1_ADB structure
 * which contains a table of values to decode the
 * relevant type
 */

#define ASN1_TFLG_ADB_MASK

#define ASN1_TFLG_ADB_OID

/* This is the actual ASN1 item itself */

struct ASN1_ITEM_st {};

/* These are values for the itype field and
 * determine how the type is interpreted.
 *
 * For PRIMITIVE types the underlying type
 * determines the behaviour if items is NULL.
 *
 * Otherwise templates must contain a single 
 * template and the type is treated in the
 * same way as the type specified in the template.
 *
 * For SEQUENCE types the templates field points
 * to the members, the size field is the
 * structure size.
 *
 * For CHOICE types the templates field points
 * to each possible member (typically a union)
 * and the 'size' field is the offset of the
 * selector.
 *
 * The 'funcs' field is used for application
 * specific functions. 
 *
 * The EXTERN type uses a new style d2i/i2d.
 * The new style should be used where possible
 * because it avoids things like the d2i IMPLICIT
 * hack.
 *
 * MSTRING is a multiple string type, it is used
 * for a CHOICE of character strings where the
 * actual strings all occupy an ASN1_STRING
 * structure. In this case the 'utype' field
 * has a special meaning, it is used as a mask
 * of acceptable types using the B_ASN1 constants.
 *
 */

#define ASN1_ITYPE_PRIMITIVE

#define ASN1_ITYPE_SEQUENCE

#define ASN1_ITYPE_CHOICE

#define ASN1_ITYPE_EXTERN

#define ASN1_ITYPE_MSTRING

/* Deprecated tag and length cache */
struct ASN1_TLC_st;

/* This is the ASN1_AUX structure: it handles various
 * miscellaneous requirements. For example the use of
 * reference counts and an informational callback.
 *
 * The "informational callback" is called at various
 * points during the ASN1 encoding and decoding. It can
 * be used to provide minor customisation of the structures
 * used. This is most useful where the supplied routines
 * *almost* do the right thing but need some extra help
 * at a few points. If the callback returns zero then
 * it is assumed a fatal error has occurred and the 
 * main operation should be abandoned.
 *
 * If major changes in the default behaviour are required
 * then an external type is more appropriate.
 */

ASN1_aux_cb;

ASN1_AUX;

/* Flags in ASN1_AUX */

/* Use a reference count */
#define ASN1_AFLG_REFCOUNT
/* Save the encoding of structure (useful for signatures) */
#define ASN1_AFLG_ENCODING

/* operation values for asn1_cb */

#define ASN1_OP_NEW_PRE
#define ASN1_OP_NEW_POST
#define ASN1_OP_FREE_PRE
#define ASN1_OP_FREE_POST
#define ASN1_OP_D2I_PRE
#define ASN1_OP_D2I_POST
/* ASN1_OP_I2D_PRE and ASN1_OP_I2D_POST are not supported. We leave the
 * constants undefined so code relying on them does not accidentally compile. */
#define ASN1_OP_PRINT_PRE
#define ASN1_OP_PRINT_POST
#define ASN1_OP_STREAM_PRE
#define ASN1_OP_STREAM_POST
#define ASN1_OP_DETACHED_PRE
#define ASN1_OP_DETACHED_POST

/* Macro to implement a primitive type */
#define IMPLEMENT_ASN1_TYPE(stname)
#define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex)

/* Macro to implement a multi string type */
#define IMPLEMENT_ASN1_MSTRING(itname, mask)

#define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs)

/* Macro to implement standard functions in terms of ASN1_ITEM structures */

#define IMPLEMENT_ASN1_FUNCTIONS(stname)

#define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname)

#define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname)

#define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname)

#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname)

#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname)

#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)

#define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname)

#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) 

/* This includes evil casts to remove const: they will go away when full
 * ASN1 constification is done.
 */
#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname)

#define IMPLEMENT_ASN1_DUP_FUNCTION(stname)

#define IMPLEMENT_ASN1_DUP_FUNCTION_const(stname)

#define IMPLEMENT_ASN1_FUNCTIONS_const(name)

#define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname)

/* external definitions for primitive types */

DECLARE_ASN1_ITEM(ASN1_SEQUENCE)

DEFINE_STACK_OF()


#if defined(__cplusplus)
}  // extern "C"
#endif

#endif  // OPENSSL_HEADER_ASN1T_H