Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #ifndef NSSCKMDT_H |
michael@0 | 6 | #define NSSCKMDT_H |
michael@0 | 7 | |
michael@0 | 8 | /* |
michael@0 | 9 | * nssckmdt.h |
michael@0 | 10 | * |
michael@0 | 11 | * This file specifies the basic types that must be implemented by |
michael@0 | 12 | * any Module using the NSS Cryptoki Framework. |
michael@0 | 13 | */ |
michael@0 | 14 | |
michael@0 | 15 | #ifndef NSSBASET_H |
michael@0 | 16 | #include "nssbaset.h" |
michael@0 | 17 | #endif /* NSSBASET_H */ |
michael@0 | 18 | |
michael@0 | 19 | #ifndef NSSCKT_H |
michael@0 | 20 | #include "nssckt.h" |
michael@0 | 21 | #endif /* NSSCKT_H */ |
michael@0 | 22 | |
michael@0 | 23 | #ifndef NSSCKFWT_H |
michael@0 | 24 | #include "nssckfwt.h" |
michael@0 | 25 | #endif /* NSSCKFWT_H */ |
michael@0 | 26 | |
michael@0 | 27 | typedef struct NSSCKMDInstanceStr NSSCKMDInstance; |
michael@0 | 28 | typedef struct NSSCKMDSlotStr NSSCKMDSlot; |
michael@0 | 29 | typedef struct NSSCKMDTokenStr NSSCKMDToken; |
michael@0 | 30 | typedef struct NSSCKMDSessionStr NSSCKMDSession; |
michael@0 | 31 | typedef struct NSSCKMDCryptoOperationStr NSSCKMDCryptoOperation; |
michael@0 | 32 | typedef struct NSSCKMDFindObjectsStr NSSCKMDFindObjects; |
michael@0 | 33 | typedef struct NSSCKMDMechanismStr NSSCKMDMechanism; |
michael@0 | 34 | typedef struct NSSCKMDObjectStr NSSCKMDObject; |
michael@0 | 35 | |
michael@0 | 36 | /* |
michael@0 | 37 | * NSSCKFWItem |
michael@0 | 38 | * |
michael@0 | 39 | * This is a structure used by modules to return object attributes. |
michael@0 | 40 | * The needsFreeing bit indicates whether the object needs to be freed. |
michael@0 | 41 | * If so, the framework will call the FreeAttribute function on the item |
michael@0 | 42 | * after it is done using it. |
michael@0 | 43 | * |
michael@0 | 44 | */ |
michael@0 | 45 | |
michael@0 | 46 | typedef struct { |
michael@0 | 47 | PRBool needsFreeing; |
michael@0 | 48 | NSSItem* item; |
michael@0 | 49 | } NSSCKFWItem ; |
michael@0 | 50 | |
michael@0 | 51 | /* |
michael@0 | 52 | * NSSCKMDInstance |
michael@0 | 53 | * |
michael@0 | 54 | * This is the basic handle for an instance of a PKCS#11 Module. |
michael@0 | 55 | * It is returned by the Module's CreateInstance routine, and |
michael@0 | 56 | * may be obtained from the corresponding NSSCKFWInstance object. |
michael@0 | 57 | * It contains a pointer for use by the Module, to store any |
michael@0 | 58 | * instance-related data, and it contains the EPV for a set of |
michael@0 | 59 | * routines which the Module may implement for use by the Framework. |
michael@0 | 60 | * Some of these routines are optional; others are mandatory. |
michael@0 | 61 | */ |
michael@0 | 62 | |
michael@0 | 63 | struct NSSCKMDInstanceStr { |
michael@0 | 64 | /* |
michael@0 | 65 | * The Module may use this pointer for its own purposes. |
michael@0 | 66 | */ |
michael@0 | 67 | void *etc; |
michael@0 | 68 | |
michael@0 | 69 | /* |
michael@0 | 70 | * This routine is called by the Framework to initialize |
michael@0 | 71 | * the Module. This routine is optional; if unimplemented, |
michael@0 | 72 | * it won't be called. If this routine returns an error, |
michael@0 | 73 | * then the initialization will fail. |
michael@0 | 74 | */ |
michael@0 | 75 | CK_RV (PR_CALLBACK *Initialize)( |
michael@0 | 76 | NSSCKMDInstance *mdInstance, |
michael@0 | 77 | NSSCKFWInstance *fwInstance, |
michael@0 | 78 | NSSUTF8 *configurationData |
michael@0 | 79 | ); |
michael@0 | 80 | |
michael@0 | 81 | /* |
michael@0 | 82 | * This routine is called when the Framework is finalizing |
michael@0 | 83 | * the PKCS#11 Module. It is the last thing called before |
michael@0 | 84 | * the NSSCKFWInstance's NSSArena is destroyed. This routine |
michael@0 | 85 | * is optional; if unimplemented, it merely won't be called. |
michael@0 | 86 | */ |
michael@0 | 87 | void (PR_CALLBACK *Finalize)( |
michael@0 | 88 | NSSCKMDInstance *mdInstance, |
michael@0 | 89 | NSSCKFWInstance *fwInstance |
michael@0 | 90 | ); |
michael@0 | 91 | |
michael@0 | 92 | /* |
michael@0 | 93 | * This routine gets the number of slots. This value must |
michael@0 | 94 | * never change, once the instance is initialized. This |
michael@0 | 95 | * routine must be implemented. It may return zero on error. |
michael@0 | 96 | */ |
michael@0 | 97 | CK_ULONG (PR_CALLBACK *GetNSlots)( |
michael@0 | 98 | NSSCKMDInstance *mdInstance, |
michael@0 | 99 | NSSCKFWInstance *fwInstance, |
michael@0 | 100 | CK_RV *pError |
michael@0 | 101 | ); |
michael@0 | 102 | |
michael@0 | 103 | /* |
michael@0 | 104 | * This routine returns the version of the Cryptoki standard |
michael@0 | 105 | * to which this Module conforms. This routine is optional; |
michael@0 | 106 | * if unimplemented, the Framework uses the version to which |
michael@0 | 107 | * ~it~ was implemented. |
michael@0 | 108 | */ |
michael@0 | 109 | CK_VERSION (PR_CALLBACK *GetCryptokiVersion)( |
michael@0 | 110 | NSSCKMDInstance *mdInstance, |
michael@0 | 111 | NSSCKFWInstance *fwInstance |
michael@0 | 112 | ); |
michael@0 | 113 | |
michael@0 | 114 | /* |
michael@0 | 115 | * This routine returns a pointer to a UTF8-encoded string |
michael@0 | 116 | * containing the manufacturer ID for this Module. Only |
michael@0 | 117 | * the characters completely encoded in the first thirty- |
michael@0 | 118 | * two bytes are significant. This routine is optional. |
michael@0 | 119 | * The string returned is never freed; if dynamically generated, |
michael@0 | 120 | * the space for it should be allocated from the NSSArena |
michael@0 | 121 | * that may be obtained from the NSSCKFWInstance. This |
michael@0 | 122 | * routine may return NULL upon error; however if *pError |
michael@0 | 123 | * is CKR_OK, the NULL will be considered the valid response. |
michael@0 | 124 | */ |
michael@0 | 125 | NSSUTF8 *(PR_CALLBACK *GetManufacturerID)( |
michael@0 | 126 | NSSCKMDInstance *mdInstance, |
michael@0 | 127 | NSSCKFWInstance *fwInstance, |
michael@0 | 128 | CK_RV *pError |
michael@0 | 129 | ); |
michael@0 | 130 | |
michael@0 | 131 | /* |
michael@0 | 132 | * This routine returns a pointer to a UTF8-encoded string |
michael@0 | 133 | * containing a description of this Module library. Only |
michael@0 | 134 | * the characters completely encoded in the first thirty- |
michael@0 | 135 | * two bytes are significant. This routine is optional. |
michael@0 | 136 | * The string returned is never freed; if dynamically generated, |
michael@0 | 137 | * the space for it should be allocated from the NSSArena |
michael@0 | 138 | * that may be obtained from the NSSCKFWInstance. This |
michael@0 | 139 | * routine may return NULL upon error; however if *pError |
michael@0 | 140 | * is CKR_OK, the NULL will be considered the valid response. |
michael@0 | 141 | */ |
michael@0 | 142 | NSSUTF8 *(PR_CALLBACK *GetLibraryDescription)( |
michael@0 | 143 | NSSCKMDInstance *mdInstance, |
michael@0 | 144 | NSSCKFWInstance *fwInstance, |
michael@0 | 145 | CK_RV *pError |
michael@0 | 146 | ); |
michael@0 | 147 | |
michael@0 | 148 | /* |
michael@0 | 149 | * This routine returns the version of this Module library. |
michael@0 | 150 | * This routine is optional; if unimplemented, the Framework |
michael@0 | 151 | * will assume a Module library version of 0.1. |
michael@0 | 152 | */ |
michael@0 | 153 | CK_VERSION (PR_CALLBACK *GetLibraryVersion)( |
michael@0 | 154 | NSSCKMDInstance *mdInstance, |
michael@0 | 155 | NSSCKFWInstance *fwInstance |
michael@0 | 156 | ); |
michael@0 | 157 | |
michael@0 | 158 | /* |
michael@0 | 159 | * This routine returns CK_TRUE if the Module wishes to |
michael@0 | 160 | * handle session objects. This routine is optional. |
michael@0 | 161 | * If this routine is NULL, or if it exists but returns |
michael@0 | 162 | * CK_FALSE, the Framework will assume responsibility |
michael@0 | 163 | * for managing session objects. |
michael@0 | 164 | */ |
michael@0 | 165 | CK_BBOOL (PR_CALLBACK *ModuleHandlesSessionObjects)( |
michael@0 | 166 | NSSCKMDInstance *mdInstance, |
michael@0 | 167 | NSSCKFWInstance *fwInstance |
michael@0 | 168 | ); |
michael@0 | 169 | |
michael@0 | 170 | /* |
michael@0 | 171 | * This routine stuffs pointers to NSSCKMDSlot objects into |
michael@0 | 172 | * the specified array; one for each slot supported by this |
michael@0 | 173 | * instance. The Framework will determine the size needed |
michael@0 | 174 | * for the array by calling GetNSlots. This routine is |
michael@0 | 175 | * required. |
michael@0 | 176 | */ |
michael@0 | 177 | CK_RV (PR_CALLBACK *GetSlots)( |
michael@0 | 178 | NSSCKMDInstance *mdInstance, |
michael@0 | 179 | NSSCKFWInstance *fwInstance, |
michael@0 | 180 | NSSCKMDSlot *slots[] |
michael@0 | 181 | ); |
michael@0 | 182 | |
michael@0 | 183 | /* |
michael@0 | 184 | * This call returns a pointer to the slot in which an event |
michael@0 | 185 | * has occurred. If the block argument is CK_TRUE, the call |
michael@0 | 186 | * should block until a slot event occurs; if CK_FALSE, it |
michael@0 | 187 | * should check to see if an event has occurred, occurred, |
michael@0 | 188 | * but return NULL (and set *pError to CK_NO_EVENT) if one |
michael@0 | 189 | * hasn't. This routine is optional; if unimplemented, the |
michael@0 | 190 | * Framework will assume that no event has happened. This |
michael@0 | 191 | * routine may return NULL upon error. |
michael@0 | 192 | */ |
michael@0 | 193 | NSSCKMDSlot *(PR_CALLBACK *WaitForSlotEvent)( |
michael@0 | 194 | NSSCKMDInstance *mdInstance, |
michael@0 | 195 | NSSCKFWInstance *fwInstance, |
michael@0 | 196 | CK_BBOOL block, |
michael@0 | 197 | CK_RV *pError |
michael@0 | 198 | ); |
michael@0 | 199 | |
michael@0 | 200 | /* |
michael@0 | 201 | * This object may be extended in future versions of the |
michael@0 | 202 | * NSS Cryptoki Framework. To allow for some flexibility |
michael@0 | 203 | * in the area of binary compatibility, this field should |
michael@0 | 204 | * be NULL. |
michael@0 | 205 | */ |
michael@0 | 206 | void *null; |
michael@0 | 207 | }; |
michael@0 | 208 | |
michael@0 | 209 | |
michael@0 | 210 | /* |
michael@0 | 211 | * NSSCKMDSlot |
michael@0 | 212 | * |
michael@0 | 213 | * This is the basic handle for a PKCS#11 Module Slot. It is |
michael@0 | 214 | * created by the NSSCKMDInstance->GetSlots call, and may be |
michael@0 | 215 | * obtained from the Framework's corresponding NSSCKFWSlot |
michael@0 | 216 | * object. It contains a pointer for use by the Module, to |
michael@0 | 217 | * store any slot-related data, and it contains the EPV for |
michael@0 | 218 | * a set of routines which the Module may implement for use |
michael@0 | 219 | * by the Framework. Some of these routines are optional. |
michael@0 | 220 | */ |
michael@0 | 221 | |
michael@0 | 222 | struct NSSCKMDSlotStr { |
michael@0 | 223 | /* |
michael@0 | 224 | * The Module may use this pointer for its own purposes. |
michael@0 | 225 | */ |
michael@0 | 226 | void *etc; |
michael@0 | 227 | |
michael@0 | 228 | /* |
michael@0 | 229 | * This routine is called during the Framework initialization |
michael@0 | 230 | * step, after the Framework Instance has obtained the list |
michael@0 | 231 | * of slots (by calling NSSCKMDInstance->GetSlots). Any slot- |
michael@0 | 232 | * specific initialization can be done here. This routine is |
michael@0 | 233 | * optional; if unimplemented, it won't be called. Note that |
michael@0 | 234 | * if this routine returns an error, the entire Framework |
michael@0 | 235 | * initialization for this Module will fail. |
michael@0 | 236 | */ |
michael@0 | 237 | CK_RV (PR_CALLBACK *Initialize)( |
michael@0 | 238 | NSSCKMDSlot *mdSlot, |
michael@0 | 239 | NSSCKFWSlot *fwSlot, |
michael@0 | 240 | NSSCKMDInstance *mdInstance, |
michael@0 | 241 | NSSCKFWInstance *fwInstance |
michael@0 | 242 | ); |
michael@0 | 243 | |
michael@0 | 244 | /* |
michael@0 | 245 | * This routine is called when the Framework is finalizing |
michael@0 | 246 | * the PKCS#11 Module. This call (for each of the slots) |
michael@0 | 247 | * is the last thing called before NSSCKMDInstance->Finalize. |
michael@0 | 248 | * This routine is optional; if unimplemented, it merely |
michael@0 | 249 | * won't be called. Note: In the rare circumstance that |
michael@0 | 250 | * the Framework initialization cannot complete (due to, |
michael@0 | 251 | * for example, memory limitations), this can be called with |
michael@0 | 252 | * a NULL value for fwSlot. |
michael@0 | 253 | */ |
michael@0 | 254 | void (PR_CALLBACK *Destroy)( |
michael@0 | 255 | NSSCKMDSlot *mdSlot, |
michael@0 | 256 | NSSCKFWSlot *fwSlot, |
michael@0 | 257 | NSSCKMDInstance *mdInstance, |
michael@0 | 258 | NSSCKFWInstance *fwInstance |
michael@0 | 259 | ); |
michael@0 | 260 | |
michael@0 | 261 | /* |
michael@0 | 262 | * This routine returns a pointer to a UTF8-encoded string |
michael@0 | 263 | * containing a description of this slot. Only the characters |
michael@0 | 264 | * completely encoded in the first sixty-four bytes are |
michael@0 | 265 | * significant. This routine is optional. The string |
michael@0 | 266 | * returned is never freed; if dynamically generated, |
michael@0 | 267 | * the space for it should be allocated from the NSSArena |
michael@0 | 268 | * that may be obtained from the NSSCKFWInstance. This |
michael@0 | 269 | * routine may return NULL upon error; however if *pError |
michael@0 | 270 | * is CKR_OK, the NULL will be considered the valid response. |
michael@0 | 271 | */ |
michael@0 | 272 | NSSUTF8 *(PR_CALLBACK *GetSlotDescription)( |
michael@0 | 273 | NSSCKMDSlot *mdSlot, |
michael@0 | 274 | NSSCKFWSlot *fwSlot, |
michael@0 | 275 | NSSCKMDInstance *mdInstance, |
michael@0 | 276 | NSSCKFWInstance *fwInstance, |
michael@0 | 277 | CK_RV *pError |
michael@0 | 278 | ); |
michael@0 | 279 | |
michael@0 | 280 | /* |
michael@0 | 281 | * This routine returns a pointer to a UTF8-encoded string |
michael@0 | 282 | * containing a description of the manufacturer of this slot. |
michael@0 | 283 | * Only the characters completely encoded in the first thirty- |
michael@0 | 284 | * two bytes are significant. This routine is optional. |
michael@0 | 285 | * The string returned is never freed; if dynamically generated, |
michael@0 | 286 | * the space for it should be allocated from the NSSArena |
michael@0 | 287 | * that may be obtained from the NSSCKFWInstance. This |
michael@0 | 288 | * routine may return NULL upon error; however if *pError |
michael@0 | 289 | * is CKR_OK, the NULL will be considered the valid response. |
michael@0 | 290 | */ |
michael@0 | 291 | NSSUTF8 *(PR_CALLBACK *GetManufacturerID)( |
michael@0 | 292 | NSSCKMDSlot *mdSlot, |
michael@0 | 293 | NSSCKFWSlot *fwSlot, |
michael@0 | 294 | NSSCKMDInstance *mdInstance, |
michael@0 | 295 | NSSCKFWInstance *fwInstance, |
michael@0 | 296 | CK_RV *pError |
michael@0 | 297 | ); |
michael@0 | 298 | |
michael@0 | 299 | /* |
michael@0 | 300 | * This routine returns CK_TRUE if a token is present in this |
michael@0 | 301 | * slot. This routine is optional; if unimplemented, CK_TRUE |
michael@0 | 302 | * is assumed. |
michael@0 | 303 | */ |
michael@0 | 304 | CK_BBOOL (PR_CALLBACK *GetTokenPresent)( |
michael@0 | 305 | NSSCKMDSlot *mdSlot, |
michael@0 | 306 | NSSCKFWSlot *fwSlot, |
michael@0 | 307 | NSSCKMDInstance *mdInstance, |
michael@0 | 308 | NSSCKFWInstance *fwInstance |
michael@0 | 309 | ); |
michael@0 | 310 | |
michael@0 | 311 | /* |
michael@0 | 312 | * This routine returns CK_TRUE if the slot supports removable |
michael@0 | 313 | * tokens. This routine is optional; if unimplemented, CK_FALSE |
michael@0 | 314 | * is assumed. |
michael@0 | 315 | */ |
michael@0 | 316 | CK_BBOOL (PR_CALLBACK *GetRemovableDevice)( |
michael@0 | 317 | NSSCKMDSlot *mdSlot, |
michael@0 | 318 | NSSCKFWSlot *fwSlot, |
michael@0 | 319 | NSSCKMDInstance *mdInstance, |
michael@0 | 320 | NSSCKFWInstance *fwInstance |
michael@0 | 321 | ); |
michael@0 | 322 | |
michael@0 | 323 | /* |
michael@0 | 324 | * This routine returns CK_TRUE if this slot is a hardware |
michael@0 | 325 | * device, or CK_FALSE if this slot is a software device. This |
michael@0 | 326 | * routine is optional; if unimplemented, CK_FALSE is assumed. |
michael@0 | 327 | */ |
michael@0 | 328 | CK_BBOOL (PR_CALLBACK *GetHardwareSlot)( |
michael@0 | 329 | NSSCKMDSlot *mdSlot, |
michael@0 | 330 | NSSCKFWSlot *fwSlot, |
michael@0 | 331 | NSSCKMDInstance *mdInstance, |
michael@0 | 332 | NSSCKFWInstance *fwInstance |
michael@0 | 333 | ); |
michael@0 | 334 | |
michael@0 | 335 | /* |
michael@0 | 336 | * This routine returns the version of this slot's hardware. |
michael@0 | 337 | * This routine is optional; if unimplemented, the Framework |
michael@0 | 338 | * will assume a hardware version of 0.1. |
michael@0 | 339 | */ |
michael@0 | 340 | CK_VERSION (PR_CALLBACK *GetHardwareVersion)( |
michael@0 | 341 | NSSCKMDSlot *mdSlot, |
michael@0 | 342 | NSSCKFWSlot *fwSlot, |
michael@0 | 343 | NSSCKMDInstance *mdInstance, |
michael@0 | 344 | NSSCKFWInstance *fwInstance |
michael@0 | 345 | ); |
michael@0 | 346 | |
michael@0 | 347 | /* |
michael@0 | 348 | * This routine returns the version of this slot's firmware. |
michael@0 | 349 | * This routine is optional; if unimplemented, the Framework |
michael@0 | 350 | * will assume a hardware version of 0.1. |
michael@0 | 351 | */ |
michael@0 | 352 | CK_VERSION (PR_CALLBACK *GetFirmwareVersion)( |
michael@0 | 353 | NSSCKMDSlot *mdSlot, |
michael@0 | 354 | NSSCKFWSlot *fwSlot, |
michael@0 | 355 | NSSCKMDInstance *mdInstance, |
michael@0 | 356 | NSSCKFWInstance *fwInstance |
michael@0 | 357 | ); |
michael@0 | 358 | |
michael@0 | 359 | /* |
michael@0 | 360 | * This routine should return a pointer to an NSSCKMDToken |
michael@0 | 361 | * object corresponding to the token in the specified slot. |
michael@0 | 362 | * The NSSCKFWToken object passed in has an NSSArena |
michael@0 | 363 | * available which is dedicated for this token. This routine |
michael@0 | 364 | * must be implemented. This routine may return NULL upon |
michael@0 | 365 | * error. |
michael@0 | 366 | */ |
michael@0 | 367 | NSSCKMDToken *(PR_CALLBACK *GetToken)( |
michael@0 | 368 | NSSCKMDSlot *mdSlot, |
michael@0 | 369 | NSSCKFWSlot *fwSlot, |
michael@0 | 370 | NSSCKMDInstance *mdInstance, |
michael@0 | 371 | NSSCKFWInstance *fwInstance, |
michael@0 | 372 | CK_RV *pError |
michael@0 | 373 | ); |
michael@0 | 374 | |
michael@0 | 375 | /* |
michael@0 | 376 | * This object may be extended in future versions of the |
michael@0 | 377 | * NSS Cryptoki Framework. To allow for some flexibility |
michael@0 | 378 | * in the area of binary compatibility, this field should |
michael@0 | 379 | * be NULL. |
michael@0 | 380 | */ |
michael@0 | 381 | void *null; |
michael@0 | 382 | }; |
michael@0 | 383 | |
michael@0 | 384 | /* |
michael@0 | 385 | * NSSCKMDToken |
michael@0 | 386 | * |
michael@0 | 387 | * This is the basic handle for a PKCS#11 Token. It is created by |
michael@0 | 388 | * the NSSCKMDSlot->GetToken call, and may be obtained from the |
michael@0 | 389 | * Framework's corresponding NSSCKFWToken object. It contains a |
michael@0 | 390 | * pointer for use by the Module, to store any token-related |
michael@0 | 391 | * data, and it contains the EPV for a set of routines which the |
michael@0 | 392 | * Module may implement for use by the Framework. Some of these |
michael@0 | 393 | * routines are optional. |
michael@0 | 394 | */ |
michael@0 | 395 | |
michael@0 | 396 | struct NSSCKMDTokenStr { |
michael@0 | 397 | /* |
michael@0 | 398 | * The Module may use this pointer for its own purposes. |
michael@0 | 399 | */ |
michael@0 | 400 | void *etc; |
michael@0 | 401 | |
michael@0 | 402 | /* |
michael@0 | 403 | * This routine is used to prepare a Module token object for |
michael@0 | 404 | * use. It is called after the NSSCKMDToken object is obtained |
michael@0 | 405 | * from NSSCKMDSlot->GetToken. It is named "Setup" here because |
michael@0 | 406 | * Cryptoki already defines "InitToken" to do the process of |
michael@0 | 407 | * wiping out any existing state on a token and preparing it for |
michael@0 | 408 | * a new use. This routine is optional; if unimplemented, it |
michael@0 | 409 | * merely won't be called. |
michael@0 | 410 | */ |
michael@0 | 411 | CK_RV (PR_CALLBACK *Setup)( |
michael@0 | 412 | NSSCKMDToken *mdToken, |
michael@0 | 413 | NSSCKFWToken *fwToken, |
michael@0 | 414 | NSSCKMDInstance *mdInstance, |
michael@0 | 415 | NSSCKFWInstance *fwInstance |
michael@0 | 416 | ); |
michael@0 | 417 | |
michael@0 | 418 | /* |
michael@0 | 419 | * This routine is called by the Framework whenever it notices |
michael@0 | 420 | * that the token object is invalid. (Typically this is when a |
michael@0 | 421 | * routine indicates an error such as CKR_DEVICE_REMOVED). This |
michael@0 | 422 | * call is the last thing called before the NSSArena in the |
michael@0 | 423 | * corresponding NSSCKFWToken is destroyed. This routine is |
michael@0 | 424 | * optional; if unimplemented, it merely won't be called. |
michael@0 | 425 | */ |
michael@0 | 426 | void (PR_CALLBACK *Invalidate)( |
michael@0 | 427 | NSSCKMDToken *mdToken, |
michael@0 | 428 | NSSCKFWToken *fwToken, |
michael@0 | 429 | NSSCKMDInstance *mdInstance, |
michael@0 | 430 | NSSCKFWInstance *fwInstance |
michael@0 | 431 | ); |
michael@0 | 432 | |
michael@0 | 433 | /* |
michael@0 | 434 | * This routine initialises the token in the specified slot. |
michael@0 | 435 | * This routine is optional; if unimplemented, the Framework |
michael@0 | 436 | * will fail this operation with an error of CKR_DEVICE_ERROR. |
michael@0 | 437 | */ |
michael@0 | 438 | |
michael@0 | 439 | CK_RV (PR_CALLBACK *InitToken)( |
michael@0 | 440 | NSSCKMDToken *mdToken, |
michael@0 | 441 | NSSCKFWToken *fwToken, |
michael@0 | 442 | NSSCKMDInstance *mdInstance, |
michael@0 | 443 | NSSCKFWInstance *fwInstance, |
michael@0 | 444 | NSSItem *pin, |
michael@0 | 445 | NSSUTF8 *label |
michael@0 | 446 | ); |
michael@0 | 447 | |
michael@0 | 448 | /* |
michael@0 | 449 | * This routine returns a pointer to a UTF8-encoded string |
michael@0 | 450 | * containing this token's label. Only the characters |
michael@0 | 451 | * completely encoded in the first thirty-two bytes are |
michael@0 | 452 | * significant. This routine is optional. The string |
michael@0 | 453 | * returned is never freed; if dynamically generated, |
michael@0 | 454 | * the space for it should be allocated from the NSSArena |
michael@0 | 455 | * that may be obtained from the NSSCKFWInstance. This |
michael@0 | 456 | * routine may return NULL upon error; however if *pError |
michael@0 | 457 | * is CKR_OK, the NULL will be considered the valid response. |
michael@0 | 458 | */ |
michael@0 | 459 | NSSUTF8 *(PR_CALLBACK *GetLabel)( |
michael@0 | 460 | NSSCKMDToken *mdToken, |
michael@0 | 461 | NSSCKFWToken *fwToken, |
michael@0 | 462 | NSSCKMDInstance *mdInstance, |
michael@0 | 463 | NSSCKFWInstance *fwInstance, |
michael@0 | 464 | CK_RV *pError |
michael@0 | 465 | ); |
michael@0 | 466 | |
michael@0 | 467 | /* |
michael@0 | 468 | * This routine returns a pointer to a UTF8-encoded string |
michael@0 | 469 | * containing this token's manufacturer ID. Only the characters |
michael@0 | 470 | * completely encoded in the first thirty-two bytes are |
michael@0 | 471 | * significant. This routine is optional. The string |
michael@0 | 472 | * returned is never freed; if dynamically generated, |
michael@0 | 473 | * the space for it should be allocated from the NSSArena |
michael@0 | 474 | * that may be obtained from the NSSCKFWInstance. This |
michael@0 | 475 | * routine may return NULL upon error; however if *pError |
michael@0 | 476 | * is CKR_OK, the NULL will be considered the valid response. |
michael@0 | 477 | */ |
michael@0 | 478 | NSSUTF8 *(PR_CALLBACK *GetManufacturerID)( |
michael@0 | 479 | NSSCKMDToken *mdToken, |
michael@0 | 480 | NSSCKFWToken *fwToken, |
michael@0 | 481 | NSSCKMDInstance *mdInstance, |
michael@0 | 482 | NSSCKFWInstance *fwInstance, |
michael@0 | 483 | CK_RV *pError |
michael@0 | 484 | ); |
michael@0 | 485 | |
michael@0 | 486 | /* |
michael@0 | 487 | * This routine returns a pointer to a UTF8-encoded string |
michael@0 | 488 | * containing this token's model name. Only the characters |
michael@0 | 489 | * completely encoded in the first thirty-two bytes are |
michael@0 | 490 | * significant. This routine is optional. The string |
michael@0 | 491 | * returned is never freed; if dynamically generated, |
michael@0 | 492 | * the space for it should be allocated from the NSSArena |
michael@0 | 493 | * that may be obtained from the NSSCKFWInstance. This |
michael@0 | 494 | * routine may return NULL upon error; however if *pError |
michael@0 | 495 | * is CKR_OK, the NULL will be considered the valid response. |
michael@0 | 496 | */ |
michael@0 | 497 | NSSUTF8 *(PR_CALLBACK *GetModel)( |
michael@0 | 498 | NSSCKMDToken *mdToken, |
michael@0 | 499 | NSSCKFWToken *fwToken, |
michael@0 | 500 | NSSCKMDInstance *mdInstance, |
michael@0 | 501 | NSSCKFWInstance *fwInstance, |
michael@0 | 502 | CK_RV *pError |
michael@0 | 503 | ); |
michael@0 | 504 | |
michael@0 | 505 | /* |
michael@0 | 506 | * This routine returns a pointer to a UTF8-encoded string |
michael@0 | 507 | * containing this token's serial number. Only the characters |
michael@0 | 508 | * completely encoded in the first thirty-two bytes are |
michael@0 | 509 | * significant. This routine is optional. The string |
michael@0 | 510 | * returned is never freed; if dynamically generated, |
michael@0 | 511 | * the space for it should be allocated from the NSSArena |
michael@0 | 512 | * that may be obtained from the NSSCKFWInstance. This |
michael@0 | 513 | * routine may return NULL upon error; however if *pError |
michael@0 | 514 | * is CKR_OK, the NULL will be considered the valid response. |
michael@0 | 515 | */ |
michael@0 | 516 | NSSUTF8 *(PR_CALLBACK *GetSerialNumber)( |
michael@0 | 517 | NSSCKMDToken *mdToken, |
michael@0 | 518 | NSSCKFWToken *fwToken, |
michael@0 | 519 | NSSCKMDInstance *mdInstance, |
michael@0 | 520 | NSSCKFWInstance *fwInstance, |
michael@0 | 521 | CK_RV *pError |
michael@0 | 522 | ); |
michael@0 | 523 | |
michael@0 | 524 | /* |
michael@0 | 525 | * This routine returns CK_TRUE if the token has its own |
michael@0 | 526 | * random number generator. This routine is optional; if |
michael@0 | 527 | * unimplemented, CK_FALSE is assumed. |
michael@0 | 528 | */ |
michael@0 | 529 | CK_BBOOL (PR_CALLBACK *GetHasRNG)( |
michael@0 | 530 | NSSCKMDToken *mdToken, |
michael@0 | 531 | NSSCKFWToken *fwToken, |
michael@0 | 532 | NSSCKMDInstance *mdInstance, |
michael@0 | 533 | NSSCKFWInstance *fwInstance |
michael@0 | 534 | ); |
michael@0 | 535 | |
michael@0 | 536 | /* |
michael@0 | 537 | * This routine returns CK_TRUE if this token is write-protected. |
michael@0 | 538 | * This routine is optional; if unimplemented, CK_FALSE is |
michael@0 | 539 | * assumed. |
michael@0 | 540 | */ |
michael@0 | 541 | CK_BBOOL (PR_CALLBACK *GetIsWriteProtected)( |
michael@0 | 542 | NSSCKMDToken *mdToken, |
michael@0 | 543 | NSSCKFWToken *fwToken, |
michael@0 | 544 | NSSCKMDInstance *mdInstance, |
michael@0 | 545 | NSSCKFWInstance *fwInstance |
michael@0 | 546 | ); |
michael@0 | 547 | |
michael@0 | 548 | /* |
michael@0 | 549 | * This routine returns CK_TRUE if this token requires a login. |
michael@0 | 550 | * This routine is optional; if unimplemented, CK_FALSE is |
michael@0 | 551 | * assumed. |
michael@0 | 552 | */ |
michael@0 | 553 | CK_BBOOL (PR_CALLBACK *GetLoginRequired)( |
michael@0 | 554 | NSSCKMDToken *mdToken, |
michael@0 | 555 | NSSCKFWToken *fwToken, |
michael@0 | 556 | NSSCKMDInstance *mdInstance, |
michael@0 | 557 | NSSCKFWInstance *fwInstance |
michael@0 | 558 | ); |
michael@0 | 559 | |
michael@0 | 560 | /* |
michael@0 | 561 | * This routine returns CK_TRUE if the normal user's PIN on this |
michael@0 | 562 | * token has been initialised. This routine is optional; if |
michael@0 | 563 | * unimplemented, CK_FALSE is assumed. |
michael@0 | 564 | */ |
michael@0 | 565 | CK_BBOOL (PR_CALLBACK *GetUserPinInitialized)( |
michael@0 | 566 | NSSCKMDToken *mdToken, |
michael@0 | 567 | NSSCKFWToken *fwToken, |
michael@0 | 568 | NSSCKMDInstance *mdInstance, |
michael@0 | 569 | NSSCKFWInstance *fwInstance |
michael@0 | 570 | ); |
michael@0 | 571 | |
michael@0 | 572 | /* |
michael@0 | 573 | * This routine returns CK_TRUE if a successful save of a |
michael@0 | 574 | * session's cryptographic operations state ~always~ contains |
michael@0 | 575 | * all keys needed to restore the state of the session. This |
michael@0 | 576 | * routine is optional; if unimplemented, CK_FALSE is assumed. |
michael@0 | 577 | */ |
michael@0 | 578 | CK_BBOOL (PR_CALLBACK *GetRestoreKeyNotNeeded)( |
michael@0 | 579 | NSSCKMDToken *mdToken, |
michael@0 | 580 | NSSCKFWToken *fwToken, |
michael@0 | 581 | NSSCKMDInstance *mdInstance, |
michael@0 | 582 | NSSCKFWInstance *fwInstance |
michael@0 | 583 | ); |
michael@0 | 584 | |
michael@0 | 585 | /* |
michael@0 | 586 | * This routine returns CK_TRUE if the token has its own |
michael@0 | 587 | * hardware clock. This routine is optional; if unimplemented, |
michael@0 | 588 | * CK_FALSE is assumed. |
michael@0 | 589 | */ |
michael@0 | 590 | CK_BBOOL (PR_CALLBACK *GetHasClockOnToken)( |
michael@0 | 591 | NSSCKMDToken *mdToken, |
michael@0 | 592 | NSSCKFWToken *fwToken, |
michael@0 | 593 | NSSCKMDInstance *mdInstance, |
michael@0 | 594 | NSSCKFWInstance *fwInstance |
michael@0 | 595 | ); |
michael@0 | 596 | |
michael@0 | 597 | /* |
michael@0 | 598 | * This routine returns CK_TRUE if the token has a protected |
michael@0 | 599 | * authentication path. This routine is optional; if |
michael@0 | 600 | * unimplemented, CK_FALSE is assumed. |
michael@0 | 601 | */ |
michael@0 | 602 | CK_BBOOL (PR_CALLBACK *GetHasProtectedAuthenticationPath)( |
michael@0 | 603 | NSSCKMDToken *mdToken, |
michael@0 | 604 | NSSCKFWToken *fwToken, |
michael@0 | 605 | NSSCKMDInstance *mdInstance, |
michael@0 | 606 | NSSCKFWInstance *fwInstance |
michael@0 | 607 | ); |
michael@0 | 608 | |
michael@0 | 609 | /* |
michael@0 | 610 | * This routine returns CK_TRUE if the token supports dual |
michael@0 | 611 | * cryptographic operations within a single session. This |
michael@0 | 612 | * routine is optional; if unimplemented, CK_FALSE is assumed. |
michael@0 | 613 | */ |
michael@0 | 614 | CK_BBOOL (PR_CALLBACK *GetSupportsDualCryptoOperations)( |
michael@0 | 615 | NSSCKMDToken *mdToken, |
michael@0 | 616 | NSSCKFWToken *fwToken, |
michael@0 | 617 | NSSCKMDInstance *mdInstance, |
michael@0 | 618 | NSSCKFWInstance *fwInstance |
michael@0 | 619 | ); |
michael@0 | 620 | |
michael@0 | 621 | /* |
michael@0 | 622 | * XXX fgmr-- should we have a call to return all the flags |
michael@0 | 623 | * at once, for folks who already know about Cryptoki? |
michael@0 | 624 | */ |
michael@0 | 625 | |
michael@0 | 626 | /* |
michael@0 | 627 | * This routine returns the maximum number of sessions that |
michael@0 | 628 | * may be opened on this token. This routine is optional; |
michael@0 | 629 | * if unimplemented, the special value CK_UNAVAILABLE_INFORMATION |
michael@0 | 630 | * is assumed. XXX fgmr-- or CK_EFFECTIVELY_INFINITE? |
michael@0 | 631 | */ |
michael@0 | 632 | CK_ULONG (PR_CALLBACK *GetMaxSessionCount)( |
michael@0 | 633 | NSSCKMDToken *mdToken, |
michael@0 | 634 | NSSCKFWToken *fwToken, |
michael@0 | 635 | NSSCKMDInstance *mdInstance, |
michael@0 | 636 | NSSCKFWInstance *fwInstance |
michael@0 | 637 | ); |
michael@0 | 638 | |
michael@0 | 639 | /* |
michael@0 | 640 | * This routine returns the maximum number of read/write |
michael@0 | 641 | * sesisons that may be opened on this token. This routine |
michael@0 | 642 | * is optional; if unimplemented, the special value |
michael@0 | 643 | * CK_UNAVAILABLE_INFORMATION is assumed. XXX fgmr-- or |
michael@0 | 644 | * CK_EFFECTIVELY_INFINITE? |
michael@0 | 645 | */ |
michael@0 | 646 | CK_ULONG (PR_CALLBACK *GetMaxRwSessionCount)( |
michael@0 | 647 | NSSCKMDToken *mdToken, |
michael@0 | 648 | NSSCKFWToken *fwToken, |
michael@0 | 649 | NSSCKMDInstance *mdInstance, |
michael@0 | 650 | NSSCKFWInstance *fwInstance |
michael@0 | 651 | ); |
michael@0 | 652 | |
michael@0 | 653 | /* |
michael@0 | 654 | * This routine returns the maximum PIN code length that is |
michael@0 | 655 | * supported on this token. This routine is optional; |
michael@0 | 656 | * if unimplemented, the special value CK_UNAVAILABLE_INFORMATION |
michael@0 | 657 | * is assumed. |
michael@0 | 658 | */ |
michael@0 | 659 | CK_ULONG (PR_CALLBACK *GetMaxPinLen)( |
michael@0 | 660 | NSSCKMDToken *mdToken, |
michael@0 | 661 | NSSCKFWToken *fwToken, |
michael@0 | 662 | NSSCKMDInstance *mdInstance, |
michael@0 | 663 | NSSCKFWInstance *fwInstance |
michael@0 | 664 | ); |
michael@0 | 665 | |
michael@0 | 666 | /* |
michael@0 | 667 | * This routine returns the minimum PIN code length that is |
michael@0 | 668 | * supported on this token. This routine is optional; if |
michael@0 | 669 | * unimplemented, the special value CK_UNAVAILABLE_INFORMATION |
michael@0 | 670 | * is assumed. XXX fgmr-- or 0? |
michael@0 | 671 | */ |
michael@0 | 672 | CK_ULONG (PR_CALLBACK *GetMinPinLen)( |
michael@0 | 673 | NSSCKMDToken *mdToken, |
michael@0 | 674 | NSSCKFWToken *fwToken, |
michael@0 | 675 | NSSCKMDInstance *mdInstance, |
michael@0 | 676 | NSSCKFWInstance *fwInstance |
michael@0 | 677 | ); |
michael@0 | 678 | |
michael@0 | 679 | /* |
michael@0 | 680 | * This routine returns the total amount of memory on the token |
michael@0 | 681 | * in which public objects may be stored. This routine is |
michael@0 | 682 | * optional; if unimplemented, the special value |
michael@0 | 683 | * CK_UNAVAILABLE_INFORMATION is assumed. |
michael@0 | 684 | */ |
michael@0 | 685 | CK_ULONG (PR_CALLBACK *GetTotalPublicMemory)( |
michael@0 | 686 | NSSCKMDToken *mdToken, |
michael@0 | 687 | NSSCKFWToken *fwToken, |
michael@0 | 688 | NSSCKMDInstance *mdInstance, |
michael@0 | 689 | NSSCKFWInstance *fwInstance |
michael@0 | 690 | ); |
michael@0 | 691 | |
michael@0 | 692 | /* |
michael@0 | 693 | * This routine returns the amount of unused memory on the |
michael@0 | 694 | * token in which public objects may be stored. This routine |
michael@0 | 695 | * is optional; if unimplemented, the special value |
michael@0 | 696 | * CK_UNAVAILABLE_INFORMATION is assumed. |
michael@0 | 697 | */ |
michael@0 | 698 | CK_ULONG (PR_CALLBACK *GetFreePublicMemory)( |
michael@0 | 699 | NSSCKMDToken *mdToken, |
michael@0 | 700 | NSSCKFWToken *fwToken, |
michael@0 | 701 | NSSCKMDInstance *mdInstance, |
michael@0 | 702 | NSSCKFWInstance *fwInstance |
michael@0 | 703 | ); |
michael@0 | 704 | |
michael@0 | 705 | /* |
michael@0 | 706 | * This routine returns the total amount of memory on the token |
michael@0 | 707 | * in which private objects may be stored. This routine is |
michael@0 | 708 | * optional; if unimplemented, the special value |
michael@0 | 709 | * CK_UNAVAILABLE_INFORMATION is assumed. |
michael@0 | 710 | */ |
michael@0 | 711 | CK_ULONG (PR_CALLBACK *GetTotalPrivateMemory)( |
michael@0 | 712 | NSSCKMDToken *mdToken, |
michael@0 | 713 | NSSCKFWToken *fwToken, |
michael@0 | 714 | NSSCKMDInstance *mdInstance, |
michael@0 | 715 | NSSCKFWInstance *fwInstance |
michael@0 | 716 | ); |
michael@0 | 717 | |
michael@0 | 718 | /* |
michael@0 | 719 | * This routine returns the amount of unused memory on the |
michael@0 | 720 | * token in which private objects may be stored. This routine |
michael@0 | 721 | * is optional; if unimplemented, the special value |
michael@0 | 722 | * CK_UNAVAILABLE_INFORMATION is assumed. |
michael@0 | 723 | */ |
michael@0 | 724 | CK_ULONG (PR_CALLBACK *GetFreePrivateMemory)( |
michael@0 | 725 | NSSCKMDToken *mdToken, |
michael@0 | 726 | NSSCKFWToken *fwToken, |
michael@0 | 727 | NSSCKMDInstance *mdInstance, |
michael@0 | 728 | NSSCKFWInstance *fwInstance |
michael@0 | 729 | ); |
michael@0 | 730 | |
michael@0 | 731 | /* |
michael@0 | 732 | * This routine returns the version number of this token's |
michael@0 | 733 | * hardware. This routine is optional; if unimplemented, |
michael@0 | 734 | * the value 0.1 is assumed. |
michael@0 | 735 | */ |
michael@0 | 736 | CK_VERSION (PR_CALLBACK *GetHardwareVersion)( |
michael@0 | 737 | NSSCKMDToken *mdToken, |
michael@0 | 738 | NSSCKFWToken *fwToken, |
michael@0 | 739 | NSSCKMDInstance *mdInstance, |
michael@0 | 740 | NSSCKFWInstance *fwInstance |
michael@0 | 741 | ); |
michael@0 | 742 | |
michael@0 | 743 | /* |
michael@0 | 744 | * This routine returns the version number of this token's |
michael@0 | 745 | * firmware. This routine is optional; if unimplemented, |
michael@0 | 746 | * the value 0.1 is assumed. |
michael@0 | 747 | */ |
michael@0 | 748 | CK_VERSION (PR_CALLBACK *GetFirmwareVersion)( |
michael@0 | 749 | NSSCKMDToken *mdToken, |
michael@0 | 750 | NSSCKFWToken *fwToken, |
michael@0 | 751 | NSSCKMDInstance *mdInstance, |
michael@0 | 752 | NSSCKFWInstance *fwInstance |
michael@0 | 753 | ); |
michael@0 | 754 | |
michael@0 | 755 | /* |
michael@0 | 756 | * This routine stuffs the current UTC time, as obtained from |
michael@0 | 757 | * the token, into the sixteen-byte buffer in the form |
michael@0 | 758 | * YYYYMMDDhhmmss00. This routine need only be implemented |
michael@0 | 759 | * by token which indicate that they have a real-time clock. |
michael@0 | 760 | * XXX fgmr-- think about time formats. |
michael@0 | 761 | */ |
michael@0 | 762 | CK_RV (PR_CALLBACK *GetUTCTime)( |
michael@0 | 763 | NSSCKMDToken *mdToken, |
michael@0 | 764 | NSSCKFWToken *fwToken, |
michael@0 | 765 | NSSCKMDInstance *mdInstance, |
michael@0 | 766 | NSSCKFWInstance *fwInstance, |
michael@0 | 767 | CK_CHAR utcTime[16] |
michael@0 | 768 | ); |
michael@0 | 769 | |
michael@0 | 770 | /* |
michael@0 | 771 | * This routine creates a session on the token, and returns |
michael@0 | 772 | * the corresponding NSSCKMDSession object. The value of |
michael@0 | 773 | * rw will be CK_TRUE if the session is to be a read/write |
michael@0 | 774 | * session, or CK_FALSE otherwise. An NSSArena dedicated to |
michael@0 | 775 | * the new session is available from the specified NSSCKFWSession. |
michael@0 | 776 | * This routine may return NULL upon error. |
michael@0 | 777 | */ |
michael@0 | 778 | NSSCKMDSession *(PR_CALLBACK *OpenSession)( |
michael@0 | 779 | NSSCKMDToken *mdToken, |
michael@0 | 780 | NSSCKFWToken *fwToken, |
michael@0 | 781 | NSSCKMDInstance *mdInstance, |
michael@0 | 782 | NSSCKFWInstance *fwInstance, |
michael@0 | 783 | NSSCKFWSession *fwSession, |
michael@0 | 784 | CK_BBOOL rw, |
michael@0 | 785 | CK_RV *pError |
michael@0 | 786 | ); |
michael@0 | 787 | |
michael@0 | 788 | /* |
michael@0 | 789 | * This routine returns the number of PKCS#11 Mechanisms |
michael@0 | 790 | * supported by this token. This routine is optional; if |
michael@0 | 791 | * unimplemented, zero is assumed. |
michael@0 | 792 | */ |
michael@0 | 793 | CK_ULONG (PR_CALLBACK *GetMechanismCount)( |
michael@0 | 794 | NSSCKMDToken *mdToken, |
michael@0 | 795 | NSSCKFWToken *fwToken, |
michael@0 | 796 | NSSCKMDInstance *mdInstance, |
michael@0 | 797 | NSSCKFWInstance *fwInstance |
michael@0 | 798 | ); |
michael@0 | 799 | |
michael@0 | 800 | /* |
michael@0 | 801 | * This routine stuffs into the specified array the types |
michael@0 | 802 | * of the mechanisms supported by this token. The Framework |
michael@0 | 803 | * determines the size of the array by calling GetMechanismCount. |
michael@0 | 804 | */ |
michael@0 | 805 | CK_RV (PR_CALLBACK *GetMechanismTypes)( |
michael@0 | 806 | NSSCKMDToken *mdToken, |
michael@0 | 807 | NSSCKFWToken *fwToken, |
michael@0 | 808 | NSSCKMDInstance *mdInstance, |
michael@0 | 809 | NSSCKFWInstance *fwInstance, |
michael@0 | 810 | CK_MECHANISM_TYPE types[] |
michael@0 | 811 | ); |
michael@0 | 812 | |
michael@0 | 813 | /* |
michael@0 | 814 | * This routine returns a pointer to a Module mechanism |
michael@0 | 815 | * object corresponding to a specified type. This routine |
michael@0 | 816 | * need only exist for tokens implementing at least one |
michael@0 | 817 | * mechanism. |
michael@0 | 818 | */ |
michael@0 | 819 | NSSCKMDMechanism *(PR_CALLBACK *GetMechanism)( |
michael@0 | 820 | NSSCKMDToken *mdToken, |
michael@0 | 821 | NSSCKFWToken *fwToken, |
michael@0 | 822 | NSSCKMDInstance *mdInstance, |
michael@0 | 823 | NSSCKFWInstance *fwInstance, |
michael@0 | 824 | CK_MECHANISM_TYPE which, |
michael@0 | 825 | CK_RV *pError |
michael@0 | 826 | ); |
michael@0 | 827 | |
michael@0 | 828 | /* |
michael@0 | 829 | * This object may be extended in future versions of the |
michael@0 | 830 | * NSS Cryptoki Framework. To allow for some flexibility |
michael@0 | 831 | * in the area of binary compatibility, this field should |
michael@0 | 832 | * be NULL. |
michael@0 | 833 | */ |
michael@0 | 834 | void *null; |
michael@0 | 835 | }; |
michael@0 | 836 | |
michael@0 | 837 | /* |
michael@0 | 838 | * NSSCKMDSession |
michael@0 | 839 | * |
michael@0 | 840 | * This is the basic handle for a session on a PKCS#11 Token. It |
michael@0 | 841 | * is created by NSSCKMDToken->OpenSession, and may be obtained |
michael@0 | 842 | * from the Framework's corresponding NSSCKFWSession object. It |
michael@0 | 843 | * contains a pointer for use by the Module, to store any session- |
michael@0 | 844 | * realted data, and it contains the EPV for a set of routines |
michael@0 | 845 | * which the Module may implement for use by the Framework. Some |
michael@0 | 846 | * of these routines are optional. |
michael@0 | 847 | */ |
michael@0 | 848 | |
michael@0 | 849 | struct NSSCKMDSessionStr { |
michael@0 | 850 | /* |
michael@0 | 851 | * The Module may use this pointer for its own purposes. |
michael@0 | 852 | */ |
michael@0 | 853 | void *etc; |
michael@0 | 854 | |
michael@0 | 855 | /* |
michael@0 | 856 | * This routine is called by the Framework when a session is |
michael@0 | 857 | * closed. This call is the last thing called before the |
michael@0 | 858 | * NSSArena in the correspoinding NSSCKFWSession is destroyed. |
michael@0 | 859 | * This routine is optional; if unimplemented, it merely won't |
michael@0 | 860 | * be called. |
michael@0 | 861 | */ |
michael@0 | 862 | void (PR_CALLBACK *Close)( |
michael@0 | 863 | NSSCKMDSession *mdSession, |
michael@0 | 864 | NSSCKFWSession *fwSession, |
michael@0 | 865 | NSSCKMDToken *mdToken, |
michael@0 | 866 | NSSCKFWToken *fwToken, |
michael@0 | 867 | NSSCKMDInstance *mdInstance, |
michael@0 | 868 | NSSCKFWInstance *fwInstance |
michael@0 | 869 | ); |
michael@0 | 870 | |
michael@0 | 871 | /* |
michael@0 | 872 | * This routine is used to get any device-specific error. |
michael@0 | 873 | * This routine is optional. |
michael@0 | 874 | */ |
michael@0 | 875 | CK_ULONG (PR_CALLBACK *GetDeviceError)( |
michael@0 | 876 | NSSCKMDSession *mdSession, |
michael@0 | 877 | NSSCKFWSession *fwSession, |
michael@0 | 878 | NSSCKMDToken *mdToken, |
michael@0 | 879 | NSSCKFWToken *fwToken, |
michael@0 | 880 | NSSCKMDInstance *mdInstance, |
michael@0 | 881 | NSSCKFWInstance *fwInstance |
michael@0 | 882 | ); |
michael@0 | 883 | |
michael@0 | 884 | /* |
michael@0 | 885 | * This routine is used to log in a user to the token. This |
michael@0 | 886 | * routine is optional, since the Framework's NSSCKFWSession |
michael@0 | 887 | * object keeps track of the login state. |
michael@0 | 888 | */ |
michael@0 | 889 | CK_RV (PR_CALLBACK *Login)( |
michael@0 | 890 | NSSCKMDSession *mdSession, |
michael@0 | 891 | NSSCKFWSession *fwSession, |
michael@0 | 892 | NSSCKMDToken *mdToken, |
michael@0 | 893 | NSSCKFWToken *fwToken, |
michael@0 | 894 | NSSCKMDInstance *mdInstance, |
michael@0 | 895 | NSSCKFWInstance *fwInstance, |
michael@0 | 896 | CK_USER_TYPE userType, |
michael@0 | 897 | NSSItem *pin, |
michael@0 | 898 | CK_STATE oldState, |
michael@0 | 899 | CK_STATE newState |
michael@0 | 900 | ); |
michael@0 | 901 | |
michael@0 | 902 | /* |
michael@0 | 903 | * This routine is used to log out a user from the token. This |
michael@0 | 904 | * routine is optional, since the Framework's NSSCKFWSession |
michael@0 | 905 | * object keeps track of the login state. |
michael@0 | 906 | */ |
michael@0 | 907 | CK_RV (PR_CALLBACK *Logout)( |
michael@0 | 908 | NSSCKMDSession *mdSession, |
michael@0 | 909 | NSSCKFWSession *fwSession, |
michael@0 | 910 | NSSCKMDToken *mdToken, |
michael@0 | 911 | NSSCKFWToken *fwToken, |
michael@0 | 912 | NSSCKMDInstance *mdInstance, |
michael@0 | 913 | NSSCKFWInstance *fwInstance, |
michael@0 | 914 | CK_STATE oldState, |
michael@0 | 915 | CK_STATE newState |
michael@0 | 916 | ); |
michael@0 | 917 | |
michael@0 | 918 | /* |
michael@0 | 919 | * This routine is used to initialize the normal user's PIN or |
michael@0 | 920 | * password. This will only be called in the "read/write |
michael@0 | 921 | * security officer functions" state. If this token has a |
michael@0 | 922 | * protected authentication path, then the pin argument will |
michael@0 | 923 | * be NULL. This routine is optional; if unimplemented, the |
michael@0 | 924 | * Framework will return the error CKR_TOKEN_WRITE_PROTECTED. |
michael@0 | 925 | */ |
michael@0 | 926 | CK_RV (PR_CALLBACK *InitPIN)( |
michael@0 | 927 | NSSCKMDSession *mdSession, |
michael@0 | 928 | NSSCKFWSession *fwSession, |
michael@0 | 929 | NSSCKMDToken *mdToken, |
michael@0 | 930 | NSSCKFWToken *fwToken, |
michael@0 | 931 | NSSCKMDInstance *mdInstance, |
michael@0 | 932 | NSSCKFWInstance *fwInstance, |
michael@0 | 933 | NSSItem *pin |
michael@0 | 934 | ); |
michael@0 | 935 | |
michael@0 | 936 | /* |
michael@0 | 937 | * This routine is used to modify a user's PIN or password. This |
michael@0 | 938 | * routine will only be called in the "read/write security officer |
michael@0 | 939 | * functions" or "read/write user functions" state. If this token |
michael@0 | 940 | * has a protected authentication path, then the pin arguments |
michael@0 | 941 | * will be NULL. This routine is optional; if unimplemented, the |
michael@0 | 942 | * Framework will return the error CKR_TOKEN_WRITE_PROTECTED. |
michael@0 | 943 | */ |
michael@0 | 944 | CK_RV (PR_CALLBACK *SetPIN)( |
michael@0 | 945 | NSSCKMDSession *mdSession, |
michael@0 | 946 | NSSCKFWSession *fwSession, |
michael@0 | 947 | NSSCKMDToken *mdToken, |
michael@0 | 948 | NSSCKFWToken *fwToken, |
michael@0 | 949 | NSSCKMDInstance *mdInstance, |
michael@0 | 950 | NSSCKFWInstance *fwInstance, |
michael@0 | 951 | NSSItem *oldPin, |
michael@0 | 952 | NSSItem *newPin |
michael@0 | 953 | ); |
michael@0 | 954 | |
michael@0 | 955 | /* |
michael@0 | 956 | * This routine is used to find out how much space would be required |
michael@0 | 957 | * to save the current operational state. This routine is optional; |
michael@0 | 958 | * if unimplemented, the Framework will reject any attempts to save |
michael@0 | 959 | * the operational state with the error CKR_STATE_UNSAVEABLE. This |
michael@0 | 960 | * routine may return zero on error. |
michael@0 | 961 | */ |
michael@0 | 962 | CK_ULONG (PR_CALLBACK *GetOperationStateLen)( |
michael@0 | 963 | NSSCKMDSession *mdSession, |
michael@0 | 964 | NSSCKFWSession *fwSession, |
michael@0 | 965 | NSSCKMDToken *mdToken, |
michael@0 | 966 | NSSCKFWToken *fwToken, |
michael@0 | 967 | NSSCKMDInstance *mdInstance, |
michael@0 | 968 | NSSCKFWInstance *fwInstance, |
michael@0 | 969 | CK_RV *pError |
michael@0 | 970 | ); |
michael@0 | 971 | |
michael@0 | 972 | /* |
michael@0 | 973 | * This routine is used to store the current operational state. This |
michael@0 | 974 | * routine is only required if GetOperationStateLen is implemented |
michael@0 | 975 | * and can return a nonzero value. The buffer in the specified item |
michael@0 | 976 | * will be pre-allocated, and the length will specify the amount of |
michael@0 | 977 | * space available (which may be more than GetOperationStateLen |
michael@0 | 978 | * asked for, but which will not be smaller). |
michael@0 | 979 | */ |
michael@0 | 980 | CK_RV (PR_CALLBACK *GetOperationState)( |
michael@0 | 981 | NSSCKMDSession *mdSession, |
michael@0 | 982 | NSSCKFWSession *fwSession, |
michael@0 | 983 | NSSCKMDToken *mdToken, |
michael@0 | 984 | NSSCKFWToken *fwToken, |
michael@0 | 985 | NSSCKMDInstance *mdInstance, |
michael@0 | 986 | NSSCKFWInstance *fwInstance, |
michael@0 | 987 | NSSItem *buffer |
michael@0 | 988 | ); |
michael@0 | 989 | |
michael@0 | 990 | /* |
michael@0 | 991 | * This routine is used to restore an operational state previously |
michael@0 | 992 | * obtained with GetOperationState. The Framework will take pains |
michael@0 | 993 | * to be sure that the state is (or was at one point) valid; if the |
michael@0 | 994 | * Module notices that the state is invalid, it should return an |
michael@0 | 995 | * error, but it is not required to be paranoid about the issue. |
michael@0 | 996 | * [XXX fgmr-- should (can?) the framework verify the keys match up?] |
michael@0 | 997 | * This routine is required only if GetOperationState is implemented. |
michael@0 | 998 | */ |
michael@0 | 999 | CK_RV (PR_CALLBACK *SetOperationState)( |
michael@0 | 1000 | NSSCKMDSession *mdSession, |
michael@0 | 1001 | NSSCKFWSession *fwSession, |
michael@0 | 1002 | NSSCKMDToken *mdToken, |
michael@0 | 1003 | NSSCKFWToken *fwToken, |
michael@0 | 1004 | NSSCKMDInstance *mdInstance, |
michael@0 | 1005 | NSSCKFWInstance *fwInstance, |
michael@0 | 1006 | NSSItem *state, |
michael@0 | 1007 | NSSCKMDObject *mdEncryptionKey, |
michael@0 | 1008 | NSSCKFWObject *fwEncryptionKey, |
michael@0 | 1009 | NSSCKMDObject *mdAuthenticationKey, |
michael@0 | 1010 | NSSCKFWObject *fwAuthenticationKey |
michael@0 | 1011 | ); |
michael@0 | 1012 | |
michael@0 | 1013 | /* |
michael@0 | 1014 | * This routine is used to create an object. The specified template |
michael@0 | 1015 | * will only specify a session object if the Module has indicated |
michael@0 | 1016 | * that it wishes to handle its own session objects. This routine |
michael@0 | 1017 | * is optional; if unimplemented, the Framework will reject the |
michael@0 | 1018 | * operation with the error CKR_TOKEN_WRITE_PROTECTED. Space for |
michael@0 | 1019 | * token objects should come from the NSSArena available from the |
michael@0 | 1020 | * NSSCKFWToken object; space for session objects (if supported) |
michael@0 | 1021 | * should come from the NSSArena available from the NSSCKFWSession |
michael@0 | 1022 | * object. The appropriate NSSArena pointer will, as a convenience, |
michael@0 | 1023 | * be passed as the handyArenaPointer argument. This routine may |
michael@0 | 1024 | * return NULL upon error. |
michael@0 | 1025 | */ |
michael@0 | 1026 | NSSCKMDObject *(PR_CALLBACK *CreateObject)( |
michael@0 | 1027 | NSSCKMDSession *mdSession, |
michael@0 | 1028 | NSSCKFWSession *fwSession, |
michael@0 | 1029 | NSSCKMDToken *mdToken, |
michael@0 | 1030 | NSSCKFWToken *fwToken, |
michael@0 | 1031 | NSSCKMDInstance *mdInstance, |
michael@0 | 1032 | NSSCKFWInstance *fwInstance, |
michael@0 | 1033 | NSSArena *handyArenaPointer, |
michael@0 | 1034 | CK_ATTRIBUTE_PTR pTemplate, |
michael@0 | 1035 | CK_ULONG ulAttributeCount, |
michael@0 | 1036 | CK_RV *pError |
michael@0 | 1037 | ); |
michael@0 | 1038 | |
michael@0 | 1039 | /* |
michael@0 | 1040 | * This routine is used to make a copy of an object. It is entirely |
michael@0 | 1041 | * optional; if unimplemented, the Framework will try to use |
michael@0 | 1042 | * CreateObject instead. If the Module has indicated that it does |
michael@0 | 1043 | * not wish to handle session objects, then this routine will only |
michael@0 | 1044 | * be called to copy a token object to another token object. |
michael@0 | 1045 | * Otherwise, either the original object or the new may be of |
michael@0 | 1046 | * either the token or session variety. As with CreateObject, the |
michael@0 | 1047 | * handyArenaPointer will point to the appropriate arena for the |
michael@0 | 1048 | * new object. This routine may return NULL upon error. |
michael@0 | 1049 | */ |
michael@0 | 1050 | NSSCKMDObject *(PR_CALLBACK *CopyObject)( |
michael@0 | 1051 | NSSCKMDSession *mdSession, |
michael@0 | 1052 | NSSCKFWSession *fwSession, |
michael@0 | 1053 | NSSCKMDToken *mdToken, |
michael@0 | 1054 | NSSCKFWToken *fwToken, |
michael@0 | 1055 | NSSCKMDInstance *mdInstance, |
michael@0 | 1056 | NSSCKFWInstance *fwInstance, |
michael@0 | 1057 | NSSCKMDObject *mdOldObject, |
michael@0 | 1058 | NSSCKFWObject *fwOldObject, |
michael@0 | 1059 | NSSArena *handyArenaPointer, |
michael@0 | 1060 | CK_ATTRIBUTE_PTR pTemplate, |
michael@0 | 1061 | CK_ULONG ulAttributeCount, |
michael@0 | 1062 | CK_RV *pError |
michael@0 | 1063 | ); |
michael@0 | 1064 | |
michael@0 | 1065 | /* |
michael@0 | 1066 | * This routine is used to begin an object search. This routine may |
michael@0 | 1067 | * be unimplemented only if the Module does not handle session |
michael@0 | 1068 | * objects, and if none of its tokens have token objects. The |
michael@0 | 1069 | * NSSCKFWFindObjects pointer has an NSSArena that may be used for |
michael@0 | 1070 | * storage for the life of this "find" operation. This routine may |
michael@0 | 1071 | * return NULL upon error. If the Module can determine immediately |
michael@0 | 1072 | * that the search will not find any matching objects, it may return |
michael@0 | 1073 | * NULL, and specify CKR_OK as the error. |
michael@0 | 1074 | */ |
michael@0 | 1075 | NSSCKMDFindObjects *(PR_CALLBACK *FindObjectsInit)( |
michael@0 | 1076 | NSSCKMDSession *mdSession, |
michael@0 | 1077 | NSSCKFWSession *fwSession, |
michael@0 | 1078 | NSSCKMDToken *mdToken, |
michael@0 | 1079 | NSSCKFWToken *fwToken, |
michael@0 | 1080 | NSSCKMDInstance *mdInstance, |
michael@0 | 1081 | NSSCKFWInstance *fwInstance, |
michael@0 | 1082 | CK_ATTRIBUTE_PTR pTemplate, |
michael@0 | 1083 | CK_ULONG ulAttributeCount, |
michael@0 | 1084 | CK_RV *pError |
michael@0 | 1085 | ); |
michael@0 | 1086 | |
michael@0 | 1087 | /* |
michael@0 | 1088 | * This routine seeds the random-number generator. It is |
michael@0 | 1089 | * optional, even if GetRandom is implemented. If unimplemented, |
michael@0 | 1090 | * the Framework will issue the error CKR_RANDOM_SEED_NOT_SUPPORTED. |
michael@0 | 1091 | */ |
michael@0 | 1092 | CK_RV (PR_CALLBACK *SeedRandom)( |
michael@0 | 1093 | NSSCKMDSession *mdSession, |
michael@0 | 1094 | NSSCKFWSession *fwSession, |
michael@0 | 1095 | NSSCKMDToken *mdToken, |
michael@0 | 1096 | NSSCKFWToken *fwToken, |
michael@0 | 1097 | NSSCKMDInstance *mdInstance, |
michael@0 | 1098 | NSSCKFWInstance *fwInstance, |
michael@0 | 1099 | NSSItem *seed |
michael@0 | 1100 | ); |
michael@0 | 1101 | |
michael@0 | 1102 | /* |
michael@0 | 1103 | * This routine gets random data. It is optional. If unimplemented, |
michael@0 | 1104 | * the Framework will issue the error CKR_RANDOM_NO_RNG. |
michael@0 | 1105 | */ |
michael@0 | 1106 | CK_RV (PR_CALLBACK *GetRandom)( |
michael@0 | 1107 | NSSCKMDSession *mdSession, |
michael@0 | 1108 | NSSCKFWSession *fwSession, |
michael@0 | 1109 | NSSCKMDToken *mdToken, |
michael@0 | 1110 | NSSCKFWToken *fwToken, |
michael@0 | 1111 | NSSCKMDInstance *mdInstance, |
michael@0 | 1112 | NSSCKFWInstance *fwInstance, |
michael@0 | 1113 | NSSItem *buffer |
michael@0 | 1114 | ); |
michael@0 | 1115 | |
michael@0 | 1116 | /* |
michael@0 | 1117 | * This object may be extended in future versions of the |
michael@0 | 1118 | * NSS Cryptoki Framework. To allow for some flexibility |
michael@0 | 1119 | * in the area of binary compatibility, this field should |
michael@0 | 1120 | * be NULL. |
michael@0 | 1121 | */ |
michael@0 | 1122 | void *null; |
michael@0 | 1123 | }; |
michael@0 | 1124 | |
michael@0 | 1125 | /* |
michael@0 | 1126 | * NSSCKMDFindObjects |
michael@0 | 1127 | * |
michael@0 | 1128 | * This is the basic handle for an object search. It is |
michael@0 | 1129 | * created by NSSCKMDSession->FindObjectsInit, and may be |
michael@0 | 1130 | * obtained from the Framework's corresponding object. |
michael@0 | 1131 | * It contains a pointer for use by the Module, to store |
michael@0 | 1132 | * any search-related data, and it contains the EPV for a |
michael@0 | 1133 | * set of routines which the Module may implement for use |
michael@0 | 1134 | * by the Framework. Some of these routines are optional. |
michael@0 | 1135 | */ |
michael@0 | 1136 | |
michael@0 | 1137 | struct NSSCKMDFindObjectsStr { |
michael@0 | 1138 | /* |
michael@0 | 1139 | * The Module may use this pointer for its own purposes. |
michael@0 | 1140 | */ |
michael@0 | 1141 | void *etc; |
michael@0 | 1142 | |
michael@0 | 1143 | /* |
michael@0 | 1144 | * This routine is called by the Framework to finish a |
michael@0 | 1145 | * search operation. Note that the Framework may finish |
michael@0 | 1146 | * a search before it has completed. This routine is |
michael@0 | 1147 | * optional; if unimplemented, it merely won't be called. |
michael@0 | 1148 | */ |
michael@0 | 1149 | void (PR_CALLBACK *Final)( |
michael@0 | 1150 | NSSCKMDFindObjects *mdFindObjects, |
michael@0 | 1151 | NSSCKFWFindObjects *fwFindObjects, |
michael@0 | 1152 | NSSCKMDSession *mdSession, |
michael@0 | 1153 | NSSCKFWSession *fwSession, |
michael@0 | 1154 | NSSCKMDToken *mdToken, |
michael@0 | 1155 | NSSCKFWToken *fwToken, |
michael@0 | 1156 | NSSCKMDInstance *mdInstance, |
michael@0 | 1157 | NSSCKFWInstance *fwInstance |
michael@0 | 1158 | ); |
michael@0 | 1159 | |
michael@0 | 1160 | /* |
michael@0 | 1161 | * This routine is used to obtain another pointer to an |
michael@0 | 1162 | * object matching the search criteria. This routine is |
michael@0 | 1163 | * required. If no (more) objects match the search, it |
michael@0 | 1164 | * should return NULL and set the error to CKR_OK. |
michael@0 | 1165 | */ |
michael@0 | 1166 | NSSCKMDObject *(PR_CALLBACK *Next)( |
michael@0 | 1167 | NSSCKMDFindObjects *mdFindObjects, |
michael@0 | 1168 | NSSCKFWFindObjects *fwFindObjects, |
michael@0 | 1169 | NSSCKMDSession *mdSession, |
michael@0 | 1170 | NSSCKFWSession *fwSession, |
michael@0 | 1171 | NSSCKMDToken *mdToken, |
michael@0 | 1172 | NSSCKFWToken *fwToken, |
michael@0 | 1173 | NSSCKMDInstance *mdInstance, |
michael@0 | 1174 | NSSCKFWInstance *fwInstance, |
michael@0 | 1175 | NSSArena *arena, |
michael@0 | 1176 | CK_RV *pError |
michael@0 | 1177 | ); |
michael@0 | 1178 | |
michael@0 | 1179 | /* |
michael@0 | 1180 | * This object may be extended in future versions of the |
michael@0 | 1181 | * NSS Cryptoki Framework. To allow for some flexibility |
michael@0 | 1182 | * in the area of binary compatibility, this field should |
michael@0 | 1183 | * be NULL. |
michael@0 | 1184 | */ |
michael@0 | 1185 | void *null; |
michael@0 | 1186 | }; |
michael@0 | 1187 | |
michael@0 | 1188 | /* |
michael@0 | 1189 | * NSSCKMDCryptoOperaion |
michael@0 | 1190 | * |
michael@0 | 1191 | * This is the basic handle for an encryption, decryption, |
michael@0 | 1192 | * sign, verify, or hash opertion. |
michael@0 | 1193 | * created by NSSCKMDMechanism->XXXXInit, and may be |
michael@0 | 1194 | * obtained from the Framework's corresponding object. |
michael@0 | 1195 | * It contains a pointer for use by the Module, to store |
michael@0 | 1196 | * any intermediate data, and it contains the EPV for a |
michael@0 | 1197 | * set of routines which the Module may implement for use |
michael@0 | 1198 | * by the Framework. Some of these routines are optional. |
michael@0 | 1199 | */ |
michael@0 | 1200 | |
michael@0 | 1201 | struct NSSCKMDCryptoOperationStr { |
michael@0 | 1202 | /* |
michael@0 | 1203 | * The Module may use this pointer for its own purposes. |
michael@0 | 1204 | */ |
michael@0 | 1205 | void *etc; |
michael@0 | 1206 | |
michael@0 | 1207 | /* |
michael@0 | 1208 | * This routine is called by the Framework clean up the mdCryptoOperation |
michael@0 | 1209 | * structure. |
michael@0 | 1210 | * This routine is optional; if unimplemented, it will be ignored. |
michael@0 | 1211 | */ |
michael@0 | 1212 | void (PR_CALLBACK *Destroy)( |
michael@0 | 1213 | NSSCKMDCryptoOperation *mdCryptoOperation, |
michael@0 | 1214 | NSSCKFWCryptoOperation *fwCryptoOperation, |
michael@0 | 1215 | NSSCKMDInstance *mdInstance, |
michael@0 | 1216 | NSSCKFWInstance *fwInstance |
michael@0 | 1217 | ); |
michael@0 | 1218 | |
michael@0 | 1219 | |
michael@0 | 1220 | /* |
michael@0 | 1221 | * how many bytes do we need to finish this buffer? |
michael@0 | 1222 | * must be implemented if Final is implemented. |
michael@0 | 1223 | */ |
michael@0 | 1224 | CK_ULONG (PR_CALLBACK *GetFinalLength)( |
michael@0 | 1225 | NSSCKMDCryptoOperation *mdCryptoOperation, |
michael@0 | 1226 | NSSCKFWCryptoOperation *fwCryptoOperation, |
michael@0 | 1227 | NSSCKMDSession *mdSession, |
michael@0 | 1228 | NSSCKFWSession *fwSession, |
michael@0 | 1229 | NSSCKMDToken *mdToken, |
michael@0 | 1230 | NSSCKFWToken *fwToken, |
michael@0 | 1231 | NSSCKMDInstance *mdInstance, |
michael@0 | 1232 | NSSCKFWInstance *fwInstance, |
michael@0 | 1233 | CK_RV *pError |
michael@0 | 1234 | ); |
michael@0 | 1235 | |
michael@0 | 1236 | /* |
michael@0 | 1237 | * how many bytes do we need to complete the next operation. |
michael@0 | 1238 | * used in both Update and UpdateFinal. |
michael@0 | 1239 | */ |
michael@0 | 1240 | CK_ULONG (PR_CALLBACK *GetOperationLength)( |
michael@0 | 1241 | NSSCKMDCryptoOperation *mdCryptoOperation, |
michael@0 | 1242 | NSSCKFWCryptoOperation *fwCryptoOperation, |
michael@0 | 1243 | NSSCKMDSession *mdSession, |
michael@0 | 1244 | NSSCKFWSession *fwSession, |
michael@0 | 1245 | NSSCKMDToken *mdToken, |
michael@0 | 1246 | NSSCKFWToken *fwToken, |
michael@0 | 1247 | NSSCKMDInstance *mdInstance, |
michael@0 | 1248 | NSSCKFWInstance *fwInstance, |
michael@0 | 1249 | const NSSItem *inputBuffer, |
michael@0 | 1250 | CK_RV *pError |
michael@0 | 1251 | ); |
michael@0 | 1252 | |
michael@0 | 1253 | /* |
michael@0 | 1254 | * This routine is called by the Framework to finish a |
michael@0 | 1255 | * search operation. Note that the Framework may finish |
michael@0 | 1256 | * a search before it has completed. This routine is |
michael@0 | 1257 | * optional; if unimplemented, it merely won't be called. |
michael@0 | 1258 | * The respective final call with fail with CKR_FUNCTION_FAILED |
michael@0 | 1259 | * Final should not free the mdCryptoOperation. |
michael@0 | 1260 | */ |
michael@0 | 1261 | CK_RV(PR_CALLBACK *Final)( |
michael@0 | 1262 | NSSCKMDCryptoOperation *mdCryptoOperation, |
michael@0 | 1263 | NSSCKFWCryptoOperation *fwCryptoOperation, |
michael@0 | 1264 | NSSCKMDSession *mdSession, |
michael@0 | 1265 | NSSCKFWSession *fwSession, |
michael@0 | 1266 | NSSCKMDToken *mdToken, |
michael@0 | 1267 | NSSCKFWToken *fwToken, |
michael@0 | 1268 | NSSCKMDInstance *mdInstance, |
michael@0 | 1269 | NSSCKFWInstance *fwInstance, |
michael@0 | 1270 | NSSItem *outputBuffer |
michael@0 | 1271 | ); |
michael@0 | 1272 | |
michael@0 | 1273 | |
michael@0 | 1274 | /* |
michael@0 | 1275 | * This routine is called by the Framework to complete the |
michael@0 | 1276 | * next step in an encryption/decryption operation. |
michael@0 | 1277 | * This routine is optional; if unimplemented, the respective |
michael@0 | 1278 | * update call with fail with CKR_FUNCTION_FAILED. |
michael@0 | 1279 | * Update should not be implemented for signing/verification/digest |
michael@0 | 1280 | * mechanisms. |
michael@0 | 1281 | */ |
michael@0 | 1282 | CK_RV(PR_CALLBACK *Update)( |
michael@0 | 1283 | NSSCKMDCryptoOperation *mdCryptoOperation, |
michael@0 | 1284 | NSSCKFWCryptoOperation *fwCryptoOperation, |
michael@0 | 1285 | NSSCKMDSession *mdSession, |
michael@0 | 1286 | NSSCKFWSession *fwSession, |
michael@0 | 1287 | NSSCKMDToken *mdToken, |
michael@0 | 1288 | NSSCKFWToken *fwToken, |
michael@0 | 1289 | NSSCKMDInstance *mdInstance, |
michael@0 | 1290 | NSSCKFWInstance *fwInstance, |
michael@0 | 1291 | const NSSItem *inputBuffer, |
michael@0 | 1292 | NSSItem *outputBuffer |
michael@0 | 1293 | ); |
michael@0 | 1294 | |
michael@0 | 1295 | /* |
michael@0 | 1296 | * This routine is called by the Framework to complete the |
michael@0 | 1297 | * next step in a signing/verification/digest operation. |
michael@0 | 1298 | * This routine is optional; if unimplemented, the respective |
michael@0 | 1299 | * update call with fail with CKR_FUNCTION_FAILED |
michael@0 | 1300 | * Update should not be implemented for encryption/decryption |
michael@0 | 1301 | * mechanisms. |
michael@0 | 1302 | */ |
michael@0 | 1303 | CK_RV(PR_CALLBACK *DigestUpdate)( |
michael@0 | 1304 | NSSCKMDCryptoOperation *mdCryptoOperation, |
michael@0 | 1305 | NSSCKFWCryptoOperation *fwCryptoOperation, |
michael@0 | 1306 | NSSCKMDSession *mdSession, |
michael@0 | 1307 | NSSCKFWSession *fwSession, |
michael@0 | 1308 | NSSCKMDToken *mdToken, |
michael@0 | 1309 | NSSCKFWToken *fwToken, |
michael@0 | 1310 | NSSCKMDInstance *mdInstance, |
michael@0 | 1311 | NSSCKFWInstance *fwInstance, |
michael@0 | 1312 | const NSSItem *inputBuffer |
michael@0 | 1313 | ); |
michael@0 | 1314 | |
michael@0 | 1315 | /* |
michael@0 | 1316 | * This routine is called by the Framework to complete a |
michael@0 | 1317 | * single step operation. This routine is optional; if unimplemented, |
michael@0 | 1318 | * the framework will use the Update and Final functions to complete |
michael@0 | 1319 | * the operation. |
michael@0 | 1320 | */ |
michael@0 | 1321 | CK_RV(PR_CALLBACK *UpdateFinal)( |
michael@0 | 1322 | NSSCKMDCryptoOperation *mdCryptoOperation, |
michael@0 | 1323 | NSSCKFWCryptoOperation *fwCryptoOperation, |
michael@0 | 1324 | NSSCKMDSession *mdSession, |
michael@0 | 1325 | NSSCKFWSession *fwSession, |
michael@0 | 1326 | NSSCKMDToken *mdToken, |
michael@0 | 1327 | NSSCKFWToken *fwToken, |
michael@0 | 1328 | NSSCKMDInstance *mdInstance, |
michael@0 | 1329 | NSSCKFWInstance *fwInstance, |
michael@0 | 1330 | const NSSItem *inputBuffer, |
michael@0 | 1331 | NSSItem *outputBuffer |
michael@0 | 1332 | ); |
michael@0 | 1333 | |
michael@0 | 1334 | /* |
michael@0 | 1335 | * This routine is called by the Framework to complete next |
michael@0 | 1336 | * step in a combined operation. The Decrypt/Encrypt mechanism |
michael@0 | 1337 | * should define and drive the combo step. |
michael@0 | 1338 | * This routine is optional; if unimplemented, |
michael@0 | 1339 | * the framework will use the appropriate Update functions to complete |
michael@0 | 1340 | * the operation. |
michael@0 | 1341 | */ |
michael@0 | 1342 | CK_RV(PR_CALLBACK *UpdateCombo)( |
michael@0 | 1343 | NSSCKMDCryptoOperation *mdCryptoOperation, |
michael@0 | 1344 | NSSCKFWCryptoOperation *fwCryptoOperation, |
michael@0 | 1345 | NSSCKMDCryptoOperation *mdPeerCryptoOperation, |
michael@0 | 1346 | NSSCKFWCryptoOperation *fwPeerCryptoOperation, |
michael@0 | 1347 | NSSCKMDSession *mdSession, |
michael@0 | 1348 | NSSCKFWSession *fwSession, |
michael@0 | 1349 | NSSCKMDToken *mdToken, |
michael@0 | 1350 | NSSCKFWToken *fwToken, |
michael@0 | 1351 | NSSCKMDInstance *mdInstance, |
michael@0 | 1352 | NSSCKFWInstance *fwInstance, |
michael@0 | 1353 | const NSSItem *inputBuffer, |
michael@0 | 1354 | NSSItem *outputBuffer |
michael@0 | 1355 | ); |
michael@0 | 1356 | |
michael@0 | 1357 | /* |
michael@0 | 1358 | * Hash a key directly into the digest |
michael@0 | 1359 | */ |
michael@0 | 1360 | CK_RV(PR_CALLBACK *DigestKey)( |
michael@0 | 1361 | NSSCKMDCryptoOperation *mdCryptoOperation, |
michael@0 | 1362 | NSSCKFWCryptoOperation *fwCryptoOperation, |
michael@0 | 1363 | NSSCKMDToken *mdToken, |
michael@0 | 1364 | NSSCKFWToken *fwToken, |
michael@0 | 1365 | NSSCKMDInstance *mdInstance, |
michael@0 | 1366 | NSSCKFWInstance *fwInstance, |
michael@0 | 1367 | NSSCKMDObject *mdKey, |
michael@0 | 1368 | NSSCKFWObject *fwKey |
michael@0 | 1369 | ); |
michael@0 | 1370 | |
michael@0 | 1371 | /* |
michael@0 | 1372 | * This object may be extended in future versions of the |
michael@0 | 1373 | * NSS Cryptoki Framework. To allow for some flexibility |
michael@0 | 1374 | * in the area of binary compatibility, this field should |
michael@0 | 1375 | * be NULL. |
michael@0 | 1376 | */ |
michael@0 | 1377 | void *null; |
michael@0 | 1378 | }; |
michael@0 | 1379 | |
michael@0 | 1380 | /* |
michael@0 | 1381 | * NSSCKMDMechanism |
michael@0 | 1382 | * |
michael@0 | 1383 | */ |
michael@0 | 1384 | |
michael@0 | 1385 | struct NSSCKMDMechanismStr { |
michael@0 | 1386 | /* |
michael@0 | 1387 | * The Module may use this pointer for its own purposes. |
michael@0 | 1388 | */ |
michael@0 | 1389 | void *etc; |
michael@0 | 1390 | |
michael@0 | 1391 | /* |
michael@0 | 1392 | * This also frees the fwMechanism if appropriate. |
michael@0 | 1393 | * If it is not supplied, the Framework will assume that the Token |
michael@0 | 1394 | * Manages a static list of mechanisms and the function will not be called. |
michael@0 | 1395 | */ |
michael@0 | 1396 | void (PR_CALLBACK *Destroy)( |
michael@0 | 1397 | NSSCKMDMechanism *mdMechanism, |
michael@0 | 1398 | NSSCKFWMechanism *fwMechanism, |
michael@0 | 1399 | NSSCKMDInstance *mdInstance, |
michael@0 | 1400 | NSSCKFWInstance *fwInstance |
michael@0 | 1401 | ); |
michael@0 | 1402 | |
michael@0 | 1403 | |
michael@0 | 1404 | /* |
michael@0 | 1405 | * This routine returns the minimum key size allowed for |
michael@0 | 1406 | * this mechanism. This routine is optional; if unimplemented, |
michael@0 | 1407 | * zero will be assumed. This routine may return zero on |
michael@0 | 1408 | * error; if the error is CKR_OK, zero will be accepted as |
michael@0 | 1409 | * a valid response. |
michael@0 | 1410 | */ |
michael@0 | 1411 | CK_ULONG (PR_CALLBACK *GetMinKeySize)( |
michael@0 | 1412 | NSSCKMDMechanism *mdMechanism, |
michael@0 | 1413 | NSSCKFWMechanism *fwMechanism, |
michael@0 | 1414 | NSSCKMDToken *mdToken, |
michael@0 | 1415 | NSSCKFWToken *fwToken, |
michael@0 | 1416 | NSSCKMDInstance *mdInstance, |
michael@0 | 1417 | NSSCKFWInstance *fwInstance, |
michael@0 | 1418 | CK_RV *pError |
michael@0 | 1419 | ); |
michael@0 | 1420 | |
michael@0 | 1421 | /* |
michael@0 | 1422 | * This routine returns the maximum key size allowed for |
michael@0 | 1423 | * this mechanism. This routine is optional; if unimplemented, |
michael@0 | 1424 | * zero will be assumed. This routine may return zero on |
michael@0 | 1425 | * error; if the error is CKR_OK, zero will be accepted as |
michael@0 | 1426 | * a valid response. |
michael@0 | 1427 | */ |
michael@0 | 1428 | CK_ULONG (PR_CALLBACK *GetMaxKeySize)( |
michael@0 | 1429 | NSSCKMDMechanism *mdMechanism, |
michael@0 | 1430 | NSSCKFWMechanism *fwMechanism, |
michael@0 | 1431 | NSSCKMDToken *mdToken, |
michael@0 | 1432 | NSSCKFWToken *fwToken, |
michael@0 | 1433 | NSSCKMDInstance *mdInstance, |
michael@0 | 1434 | NSSCKFWInstance *fwInstance, |
michael@0 | 1435 | CK_RV *pError |
michael@0 | 1436 | ); |
michael@0 | 1437 | |
michael@0 | 1438 | /* |
michael@0 | 1439 | * This routine is called to determine if the mechanism is |
michael@0 | 1440 | * implemented in hardware or software. It returns CK_TRUE |
michael@0 | 1441 | * if it is done in hardware. |
michael@0 | 1442 | */ |
michael@0 | 1443 | CK_BBOOL (PR_CALLBACK *GetInHardware)( |
michael@0 | 1444 | NSSCKMDMechanism *mdMechanism, |
michael@0 | 1445 | NSSCKFWMechanism *fwMechanism, |
michael@0 | 1446 | NSSCKMDToken *mdToken, |
michael@0 | 1447 | NSSCKFWToken *fwToken, |
michael@0 | 1448 | NSSCKMDInstance *mdInstance, |
michael@0 | 1449 | NSSCKFWInstance *fwInstance, |
michael@0 | 1450 | CK_RV *pError |
michael@0 | 1451 | ); |
michael@0 | 1452 | |
michael@0 | 1453 | /* |
michael@0 | 1454 | * The crypto routines themselves. Most crypto operations may |
michael@0 | 1455 | * be performed in two ways, streaming and single-part. The |
michael@0 | 1456 | * streaming operations involve the use of (typically) three |
michael@0 | 1457 | * calls-- an Init method to set up the operation, an Update |
michael@0 | 1458 | * method to feed data to the operation, and a Final method to |
michael@0 | 1459 | * obtain the final result. Single-part operations involve |
michael@0 | 1460 | * one method, to perform the crypto operation all at once. |
michael@0 | 1461 | * |
michael@0 | 1462 | * The NSS Cryptoki Framework can implement the single-part |
michael@0 | 1463 | * operations in terms of the streaming operations on behalf |
michael@0 | 1464 | * of the Module. There are a few variances. |
michael@0 | 1465 | * |
michael@0 | 1466 | * Only the Init Functions are defined by the mechanism. Each |
michael@0 | 1467 | * init function will return a NSSCKFWCryptoOperation which |
michael@0 | 1468 | * can supply update, final, the single part updateFinal, and |
michael@0 | 1469 | * the combo updateCombo functions. |
michael@0 | 1470 | * |
michael@0 | 1471 | * For simplicity, the routines are listed in summary here: |
michael@0 | 1472 | * |
michael@0 | 1473 | * EncryptInit, |
michael@0 | 1474 | * DecryptInit, |
michael@0 | 1475 | * DigestInit, |
michael@0 | 1476 | * SignInit, |
michael@0 | 1477 | * SignRecoverInit; |
michael@0 | 1478 | * VerifyInit, |
michael@0 | 1479 | * VerifyRecoverInit; |
michael@0 | 1480 | * |
michael@0 | 1481 | * The key-management routines are |
michael@0 | 1482 | * |
michael@0 | 1483 | * GenerateKey |
michael@0 | 1484 | * GenerateKeyPair |
michael@0 | 1485 | * WrapKey |
michael@0 | 1486 | * UnwrapKey |
michael@0 | 1487 | * DeriveKey |
michael@0 | 1488 | * |
michael@0 | 1489 | * All of these routines based on the Cryptoki API; |
michael@0 | 1490 | * see PKCS#11 for further information. |
michael@0 | 1491 | */ |
michael@0 | 1492 | |
michael@0 | 1493 | /* |
michael@0 | 1494 | */ |
michael@0 | 1495 | NSSCKMDCryptoOperation * (PR_CALLBACK *EncryptInit)( |
michael@0 | 1496 | NSSCKMDMechanism *mdMechanism, |
michael@0 | 1497 | NSSCKFWMechanism *fwMechanism, |
michael@0 | 1498 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 1499 | NSSCKMDSession *mdSession, |
michael@0 | 1500 | NSSCKFWSession *fwSession, |
michael@0 | 1501 | NSSCKMDToken *mdToken, |
michael@0 | 1502 | NSSCKFWToken *fwToken, |
michael@0 | 1503 | NSSCKMDInstance *mdInstance, |
michael@0 | 1504 | NSSCKFWInstance *fwInstance, |
michael@0 | 1505 | NSSCKMDObject *mdKey, |
michael@0 | 1506 | NSSCKFWObject *fwKey, |
michael@0 | 1507 | CK_RV *pError |
michael@0 | 1508 | ); |
michael@0 | 1509 | |
michael@0 | 1510 | /* |
michael@0 | 1511 | */ |
michael@0 | 1512 | NSSCKMDCryptoOperation * (PR_CALLBACK *DecryptInit)( |
michael@0 | 1513 | NSSCKMDMechanism *mdMechanism, |
michael@0 | 1514 | NSSCKFWMechanism *fwMechanism, |
michael@0 | 1515 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 1516 | NSSCKMDSession *mdSession, |
michael@0 | 1517 | NSSCKFWSession *fwSession, |
michael@0 | 1518 | NSSCKMDToken *mdToken, |
michael@0 | 1519 | NSSCKFWToken *fwToken, |
michael@0 | 1520 | NSSCKMDInstance *mdInstance, |
michael@0 | 1521 | NSSCKFWInstance *fwInstance, |
michael@0 | 1522 | NSSCKMDObject *mdKey, |
michael@0 | 1523 | NSSCKFWObject *fwKey, |
michael@0 | 1524 | CK_RV *pError |
michael@0 | 1525 | ); |
michael@0 | 1526 | |
michael@0 | 1527 | /* |
michael@0 | 1528 | */ |
michael@0 | 1529 | NSSCKMDCryptoOperation * (PR_CALLBACK *DigestInit)( |
michael@0 | 1530 | NSSCKMDMechanism *mdMechanism, |
michael@0 | 1531 | NSSCKFWMechanism *fwMechanism, |
michael@0 | 1532 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 1533 | NSSCKMDSession *mdSession, |
michael@0 | 1534 | NSSCKFWSession *fwSession, |
michael@0 | 1535 | NSSCKMDToken *mdToken, |
michael@0 | 1536 | NSSCKFWToken *fwToken, |
michael@0 | 1537 | NSSCKMDInstance *mdInstance, |
michael@0 | 1538 | NSSCKFWInstance *fwInstance, |
michael@0 | 1539 | CK_RV *pError |
michael@0 | 1540 | ); |
michael@0 | 1541 | |
michael@0 | 1542 | |
michael@0 | 1543 | /* |
michael@0 | 1544 | */ |
michael@0 | 1545 | NSSCKMDCryptoOperation * (PR_CALLBACK *SignInit)( |
michael@0 | 1546 | NSSCKMDMechanism *mdMechanism, |
michael@0 | 1547 | NSSCKFWMechanism *fwMechanism, |
michael@0 | 1548 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 1549 | NSSCKMDSession *mdSession, |
michael@0 | 1550 | NSSCKFWSession *fwSession, |
michael@0 | 1551 | NSSCKMDToken *mdToken, |
michael@0 | 1552 | NSSCKFWToken *fwToken, |
michael@0 | 1553 | NSSCKMDInstance *mdInstance, |
michael@0 | 1554 | NSSCKFWInstance *fwInstance, |
michael@0 | 1555 | NSSCKMDObject *mdKey, |
michael@0 | 1556 | NSSCKFWObject *fwKey, |
michael@0 | 1557 | CK_RV *pError |
michael@0 | 1558 | ); |
michael@0 | 1559 | |
michael@0 | 1560 | /* |
michael@0 | 1561 | */ |
michael@0 | 1562 | NSSCKMDCryptoOperation * (PR_CALLBACK *VerifyInit)( |
michael@0 | 1563 | NSSCKMDMechanism *mdMechanism, |
michael@0 | 1564 | NSSCKFWMechanism *fwMechanism, |
michael@0 | 1565 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 1566 | NSSCKMDSession *mdSession, |
michael@0 | 1567 | NSSCKFWSession *fwSession, |
michael@0 | 1568 | NSSCKMDToken *mdToken, |
michael@0 | 1569 | NSSCKFWToken *fwToken, |
michael@0 | 1570 | NSSCKMDInstance *mdInstance, |
michael@0 | 1571 | NSSCKFWInstance *fwInstance, |
michael@0 | 1572 | NSSCKMDObject *mdKey, |
michael@0 | 1573 | NSSCKFWObject *fwKey, |
michael@0 | 1574 | CK_RV *pError |
michael@0 | 1575 | ); |
michael@0 | 1576 | |
michael@0 | 1577 | /* |
michael@0 | 1578 | */ |
michael@0 | 1579 | NSSCKMDCryptoOperation * (PR_CALLBACK *SignRecoverInit)( |
michael@0 | 1580 | NSSCKMDMechanism *mdMechanism, |
michael@0 | 1581 | NSSCKFWMechanism *fwMechanism, |
michael@0 | 1582 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 1583 | NSSCKMDSession *mdSession, |
michael@0 | 1584 | NSSCKFWSession *fwSession, |
michael@0 | 1585 | NSSCKMDToken *mdToken, |
michael@0 | 1586 | NSSCKFWToken *fwToken, |
michael@0 | 1587 | NSSCKMDInstance *mdInstance, |
michael@0 | 1588 | NSSCKFWInstance *fwInstance, |
michael@0 | 1589 | NSSCKMDObject *mdKey, |
michael@0 | 1590 | NSSCKFWObject *fwKey, |
michael@0 | 1591 | CK_RV *pError |
michael@0 | 1592 | ); |
michael@0 | 1593 | |
michael@0 | 1594 | /* |
michael@0 | 1595 | */ |
michael@0 | 1596 | NSSCKMDCryptoOperation * (PR_CALLBACK *VerifyRecoverInit)( |
michael@0 | 1597 | NSSCKMDMechanism *mdMechanism, |
michael@0 | 1598 | NSSCKFWMechanism *fwMechanism, |
michael@0 | 1599 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 1600 | NSSCKMDSession *mdSession, |
michael@0 | 1601 | NSSCKFWSession *fwSession, |
michael@0 | 1602 | NSSCKMDToken *mdToken, |
michael@0 | 1603 | NSSCKFWToken *fwToken, |
michael@0 | 1604 | NSSCKMDInstance *mdInstance, |
michael@0 | 1605 | NSSCKFWInstance *fwInstance, |
michael@0 | 1606 | NSSCKMDObject *mdKey, |
michael@0 | 1607 | NSSCKFWObject *fwKey, |
michael@0 | 1608 | CK_RV *pError |
michael@0 | 1609 | ); |
michael@0 | 1610 | |
michael@0 | 1611 | /* |
michael@0 | 1612 | * Key management operations. |
michael@0 | 1613 | */ |
michael@0 | 1614 | |
michael@0 | 1615 | /* |
michael@0 | 1616 | * This routine generates a key. This routine may return NULL |
michael@0 | 1617 | * upon error. |
michael@0 | 1618 | */ |
michael@0 | 1619 | NSSCKMDObject *(PR_CALLBACK *GenerateKey)( |
michael@0 | 1620 | NSSCKMDMechanism *mdMechanism, |
michael@0 | 1621 | NSSCKFWMechanism *fwMechanism, |
michael@0 | 1622 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 1623 | NSSCKMDSession *mdSession, |
michael@0 | 1624 | NSSCKFWSession *fwSession, |
michael@0 | 1625 | NSSCKMDToken *mdToken, |
michael@0 | 1626 | NSSCKFWToken *fwToken, |
michael@0 | 1627 | NSSCKMDInstance *mdInstance, |
michael@0 | 1628 | NSSCKFWInstance *fwInstance, |
michael@0 | 1629 | CK_ATTRIBUTE_PTR pTemplate, |
michael@0 | 1630 | CK_ULONG ulAttributeCount, |
michael@0 | 1631 | CK_RV *pError |
michael@0 | 1632 | ); |
michael@0 | 1633 | |
michael@0 | 1634 | /* |
michael@0 | 1635 | * This routine generates a key pair. |
michael@0 | 1636 | */ |
michael@0 | 1637 | CK_RV (PR_CALLBACK *GenerateKeyPair)( |
michael@0 | 1638 | NSSCKMDMechanism *mdMechanism, |
michael@0 | 1639 | NSSCKFWMechanism *fwMechanism, |
michael@0 | 1640 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 1641 | NSSCKMDSession *mdSession, |
michael@0 | 1642 | NSSCKFWSession *fwSession, |
michael@0 | 1643 | NSSCKMDToken *mdToken, |
michael@0 | 1644 | NSSCKFWToken *fwToken, |
michael@0 | 1645 | NSSCKMDInstance *mdInstance, |
michael@0 | 1646 | NSSCKFWInstance *fwInstance, |
michael@0 | 1647 | CK_ATTRIBUTE_PTR pPublicKeyTemplate, |
michael@0 | 1648 | CK_ULONG ulPublicKeyAttributeCount, |
michael@0 | 1649 | CK_ATTRIBUTE_PTR pPrivateKeyTemplate, |
michael@0 | 1650 | CK_ULONG ulPrivateKeyAttributeCount, |
michael@0 | 1651 | NSSCKMDObject **pPublicKey, |
michael@0 | 1652 | NSSCKMDObject **pPrivateKey |
michael@0 | 1653 | ); |
michael@0 | 1654 | |
michael@0 | 1655 | /* |
michael@0 | 1656 | * This routine wraps a key. |
michael@0 | 1657 | */ |
michael@0 | 1658 | CK_ULONG (PR_CALLBACK *GetWrapKeyLength)( |
michael@0 | 1659 | NSSCKMDMechanism *mdMechanism, |
michael@0 | 1660 | NSSCKFWMechanism *fwMechanism, |
michael@0 | 1661 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 1662 | NSSCKMDSession *mdSession, |
michael@0 | 1663 | NSSCKFWSession *fwSession, |
michael@0 | 1664 | NSSCKMDToken *mdToken, |
michael@0 | 1665 | NSSCKFWToken *fwToken, |
michael@0 | 1666 | NSSCKMDInstance *mdInstance, |
michael@0 | 1667 | NSSCKFWInstance *fwInstance, |
michael@0 | 1668 | NSSCKMDObject *mdWrappingKey, |
michael@0 | 1669 | NSSCKFWObject *fwWrappingKey, |
michael@0 | 1670 | NSSCKMDObject *mdWrappedKey, |
michael@0 | 1671 | NSSCKFWObject *fwWrappedKey, |
michael@0 | 1672 | CK_RV *pError |
michael@0 | 1673 | ); |
michael@0 | 1674 | |
michael@0 | 1675 | /* |
michael@0 | 1676 | * This routine wraps a key. |
michael@0 | 1677 | */ |
michael@0 | 1678 | CK_RV (PR_CALLBACK *WrapKey)( |
michael@0 | 1679 | NSSCKMDMechanism *mdMechanism, |
michael@0 | 1680 | NSSCKFWMechanism *fwMechanism, |
michael@0 | 1681 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 1682 | NSSCKMDSession *mdSession, |
michael@0 | 1683 | NSSCKFWSession *fwSession, |
michael@0 | 1684 | NSSCKMDToken *mdToken, |
michael@0 | 1685 | NSSCKFWToken *fwToken, |
michael@0 | 1686 | NSSCKMDInstance *mdInstance, |
michael@0 | 1687 | NSSCKFWInstance *fwInstance, |
michael@0 | 1688 | NSSCKMDObject *mdWrappingKey, |
michael@0 | 1689 | NSSCKFWObject *fwWrappingKey, |
michael@0 | 1690 | NSSCKMDObject *mdKeyObject, |
michael@0 | 1691 | NSSCKFWObject *fwKeyObject, |
michael@0 | 1692 | NSSItem *wrappedKey |
michael@0 | 1693 | ); |
michael@0 | 1694 | |
michael@0 | 1695 | /* |
michael@0 | 1696 | * This routine unwraps a key. This routine may return NULL |
michael@0 | 1697 | * upon error. |
michael@0 | 1698 | */ |
michael@0 | 1699 | NSSCKMDObject *(PR_CALLBACK *UnwrapKey)( |
michael@0 | 1700 | NSSCKMDMechanism *mdMechanism, |
michael@0 | 1701 | NSSCKFWMechanism *fwMechanism, |
michael@0 | 1702 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 1703 | NSSCKMDSession *mdSession, |
michael@0 | 1704 | NSSCKFWSession *fwSession, |
michael@0 | 1705 | NSSCKMDToken *mdToken, |
michael@0 | 1706 | NSSCKFWToken *fwToken, |
michael@0 | 1707 | NSSCKMDInstance *mdInstance, |
michael@0 | 1708 | NSSCKFWInstance *fwInstance, |
michael@0 | 1709 | NSSCKMDObject *mdWrappingKey, |
michael@0 | 1710 | NSSCKFWObject *fwWrappingKey, |
michael@0 | 1711 | NSSItem *wrappedKey, |
michael@0 | 1712 | CK_ATTRIBUTE_PTR pTemplate, |
michael@0 | 1713 | CK_ULONG ulAttributeCount, |
michael@0 | 1714 | CK_RV *pError |
michael@0 | 1715 | ); |
michael@0 | 1716 | |
michael@0 | 1717 | /* |
michael@0 | 1718 | * This routine derives a key. This routine may return NULL |
michael@0 | 1719 | * upon error. |
michael@0 | 1720 | */ |
michael@0 | 1721 | NSSCKMDObject *(PR_CALLBACK *DeriveKey)( |
michael@0 | 1722 | NSSCKMDMechanism *mdMechanism, |
michael@0 | 1723 | NSSCKFWMechanism *fwMechanism, |
michael@0 | 1724 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 1725 | NSSCKMDSession *mdSession, |
michael@0 | 1726 | NSSCKFWSession *fwSession, |
michael@0 | 1727 | NSSCKMDToken *mdToken, |
michael@0 | 1728 | NSSCKFWToken *fwToken, |
michael@0 | 1729 | NSSCKMDInstance *mdInstance, |
michael@0 | 1730 | NSSCKFWInstance *fwInstance, |
michael@0 | 1731 | NSSCKMDObject *mdBaseKey, |
michael@0 | 1732 | NSSCKFWObject *fwBaseKey, |
michael@0 | 1733 | CK_ATTRIBUTE_PTR pTemplate, |
michael@0 | 1734 | CK_ULONG ulAttributeCount, |
michael@0 | 1735 | CK_RV *pError |
michael@0 | 1736 | ); |
michael@0 | 1737 | |
michael@0 | 1738 | /* |
michael@0 | 1739 | * This object may be extended in future versions of the |
michael@0 | 1740 | * NSS Cryptoki Framework. To allow for some flexibility |
michael@0 | 1741 | * in the area of binary compatibility, this field should |
michael@0 | 1742 | * be NULL. |
michael@0 | 1743 | */ |
michael@0 | 1744 | void *null; |
michael@0 | 1745 | }; |
michael@0 | 1746 | |
michael@0 | 1747 | /* |
michael@0 | 1748 | * NSSCKMDObject |
michael@0 | 1749 | * |
michael@0 | 1750 | * This is the basic handle for any object used by a PKCS#11 Module. |
michael@0 | 1751 | * Modules must implement it if they support their own objects, and |
michael@0 | 1752 | * the Framework supports it for Modules that do not handle session |
michael@0 | 1753 | * objects. This type contains a pointer for use by the implementor, |
michael@0 | 1754 | * to store any object-specific data, and it contains an EPV for a |
michael@0 | 1755 | * set of routines used to access the object. |
michael@0 | 1756 | */ |
michael@0 | 1757 | |
michael@0 | 1758 | struct NSSCKMDObjectStr { |
michael@0 | 1759 | /* |
michael@0 | 1760 | * The implementation my use this pointer for its own purposes. |
michael@0 | 1761 | */ |
michael@0 | 1762 | void *etc; |
michael@0 | 1763 | |
michael@0 | 1764 | /* |
michael@0 | 1765 | * This routine is called by the Framework when it is letting |
michael@0 | 1766 | * go of an object handle. It can be used by the Module to |
michael@0 | 1767 | * free any resources tied up by an object "in use." It is |
michael@0 | 1768 | * optional. |
michael@0 | 1769 | */ |
michael@0 | 1770 | void (PR_CALLBACK *Finalize)( |
michael@0 | 1771 | NSSCKMDObject *mdObject, |
michael@0 | 1772 | NSSCKFWObject *fwObject, |
michael@0 | 1773 | NSSCKMDSession *mdSession, |
michael@0 | 1774 | NSSCKFWSession *fwSession, |
michael@0 | 1775 | NSSCKMDToken *mdToken, |
michael@0 | 1776 | NSSCKFWToken *fwToken, |
michael@0 | 1777 | NSSCKMDInstance *mdInstance, |
michael@0 | 1778 | NSSCKFWInstance *fwInstance |
michael@0 | 1779 | ); |
michael@0 | 1780 | |
michael@0 | 1781 | /* |
michael@0 | 1782 | * This routine is used to completely destroy an object. |
michael@0 | 1783 | * It is optional. The parameter fwObject might be NULL |
michael@0 | 1784 | * if the framework runs out of memory at the wrong moment. |
michael@0 | 1785 | */ |
michael@0 | 1786 | CK_RV (PR_CALLBACK *Destroy)( |
michael@0 | 1787 | NSSCKMDObject *mdObject, |
michael@0 | 1788 | NSSCKFWObject *fwObject, |
michael@0 | 1789 | NSSCKMDSession *mdSession, |
michael@0 | 1790 | NSSCKFWSession *fwSession, |
michael@0 | 1791 | NSSCKMDToken *mdToken, |
michael@0 | 1792 | NSSCKFWToken *fwToken, |
michael@0 | 1793 | NSSCKMDInstance *mdInstance, |
michael@0 | 1794 | NSSCKFWInstance *fwInstance |
michael@0 | 1795 | ); |
michael@0 | 1796 | |
michael@0 | 1797 | /* |
michael@0 | 1798 | * This helper routine is used by the Framework, and is especially |
michael@0 | 1799 | * useful when it is managing session objects on behalf of the |
michael@0 | 1800 | * Module. This routine is optional; if unimplemented, the |
michael@0 | 1801 | * Framework will actually look up the CKA_TOKEN attribute. In the |
michael@0 | 1802 | * event of an error, just make something up-- the Framework will |
michael@0 | 1803 | * find out soon enough anyway. |
michael@0 | 1804 | */ |
michael@0 | 1805 | CK_BBOOL (PR_CALLBACK *IsTokenObject)( |
michael@0 | 1806 | NSSCKMDObject *mdObject, |
michael@0 | 1807 | NSSCKFWObject *fwObject, |
michael@0 | 1808 | NSSCKMDSession *mdSession, |
michael@0 | 1809 | NSSCKFWSession *fwSession, |
michael@0 | 1810 | NSSCKMDToken *mdToken, |
michael@0 | 1811 | NSSCKFWToken *fwToken, |
michael@0 | 1812 | NSSCKMDInstance *mdInstance, |
michael@0 | 1813 | NSSCKFWInstance *fwInstance |
michael@0 | 1814 | ); |
michael@0 | 1815 | |
michael@0 | 1816 | /* |
michael@0 | 1817 | * This routine returns the number of attributes of which this |
michael@0 | 1818 | * object consists. It is mandatory. It can return zero on |
michael@0 | 1819 | * error. |
michael@0 | 1820 | */ |
michael@0 | 1821 | CK_ULONG (PR_CALLBACK *GetAttributeCount)( |
michael@0 | 1822 | NSSCKMDObject *mdObject, |
michael@0 | 1823 | NSSCKFWObject *fwObject, |
michael@0 | 1824 | NSSCKMDSession *mdSession, |
michael@0 | 1825 | NSSCKFWSession *fwSession, |
michael@0 | 1826 | NSSCKMDToken *mdToken, |
michael@0 | 1827 | NSSCKFWToken *fwToken, |
michael@0 | 1828 | NSSCKMDInstance *mdInstance, |
michael@0 | 1829 | NSSCKFWInstance *fwInstance, |
michael@0 | 1830 | CK_RV *pError |
michael@0 | 1831 | ); |
michael@0 | 1832 | |
michael@0 | 1833 | /* |
michael@0 | 1834 | * This routine stuffs the attribute types into the provided array. |
michael@0 | 1835 | * The array size (as obtained from GetAttributeCount) is passed in |
michael@0 | 1836 | * as a check; return CKR_BUFFER_TOO_SMALL if the count is wrong |
michael@0 | 1837 | * (either too big or too small). |
michael@0 | 1838 | */ |
michael@0 | 1839 | CK_RV (PR_CALLBACK *GetAttributeTypes)( |
michael@0 | 1840 | NSSCKMDObject *mdObject, |
michael@0 | 1841 | NSSCKFWObject *fwObject, |
michael@0 | 1842 | NSSCKMDSession *mdSession, |
michael@0 | 1843 | NSSCKFWSession *fwSession, |
michael@0 | 1844 | NSSCKMDToken *mdToken, |
michael@0 | 1845 | NSSCKFWToken *fwToken, |
michael@0 | 1846 | NSSCKMDInstance *mdInstance, |
michael@0 | 1847 | NSSCKFWInstance *fwInstance, |
michael@0 | 1848 | CK_ATTRIBUTE_TYPE_PTR typeArray, |
michael@0 | 1849 | CK_ULONG ulCount |
michael@0 | 1850 | ); |
michael@0 | 1851 | |
michael@0 | 1852 | /* |
michael@0 | 1853 | * This routine returns the size (in bytes) of the specified |
michael@0 | 1854 | * attribute. It can return zero on error. |
michael@0 | 1855 | */ |
michael@0 | 1856 | CK_ULONG (PR_CALLBACK *GetAttributeSize)( |
michael@0 | 1857 | NSSCKMDObject *mdObject, |
michael@0 | 1858 | NSSCKFWObject *fwObject, |
michael@0 | 1859 | NSSCKMDSession *mdSession, |
michael@0 | 1860 | NSSCKFWSession *fwSession, |
michael@0 | 1861 | NSSCKMDToken *mdToken, |
michael@0 | 1862 | NSSCKFWToken *fwToken, |
michael@0 | 1863 | NSSCKMDInstance *mdInstance, |
michael@0 | 1864 | NSSCKFWInstance *fwInstance, |
michael@0 | 1865 | CK_ATTRIBUTE_TYPE attribute, |
michael@0 | 1866 | CK_RV *pError |
michael@0 | 1867 | ); |
michael@0 | 1868 | |
michael@0 | 1869 | /* |
michael@0 | 1870 | * This routine returns an NSSCKFWItem structure. |
michael@0 | 1871 | * The item pointer points to an NSSItem containing the attribute value. |
michael@0 | 1872 | * The needsFreeing bit tells the framework whether to call the |
michael@0 | 1873 | * FreeAttribute function . Upon error, an NSSCKFWItem structure |
michael@0 | 1874 | * with a NULL NSSItem item pointer will be returned |
michael@0 | 1875 | */ |
michael@0 | 1876 | NSSCKFWItem (PR_CALLBACK *GetAttribute)( |
michael@0 | 1877 | NSSCKMDObject *mdObject, |
michael@0 | 1878 | NSSCKFWObject *fwObject, |
michael@0 | 1879 | NSSCKMDSession *mdSession, |
michael@0 | 1880 | NSSCKFWSession *fwSession, |
michael@0 | 1881 | NSSCKMDToken *mdToken, |
michael@0 | 1882 | NSSCKFWToken *fwToken, |
michael@0 | 1883 | NSSCKMDInstance *mdInstance, |
michael@0 | 1884 | NSSCKFWInstance *fwInstance, |
michael@0 | 1885 | CK_ATTRIBUTE_TYPE attribute, |
michael@0 | 1886 | CK_RV *pError |
michael@0 | 1887 | ); |
michael@0 | 1888 | |
michael@0 | 1889 | /* |
michael@0 | 1890 | * This routine returns CKR_OK if the attribute could be freed. |
michael@0 | 1891 | */ |
michael@0 | 1892 | CK_RV (PR_CALLBACK *FreeAttribute)( |
michael@0 | 1893 | NSSCKFWItem * item |
michael@0 | 1894 | ); |
michael@0 | 1895 | |
michael@0 | 1896 | /* |
michael@0 | 1897 | * This routine changes the specified attribute. If unimplemented, |
michael@0 | 1898 | * the object will be considered read-only. |
michael@0 | 1899 | */ |
michael@0 | 1900 | CK_RV (PR_CALLBACK *SetAttribute)( |
michael@0 | 1901 | NSSCKMDObject *mdObject, |
michael@0 | 1902 | NSSCKFWObject *fwObject, |
michael@0 | 1903 | NSSCKMDSession *mdSession, |
michael@0 | 1904 | NSSCKFWSession *fwSession, |
michael@0 | 1905 | NSSCKMDToken *mdToken, |
michael@0 | 1906 | NSSCKFWToken *fwToken, |
michael@0 | 1907 | NSSCKMDInstance *mdInstance, |
michael@0 | 1908 | NSSCKFWInstance *fwInstance, |
michael@0 | 1909 | CK_ATTRIBUTE_TYPE attribute, |
michael@0 | 1910 | NSSItem *value |
michael@0 | 1911 | ); |
michael@0 | 1912 | |
michael@0 | 1913 | /* |
michael@0 | 1914 | * This routine returns the storage requirements of this object, |
michael@0 | 1915 | * in bytes. Cryptoki doesn't strictly define the definition, |
michael@0 | 1916 | * but it should relate to the values returned by the "Get Memory" |
michael@0 | 1917 | * routines of the NSSCKMDToken. This routine is optional; if |
michael@0 | 1918 | * unimplemented, the Framework will consider this information |
michael@0 | 1919 | * sensitive. This routine may return zero on error. If the |
michael@0 | 1920 | * specified error is CKR_OK, zero will be accepted as a valid |
michael@0 | 1921 | * response. |
michael@0 | 1922 | */ |
michael@0 | 1923 | CK_ULONG (PR_CALLBACK *GetObjectSize)( |
michael@0 | 1924 | NSSCKMDObject *mdObject, |
michael@0 | 1925 | NSSCKFWObject *fwObject, |
michael@0 | 1926 | NSSCKMDSession *mdSession, |
michael@0 | 1927 | NSSCKFWSession *fwSession, |
michael@0 | 1928 | NSSCKMDToken *mdToken, |
michael@0 | 1929 | NSSCKFWToken *fwToken, |
michael@0 | 1930 | NSSCKMDInstance *mdInstance, |
michael@0 | 1931 | NSSCKFWInstance *fwInstance, |
michael@0 | 1932 | CK_RV *pError |
michael@0 | 1933 | ); |
michael@0 | 1934 | |
michael@0 | 1935 | /* |
michael@0 | 1936 | * This object may be extended in future versions of the |
michael@0 | 1937 | * NSS Cryptoki Framework. To allow for some flexibility |
michael@0 | 1938 | * in the area of binary compatibility, this field should |
michael@0 | 1939 | * be NULL. |
michael@0 | 1940 | */ |
michael@0 | 1941 | void *null; |
michael@0 | 1942 | }; |
michael@0 | 1943 | |
michael@0 | 1944 | |
michael@0 | 1945 | #endif /* NSSCKMDT_H */ |