/*******************************************************************
 *
 * This file was generated by TIS/ASN1COMP Ver. 4.2, an ASN.1 compiler.
 * TIS/ASN1COMP is Copyright (c) 1998, TIS Labs at Network Associates, Inc.
 *
 * This file was AUTOMATICALLY GENERATED on Mon May 17 09:25:53 1999
 *
 ******************************************************************/

#ifndef cert_UTIL_H_
#define cert_UTIL_H_

#include <stdlib.h>
#include <string.h>

#ifndef PKITRUE
#define PKIFALSE (0)
#define PKITRUE (1)
#endif

#ifndef NULL
#define NULL  ((void *) 0)
#endif

/*****
*
* Primitive type definitions
*
*****/

/* BOOLEAN */
typedef struct
{
    size_t len;  /* # of bytes in value */
    int    val;  /* the boolean */
} PKIBooleanBlock;

/* NULL */
typedef struct
{
    size_t  len; /* unused */
} PKINullBlock;

/* Variable Length Entity */
typedef struct
{
    size_t         len;  /* # of bytes in value */
    unsigned char  *val; /* pointer to the bytes of value */
} PKIVariableBlock;

/* Bit String Entity */
typedef struct
{
    size_t        len;   /* # of bytes in value */
    unsigned char *val;  /* pointer to the bytes of value */
    int           nuub;  /* number of unused bits in LSByte */
} PKIBitstringBlock;

typedef PKINullBlock     PKINULL;
typedef PKIBooleanBlock   PKIBOOLEAN ;
typedef PKIVariableBlock  PKIOBJECT_ID ;
typedef PKIVariableBlock  PKIGeneralizedTime ;
typedef PKIVariableBlock  PKIIA5String ;
typedef PKIVariableBlock  PKIINTEGER ;
typedef PKIBitstringBlock PKIBIT_STRING ;
typedef PKIVariableBlock  PKIOCTET_STRING ;
typedef PKIVariableBlock  PKIT61String ;
typedef PKIVariableBlock  PKIANY ;
typedef PKIVariableBlock  PKIUTCTime ;
typedef PKIVariableBlock  PKINumericString ;
typedef PKIVariableBlock  PKIPrintableString ;
typedef PKIVariableBlock  PKIVisibleString ;

/*
 * #define ID values for defines for asn types.
 */
#define PKIID_reserved 0x00
#define PKIID_BOOLEAN 0x01
#define PKIID_INTEGER 0x02
#define PKIID_BIT_STRING 0x03
#define PKIID_OCTET_STRING 0x04
#define PKIID_NULL 0x05
#define PKIID_OBJECT_IDENTIFIER 0x06
#define PKIID_OBJECT_ID 0x06
#define PKIID_ObjectDescriptor 0x07
#define PKIID_EXTERNAL 0x08
#define PKIID_REAL 0x09
#define PKIID_SEQUENCE 0x10
#define PKIID_SEQUENCE_OF 0x10
#define PKIID_SET 0x11
#define PKIID_SET_OF 0x011
#define PKIID_NumericString 0x12
#define PKIID_PrintableString 0x13
#define PKIID_T61String 0x14
#define PKIID_TeletexString 0x14
#define PKIID_VideotexString 0x15
#define PKIID_IA5String 0x16
#define PKIID_UTCTime 0x17
#define PKIID_GeneralizedTime 0x18
#define PKIID_GraphicString 0x19
#define PKIID_VisibleString 0x1a
#define PKIID_ISO646String 0x1a
#define PKIID_GeneralString 0x1b

#define PKIID_IMPORTED 0xFA
#define PKIID_UNIVERSAL 0xFB
#define PKIID_CHOICE 0xFC
#define PKIID_SYNONYM 0xFD
#define PKIID_ANY 0xFE

/*********************************************************************
* Error return codes from pack and unpack (uip).
**********************************************************************/

#define PKIErrPackUnderrun (-1)
#define PKIErrPackOverrun (-2)
#define PKIErrPackSEQOFArrayTooLong   (-3) /* lth > MAX of that type */
#define PKIErrPackNoBlock (-5) /* ASN block ptr is NULL */
#define PKIErrUnpackNoStructure (-6) /* block pointer is NULL */
#define PKIErrUnpackNoBlockPtr (-7) /* ASN block pointer pointer is NULL */
#define PKIErrUnpackNoBlock (-8) /* ASN block pointer is NULL */
#define PKIErrUnpackOverrun (-9)
#define PKIErrUnpackUnderrun (-10)
#define PKIErrUnpackBooleanLth (-11) /* a boolean block with lth != 1 */
#define PKIErrUnpackTaggedLth (-12) /* a context tag lth failed to match 
				    the length of the contents */
#define PKIErrUnpackReqMissing (-13) /* a required substructure is missing */
#define PKIErrUnpackNullLth (-14) /* a NULL block with lth != 0 */
#define PKIErrPackSETOFArrayTooLong   (-15) /* lth > MAX of that type */
#define PKIErrPackSETOFUnsortable   (-16) /* SET OF with identical elements */
#define PKIErrOutOfMemory   (-17) /* Out of memory */
#define PKIErrPackBufferTooShort (-18) /* provided buffer space too short */
#define PKIErrUnpackInvalidEncoding (-19)
#define PKIErrBadContext (-20)
#define PKIErrUnpackSetBadType (-21)
#define PKIErrUnpackDuplicateField (-22)

/*
 * Error code for choice when it has a bad type
 */
#define PKIErrChoiceBadType (-50)

/*
 * Error codes for bad characters in strings
 */
#define PKIErrBadNumericString (-60)
#define PKIErrBadPrintableString (-61)

#define PKIErrNotFoundInDict (-70)

/*********************************************************************
* PKIERR macro
*
*  This can be re-defined as exit(x) for debugging
**********************************************************************/

#define PKIERR( x )     { *erret = x; PKIErrorHalt(x); }

void PKIErrorHalt ( int x );

/*********************************************************************
* Memory Mgmt Callbacks
**********************************************************************/

typedef struct PKIMemoryMgr PKIMemoryMgr;

extern PKIMemoryMgr PKIdefaultMemoryMgrStruct;

typedef void *(*PKIMemoryMgrAllocationProc)(
                        PKIMemoryMgr *mgr,
                        size_t requestSize);

typedef int (*PKIMemoryMgrReallocationProc)(
                        PKIMemoryMgr *mgr,
                        void **allocation,
                        size_t newAllocationSize);

typedef int (*PKIMemoryMgrDeallocationProc)(
                        PKIMemoryMgr *mgr,
                        void *allocation);

/* memory management structure */
struct PKIMemoryMgr {
        void    *customValue;
        PKIMemoryMgrAllocationProc allocProc;
        PKIMemoryMgrReallocationProc reallocProc;
        PKIMemoryMgrDeallocationProc deallocProc;
};

#define PKIAlloc(mgr, size) (*(mgr)->allocProc)(mgr, size)
#define PKIRealloc(mgr, ptr, newsize) \
              (*(mgr)->reallocProc)(mgr, ptr, newsize)
#define PKIFree(mgr, ptr) (*(mgr)->deallocProc)(mgr, ptr)

struct PKICONTEXT {
    void *customValue;
    PKIMemoryMgr *memMgr;
};
typedef struct PKICONTEXT PKICONTEXT;

/*********************************************************************
* Utility routine definitions
**********************************************************************/

size_t PKILengthSize(size_t x);
size_t PKITagged(size_t inner, int seqlike );
size_t PKIPutByte(unsigned char *buf, unsigned char byte );
size_t PKIPutLength(unsigned char *buf, size_t length );
size_t PKIGetByte(const unsigned char *buf, unsigned char *byte);
size_t PKIGetLength(const unsigned char *buf, size_t *length);
size_t PKIPutTag(unsigned char *buf, unsigned char tagbyte, size_t length );
size_t PKITakeTag(const unsigned char *buf, unsigned char tag, size_t *length);
int PKICompareElems(const void *a, const void *b);


long PKIGetIntVal (PKICONTEXT *ctx, PKIINTEGER *b, int *error);
int PKIPutIntVal (PKICONTEXT *ctx, PKIINTEGER *b, long v);
int PKIPutUIntBytes(PKICONTEXT *ctx, PKIINTEGER *b,
                   const unsigned char *v, size_t lth);
int PKIPutOctVal(PKICONTEXT *ctx, PKIVariableBlock *b, const unsigned char *v, size_t lth);
char *PKIGetStrVal(PKICONTEXT *ctx, PKIVariableBlock *b);
int PKIPutStrVal(PKICONTEXT *ctx, PKIVariableBlock *b, const char *v);
int PKIPutBitString (PKICONTEXT *ctx, PKIBIT_STRING *b,
		    const unsigned char *str, size_t len, int nuub);
int PKIGetBoolVal(PKICONTEXT *ctx, PKIBOOLEAN *b);
int PKIPutBoolVal(PKICONTEXT *ctx, PKIBOOLEAN *b, int val);

/*********************************************************************
* For tracing ASN.1 processing via compiler-generated routines.
**********************************************************************/

#ifdef PKITRACE

extern int PKITRACE_LEVEL;

int PKITRACE_trval(unsigned char *enc, int len, int lev);

#define PKITRACE_INCR_LEVEL \
        PKITRACE_LEVEL++
#define PKITRACE_DECR_LEVEL \
        PKITRACE_LEVEL--
#define PKITRACE_PRINT_LENGTH(n) \
        fprintf(stderr, "<%d>", n)
#define PKITRACE_PRINT_TAG(tag, rtag) \
        { int j; fprintf(stderr, "\n"); \
	for ( j=0 ; j<PKITRACE_LEVEL ; j++ ) fprintf(stderr, ".  "); \
	fprintf(stderr, "%02x EXPLICIT [%d] ", tag, rtag); }
#define PKITRACE_PRINT_FN(tag, rtag, type, name) \
        { int j; fprintf(stderr, "\n"); \
	for ( j=0 ; j<PKITRACE_LEVEL ; j++ ) fprintf(stderr, ".  "); \
	fprintf(stderr, "%02x ", tag); \
	if ( tag != rtag) fprintf(stderr, "IMPLICIT "); \
	fprintf(stderr, "%s %s ", type, name); }
#define PKITRACE_PRINT_FM(tag, rtag, type) \
        { int j; fprintf(stderr, "\n"); \
	for ( j=0 ; j<PKITRACE_LEVEL ; j++ ) fprintf(stderr, ".  "); \
	fprintf(stderr, "%02x ", tag); \
	if ( tag != rtag) fprintf(stderr, "IMPLICIT "); \
	fprintf(stderr, "%s ", type); }
#define PKITRACE_PRINT_DATA(buf, lth) \
        PKITRACE_trval( buf, lth, PKITRACE_LEVEL+1)
#define PKITRACE_name(name)

#else
#define PKITRACE_INCR_LEVEL
#define PKITRACE_DECR_LEVEL
#define PKITRACE_PRINT_LENGTH(n)
#define PKITRACE_PRINT_TAG(tag, rtag)
#define PKITRACE_PRINT_FN(tag, rtag, type, name)
#define PKITRACE_PRINT_FM(tag, rtag, type)
#define PKITRACE_PRINT_DATA(buf, lth)
#define PKITRACE_name(name) (void)name
#endif

/********************************************************************
* Primitive object routines.
**********************************************************************/

void *PKINewVariableBlock(PKICONTEXT *ctx);
void PKIFreeVariableBlock (
    PKICONTEXT *ctx,
    PKIVariableBlock *f);
void PKIDropInPlaceVariableBlock (
    PKICONTEXT *ctx,
    PKIVariableBlock *f);
size_t PKISizeofVariableBlockInternal(
    PKIVariableBlock *block,
    int outerSizeFlag,
    int expTaggedFlag);
size_t PKISizeofVariableBlock(
    PKICONTEXT *ctx,
    PKIVariableBlock *block,
    int outerSizeFlag);

/********************************************************************
* Base ASN type building, packing and unpacking routines.
**********************************************************************/

#define PKINewANY PKINewVariableBlock
#define PKIDropInPlaceANY PKIDropInPlaceVariableBlock
#define PKIFreeANY PKIFreeVariableBlock
size_t PKISizeofANYInternal(
    PKIANY *b,
    int outerSizeFlag,
    int expTaggedFlag);
size_t PKISizeofANY(
    PKICONTEXT *ctx,
    PKIANY *b,
    int outerSizeFlag);
size_t PKIPackANYInternal(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIANY *block,
    unsigned char tag,
    int *erret);
size_t PKIPackANY(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIANY *block,
    int *erret);
size_t PKIUnpkInPlaceANY(
    PKICONTEXT *ctx,
    PKIANY *asnstruct,
    const unsigned char *buf,
    size_t buflen, 
    unsigned char tag,
    int *erret);
size_t PKIUnpackANYInternal(
    PKICONTEXT *ctx,
    PKIANY **asnstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int        *erret);
size_t PKIUnpackANY(
    PKICONTEXT *ctx,
    PKIANY **asnstruct,
    const unsigned char *buf,
    size_t buflen,
    int        *erret);

PKIBIT_STRING *PKINewBIT_STRING(
    PKICONTEXT *ctx);
void PKIFreeBIT_STRING(
    PKICONTEXT *ctx,
    PKIBIT_STRING *f);
void PKIDropInPlaceBIT_STRING(
    PKICONTEXT *ctx,
    PKIBIT_STRING *f);
size_t PKISizeofBIT_STRINGInternal(
    PKIBIT_STRING *b,
    int outerSizeFlag,
    int expTaggedFlag);
size_t PKISizeofBIT_STRING(
    PKICONTEXT *ctx,
    PKIBIT_STRING *b,
    int outerSizeFlag);
size_t PKIPackBIT_STRINGInternal(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIBIT_STRING *bitblock,
    unsigned char tag,
    int *erret);
size_t PKIPackBIT_STRING(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIBIT_STRING *bitblock,
    int *erret);
size_t PKIUnpkInPlaceBIT_STRING(
    PKICONTEXT *ctx,
    PKIBIT_STRING *bitstruct,
    const unsigned char *buf,
    size_t buflen, 
    unsigned char tag,
    int *erret);
size_t PKIUnpackBIT_STRINGInternal(
    PKICONTEXT *ctx,
    PKIBIT_STRING **bitstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char  tag,
    int        *erret); /* error return */
size_t PKIUnpackBIT_STRING(
    PKICONTEXT *ctx,
    PKIBIT_STRING **bitstruct,
    const unsigned char *buf,
    size_t buflen,
    int        *erret);

PKIBOOLEAN *PKINewBOOLEAN (PKICONTEXT *ctx);
void PKIFreeBOOLEAN (PKICONTEXT *ctx, PKIBOOLEAN *f);
void PKIDropInPlaceBOOLEAN (PKICONTEXT *ctx, PKIBOOLEAN *f);
size_t PKISizeofBOOLEANInternal(
    PKIBOOLEAN *b,
    int outerSizeFlag,
    int expTaggedFlag);
size_t PKISizeofBOOLEAN(
    PKICONTEXT *ctx,
    PKIBOOLEAN *b,
    int outerSizeFlag);
size_t PKIPackBOOLEANInternal(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIBOOLEAN *boolblock,
    unsigned char tag,
    int *erret );
size_t PKIPackBOOLEAN(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIBOOLEAN *boolblock,
    int *erret);
size_t PKIUnpkInPlaceBOOLEAN(
    PKICONTEXT *ctx,
    PKIBOOLEAN *boolstruct, /* output block */
    const unsigned char *buf,    /* loc of input pointer */
    size_t buflen,         /* max end of my region */
    unsigned char tag,
    int *erret);           /* error return location */
size_t PKIUnpackBOOLEANInternal(
    PKICONTEXT *ctx,
    PKIBOOLEAN **boolstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int        *erret);  /* error return */
size_t PKIUnpackBOOLEAN(
    PKICONTEXT *ctx,
    PKIBOOLEAN **boolstruct,
    const unsigned char *buf,
    size_t buflen,
    int        *erret);

#define PKINewGeneralizedTime PKINewVariableBlock
#define PKIDropInPlaceGeneralizedTime PKIDropInPlaceVariableBlock
#define PKIFreeGeneralizedTime PKIFreeVariableBlock
#define PKISizeofGeneralizedTimeInternal PKISizeofVariableBlockInternal
#define PKISizeofGeneralizedTime PKISizeofVariableBlock
size_t PKIPackGeneralizedTimeInternal(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIGeneralizedTime *timeblock,
    unsigned char tag,
    int *erret);
size_t PKIPackGeneralizedTime(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIGeneralizedTime *timeblock,
    int *erret);
size_t PKIUnpkInPlaceGeneralizedTime(
    PKICONTEXT *ctx,
    PKIGeneralizedTime *timestruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int *erret);
size_t PKIUnpackGeneralizedTimeInternal( 
    PKICONTEXT *ctx,
    PKIGeneralizedTime **timestruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int        *erret);  /* error return */
size_t PKIUnpackGeneralizedTime( 
    PKICONTEXT *ctx,
    PKIGeneralizedTime **timestruct,
    const unsigned char *buf,
    size_t buflen,
    int        *erret);

#define PKINewIA5String PKINewVariableBlock
#define PKIDropInPlaceIA5String PKIDropInPlaceVariableBlock
#define PKIFreeIA5String PKIFreeVariableBlock
#define PKISizeofIA5StringInternal PKISizeofVariableBlockInternal
#define PKISizeofIA5String PKISizeofVariableBlock
size_t PKIPackIA5StringInternal(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIIA5String *strblock,
    unsigned char tag,
    int *erret);
size_t PKIPackIA5String(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIIA5String *strblock,
    int *erret);
size_t PKIUnpkInPlaceIA5String(
    PKICONTEXT *ctx,
    PKIIA5String *strblock,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int *erret);
size_t PKIUnpackIA5StringInternal(
    PKICONTEXT *ctx,
    PKIIA5String **strblock,
    const unsigned char *buf,
    size_t buflen, 
    unsigned char tag,
    int        *erret);  /* error return */
size_t PKIUnpackIA5String(
    PKICONTEXT *ctx,
    PKIIA5String **strblock,
    const unsigned char *buf,
    size_t buflen, 
    int        *erret);

#define PKINewINTEGER PKINewVariableBlock
#define PKIDropInPlaceINTEGER PKIDropInPlaceVariableBlock
#define PKIFreeINTEGER PKIFreeVariableBlock
size_t PKISizeofINTEGERInternal(
    PKIINTEGER *b,
    int outerSizeFlag,
    int expTaggedSize);
size_t PKISizeofINTEGER(
    PKICONTEXT *ctx,
    PKIINTEGER *b,
    int outerSizeFlag);
size_t PKIPackINTEGERInternal(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIINTEGER *intblock,
    unsigned char tag,
    int *erret);
size_t PKIPackINTEGER(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIINTEGER *intblock,
    int *erret);
size_t PKIUnpkInPlaceINTEGER(
    PKICONTEXT *ctx,
    PKIINTEGER *intstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int *erret);
size_t PKIUnpackINTEGERInternal( 
    PKICONTEXT *ctx,
    PKIINTEGER **intstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int        *erret);  /* error return */
size_t PKIUnpackINTEGER( 
    PKICONTEXT *ctx,
    PKIINTEGER **intstruct,
    const unsigned char *buf,
    size_t buflen, 
    int        *erret);

#define PKINewNumericString PKINewVariableBlock
#define PKIDropInPlaceNumericString PKIDropInPlaceVariableBlock
#define PKIFreeNumericString PKIFreeVariableBlock
#define PKISizeofNumericStringInternal PKISizeofVariableBlockInternal
#define PKISizeofNumericString PKISizeofVariableBlock
size_t PKIPackNumericStringInternal(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKINumericString *numblock,
    unsigned char tag,
    int *erret );
size_t PKIPackNumericString(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKINumericString *numblock,
    int *erret );
size_t PKIUnpkInPlaceNumericString(
    PKICONTEXT *ctx,
    PKINumericString *numstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int *erret) ;
size_t PKIUnpackNumericStringInternal(
    PKICONTEXT *ctx,
    PKINumericString **numstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char  tag,
    int       *erret);  /* error return */
size_t PKIUnpackNumericString(
    PKICONTEXT *ctx,
    PKINumericString **numstruct,
    const unsigned char *buf,
    size_t buflen,
    int       *erret);

PKINULL *PKINewNULL (PKICONTEXT *ctx) ;
void PKIFreeNULL (PKICONTEXT *ctx, PKINULL *f) ;
void PKIDropInPlaceNULL (PKICONTEXT *ctx, PKINULL *f) ;
size_t PKISizeofNULLInternal(
    PKINULL *b,
    int outerSizeFlag,
    int expTaggedFlag);
size_t PKISizeofNULL(
    PKICONTEXT *ctx,
    PKINULL *b,
    int outerSizeFlag);
size_t PKIPackNULLInternal(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKINULL *asnblock,
    unsigned char tag,
    int *erret);
size_t PKIPackNULL(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKINULL *asnblock,
    int *erret);
size_t PKIUnpkInPlaceNULL(
    PKICONTEXT *ctx,
    PKINULL *nullstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int *erret);
size_t PKIUnpackNULLInternal(
    PKICONTEXT *ctx,
    PKINULL **nullstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int        *erret);  /* error return */
size_t PKIUnpackNULL(
    PKICONTEXT *ctx,
    PKINULL **nullstruct,
    const unsigned char *buf,
    size_t buflen,
    int        *erret);

#define PKINewOBJECT_ID PKINewVariableBlock
#define PKIDropInPlaceOBJECT_ID PKIDropInPlaceVariableBlock
#define PKIFreeOBJECT_ID PKIFreeVariableBlock
#define PKISizeofOBJECT_IDInternal PKISizeofVariableBlockInternal
#define PKISizeofOBJECT_ID PKISizeofVariableBlock
size_t PKIPackOBJECT_IDInternal(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIOBJECT_ID *oidblock,
    unsigned char tag,
    int *erret);
size_t PKIPackOBJECT_ID(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIOBJECT_ID *oidblock,
    int *erret);
int PKIUnpkInPlaceOBJECT_ID(
    PKICONTEXT *ctx,
    PKIOBJECT_ID *oidstruct,
    const unsigned char *buf,
    size_t buflen, 
    unsigned char tag,
    int *erret) ;
size_t PKIUnpackOBJECT_IDInternal(
    PKICONTEXT *ctx,
    PKIOBJECT_ID **oidstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int        *erret);  /* error return */
size_t PKIUnpackOBJECT_ID(
    PKICONTEXT *ctx,
    PKIOBJECT_ID **oidstruct,
    const unsigned char *buf,
    size_t buflen, 
    int        *erret);

#define PKINewOCTET_STRING PKINewVariableBlock
#define PKIDropInPlaceOCTET_STRING PKIDropInPlaceVariableBlock
#define PKIFreeOCTET_STRING PKIFreeVariableBlock
#define PKISizeofOCTET_STRINGInternal PKISizeofVariableBlockInternal
#define PKISizeofOCTET_STRING PKISizeofVariableBlock
size_t PKIPackOCTET_STRINGInternal(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIOCTET_STRING *octblock,
    unsigned char tag,
    int *erret);
size_t PKIPackOCTET_STRING(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIOCTET_STRING *octblock,
    int *erret);
size_t PKIUnpkInPlaceOCTET_STRING(
    PKICONTEXT *ctx,
    PKIOCTET_STRING *octstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int *erret);
size_t PKIUnpackOCTET_STRINGInternal(
    PKICONTEXT *ctx,
    PKIOCTET_STRING **octstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int        *erret) ; /* error return */
size_t PKIUnpackOCTET_STRING(
    PKICONTEXT *ctx,
    PKIOCTET_STRING **octstruct,
    const unsigned char *buf,
    size_t buflen, 
    int        *erret);

#define PKINewPrintableString PKINewVariableBlock
#define PKIDropInPlacePrintableString PKIDropInPlaceVariableBlock
#define PKIFreePrintableString PKIFreeVariableBlock
#define PKISizeofPrintableStringInternal PKISizeofVariableBlockInternal
#define PKISizeofPrintableString PKISizeofVariableBlock
size_t PKIPackPrintableStringInternal(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIPrintableString *strblock,
    unsigned char tag,
    int *erret );
size_t PKIPackPrintableString(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIPrintableString *strblock,
    int *erret );
int PKIUnpkInPlacePrintableString(
    PKICONTEXT *ctx,
    PKIPrintableString *printstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int *erret);
size_t PKIUnpackPrintableStringInternal(
    PKICONTEXT *ctx,
    PKIPrintableString **printstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char  tag,
    int       *erret) ;
size_t PKIUnpackPrintableString(
    PKICONTEXT *ctx,
    PKIPrintableString **printstruct,
    const unsigned char *buf,
    size_t buflen,
    int       *erret);

#define PKINewT61String PKINewVariableBlock
#define PKIDropInPlaceT61String PKIDropInPlaceVariableBlock
#define PKIFreeT61String PKIFreeVariableBlock
#define PKISizeofT61StringInternal PKISizeofVariableBlockInternal
#define PKISizeofT61String PKISizeofVariableBlock
size_t PKIPackT61StringInternal(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIT61String *strblock,
    unsigned char tag,
    int *erret);
size_t PKIPackT61String(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIT61String *strblock,
    int *erret);
size_t PKIUnpkInPlaceT61String(
    PKICONTEXT *ctx,
    PKIT61String *strstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int *erret) ;
size_t PKIUnpackT61StringInternal(
    PKICONTEXT *ctx,
    PKIT61String **strstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int        *erret);
size_t PKIUnpackT61String(
    PKICONTEXT *ctx,
    PKIT61String **strstruct,
    const unsigned char *buf,
    size_t buflen,
    int        *erret);

#define PKINewUTCTime PKINewVariableBlock
#define PKIDropInPlaceUTCTime PKIDropInPlaceVariableBlock
#define PKIFreeUTCTime PKIFreeVariableBlock
#define PKISizeofUTCTimeInternal PKISizeofVariableBlockInternal
#define PKISizeofUTCTime PKISizeofVariableBlock
size_t PKIPackUTCTimeInternal(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIUTCTime *timeblock,
    unsigned char tag,
    int *erret);
size_t PKIPackUTCTime(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIUTCTime *timeblock,
    int *erret);
size_t PKIUnpkInPlaceUTCTime(
    PKICONTEXT *ctx,
    PKIUTCTime *timestruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int *erret);
size_t PKIUnpackUTCTimeInternal(
    PKICONTEXT *ctx,
    PKIUTCTime **strstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int        *erret);
size_t PKIUnpackUTCTime(
    PKICONTEXT *ctx,
    PKIUTCTime **timestruct,
    const unsigned char *buf,
    size_t buflen, 
    int        *erret);

#define PKINewVisibleString PKINewVariableBlock
#define PKIDropInPlaceVisibleString PKIDropInPlaceVariableBlock
#define PKIFreeVisibleString PKIFreeVariableBlock
#define PKISizeofVisibleStringInternal PKISizeofVariableBlockInternal
#define PKISizeofVisibleString PKISizeofVariableBlock
size_t PKIPackVisibleStringInternal(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIVisibleString *strstruct,
    unsigned char tag,
    int *erret);
size_t PKIPackVisibleString(
    PKICONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PKIVisibleString *strblock,
    int *erret);
size_t PKIUnpkInPlaceVisibleString(
    PKICONTEXT *ctx,
    PKIVisibleString *strstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int *erret);
size_t PKIUnpackVisibleStringInternal(
    PKICONTEXT *ctx,
    PKIVisibleString **strstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int        *erret);
size_t PKIUnpackVisibleString(
    PKICONTEXT *ctx,
    PKIVisibleString **strstruct,
    const unsigned char *buf,
    size_t buflen,
    int        *erret);

#endif

