00001 #ifndef PRO_ASN1_H
00002 #define PRO_ASN1_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00046 #include <sys/types.h>
00047 #include <stdint.h>
00048
00049 #ifndef MAX_OID_LEN
00050 #define MAX_OID_LEN 32
00051 #endif
00052
00053 #define MAX_SUBID 0xFFFFFFFF
00054
00055 #define MIN_OID_LEN 2
00056
00057 #define ASN_BOOLEAN 0x01
00058 #define ASN_INTEGER 0x02
00059 #define ASN_BIT_STR 0x03
00060 #define ASN_OCTET_STR 0x04
00061 #define ASN_NULL 0x05
00062 #define ASN_OBJECT_ID 0x06
00063 #define ASN_SEQUENCE 0x10
00064 #define ASN_SET 0x11
00065
00066 #define ASN_UNIVERSAL 0x00
00067 #define ASN_APPLICATION 0x40
00068 #define ASN_CONTEXT 0x80
00069 #define ASN_PRIVATE 0xC0
00070
00071 #define ASN_PRIMITIVE 0x00
00072 #define ASN_CONSTRUCTOR 0x20
00073
00074 #define ASN_LONG_LEN 0x80
00075 #define ASN_EXTENSION_ID 0x1F
00076
00077
00078 #define ASN_IPADDRESS (ASN_APPLICATION | 0)
00079 #define ASN_COUNTER (ASN_APPLICATION | 1)
00080 #define ASN_GAUGE (ASN_APPLICATION | 2)
00081 #define ASN_UNSIGNED (ASN_APPLICATION | 2)
00082 #define ASN_TIMETICKS (ASN_APPLICATION | 3)
00083 #define ASN_OPAQUE (ASN_APPLICATION | 4)
00084
00085
00086 #define ASN_NSAP (ASN_APPLICATION | 5)
00087 #define ASN_COUNTER64 (ASN_APPLICATION | 6)
00088 #define ASN_UINTEGER (ASN_APPLICATION | 7)
00089
00090 #define ACL_RONLY 0xAAAA
00091 #define ACL_RWRITE 0xAABA
00092 #define ACL_NOACCESS 0x0000
00093
00094 #define ASN_BIT8 0x80
00095
00096 typedef uint32_t OID;
00097
00098
00099
00100
00101 typedef struct {
00102 uint32_t high;
00103 uint32_t low;
00104 } UNSIGNED64;
00105
00106 extern CONST uint8_t *AsnHeaderParse(CONST uint8_t *, size_t *, uint8_t *);
00107 extern uint8_t *AsnHeaderBuild(uint8_t *, size_t *, uint8_t, size_t);
00108
00109 extern CONST uint8_t * AsnSequenceParse(CONST uint8_t *, size_t *, uint8_t);
00110 extern uint8_t *AsnSequenceBuild(uint8_t *, size_t *, uint8_t, size_t);
00111
00112 extern CONST uint8_t *AsnIntegerParse(CONST uint8_t *, size_t *, uint8_t *, long *);
00113 extern uint8_t *AsnIntegerBuild(uint8_t *, size_t *, uint8_t, long *);
00114
00115 extern CONST uint8_t *AsnUnsignedParse(CONST uint8_t *, size_t *, uint8_t *, uint32_t *);
00116 extern uint8_t *AsnUnsignedBuild(uint8_t *, size_t *, uint8_t, uint32_t *);
00117
00118 extern CONST uint8_t *AsnOctetStringParse(CONST uint8_t *, size_t *, uint8_t *, uint8_t *, size_t *);
00119 extern uint8_t *AsnOctetStringBuild(uint8_t *, size_t *, uint8_t, CONST uint8_t *, size_t);
00120
00121 extern CONST uint8_t *AsnOidParse(CONST uint8_t *, size_t *, uint8_t *, OID *, size_t *);
00122 extern uint8_t *AsnOidBuild(uint8_t *, size_t *, uint8_t, CONST OID *, size_t);
00123
00124 extern CONST uint8_t *AsnNullParse(CONST uint8_t *, size_t *, uint8_t *);
00125 extern uint8_t *AsnNullBuild(uint8_t *, size_t *, uint8_t);
00126
00127 extern CONST uint8_t *AsnBitStringParse(CONST uint8_t *, size_t *, uint8_t *, uint8_t *, size_t *);
00128 extern uint8_t *AsnBitStringBuild(uint8_t *, size_t *, uint8_t, CONST uint8_t *, size_t);
00129
00130 extern CONST uint8_t *AsnUnsigned64Parse(CONST uint8_t *, size_t *, uint8_t *, UNSIGNED64 *);
00131 extern uint8_t *AsnUnsigned64Build(uint8_t *, size_t *, uint8_t, CONST UNSIGNED64 *);
00132
00133
00134 #endif