summaryrefslogtreecommitdiff
path: root/plugins/CryptoPP/PGPw/sdk6/include/pgpUtilities.h
blob: d92c999cf9e94641e432bda818ea36f49c84e018 (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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/*____________________________________________________________________________
	pgpUtilities.h
	
	Copyright (C) 1997 Network Associates Inc. and affiliated companies.
	All rights reserved.
	
	This file contains miscellaneous utility functions needed for the PGPsdk.

	$Id: pgpUtilities.h,v 1.68 1999/03/25 01:46:38 heller Exp $
____________________________________________________________________________*/

#ifndef Included_pgpUtilities_h	/* [ */
#define Included_pgpUtilities_h

#if PGP_MACINTOSH	/* [ */
#include <Files.h>
#endif	/* ] PGP_MACINTOSH */

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

#include <time.h>


#if PRAGMA_ALIGN_SUPPORTED
#pragma options align=mac68k	/* [ */
#endif


#if PGP_MACINTOSH	/* [ */

#define kPGPMacFileCreator_Keys				'pgpK'
#define kPGPMacFileCreator_DecryptedBinary	'????'
#define kPGPMacFileCreator_DecryptedText	'ttxt'
#define kPGPMacFileCreator_Tools			'pgpM'

#define kPGPMacFileType_ArmorFile		'TEXT'
#define kPGPMacFileType_EncryptedData	'pgEF'
#define kPGPMacFileType_SignedData		'pgSF'
#define kPGPMacFileType_DetachedSig		'pgDS'
#define kPGPMacFileType_RandomSeed		'pgRS'
#define kPGPMacFileType_PrivRing		'pgRR'
#define kPGPMacFileType_PubRing			'pgPR'
#define kPGPMacFileType_Groups			'pgGR'
#define kPGPMacFileType_Preferences		'pref'
#define kPGPMacFileType_DecryptedText	'TEXT'
#define kPGPMacFileType_DecryptedBinary	'BINA'
#define kPGPMacFileType_KeyShares		'pgSK'
#define kPGPMacFileType_Exported509Keys	'pgX5'

#endif	/* ] PGP_MACINTOSH */

PGP_BEGIN_C_DECLARATIONS
#if PRAGMA_IMPORT_SUPPORTED
#pragma import on
#endif

/*____________________________________________________________________________
	Context routines
____________________________________________________________________________*/

/*____________________________________________________________________________
	API version:
	Top byte is major, next 3 nibbles minor, next 2 bug fix,
	last nibble reserved:  0xMMmmmrrR
	
	example: 1.0.0 = 0x01000000
	
	0x01000000		SDK 1.0.0
	0x02000000		SDK 1.1.0
	0x02000010		SDK 1.1.1
	0x03000000		SDK 1.5
	0x03000010		SDK 1.5.1
	0x03000020		SDK 1.5.2
	0x03001000		SDK 1.6
	0x03002000		SDK 1.7
	0x03002010		SDK 1.7.1
_____________________________________________________________________________*/
#define kPGPsdkAPIVersion		( (PGPUInt32)0x03002010 )
#define PGPMajorVersion( v )	( ( ((PGPUInt32)(v)) & 0xFF000000 ) >> 24 )
#define PGPMinorVersion( v )	( ( ((PGPUInt32)(v)) & 0x00FFF000 ) >> 16 )
#define PGPRevVersion( v )		( ( ((PGPUInt32)(v)) & 0x00000FF0 ) >> 4 )

typedef struct PGPNewContextStruct
{
	/* sizeofStruct must be inited to sizeof( PGPNewContextStruct ) */
	PGPUInt32				sizeofStruct;
	PGPMemoryMgrRef			memoryMgr;
} PGPNewContextStruct;



/* always pass kPGPsdkVersion */
PGPError 	PGPNewContext( PGPUInt32 clientAPIVersion,
				PGPContextRef *newContext );
PGPError 	PGPNewContextCustom( PGPUInt32 clientAPIVersion,
				PGPNewContextStruct	const *custom,
				PGPContextRef *newContext );

PGPError 	PGPFreeContext( PGPContextRef context );

PGPError 	PGPGetContextUserValue( PGPContextRef context,
						PGPUserValue *userValue );
PGPError 	PGPSetContextUserValue( PGPContextRef context,
						PGPUserValue userValue );

PGPError	PGPContextGetRandomBytes(PGPContextRef context,
						void *buf, PGPSize len );


PGPMemoryMgrRef	PGPGetContextMemoryMgr( PGPContextRef context );



/*____________________________________________________________________________
	FileRefs
____________________________________________________________________________*/

PGPError 		PGPCopyFileSpec(PGPFileSpecRef fileRef,
					PGPFileSpecRef *ref);
PGPError 		PGPFreeFileSpec(PGPFileSpecRef fileRef);

#if PGP_MACINTOSH	/* [ */

PGPError 		PGPNewFileSpecFromFSSpec(PGPContextRef context,
						const FSSpec *spec, PGPFileSpecRef *ref);
PGPError 		PGPGetFSSpecFromFileSpec(PGPFileSpecRef fileRef,
						FSSpec *spec);
#else

PGPError 		PGPNewFileSpecFromFullPath( PGPContextRef context,
						char const *path, PGPFileSpecRef *ref);

/* *fullPathPtr ***must*** be freed with PGPFreeData */
PGPError 		PGPGetFullPathFromFileSpec( PGPFileSpecRef	fileRef,
						char ** fullPathPtr);
						
#endif	/* ] PGP_MACINTOSH */


						
/*____________________________________________________________________________
	Time
____________________________________________________________________________*/
PGPTime 			PGPGetTime(void);

/* these use time_t type as returned by time() in Std C libraries */
time_t 			PGPGetStdTimeFromPGPTime(PGPTime theTime);
PGPTime 		PGPGetPGPTimeFromStdTime(time_t theTime);


/* year, month, day may be NULL if desired */
void 			PGPGetYMDFromPGPTime( PGPTime theTime,
						PGPUInt16 *year, PGPUInt16 *month, PGPUInt16 *day );


#if PGP_MACINTOSH	/* [ */
PGPUInt32 		PGPTimeToMacTime(PGPTime theTime);
PGPTime 		PGPTimeFromMacTime(PGPUInt32 theTime);
#endif	/* ] PGP_MACINTOSH */



/*____________________________________________________________________________
	MacBinary support
____________________________________________________________________________*/


/*____________________________________________________________________________
	Examine the input file to see if it's a MacBinary file.  If it is
	not a MacBinary file, then the original file is unaltered.
	Otherwise, the file is converted and the original file is deleted.
	
	The resulting file is designated by 'outPGPSpec' and may have a different
	name than the original.
	
	If the file is a TEXT file, appropriate line-end conversion is done.
	
	creator and type code pointers may be
	null but otherwise contain the mac creator and type.
	
	This routine can be called on a Mac, but generally doesn't need to be.
____________________________________________________________________________*/
PGPError	PGPMacBinaryToLocal( PGPFileSpecRef inSpec,
				PGPFileSpecRef * outSpec,
				PGPUInt32 * macCreator, PGPUInt32 * macTypeCode );




/*____________________________________________________________________________
	Library initialization

	Call PGPsdkXXXInit() before using that particular library.
	Call PGPsdkXXXCleanup() when you are done (but after disposing of any
		PGPContexts).
	
	You may call PGPsdkXXXInit multiple times (with no effect), but be sure
	to call the matching PGPsdkXXXCleanup() for each call to PGPsdkXXXInit().
____________________________________________________________________________*/

PGPError	PGPsdkInit( void );
PGPError	PGPsdkCleanup( void );

PGPError	PGPsdkNetworkLibInit( void );
PGPError	PGPsdkNetworkLibCleanup( void );

PGPError	PGPsdkUILibInit( void );
PGPError	PGPsdkUILibCleanup( void );

#if PRAGMA_IMPORT_SUPPORTED
#pragma import reset
#endif
PGP_END_C_DECLARATIONS



#if PRAGMA_ALIGN_SUPPORTED
#pragma options align=reset			/* ] */
#endif

#endif /* ] Included_pgpUtilities_h */

/*__Editor_settings____

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