⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pgpx509cert_util.h

📁 vc环境下的pgp源码
💻 H
📖 第 1 页 / 共 2 页
字号:
/*******************************************************************
 *
 * 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 Tue May 18 17:09:44 1999
 *
 ******************************************************************/

#ifndef pgpX509Cert_UTIL_H_
#define pgpX509Cert_UTIL_H_

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

#ifndef PGPASN_TRUE
#define PGPASN_FALSE (0)
#define PGPASN_TRUE (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 */
} PGPASN_BooleanBlock;

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

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

/* 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 */
} PGPASN_BitstringBlock;

typedef PGPASN_NullBlock     PGPASN_NULL;
typedef PGPASN_BooleanBlock   PGPASN_BOOLEAN ;
typedef PGPASN_VariableBlock  PGPASN_OBJECT_ID ;
typedef PGPASN_VariableBlock  PGPASN_GeneralizedTime ;
typedef PGPASN_VariableBlock  PGPASN_IA5String ;
typedef PGPASN_VariableBlock  PGPASN_INTEGER ;
typedef PGPASN_BitstringBlock PGPASN_BIT_STRING ;
typedef PGPASN_VariableBlock  PGPASN_OCTET_STRING ;
typedef PGPASN_VariableBlock  PGPASN_T61String ;
typedef PGPASN_VariableBlock  PGPASN_ANY ;
typedef PGPASN_VariableBlock  PGPASN_UTCTime ;
typedef PGPASN_VariableBlock  PGPASN_NumericString ;
typedef PGPASN_VariableBlock  PGPASN_PrintableString ;
typedef PGPASN_VariableBlock  PGPASN_VisibleString ;

/*
 * #define ID values for defines for asn types.
 */
#define PGPASN_ID_reserved 0x00
#define PGPASN_ID_BOOLEAN 0x01
#define PGPASN_ID_INTEGER 0x02
#define PGPASN_ID_BIT_STRING 0x03
#define PGPASN_ID_OCTET_STRING 0x04
#define PGPASN_ID_NULL 0x05
#define PGPASN_ID_OBJECT_IDENTIFIER 0x06
#define PGPASN_ID_OBJECT_ID 0x06
#define PGPASN_ID_ObjectDescriptor 0x07
#define PGPASN_ID_EXTERNAL 0x08
#define PGPASN_ID_REAL 0x09
#define PGPASN_ID_SEQUENCE 0x10
#define PGPASN_ID_SEQUENCE_OF 0x10
#define PGPASN_ID_SET 0x11
#define PGPASN_ID_SET_OF 0x011
#define PGPASN_ID_NumericString 0x12
#define PGPASN_ID_PrintableString 0x13
#define PGPASN_ID_T61String 0x14
#define PGPASN_ID_TeletexString 0x14
#define PGPASN_ID_VideotexString 0x15
#define PGPASN_ID_IA5String 0x16
#define PGPASN_ID_UTCTime 0x17
#define PGPASN_ID_GeneralizedTime 0x18
#define PGPASN_ID_GraphicString 0x19
#define PGPASN_ID_VisibleString 0x1a
#define PGPASN_ID_ISO646String 0x1a
#define PGPASN_ID_GeneralString 0x1b

#define PGPASN_ID_IMPORTED 0xFA
#define PGPASN_ID_UNIVERSAL 0xFB
#define PGPASN_ID_CHOICE 0xFC
#define PGPASN_ID_SYNONYM 0xFD
#define PGPASN_ID_ANY 0xFE

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

#define kPGPASNError_ErrPackUnderrun (-1)
#define kPGPASNError_ErrPackOverrun (-2)
#define kPGPASNError_ErrPackSEQOFArrayTooLong   (-3) /* lth > MAX of that type */
#define kPGPASNError_ErrPackNoBlock (-5) /* ASN block ptr is NULL */
#define kPGPASNError_ErrUnpackNoStructure (-6) /* block pointer is NULL */
#define kPGPASNError_ErrUnpackNoBlockPtr (-7) /* ASN block pointer pointer is NULL */
#define kPGPASNError_ErrUnpackNoBlock (-8) /* ASN block pointer is NULL */
#define kPGPASNError_ErrUnpackOverrun (-9)
#define kPGPASNError_ErrUnpackUnderrun (-10)
#define kPGPASNError_ErrUnpackBooleanLth (-11) /* a boolean block with lth != 1 */
#define kPGPASNError_ErrUnpackTaggedLth (-12) /* a context tag lth failed to match 
				    the length of the contents */
#define kPGPASNError_ErrUnpackReqMissing (-13) /* a required substructure is missing */
#define kPGPASNError_ErrUnpackNullLth (-14) /* a NULL block with lth != 0 */
#define kPGPASNError_ErrPackSETOFArrayTooLong   (-15) /* lth > MAX of that type */
#define kPGPASNError_ErrPackSETOFUnsortable   (-16) /* SET OF with identical elements */
#define kPGPASNError_ErrOutOfMemory   (-17) /* Out of memory */
#define kPGPASNError_ErrPackBufferTooShort (-18) /* provided buffer space too short */
#define kPGPASNError_ErrUnpackInvalidEncoding (-19)
#define kPGPASNError_ErrBadContext (-20)
#define kPGPASNError_ErrUnpackSetBadType (-21)
#define kPGPASNError_ErrUnpackDuplicateField (-22)

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

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

#define kPGPASNError_ErrNotFoundInDict (-70)

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

#define PGPASN_ERR( x )     { *erret = x; PGPASN_ErrorHalt(x); }

void PGPASN_ErrorHalt ( int x );

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

typedef struct PGPASN_MemoryMgr PGPASN_MemoryMgr;

extern PGPASN_MemoryMgr PGPASN_defaultMemoryMgrStruct;

typedef void *(*PGPASN_MemoryMgrAllocationProc)(
                        PGPASN_MemoryMgr *mgr,
                        size_t requestSize);

typedef int (*PGPASN_MemoryMgrReallocationProc)(
                        PGPASN_MemoryMgr *mgr,
                        void **allocation,
                        size_t newAllocationSize);

typedef int (*PGPASN_MemoryMgrDeallocationProc)(
                        PGPASN_MemoryMgr *mgr,
                        void *allocation);

/* memory management structure */
struct PGPASN_MemoryMgr {
        void    *customValue;
        PGPASN_MemoryMgrAllocationProc allocProc;
        PGPASN_MemoryMgrReallocationProc reallocProc;
        PGPASN_MemoryMgrDeallocationProc deallocProc;
};

#define PGPASN_Alloc(mgr, size) (*(mgr)->allocProc)(mgr, size)
#define PGPASN_Realloc(mgr, ptr, newsize) \
              (*(mgr)->reallocProc)(mgr, ptr, newsize)
#define PGPASN_Free(mgr, ptr) (*(mgr)->deallocProc)(mgr, ptr)

struct PGPASN_CONTEXT {
    void *customValue;
    PGPASN_MemoryMgr *memMgr;
};
typedef struct PGPASN_CONTEXT PGPASN_CONTEXT;

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

size_t PGPASN_LengthSize(size_t x);
size_t PGPASN_Tagged(size_t inner, int seqlike );
size_t PGPASN_PutByte(unsigned char *buf, unsigned char byte );
size_t PGPASN_PutLength(unsigned char *buf, size_t length );
size_t PGPASN_GetByte(const unsigned char *buf, unsigned char *byte);
size_t PGPASN_GetLength(const unsigned char *buf, size_t *length);
size_t PGPASN_PutTag(unsigned char *buf, unsigned char tagbyte, size_t length );
size_t PGPASN_TakeTag(const unsigned char *buf, unsigned char tag, size_t *length);
int PGPASN_CompareElems(const void *a, const void *b);


long pgpasn_GetIntVal (PGPASN_CONTEXT *ctx, PGPASN_INTEGER *b, int *error);
int pgpasn_PutIntVal (PGPASN_CONTEXT *ctx, PGPASN_INTEGER *b, long v);
int pgpasn_PutUIntBytes(PGPASN_CONTEXT *ctx, PGPASN_INTEGER *b,
                   const unsigned char *v, size_t lth);
int pgpasn_PutOctVal(PGPASN_CONTEXT *ctx, PGPASN_VariableBlock *b, const unsigned char *v, size_t lth);
char *pgpasn_GetStrVal(PGPASN_CONTEXT *ctx, PGPASN_VariableBlock *b);
int pgpasn_PutStrVal(PGPASN_CONTEXT *ctx, PGPASN_VariableBlock *b, const char *v);
int pgpasn_PutBitString (PGPASN_CONTEXT *ctx, PGPASN_BIT_STRING *b,
		    const unsigned char *str, size_t len, int nuub);
int pgpasn_GetBoolVal(PGPASN_CONTEXT *ctx, PGPASN_BOOLEAN *b);
int pgpasn_PutBoolVal(PGPASN_CONTEXT *ctx, PGPASN_BOOLEAN *b, int val);

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

#ifdef PGPASN_TRACE

extern int PGPASN_TRACE_LEVEL;

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

#define PGPASN_TRACE_INCR_LEVEL \
        PGPASN_TRACE_LEVEL++
#define PGPASN_TRACE_DECR_LEVEL \
        PGPASN_TRACE_LEVEL--
#define PGPASN_TRACE_PRINT_LENGTH(n) \
        fprintf(stderr, "<%d>", n)
#define PGPASN_TRACE_PRINT_TAG(tag, rtag) \
        { int j; fprintf(stderr, "\n"); \
	for ( j=0 ; j<PGPASN_TRACE_LEVEL ; j++ ) fprintf(stderr, ".  "); \
	fprintf(stderr, "%02x EXPLICIT [%d] ", tag, rtag); }
#define PGPASN_TRACE_PRINT_FN(tag, rtag, type, name) \
        { int j; fprintf(stderr, "\n"); \
	for ( j=0 ; j<PGPASN_TRACE_LEVEL ; j++ ) fprintf(stderr, ".  "); \
	fprintf(stderr, "%02x ", tag); \
	if ( tag != rtag) fprintf(stderr, "IMPLICIT "); \
	fprintf(stderr, "%s %s ", type, name); }
#define PGPASN_TRACE_PRINT_FM(tag, rtag, type) \
        { int j; fprintf(stderr, "\n"); \
	for ( j=0 ; j<PGPASN_TRACE_LEVEL ; j++ ) fprintf(stderr, ".  "); \
	fprintf(stderr, "%02x ", tag); \
	if ( tag != rtag) fprintf(stderr, "IMPLICIT "); \
	fprintf(stderr, "%s ", type); }
#define PGPASN_TRACE_PRINT_DATA(buf, lth) \
        PGPASN_TRACE_trval( buf, lth, PGPASN_TRACE_LEVEL+1)
#define PGPASN_TRACE_name(name)

#else
#define PGPASN_TRACE_INCR_LEVEL
#define PGPASN_TRACE_DECR_LEVEL
#define PGPASN_TRACE_PRINT_LENGTH(n)
#define PGPASN_TRACE_PRINT_TAG(tag, rtag)
#define PGPASN_TRACE_PRINT_FN(tag, rtag, type, name)
#define PGPASN_TRACE_PRINT_FM(tag, rtag, type)
#define PGPASN_TRACE_PRINT_DATA(buf, lth)
#define PGPASN_TRACE_name(name) (void)name
#endif

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

void *pgpasn_NewVariableBlock(PGPASN_CONTEXT *ctx);
void pgpasn_FreeVariableBlock (
    PGPASN_CONTEXT *ctx,
    PGPASN_VariableBlock *f);
void pgpasn_DropInPlaceVariableBlock (
    PGPASN_CONTEXT *ctx,
    PGPASN_VariableBlock *f);
size_t pgpasn_SizeofVariableBlockInternal(
    PGPASN_VariableBlock *block,
    int outerSizeFlag,
    int expTaggedFlag);
size_t pgpasn_SizeofVariableBlock(
    PGPASN_CONTEXT *ctx,
    PGPASN_VariableBlock *block,
    int outerSizeFlag);

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

#define pgpasn_NewANY pgpasn_NewVariableBlock
#define pgpasn_DropInPlaceANY pgpasn_DropInPlaceVariableBlock
#define pgpasn_FreeANY pgpasn_FreeVariableBlock
size_t pgpasn_SizeofANYInternal(
    PGPASN_ANY *b,
    int outerSizeFlag,
    int expTaggedFlag);
size_t pgpasn_SizeofANY(
    PGPASN_CONTEXT *ctx,
    PGPASN_ANY *b,
    int outerSizeFlag);
size_t pgpasn_PackANYInternal(
    PGPASN_CONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PGPASN_ANY *block,
    unsigned char tag,
    int *erret);
size_t pgpasn_PackANY(
    PGPASN_CONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PGPASN_ANY *block,
    int *erret);
size_t pgpasn_UnpkInPlaceANY(
    PGPASN_CONTEXT *ctx,
    PGPASN_ANY *asnstruct,
    const unsigned char *buf,
    size_t buflen, 
    unsigned char tag,
    int *erret);
size_t pgpasn_UnpackANYInternal(
    PGPASN_CONTEXT *ctx,
    PGPASN_ANY **asnstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int        *erret);
size_t pgpasn_UnpackANY(
    PGPASN_CONTEXT *ctx,
    PGPASN_ANY **asnstruct,
    const unsigned char *buf,
    size_t buflen,
    int        *erret);

PGPASN_BIT_STRING *pgpasn_NewBIT_STRING(
    PGPASN_CONTEXT *ctx);
void pgpasn_FreeBIT_STRING(
    PGPASN_CONTEXT *ctx,
    PGPASN_BIT_STRING *f);
void pgpasn_DropInPlaceBIT_STRING(
    PGPASN_CONTEXT *ctx,
    PGPASN_BIT_STRING *f);
size_t pgpasn_SizeofBIT_STRINGInternal(
    PGPASN_BIT_STRING *b,
    int outerSizeFlag,
    int expTaggedFlag);
size_t pgpasn_SizeofBIT_STRING(
    PGPASN_CONTEXT *ctx,
    PGPASN_BIT_STRING *b,
    int outerSizeFlag);
size_t pgpasn_PackBIT_STRINGInternal(
    PGPASN_CONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PGPASN_BIT_STRING *bitblock,
    unsigned char tag,
    int *erret);
size_t pgpasn_PackBIT_STRING(
    PGPASN_CONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PGPASN_BIT_STRING *bitblock,
    int *erret);
size_t pgpasn_UnpkInPlaceBIT_STRING(
    PGPASN_CONTEXT *ctx,
    PGPASN_BIT_STRING *bitstruct,
    const unsigned char *buf,
    size_t buflen, 
    unsigned char tag,
    int *erret);
size_t pgpasn_UnpackBIT_STRINGInternal(
    PGPASN_CONTEXT *ctx,
    PGPASN_BIT_STRING **bitstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char  tag,
    int        *erret); /* error return */
size_t pgpasn_UnpackBIT_STRING(
    PGPASN_CONTEXT *ctx,
    PGPASN_BIT_STRING **bitstruct,
    const unsigned char *buf,
    size_t buflen,
    int        *erret);

PGPASN_BOOLEAN *pgpasn_NewBOOLEAN (PGPASN_CONTEXT *ctx);
void pgpasn_FreeBOOLEAN (PGPASN_CONTEXT *ctx, PGPASN_BOOLEAN *f);
void pgpasn_DropInPlaceBOOLEAN (PGPASN_CONTEXT *ctx, PGPASN_BOOLEAN *f);
size_t pgpasn_SizeofBOOLEANInternal(
    PGPASN_BOOLEAN *b,
    int outerSizeFlag,
    int expTaggedFlag);
size_t pgpasn_SizeofBOOLEAN(
    PGPASN_CONTEXT *ctx,
    PGPASN_BOOLEAN *b,
    int outerSizeFlag);
size_t pgpasn_PackBOOLEANInternal(
    PGPASN_CONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PGPASN_BOOLEAN *boolblock,
    unsigned char tag,
    int *erret );
size_t pgpasn_PackBOOLEAN(
    PGPASN_CONTEXT *ctx,
    unsigned char *buf,
    size_t buflen,
    PGPASN_BOOLEAN *boolblock,
    int *erret);
size_t pgpasn_UnpkInPlaceBOOLEAN(
    PGPASN_CONTEXT *ctx,
    PGPASN_BOOLEAN *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 pgpasn_UnpackBOOLEANInternal(
    PGPASN_CONTEXT *ctx,
    PGPASN_BOOLEAN **boolstruct,
    const unsigned char *buf,
    size_t buflen,
    unsigned char tag,
    int        *erret);  /* error return */
size_t pgpasn_UnpackBOOLEAN(
    PGPASN_CONTEXT *ctx,
    PGPASN_BOOLEAN **boolstruct,
    const unsigned char *buf,
    size_t buflen,
    int        *erret);

#define pgpasn_NewGeneralizedTime pgpasn_NewVariableBlock
#define pgpasn_DropInPlaceGeneralizedTime pgpasn_DropInPlaceVariableBlock
#define pgpasn_FreeGeneralizedTime pgpasn_FreeVariableBlock

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -