~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/security/nss/lib/softoken/pkcs11.h

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * The contents of this file are subject to the Mozilla Public
 
3
 * License Version 1.1 (the "License"); you may not use this file
 
4
 * except in compliance with the License. You may obtain a copy of
 
5
 * the License at http://www.mozilla.org/MPL/
 
6
 * 
 
7
 * Software distributed under the License is distributed on an "AS
 
8
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 
9
 * implied. See the License for the specific language governing
 
10
 * rights and limitations under the License.
 
11
 * 
 
12
 * The Original Code is the Netscape security libraries.
 
13
 * 
 
14
 * The Initial Developer of the Original Code is Netscape
 
15
 * Communications Corporation.  Portions created by Netscape are 
 
16
 * Copyright (C) 1994-2000 Netscape Communications Corporation.  All
 
17
 * Rights Reserved.
 
18
 * 
 
19
 * Contributor(s): RSA Labs
 
20
 * 
 
21
 * Alternatively, the contents of this file may be used under the
 
22
 * terms of the GNU General Public License Version 2 or later (the
 
23
 * "GPL"), in which case the provisions of the GPL are applicable 
 
24
 * instead of those above.  If you wish to allow use of your 
 
25
 * version of this file only under the terms of the GPL and not to
 
26
 * allow others to use your version of this file under the MPL,
 
27
 * indicate your decision by deleting the provisions above and
 
28
 * replace them with the notice and other provisions required by
 
29
 * the GPL.  If you do not delete the provisions above, a recipient
 
30
 * may use your version of this file under either the MPL or the
 
31
 * GPL.
 
32
 */
 
33
/*
 
34
 * Copyright (C) 1994-1999 RSA Security Inc. Licence to copy this document
 
35
 * is granted provided that it is identified as "RSA Security In.c Public-Key
 
36
 * Cryptography Standards (PKCS)" in all material mentioning or referencing
 
37
 * this document.
 
38
 *
 
39
 * The latest version of this header can be found at:
 
40
 *    http://www.rsalabs.com/pkcs/pkcs-11/index.html
 
41
 */
 
42
#ifndef _PKCS11_H_
 
43
#define _PKCS11_H_ 1
 
44
 
 
45
#ifdef __cplusplus
 
46
extern "C" {
 
47
#endif
 
48
 
 
49
/* Before including this file (pkcs11.h) (or pkcs11t.h by
 
50
 * itself), 6 platform-specific macros must be defined.  These
 
51
 * macros are described below, and typical definitions for them
 
52
 * are also given.  Be advised that these definitions can depend
 
53
 * on both the platform and the compiler used (and possibly also
 
54
 * on whether a PKCS #11 library is linked statically or
 
55
 * dynamically).
 
56
 *
 
57
 * In addition to defining these 6 macros, the packing convention
 
58
 * for PKCS #11 structures should be set.  The PKCS #11
 
59
 * convention on packing is that structures should be 1-byte
 
60
 * aligned.
 
61
 *
 
62
 * In a Win32 environment, this might be done by using the
 
63
 * following preprocessor directive before including pkcs11.h
 
64
 * or pkcs11t.h:
 
65
 *
 
66
 * #pragma pack(push, cryptoki, 1)
 
67
 *
 
68
 * and using the following preprocessor directive after including
 
69
 * pkcs11.h or pkcs11t.h:
 
70
 *
 
71
 * #pragma pack(pop, cryptoki)
 
72
 *
 
73
 * In a Win16 environment, this might be done by using the
 
74
 * following preprocessor directive before including pkcs11.h
 
75
 * or pkcs11t.h:
 
76
 *
 
77
 * #pragma pack(1)
 
78
 *
 
79
 * In a UNIX environment, you're on your own here.  You might
 
80
 * not need to do anything.
 
81
 *
 
82
 *
 
83
 * Now for the macros:
 
84
 *
 
85
 *
 
86
 * 1. CK_PTR: The indirection string for making a pointer to an
 
87
 * object.  It can be used like this:
 
88
 *
 
89
 * typedef CK_BYTE CK_PTR CK_BYTE_PTR;
 
90
 *
 
91
 * In a Win32 environment, it might be defined by
 
92
 *
 
93
 * #define CK_PTR *
 
94
 *
 
95
 * In a Win16 environment, it might be defined by
 
96
 *
 
97
 * #define CK_PTR far *
 
98
 *
 
99
 * In a UNIX environment, it might be defined by
 
100
 *
 
101
 * #define CK_PTR *
 
102
 *
 
103
 *
 
104
 * 2. CK_DEFINE_FUNCTION(returnType, name): A macro which makes
 
105
 * an exportable PKCS #11 library function definition out of a
 
106
 * return type and a function name.  It should be used in the
 
107
 * following fashion to define the exposed PKCS #11 functions in
 
108
 * a PKCS #11 library:
 
109
 *
 
110
 * CK_DEFINE_FUNCTION(CK_RV, C_Initialize)(
 
111
 *   CK_VOID_PTR pReserved
 
112
 * )
 
113
 * {
 
114
 *   ...
 
115
 * }
 
116
 *
 
117
 * For defining a function in a Win32 PKCS #11 .dll, it might be
 
118
 * defined by
 
119
 *
 
120
 * #define CK_DEFINE_FUNCTION(returnType, name) \
 
121
 *   returnType __declspec(dllexport) name
 
122
 *
 
123
 * For defining a function in a Win16 PKCS #11 .dll, it might be
 
124
 * defined by
 
125
 *
 
126
 * #define CK_DEFINE_FUNCTION(returnType, name) \
 
127
 *   returnType __export _far _pascal name
 
128
 *
 
129
 * In a UNIX environment, it might be defined by
 
130
 *
 
131
 * #define CK_DEFINE_FUNCTION(returnType, name) \
 
132
 *   returnType name
 
133
 *
 
134
 *
 
135
 * 3. CK_DECLARE_FUNCTION(returnType, name): A macro which makes
 
136
 * an importable PKCS #11 library function declaration out of a
 
137
 * return type and a function name.  It should be used in the
 
138
 * following fashion:
 
139
 *
 
140
 * extern CK_DECLARE_FUNCTION(CK_RV, C_Initialize)(
 
141
 *   CK_VOID_PTR pReserved
 
142
 * );
 
143
 *
 
144
 * For declaring a function in a Win32 PKCS #11 .dll, it might
 
145
 * be defined by
 
146
 *
 
147
 * #define CK_DECLARE_FUNCTION(returnType, name) \
 
148
 *   returnType __declspec(dllimport) name
 
149
 *
 
150
 * For declaring a function in a Win16 PKCS #11 .dll, it might
 
151
 * be defined by
 
152
 *
 
153
 * #define CK_DECLARE_FUNCTION(returnType, name) \
 
154
 *   returnType __export _far _pascal name
 
155
 *
 
156
 * In a UNIX environment, it might be defined by
 
157
 *
 
158
 * #define CK_DECLARE_FUNCTION(returnType, name) \
 
159
 *   returnType name
 
160
 *
 
161
 *
 
162
 * 4. CK_DECLARE_FUNCTION_POINTER(returnType, name): A macro
 
163
 * which makes a PKCS #11 API function pointer declaration or
 
164
 * function pointer type declaration out of a return type and a
 
165
 * function name.  It should be used in the following fashion:
 
166
 *
 
167
 * // Define funcPtr to be a pointer to a PKCS #11 API function
 
168
 * // taking arguments args and returning CK_RV.
 
169
 * CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtr)(args);
 
170
 *
 
171
 * or
 
172
 *
 
173
 * // Define funcPtrType to be the type of a pointer to a
 
174
 * // PKCS #11 API function taking arguments args and returning
 
175
 * // CK_RV, and then define funcPtr to be a variable of type
 
176
 * // funcPtrType.
 
177
 * typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtrType)(args);
 
178
 * funcPtrType funcPtr;
 
179
 *
 
180
 * For accessing functions in a Win32 PKCS #11 .dll, in might be
 
181
 * defined by
 
182
 *
 
183
 * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
 
184
 *   returnType __declspec(dllimport) (* name)
 
185
 *
 
186
 * For accessing functions in a Win16 PKCS #11 .dll, it might be
 
187
 * defined by
 
188
 *
 
189
 * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
 
190
 *   returnType __export _far _pascal (* name)
 
191
 *
 
192
 * In a UNIX environment, it might be defined by
 
193
 *
 
194
 * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
 
195
 *   returnType (* name)
 
196
 *
 
197
 *
 
198
 * 5. CK_CALLBACK_FUNCTION(returnType, name): A macro which makes
 
199
 * a function pointer type for an application callback out of
 
200
 * a return type for the callback and a name for the callback.
 
201
 * It should be used in the following fashion:
 
202
 *
 
203
 * CK_CALLBACK_FUNCTION(CK_RV, myCallback)(args);
 
204
 *
 
205
 * to declare a function pointer, myCallback, to a callback
 
206
 * which takes arguments args and returns a CK_RV.  It can also
 
207
 * be used like this:
 
208
 *
 
209
 * typedef CK_CALLBACK_FUNCTION(CK_RV, myCallbackType)(args);
 
210
 * myCallbackType myCallback;
 
211
 *
 
212
 * In a Win32 environment, it might be defined by
 
213
 *
 
214
 * #define CK_CALLBACK_FUNCTION(returnType, name) \
 
215
 *   returnType (* name)
 
216
 *
 
217
 * In a Win16 environment, it might be defined by
 
218
 *
 
219
 * #define CK_CALLBACK_FUNCTION(returnType, name) \
 
220
 *   returnType _far _pascal (* name)
 
221
 *
 
222
 * In a UNIX environment, it might be defined by
 
223
 *
 
224
 * #define CK_CALLBACK_FUNCTION(returnType, name) \
 
225
 *   returnType (* name)
 
226
 *
 
227
 *
 
228
 * 6. NULL_PTR: This macro is the value of a NULL pointer.
 
229
 *
 
230
 * In any ANSI/ISO C environment (and in many others as well),
 
231
 * this should be defined by
 
232
 *
 
233
 * #ifndef NULL_PTR
 
234
 * #define NULL_PTR 0
 
235
 * #endif
 
236
 */
 
237
 
 
238
 
 
239
/* All the various PKCS #11 types and #define'd values are in the
 
240
 * file pkcs11t.h. */
 
241
#include "pkcs11t.h"
 
242
 
 
243
#define __PASTE(x,y)      x##y
 
244
 
 
245
 
 
246
/* packing defines */
 
247
#include "pkcs11p.h"
 
248
/* ==============================================================
 
249
 * Define the "extern" form of all the entry points.
 
250
 * ==============================================================
 
251
 */
 
252
 
 
253
#define CK_NEED_ARG_LIST  1
 
254
#define CK_PKCS11_FUNCTION_INFO(name) \
 
255
  CK_DECLARE_FUNCTION(CK_RV, name)
 
256
 
 
257
/* pkcs11f.h has all the information about the PKCS #11
 
258
 * function prototypes. */
 
259
#include "pkcs11f.h"
 
260
 
 
261
#undef CK_NEED_ARG_LIST
 
262
#undef CK_PKCS11_FUNCTION_INFO
 
263
 
 
264
 
 
265
/* ==============================================================
 
266
 * Define the typedef form of all the entry points.  That is, for
 
267
 * each PKCS #11 function C_XXX, define a type CK_C_XXX which is
 
268
 * a pointer to that kind of function.
 
269
 * ==============================================================
 
270
 */
 
271
 
 
272
#define CK_NEED_ARG_LIST  1
 
273
#define CK_PKCS11_FUNCTION_INFO(name) \
 
274
  typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, __PASTE(CK_,name))
 
275
 
 
276
/* pkcs11f.h has all the information about the PKCS #11
 
277
 * function prototypes. */
 
278
#include "pkcs11f.h"
 
279
 
 
280
#undef CK_NEED_ARG_LIST
 
281
#undef CK_PKCS11_FUNCTION_INFO
 
282
 
 
283
 
 
284
/* ==============================================================
 
285
 * Define structed vector of entry points.  A CK_FUNCTION_LIST
 
286
 * contains a CK_VERSION indicating a library's PKCS #11 version
 
287
 * and then a whole slew of function pointers to the routines in
 
288
 * the library.  This type was declared, but not defined, in
 
289
 * pkcs11t.h.
 
290
 * ==============================================================
 
291
 */
 
292
 
 
293
#define CK_PKCS11_FUNCTION_INFO(name) \
 
294
  __PASTE(CK_,name) name;
 
295
  
 
296
struct CK_FUNCTION_LIST {
 
297
 
 
298
  CK_VERSION    version;  /* PKCS #11 version */
 
299
 
 
300
/* Pile all the function pointers into the CK_FUNCTION_LIST. */
 
301
/* pkcs11f.h has all the information about the PKCS #11
 
302
 * function prototypes. */
 
303
#include "pkcs11f.h" 
 
304
 
 
305
};
 
306
 
 
307
#undef CK_PKCS11_FUNCTION_INFO
 
308
 
 
309
 
 
310
#undef __PASTE
 
311
 
 
312
/* unpack */
 
313
#include "pkcs11u.h"
 
314
 
 
315
#ifdef __cplusplus
 
316
}
 
317
#endif
 
318
 
 
319
#endif