summaryrefslogtreecommitdiff
path: root/plugins/CryptoPP/PGPw/sdk8/include/pgpBER.h
blob: ad20d033fd0bfcfe454baa06acd8f44eb38de41b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*____________________________________________________________________________
	Copyright (C) 2002 PGP Corporation
    All rights reserved.

    $Id: pgpBER.h,v 1.15 2003/08/08 04:40:39 ajivsov Exp $
____________________________________________________________________________*/

/*
 * For extremely detailed explanation of all the BER types and
 * encoding, see X.208 (Specification of Abstract Syntax Notation One (ASN.1))
 * and X.209 (Specification of Basic Encoding Rules for Abstract Syntax
 * Notation One (ASN.1)).
 *
 * These two sources will tell you everything you would ever need (and want)
 * to know about BER and ASN.1.
 */

#ifndef Included_pgpBER_h  /* [ */
#define Included_pgpBER_h

#include "pgpPubTypes.h"
#include "pgpMemoryMgr.h"
#include "pgpSockets.h"

/* BER types */
/* The X.209 BER specification actually defines a lot more
 * types than is listed here, but these are the only ones
 * the current PGPldap implementation uses. */
enum PGPberType_
{
    kPGPberType_Boolean     = 0x01, /* tag = 0x01 */
    kPGPberType_Int         = 0x02, /* tag = 0x02 */
    kPGPberType_Bitstring   = 0x03, /* tag = 0x03 */
    kPGPberType_Octetstring = 0x04, /* tag = 0x04 */
    kPGPberType_NULL        = 0x05, /* tag = 0x05 */
	kPGPberType_ObjectID	= 0x06, /* tag = 0x06 */
    kPGPberType_Enumeration = 0x0A, /* tag = 0x0A */
	kPGPberType_PrintableString = 0x0D, /* tag = 0x0D */
    kPGPberType_Sequence    = 0x30, /* constructed, tag = 0x10 */
    kPGPberType_Set         = 0x31, /* constructed, tag = 0x11 */

    kPGPberType_None        = 0xFFFFFFFF
};
PGPENUM_TYPEDEF (PGPberType_, PGPberType);

enum PGPberFormatSpecifier_
{
    kPGPberFormatSpecifier_Boolean      = 'b',
    kPGPberFormatSpecifier_Int          = 'i',
    kPGPberFormatSpecifier_Octetstring  = 'o',
    kPGPberFormatSpecifier_String       = 's',
    kPGPberFormatSpecifier_StringVector = 'v',
    kPGPberFormatSpecifier_BERVector    = 'V',  /* strings and lengths */
    kPGPberFormatSpecifier_NULL         = 'n',
    kPGPberFormatSpecifier_Enumeration  = 'e',
    kPGPberFormatSpecifier_Tag          = 't',
    kPGPberFormatSpecifier_BeginSequence= '{',
    kPGPberFormatSpecifier_EndSequence  = '}',
    kPGPberFormatSpecifier_BeginSet     = '[',
    kPGPberFormatSpecifier_EndSet       = ']',

	kPGPberFormatSpecifier_Force		= '*'
};
PGPENUM_TYPEDEF (PGPberFormatSpecifier_, PGPberFormatSpecifier);


typedef struct PGPberElement *	PGPberElementRef;

#define kInvalidPGPberElementRef	( (PGPberElementRef) NULL)
#define PGPberElementRefIsValid(ber)	\
			( (ber) != kInvalidPGPberElementRef )
#define PGPValidateBERElementRef(ber) \
			PGPValidateParam( PGPberElementRefIsValid( ber ) )

typedef struct PGPberValue
{
    PGPSize     length;
    PGPByte     *value;
} PGPberValue;

/* Functions */

	PGPError
PGPNewBERElement(
	PGPContextRef		context,
	PGPberElementRef *	ber );

/* ber_free */
	PGPError
PGPFreeBERElement(
	PGPberElementRef	ber );

/* BER encoding functions */
    PGPError
PGPberAppend(
    PGPberElementRef	ber, 
    const PGPChar8 *	s, 
	... );

	PGPError
PGPberGetEncoding(
	PGPberElementRef	ber,
	PGPByte **			encoding );

/* BER decoding functions */
	PGPError
PGPberRead(
	PGPberElementRef	ber,
	const PGPChar8 *	fmt,
	... );

	PGPError
PGPberGetLength(
	PGPberElementRef	ber,
	PGPSize *			length );

	PGPError
PGPberRewind(
	PGPberElementRef	ber );

	PGPError
PGPberNextPrimitive(
	PGPberElementRef	ber );

	PGPError
PGPberNextConstructed(
	PGPberElementRef	ber );

	PGPError
PGPberNext(
	PGPberElementRef	ber );

	PGPError
PGPberSkip(
	PGPberElementRef	ber );

	PGPError
PGPberPeek(
	PGPberElementRef	ber,
	PGPberType *		tag,
	PGPSize *			len );

	PGPError
PGPberGetIndex(
	PGPberElementRef	ber,
	PGPUInt32 *			index );

	PGPError
PGPberSetIndex(
	PGPberElementRef	ber,
	PGPUInt32			index );

	PGPError
PGPberReadResponse(
	PGPberElementRef	ber,
	PGPSocketRef		sock );

	PGPError
PGPberSetData(
	PGPberElementRef	ber,
	PGPByte *			data,
	PGPSize				len );


#endif /* ] Included_pgpBER_h */


/*__Editor_settings____

    Local Variables:
    tab-width: 4
    End:
    vi: ts=4 sw=4
    vim: si
_____________________*/