
typedef unsigned char bool;

/**
 * A generic open type structure.  This structure contains a number of 
 * octets and the data that compose the open type information.
 */
typedef struct {                /* generic open type data structure     */
   unsigned int     len;
   unsigned char	*pdata;
} ASN1OpenType;

typedef struct {
	unsigned char len;
	unsigned char data[4];
}octstring_4bytes;

typedef struct {
	unsigned char len;
	unsigned char data[8];
}octstring_8bytes;

typedef struct {
	unsigned char len;
	unsigned char data[16];
}octstring_16bytes;

typedef struct {
	unsigned char len;
	unsigned char data[32];
}octstring_32bytes;

typedef struct {
	unsigned char len;
	unsigned char data[64];
}octstring_64bytes;

typedef struct {
	unsigned char len;
	unsigned char data[128];
}octstring_128bytes;

typedef struct {
	unsigned char len;
	unsigned char data[256];
}octstring_256bytes;

extern int per_decode_Length(unsigned int *plen, unsigned char *psrc);
extern int per_encode_Length(unsigned char *pdst, int len);
extern int per_decode_OpenType(ASN1OpenType *popen, unsigned char *psrc);
extern int per_encode_OpenType(unsigned char *pdst, ASN1OpenType *popen);
extern int per_encode_Boolean(unsigned char *pdst, bool value, unsigned char *offset_bit);
extern int per_decode_Boolean(unsigned char *psrc, bool *value, unsigned char *offset_bit);
extern int per_encode_Constrained_Integer(unsigned char *pdst, unsigned int value,unsigned int lower, unsigned int upper, unsigned char *offset_bit); 
extern int per_decode_Constrained_Integer(unsigned char * psrc, unsigned int * value, unsigned int lower, unsigned int upper, unsigned char * offset_bit);
extern int per_encode_BitString(unsigned char *pdst, unsigned int numbits, unsigned char *pdata);
extern int per_decode_BitString(unsigned char *psrc, unsigned int numbits, unsigned char *pdata);
extern int per_encode_BitStr16(unsigned char *pdst, unsigned char *value, unsigned int lbits, unsigned int ubits, unsigned char *offset_bit);
extern int per_decode_BitStr16(unsigned char *psrc, unsigned char *value, unsigned int lbits, unsigned int ubits, unsigned char *offset_bit);
extern int per_encode_OctetString(unsigned char *pdst, unsigned int numocts, unsigned char *pdata);
extern int per_decode_OctetString(unsigned char *psrc, unsigned int numocts, unsigned char *pdata);
extern int per_encode_SmallNonNegWholeNumber(unsigned char *pdst, unsigned int value, unsigned char *offset_bit);
extern int per_decode_SmallNonNegWholeNumber(unsigned char *psrc, unsigned int *value, unsigned char *offset_bit);

