13 #if defined( INC_ALL )
29 #define BER_UNIVERSAL 0x00
30 #define BER_APPLICATION 0x40
31 #define BER_CONTEXT_SPECIFIC 0x80
32 #define BER_PRIVATE 0xC0
36 #define BER_CONSTRUCTED 0x20
37 #define BER_PRIMITIVE 0x00
57 #define BER_RESERVED ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_RESERVED )
58 #define BER_BOOLEAN ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_BOOLEAN )
59 #define BER_INTEGER ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_INTEGER )
60 #define BER_BITSTRING ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_BITSTRING )
61 #define BER_OCTETSTRING ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_OCTETSTRING )
62 #define BER_NULL ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_NULL )
63 #define BER_OBJECT_IDENTIFIER ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_OBJECT_IDENTIFIER )
64 #define BER_OBJECT_DESCRIPTOR ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_OBJECT_DESCRIPTOR )
65 #define BER_EXTERNAL ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_EXTERNAL )
66 #define BER_REAL ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_REAL )
67 #define BER_ENUMERATED ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_ENUMERATED )
68 #define BER_EMBEDDED_PDV ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_EMBEDDED_PDV )
69 #define BER_STRING_UTF8 ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_STRING_UTF8 )
70 #define BER_13 ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_13 )
71 #define BER_14 ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_14 )
72 #define BER_15 ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_15 )
73 #define BER_SEQUENCE ( BER_UNIVERSAL | BER_CONSTRUCTED | BER_ID_SEQUENCE )
74 #define BER_SET ( BER_UNIVERSAL | BER_CONSTRUCTED | BER_ID_SET )
75 #define BER_STRING_NUMERIC ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_STRING_NUMERIC )
76 #define BER_STRING_PRINTABLE ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_STRING_PRINTABLE )
77 #define BER_STRING_T61 ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_STRING_T61 )
78 #define BER_STRING_VIDEOTEX ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_STRING_VIDEOTEX )
79 #define BER_STRING_IA5 ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_STRING_IA5 )
80 #define BER_TIME_UTC ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_TIME_UTC )
81 #define BER_TIME_GENERALIZED ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_TIME_GENERALIZED )
82 #define BER_STRING_GRAPHIC ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_STRING_GRAPHIC )
83 #define BER_STRING_ISO646 ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_STRING_ISO646 )
84 #define BER_STRING_GENERAL ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_STRING_GENERAL )
85 #define BER_STRING_UNIVERSAL ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_STRING_UNIVERSAL )
86 #define BER_29 ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_BER29 )
87 #define BER_STRING_BMP ( BER_UNIVERSAL | BER_PRIMITIVE | BER_ID_STRING_BMP )
91 #define BER_OCTETSTRING_INDEF MKDATA( "\x24\x80" )
92 #define BER_SEQUENCE_INDEF MKDATA( "\x30\x80" )
93 #define BER_SET_INDEF MKDATA( "\x31\x80" )
94 #define BER_CTAG0_INDEF MKDATA( "\xA0\x80" )
95 #define BER_END_INDEF MKDATA( "\x00\x00" )
99 #define BER_CLASS_MASK 0xC0
100 #define BER_CONSTRUCTED_MASK 0x20
101 #define BER_SHORT_ID_MASK 0x1F
106 #define MAX_SHORT_BER_ID ( BER_STRING_BMP + 1 )
107 #define LONG_BER_ID 0x1F
113 #define MAKE_CTAG( identifier ) \
114 ( BER_CONTEXT_SPECIFIC | BER_CONSTRUCTED | ( identifier ) )
115 #define MAKE_CTAG_PRIMITIVE( identifier ) \
116 ( BER_CONTEXT_SPECIFIC | ( identifier ) )
117 #define EXTRACT_CTAG( tag ) \
118 ( ( tag ) & ~( BER_CONTEXT_SPECIFIC | BER_CONSTRUCTED ) )
132 #define DEFAULT_TAG ( -1 )
133 #define NO_TAG ( -2 )
134 #define ANY_TAG ( -3 )
138 #define MAX_TAG ( BER_CONTEXT_SPECIFIC | BER_CONSTRUCTED | \
152 #define MAX_TAG_VALUE MAX_SHORT_BER_ID
153 #define MAX_CONSTR_TAG_VALUE BER_SET
155 #define MAX_CTAG_VALUE 30
157 #define MAX_CTAG_VALUE 10
162 #define MIN_OID_SIZE 5
163 #define MAX_OID_SIZE 32
174 #define WILDCARD_OID ( const BYTE * ) \
175 "\xFF\x0E\xFF\x00\xFF\x00\xFF\x00\xFF\x00\xFF\x00\xFF\x00\xFF\x00"
176 #define WILDCARD_OID_SIZE 16
180 #define MKOID( value ) ( ( const BYTE * ) value )
186 #define writeOctetStringIndef( stream ) swrite( stream, BER_OCTETSTRING_INDEF, 2 )
187 #define writeSequenceIndef( stream ) swrite( stream, BER_SEQUENCE_INDEF, 2 )
188 #define writeSetIndef( stream ) swrite( stream, BER_SET_INDEF, 2 )
189 #define writeCtag0Indef( stream ) swrite( stream, BER_CTAG0_INDEF, 2 )
190 #define writeEndIndef( stream ) swrite( stream, BER_END_INDEF, 2 )
192 #define sizeofEOC() 2
210 #define writeTag( stream, tag ) sputc( stream, tag )
234 #define writeRawObject( stream, object, size ) \
235 swrite( stream, object, size )
263 #define sizeofOID( oid ) ( 1 + 1 + ( int ) oid[ 1 ] )
268 IN_RANGE( 1, 50 )
const int noOidSelectionEntries,
275 IN_RANGE( 1, 50 )
const int noOidSelectionEntries,
287 #define writeOID( stream, oid ) \
288 swrite( ( stream ), ( oid ), sizeofOID( oid ) )
296 #define sizeofInteger( value, valueLength ) \
297 ( int ) sizeofObject( ( valueLength ) + \
298 ( ( *( BYTE * )( value ) & 0x80 ) ? 1 : 0 ) )
314 #define readIntegerData( stream, integer, integerLength, maxLength ) \
315 readIntegerTag( stream, integer, integerLength, maxLength, NO_TAG )
316 #define readInteger( stream, integer, integerLength, maxLength ) \
317 readIntegerTag( stream, integer, integerLength, maxLength, DEFAULT_TAG )
322 #define sizeofBignum( bignum ) \
323 ( ( int ) sizeofObject( signedBignumSize( bignum ) ) )
335 STDC_NONNULL_ARG( ( 1, 2 ) );
337 #define readBignum( stream, bignum, minLen, maxLen, maxRange ) \
338 readBignumTag( stream, bignum, minLen, maxLen, maxRange, DEFAULT_TAG )
339 #define writeBignum( stream, bignum ) \
340 writeBignumTag( stream, bignum, DEFAULT_TAG )
351 IN_OPT const void *maxRange );
356 #define sizeofShortInteger( value ) \
357 ( ( ( value ) < 0x80 ) ? 3 : \
358 ( ( ( long ) value ) < 0x8000L ) ? 4 : \
359 ( ( ( long ) value ) < 0x800000L ) ? 5 : \
360 ( ( ( long ) value ) < 0x80000000UL ) ? 6 : 7 )
370 #define readShortIntegerData( stream, integer ) \
371 readShortIntegerTag( stream, integer, NO_TAG )
372 #define readShortInteger( stream, integer ) \
373 readShortIntegerTag( stream, integer, DEFAULT_TAG )
377 #define sizeofEnumerated( value ) ( ( ( value ) < 128 ) ? 3 : 4 )
380 IN_RANGE( 0, 999 )
const int enumerated,
387 #define readEnumeratedData( stream, enumeration ) \
388 readEnumeratedTag( stream, enumeration, NO_TAG )
389 #define readEnumerated( stream, enumeration ) \
390 readEnumeratedTag( stream, enumeration, DEFAULT_TAG )
394 #define sizeofBoolean() ( sizeof( BYTE ) + sizeof( BYTE ) + sizeof( BYTE ) )
403 #define readBooleanData( stream, boolean ) \
404 readBooleanTag( stream, boolean, NO_TAG )
405 #define readBoolean( stream, boolean ) \
406 readBooleanTag( stream, boolean, DEFAULT_TAG )
410 #define sizeofNull() ( sizeof( BYTE ) + sizeof( BYTE ) )
416 #define readNullData( stream ) readNullTag( stream, NO_TAG )
417 #define readNull( stream ) readNullTag( stream, DEFAULT_TAG )
435 #define readOctetStringData( stream, string, stringLength, minLength, maxLength ) \
436 readOctetStringTag( stream, string, stringLength, minLength, maxLength, NO_TAG )
437 #define readOctetString( stream, string, stringLength, minLength, maxLength ) \
438 readOctetStringTag( stream, string, stringLength, minLength, maxLength, DEFAULT_TAG )
460 #define sizeofBitString( value ) \
461 ( 3 + ( ( ( ( long ) value ) > 0xFFFFFFL ) ? 4 : \
462 ( ( ( long ) value ) > 0xFFFFL ) ? 3 : \
463 ( ( value ) > 0xFF ) ? 2 : ( value ) ? 1 : 0 ) )
473 #define readBitStringData( stream, bitString ) \
474 readBitStringTag( stream, bitString, NO_TAG )
475 #define readBitString( stream, bitString ) \
476 readBitStringTag( stream, bitString, DEFAULT_TAG )
480 #define sizeofUTCTime() ( 1 + 1 + 13 )
488 #define readUTCTimeData( stream, time ) readUTCTimeTag( stream, time, NO_TAG )
489 #define readUTCTime( stream, time ) readUTCTimeTag( stream, time, DEFAULT_TAG )
491 #define sizeofGeneralizedTime() ( 1 + 1 + 15 )
499 #define readGeneralizedTimeData( stream, time ) \
500 readGeneralizedTimeTag( stream, time, NO_TAG )
501 #define readGeneralizedTime( stream, time ) \
502 readGeneralizedTimeTag( stream, time, DEFAULT_TAG )
617 int getLongStreamObjectLength(
INOUT STREAM *stream,