Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
p6asn1.h
Go to the documentation of this file.
1 
17 #ifndef P6ASN1_H__
18 #define P6ASN1_H__ 1
19 
20 #include "p6com.h"
21 
22 
23 #ifdef __cplusplus
24 namespace P6R {
25 extern "C" {
26 #endif
27 
28 // Standard BER Universal Tag Values
29 static const P6UINT8 BER_boolean = 0x01;
30 static const P6UINT8 BER_integer = 0x02;
31 static const P6UINT8 BER_bitString = 0x03;
32 static const P6UINT8 BER_octetString = 0x04;
33 static const P6UINT8 BER_NULL = 0x05;
34 static const P6UINT8 BER_OID = 0x06; // OBJECT IDENTIFIER
35 static const P6UINT8 BER_ODC = 0x07; // Object Descriptor
36 static const P6UINT8 BER_external = 0x08;
37 static const P6UINT8 BER_real = 0x09;
38 static const P6UINT8 BER_enum = 0x0A; // ENUMERATED
39 static const P6UINT8 BER_sequence = 0x30; // SEQUENCE and SEQUENCE OF
40 static const P6UINT8 BER_set = 0x31; // SET and SET OF
41 
52 typedef struct
53 {
56 } P6ASN1OCTET;
57 
58 
80 typedef struct
81 {
83  union {
92  } type;
93 } P6ASN1INTEGER;
94 
95 
106 typedef enum
107 {
108  ASN1_BER = 0x00,
109  ASN1_DER = 0x01
111 
112 
121 static const P6ASN1FLAGS P6ASN1_NOFLAGS = 0x00000000;
122 
135 static const P6ASN1REALFLAGS P6ASN1REAL_NOFLAGS = 0x00000000;
136 static const P6ASN1REALFLAGS P6ASN1REAL_MINUSINFINITY = 0x00000001;
137 static const P6ASN1REALFLAGS P6ASN1REAL_PLUSINFINITY = 0x00000002;
138 
139 
140 #ifdef __cplusplus
141 
156 #undef INTERFACE
157 #define INTERFACE p6IAsn1
159 {
173  P6DECLCOMMETHOD(initialize)(P6THIS_ P6ASN1FLAGS flags, P6ASN1TRANSFERENCODING type ) P6PURE;
174 
202  P6DECLCOMMETHOD(encodeLength)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32& index, P6UINT32 length, P6INT8 useOctets) P6PURE;
203 
225  P6DECLCOMMETHOD(encodeOID)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32& index, const P6CHAR* pOID) P6PURE;
226 
249  P6DECLCOMMETHOD(encodeOctetString)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32& index, P6ASN1OCTET* pString, P6UINT8 overrideTag) P6PURE;
250 
270  P6DECLCOMMETHOD(encodeInteger32)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32&index, P6INT32 intValue, P6UINT8 overrideTag) P6PURE;
271 
292  P6DECLCOMMETHOD(encodeInteger64)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32& index, P6INT64 intValue, P6UINT8 overrideTag) P6PURE;
293 
313  P6DECLCOMMETHOD(encodeUnsigned32)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32& index, P6UINT32 numValue, P6UINT8 applicationTag) P6PURE;
314 
334  P6DECLCOMMETHOD(encodeUnsigned64)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32& index, P6UINT64 numValue, P6UINT8 applicationTag) P6PURE;
335 
354  P6DECLCOMMETHOD(encodeInteger)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32& index, P6ASN1INTEGER integer, P6UINT8 overrideTag) P6PURE;
355 
375  P6DECLCOMMETHOD(encodeIPAddr)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32& index, P6UINT32 ipAddress, P6UINT8 overrideTag) P6PURE;
376 
392  P6DECLCOMMETHOD(encodeNULL)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32& index, P6UINT8 overrideTag) P6PURE;
393 
420  P6DECLCOMMETHOD(encodeBoolean)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32& index, P6BOOL value, P6UINT8 overrideTag) P6PURE;
421 
449  P6DECLCOMMETHOD(encodeReal)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32& index, P6FLOAT numValue, P6ASN1REALFLAGS flags, P6UINT8 overrideTag) P6PURE;
450 
475  P6DECLCOMMETHOD(decodeLength)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32& index, P6UINT32& length) P6PURE;
476 
503  P6DECLCOMMETHOD(decodeInteger)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32& index, P6ASN1INTEGER& value) P6PURE;
504 
532  P6DECLCOMMETHOD(decodeUnsigned)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32& index, P6ASN1INTEGER& value) P6PURE;
533 
552  P6DECLCOMMETHOD(decodeBoolean)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32& index, P6BOOL& value) P6PURE;
553 
569 
585  P6DECLCOMMETHOD(toP6Uint32)(P6THIS_ P6ASN1INTEGER iValue, P6UINT32& value ) P6PURE;
586 
602 
617  P6DECLCOMMETHOD(toP6Uint64)(P6THIS_ P6ASN1INTEGER iValue, P6UINT64& value ) P6PURE;
618 
631  P6DECLCOMMETHOD(isNegative)(P6THIS_ P6ASN1INTEGER value, P6BOOL& negative ) P6PURE;
632 
644 
673  P6DECLCOMMETHOD(decodeOctetString)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32& index, P6ASN1OCTET& value) P6PURE;
674 
705  P6DECLCOMMETHOD(decodeOID)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32& index, P6CHAR* pOID, P6UINT32& oidSize) P6PURE;
706 
731  P6DECLCOMMETHOD(decodeIPAddr)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32& index, P6UINT32& ipAddress) P6PURE;
732 
752  P6DECLCOMMETHOD(decodeNULL)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32& index) P6PURE;
753 
779  P6DECLCOMMETHOD(decodeReal)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32& index, P6FLOAT& numValue, P6ASN1REALFLAGS& flags) P6PURE;
780 
801  P6DECLCOMMETHOD(skipField)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT8 tag, P6UINT32& index) P6PURE;
802 
818  P6DECLCOMMETHOD(copyOctetString)(P6THIS_ const P6ASN1OCTET* pSource, P6ASN1OCTET* pDestination ) P6PURE;
819 
831  P6DECLCOMMETHOD(freeOctetString)(P6THIS_ P6ASN1OCTET* pOctets) P6PURE;
832 };
833 
834 // {B3521209-E863-464e-8F6B-F467E1B07A5E}
835 #define IF_p6IAsn1 {0xb3521209,0xe863,0x464e,{0x8f,0x6b,0xf4,0x67,0xe1,0xb0,0x7a,0x5e}}
836 #endif
837 
838 
839 
852 #undef INTERFACE
853 #define INTERFACE p6IAsn1_2
855 {
869  P6DECLCOMMETHOD(initialize)(P6THIS_ P6ASN1FLAGS flags, P6ASN1TRANSFERENCODING type ) P6PURE;
870 
898  P6DECLCOMMETHOD(encodeLength_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32* pIndex, P6UINT32 length, P6INT8 useOctets) P6PURE;
899 
921  P6DECLCOMMETHOD(encodeOID_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32* pIndex, const P6CHAR* pOID) P6PURE;
922 
945  P6DECLCOMMETHOD(encodeOctetString_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32* pIndex, P6ASN1OCTET* pString, P6UINT8 overrideTag) P6PURE;
946 
966  P6DECLCOMMETHOD(encodeInteger32_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32* pIndex, P6INT32 intValue, P6UINT8 overrideTag) P6PURE;
967 
988  P6DECLCOMMETHOD(encodeInteger64_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32* pIndex, P6INT64 intValue, P6UINT8 overrideTag) P6PURE;
989 
1009  P6DECLCOMMETHOD(encodeUnsigned32_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32* pIndex, P6UINT32 numValue, P6UINT8 applicationTag) P6PURE;
1010 
1030  P6DECLCOMMETHOD(encodeUnsigned64_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32* pIndex, P6UINT64 numValue, P6UINT8 applicationTag) P6PURE;
1031 
1050  P6DECLCOMMETHOD(encodeInteger_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32* pIndex, P6ASN1INTEGER* pInteger, P6UINT8 overrideTag) P6PURE;
1051 
1071  P6DECLCOMMETHOD(encodeIPAddr_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32* pIndex, P6UINT32 ipAddress, P6UINT8 overrideTag) P6PURE;
1072 
1088  P6DECLCOMMETHOD(encodeNULL_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32* pIndex, P6UINT8 overrideTag) P6PURE;
1089 
1116  P6DECLCOMMETHOD(encodeBoolean_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32* pIndex, P6BOOL value, P6UINT8 overrideTag) P6PURE;
1117 
1145  P6DECLCOMMETHOD(encodeReal_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32* pIndex, P6FLOAT numValue, P6ASN1REALFLAGS flags, P6UINT8 overrideTag) P6PURE;
1146 
1171  P6DECLCOMMETHOD(decodeLength_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32* pIndex, P6UINT32* pLength) P6PURE;
1172 
1199  P6DECLCOMMETHOD(decodeInteger_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32* pIndex, P6ASN1INTEGER* pValue) P6PURE;
1200 
1228  P6DECLCOMMETHOD(decodeUnsigned_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32* pIndex, P6ASN1INTEGER* pValue) P6PURE;
1229 
1248  P6DECLCOMMETHOD(decodeBoolean_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32* pIndex, P6BOOL* pValue) P6PURE;
1249 
1265  P6DECLCOMMETHOD(toP6Int32_2)(P6THIS_ P6ASN1INTEGER* pIValue, P6INT32* pValue ) P6PURE;
1266 
1283  P6DECLCOMMETHOD(toP6Uint32_2)(P6THIS_ P6ASN1INTEGER* pIValue, P6UINT32* pValue ) P6PURE;
1284 
1300  P6DECLCOMMETHOD(toP6Int64_2)(P6THIS_ P6ASN1INTEGER* pIValue, P6INT64* pValue ) P6PURE;
1301 
1317  P6DECLCOMMETHOD(toP6Uint64_2)(P6THIS_ P6ASN1INTEGER* pIValue, P6UINT64* pValue ) P6PURE;
1318 
1332  P6DECLCOMMETHOD(isNegative_2)(P6THIS_ P6ASN1INTEGER* pValue, P6BOOL* pNegative ) P6PURE;
1333 
1345  P6DECLCOMMETHOD(setZero_2)(P6THIS_ P6ASN1INTEGER* pValue ) P6PURE;
1346 
1375  P6DECLCOMMETHOD(decodeOctetString_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32* pIndex, P6ASN1OCTET* pValue) P6PURE;
1376 
1407  P6DECLCOMMETHOD(decodeOID_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32* pIndex, P6CHAR* pOID, P6UINT32* pOidSize) P6PURE;
1408 
1433  P6DECLCOMMETHOD(decodeIPAddr_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32* pIndex, P6UINT32* pIpAddress) P6PURE;
1434 
1454  P6DECLCOMMETHOD(decodeNULL_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32* pIndex) P6PURE;
1455 
1481  P6DECLCOMMETHOD(decodeReal_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT32* pIndex, P6FLOAT* pNumValue, P6ASN1REALFLAGS* pFlags) P6PURE;
1482 
1503  P6DECLCOMMETHOD(skipField_2)(P6THIS_ P6UINT8* pBuffer, P6UINT32 bufSize, P6UINT8 tag, P6UINT32* pIndex) P6PURE;
1504 
1520  P6DECLCOMMETHOD(copyOctetString)(P6THIS_ const P6ASN1OCTET* pSource, P6ASN1OCTET* pDestination ) P6PURE;
1521 
1533  P6DECLCOMMETHOD(freeOctetString)(P6THIS_ P6ASN1OCTET* pOctets) P6PURE;
1534 };
1535 
1536 // {F0E2BFC5-D847-42CD-BD8A-C9EBF907FB94}
1537 #define IF_p6IAsn1_2 {0xf0e2bfc5,0xd847,0x42cd,{0xbd,0x8a,0xc9,0xeb,0xf9,0x7,0xfb,0x94}}
1538 
1539 // {ED95D016-7E66-4d02-A9E6-0595C788D357}
1540 #define COMP_p6Asn1 {0xed95d016,0x7e66,0x4d02,{0xa9,0xe6,0x5,0x95,0xc7,0x88,0xd3,0x57}}
1541 
1542 #ifdef __cplusplus
1543 }
1544 } // namespace
1545 #endif
1546 
1547 
1548 #endif
1549 
1550 
P6INT32 int32
Definition: p6asn1.h:88
uint64_t P6UINT64
Definition: p6types.h:79
uint32_t P6UINT32
Definition: p6types.h:77
int16_t P6INT16
Definition: p6types.h:74
#define P6DECLAREICOM
Definition: p6defs.h:191
#define P6PURE
Definition: p6defs.h:192
unsigned char P6BOOL
Boolean type.
Definition: p6types.h:133
P6UINT32 P6ASN1REALFLAGS
P6ASN1REALFLAGS.
Definition: p6asn1.h:134
char P6INT8
Definition: p6types.h:72
P6UINT8 uInt8
Definition: p6asn1.h:85
unsigned char P6UINT8
Definition: p6types.h:71
The base interface all [p6]COM components must derive from and implement.
Definition: p6comdef.h:97
int64_t P6INT64
Definition: p6types.h:78
P6ASN1TRANSFERENCODING
A transfer encoding takes the Abstract Syntax Notation (ASN) and traslates it to bytes in a network p...
Definition: p6asn1.h:106
P6UINT64 uInt64
Definition: p6asn1.h:91
NOTICE: this interface is available but depreciated.
Definition: p6asn1.h:158
P6UINT32 length
Definition: p6asn1.h:54
P6UINT32 P6ASN1FLAGS
P6ASN1FLAGS.
Definition: p6asn1.h:120
it may not contain all the symbols used by this software If you run into undefined symbol please let us know and we can provide you a build that will be compatible with your specific value
Definition: readme.txt:85
P6INT64 int64
Definition: p6asn1.h:90
This interface supports low level ASN.1 encoding and decoding functions.
Definition: p6asn1.h:854
P6INT16 int16
Definition: p6asn1.h:86
uint16_t P6UINT16
Definition: p6types.h:75
#define P6DECLCOMMETHOD(method)
Definition: p6defs.h:189
P6UINT8 choice
Definition: p6asn1.h:82
#define P6THIS_
Definition: p6defs.h:193
double P6FLOAT
Definition: p6types.h:93
P6UINT16 uInt16
Definition: p6asn1.h:87
P6COM definitions and interfaces.
P6UINT32 uInt32
Definition: p6asn1.h:89
P6UINT8 * pBytes
Definition: p6asn1.h:55
int32_t P6INT32
Definition: p6types.h:76
Matches the ASN.1 type of an array of binary bytes (i.e., any byte can be zero).
Definition: p6asn1.h:52
char P6CHAR
Narrow character type.
Definition: p6types.h:105
#define P6DECLAREIF_(iface, baseif)
Definition: p6defs.h:188
Used in decoding functions, since we do not know the type of the integer until we look at its length ...
Definition: p6asn1.h:80