Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 | * Internal data structures and functions used by pkcs11.c |
michael@0 | 6 | */ |
michael@0 | 7 | #ifndef _PKCS11I_H_ |
michael@0 | 8 | #define _PKCS11I_H_ 1 |
michael@0 | 9 | |
michael@0 | 10 | #include "nssilock.h" |
michael@0 | 11 | #include "seccomon.h" |
michael@0 | 12 | #include "secoidt.h" |
michael@0 | 13 | #include "lowkeyti.h" |
michael@0 | 14 | #include "pkcs11t.h" |
michael@0 | 15 | |
michael@0 | 16 | #include "sftkdbt.h" |
michael@0 | 17 | #include "hasht.h" |
michael@0 | 18 | |
michael@0 | 19 | /* |
michael@0 | 20 | * Configuration Defines |
michael@0 | 21 | * |
michael@0 | 22 | * The following defines affect the space verse speed trade offs of |
michael@0 | 23 | * the PKCS #11 module. For the most part the current settings are optimized |
michael@0 | 24 | * for web servers, where we want faster speed and lower lock contention at |
michael@0 | 25 | * the expense of space. |
michael@0 | 26 | */ |
michael@0 | 27 | |
michael@0 | 28 | /* |
michael@0 | 29 | * The attribute allocation strategy is static allocation: |
michael@0 | 30 | * Attributes are pre-allocated as part of the session object and used from |
michael@0 | 31 | * the object array. |
michael@0 | 32 | */ |
michael@0 | 33 | #define MAX_OBJS_ATTRS 45 /* number of attributes to preallocate in |
michael@0 | 34 | * the object (must me the absolute max) */ |
michael@0 | 35 | #define ATTR_SPACE 50 /* Maximum size of attribute data before extra |
michael@0 | 36 | * data needs to be allocated. This is set to |
michael@0 | 37 | * enough space to hold an SSL MASTER secret */ |
michael@0 | 38 | |
michael@0 | 39 | #define NSC_STRICT PR_FALSE /* forces the code to do strict template |
michael@0 | 40 | * matching when doing C_FindObject on token |
michael@0 | 41 | * objects. This will slow down search in |
michael@0 | 42 | * NSS. */ |
michael@0 | 43 | /* default search block allocations and increments */ |
michael@0 | 44 | #define NSC_CERT_BLOCK_SIZE 50 |
michael@0 | 45 | #define NSC_SEARCH_BLOCK_SIZE 5 |
michael@0 | 46 | #define NSC_SLOT_LIST_BLOCK_SIZE 10 |
michael@0 | 47 | |
michael@0 | 48 | #define NSC_FIPS_MODULE 1 |
michael@0 | 49 | #define NSC_NON_FIPS_MODULE 0 |
michael@0 | 50 | |
michael@0 | 51 | /* these are data base storage hashes, not cryptographic hashes.. The define |
michael@0 | 52 | * the effective size of the various object hash tables */ |
michael@0 | 53 | /* clients care more about memory usage than lookup performance on |
michael@0 | 54 | * cyrptographic objects. Clients also have less objects around to play with |
michael@0 | 55 | * |
michael@0 | 56 | * we eventually should make this configurable at runtime! Especially now that |
michael@0 | 57 | * NSS is a shared library. |
michael@0 | 58 | */ |
michael@0 | 59 | #define SPACE_ATTRIBUTE_HASH_SIZE 32 |
michael@0 | 60 | #define SPACE_SESSION_OBJECT_HASH_SIZE 32 |
michael@0 | 61 | #define SPACE_SESSION_HASH_SIZE 32 |
michael@0 | 62 | #define TIME_ATTRIBUTE_HASH_SIZE 32 |
michael@0 | 63 | #define TIME_SESSION_OBJECT_HASH_SIZE 1024 |
michael@0 | 64 | #define TIME_SESSION_HASH_SIZE 1024 |
michael@0 | 65 | #define MAX_OBJECT_LIST_SIZE 800 |
michael@0 | 66 | /* how many objects to keep on the free list |
michael@0 | 67 | * before we start freeing them */ |
michael@0 | 68 | #define MAX_KEY_LEN 256 /* maximum symmetric key length in bytes */ |
michael@0 | 69 | |
michael@0 | 70 | /* |
michael@0 | 71 | * LOG2_BUCKETS_PER_SESSION_LOCK must be a prime number. |
michael@0 | 72 | * With SESSION_HASH_SIZE=1024, LOG2 can be 9, 5, 1, or 0. |
michael@0 | 73 | * With SESSION_HASH_SIZE=4096, LOG2 can be 11, 9, 5, 1, or 0. |
michael@0 | 74 | * |
michael@0 | 75 | * HASH_SIZE LOG2_BUCKETS_PER BUCKETS_PER_LOCK NUMBER_OF_BUCKETS |
michael@0 | 76 | * 1024 9 512 2 |
michael@0 | 77 | * 1024 5 32 32 |
michael@0 | 78 | * 1024 1 2 512 |
michael@0 | 79 | * 1024 0 1 1024 |
michael@0 | 80 | * 4096 11 2048 2 |
michael@0 | 81 | * 4096 9 512 8 |
michael@0 | 82 | * 4096 5 32 128 |
michael@0 | 83 | * 4096 1 2 2048 |
michael@0 | 84 | * 4096 0 1 4096 |
michael@0 | 85 | */ |
michael@0 | 86 | #define LOG2_BUCKETS_PER_SESSION_LOCK 1 |
michael@0 | 87 | #define BUCKETS_PER_SESSION_LOCK (1 << (LOG2_BUCKETS_PER_SESSION_LOCK)) |
michael@0 | 88 | /* NOSPREAD sessionID to hash table index macro has been slower. */ |
michael@0 | 89 | |
michael@0 | 90 | /* define typedefs, double as forward declarations as well */ |
michael@0 | 91 | typedef struct SFTKAttributeStr SFTKAttribute; |
michael@0 | 92 | typedef struct SFTKObjectListStr SFTKObjectList; |
michael@0 | 93 | typedef struct SFTKObjectFreeListStr SFTKObjectFreeList; |
michael@0 | 94 | typedef struct SFTKObjectListElementStr SFTKObjectListElement; |
michael@0 | 95 | typedef struct SFTKObjectStr SFTKObject; |
michael@0 | 96 | typedef struct SFTKSessionObjectStr SFTKSessionObject; |
michael@0 | 97 | typedef struct SFTKTokenObjectStr SFTKTokenObject; |
michael@0 | 98 | typedef struct SFTKSessionStr SFTKSession; |
michael@0 | 99 | typedef struct SFTKSlotStr SFTKSlot; |
michael@0 | 100 | typedef struct SFTKSessionContextStr SFTKSessionContext; |
michael@0 | 101 | typedef struct SFTKSearchResultsStr SFTKSearchResults; |
michael@0 | 102 | typedef struct SFTKHashVerifyInfoStr SFTKHashVerifyInfo; |
michael@0 | 103 | typedef struct SFTKHashSignInfoStr SFTKHashSignInfo; |
michael@0 | 104 | typedef struct SFTKOAEPEncryptInfoStr SFTKOAEPEncryptInfo; |
michael@0 | 105 | typedef struct SFTKOAEPDecryptInfoStr SFTKOAEPDecryptInfo; |
michael@0 | 106 | typedef struct SFTKSSLMACInfoStr SFTKSSLMACInfo; |
michael@0 | 107 | typedef struct SFTKItemTemplateStr SFTKItemTemplate; |
michael@0 | 108 | |
michael@0 | 109 | /* define function pointer typdefs for pointer tables */ |
michael@0 | 110 | typedef void (*SFTKDestroy)(void *, PRBool); |
michael@0 | 111 | typedef void (*SFTKBegin)(void *); |
michael@0 | 112 | typedef SECStatus (*SFTKCipher)(void *,void *,unsigned int *,unsigned int, |
michael@0 | 113 | void *, unsigned int); |
michael@0 | 114 | typedef SECStatus (*SFTKVerify)(void *,void *,unsigned int,void *,unsigned int); |
michael@0 | 115 | typedef void (*SFTKHash)(void *,void *,unsigned int); |
michael@0 | 116 | typedef void (*SFTKEnd)(void *,void *,unsigned int *,unsigned int); |
michael@0 | 117 | typedef void (*SFTKFree)(void *); |
michael@0 | 118 | |
michael@0 | 119 | /* Value to tell if an attribute is modifiable or not. |
michael@0 | 120 | * NEVER: attribute is only set on creation. |
michael@0 | 121 | * ONCOPY: attribute is set on creation and can only be changed on copy. |
michael@0 | 122 | * SENSITIVE: attribute can only be changed to TRUE. |
michael@0 | 123 | * ALWAYS: attribute can always be changed. |
michael@0 | 124 | */ |
michael@0 | 125 | typedef enum { |
michael@0 | 126 | SFTK_NEVER = 0, |
michael@0 | 127 | SFTK_ONCOPY = 1, |
michael@0 | 128 | SFTK_SENSITIVE = 2, |
michael@0 | 129 | SFTK_ALWAYS = 3 |
michael@0 | 130 | } SFTKModifyType; |
michael@0 | 131 | |
michael@0 | 132 | /* |
michael@0 | 133 | * Free Status Enum... tell us more information when we think we're |
michael@0 | 134 | * deleting an object. |
michael@0 | 135 | */ |
michael@0 | 136 | typedef enum { |
michael@0 | 137 | SFTK_DestroyFailure, |
michael@0 | 138 | SFTK_Destroyed, |
michael@0 | 139 | SFTK_Busy |
michael@0 | 140 | } SFTKFreeStatus; |
michael@0 | 141 | |
michael@0 | 142 | /* |
michael@0 | 143 | * attribute values of an object. |
michael@0 | 144 | */ |
michael@0 | 145 | struct SFTKAttributeStr { |
michael@0 | 146 | SFTKAttribute *next; |
michael@0 | 147 | SFTKAttribute *prev; |
michael@0 | 148 | PRBool freeAttr; |
michael@0 | 149 | PRBool freeData; |
michael@0 | 150 | /*must be called handle to make sftkqueue_find work */ |
michael@0 | 151 | CK_ATTRIBUTE_TYPE handle; |
michael@0 | 152 | CK_ATTRIBUTE attrib; |
michael@0 | 153 | unsigned char space[ATTR_SPACE]; |
michael@0 | 154 | }; |
michael@0 | 155 | |
michael@0 | 156 | |
michael@0 | 157 | /* |
michael@0 | 158 | * doubly link list of objects |
michael@0 | 159 | */ |
michael@0 | 160 | struct SFTKObjectListStr { |
michael@0 | 161 | SFTKObjectList *next; |
michael@0 | 162 | SFTKObjectList *prev; |
michael@0 | 163 | SFTKObject *parent; |
michael@0 | 164 | }; |
michael@0 | 165 | |
michael@0 | 166 | struct SFTKObjectFreeListStr { |
michael@0 | 167 | SFTKObject *head; |
michael@0 | 168 | PZLock *lock; |
michael@0 | 169 | int count; |
michael@0 | 170 | }; |
michael@0 | 171 | |
michael@0 | 172 | /* |
michael@0 | 173 | * PKCS 11 crypto object structure |
michael@0 | 174 | */ |
michael@0 | 175 | struct SFTKObjectStr { |
michael@0 | 176 | SFTKObject *next; |
michael@0 | 177 | SFTKObject *prev; |
michael@0 | 178 | CK_OBJECT_CLASS objclass; |
michael@0 | 179 | CK_OBJECT_HANDLE handle; |
michael@0 | 180 | int refCount; |
michael@0 | 181 | PZLock *refLock; |
michael@0 | 182 | SFTKSlot *slot; |
michael@0 | 183 | void *objectInfo; |
michael@0 | 184 | SFTKFree infoFree; |
michael@0 | 185 | }; |
michael@0 | 186 | |
michael@0 | 187 | struct SFTKTokenObjectStr { |
michael@0 | 188 | SFTKObject obj; |
michael@0 | 189 | SECItem dbKey; |
michael@0 | 190 | }; |
michael@0 | 191 | |
michael@0 | 192 | struct SFTKSessionObjectStr { |
michael@0 | 193 | SFTKObject obj; |
michael@0 | 194 | SFTKObjectList sessionList; |
michael@0 | 195 | PZLock *attributeLock; |
michael@0 | 196 | SFTKSession *session; |
michael@0 | 197 | PRBool wasDerived; |
michael@0 | 198 | int nextAttr; |
michael@0 | 199 | SFTKAttribute attrList[MAX_OBJS_ATTRS]; |
michael@0 | 200 | PRBool optimizeSpace; |
michael@0 | 201 | unsigned int hashSize; |
michael@0 | 202 | SFTKAttribute *head[1]; |
michael@0 | 203 | }; |
michael@0 | 204 | |
michael@0 | 205 | /* |
michael@0 | 206 | * struct to deal with a temparary list of objects |
michael@0 | 207 | */ |
michael@0 | 208 | struct SFTKObjectListElementStr { |
michael@0 | 209 | SFTKObjectListElement *next; |
michael@0 | 210 | SFTKObject *object; |
michael@0 | 211 | }; |
michael@0 | 212 | |
michael@0 | 213 | /* |
michael@0 | 214 | * Area to hold Search results |
michael@0 | 215 | */ |
michael@0 | 216 | struct SFTKSearchResultsStr { |
michael@0 | 217 | CK_OBJECT_HANDLE *handles; |
michael@0 | 218 | int size; |
michael@0 | 219 | int index; |
michael@0 | 220 | int array_size; |
michael@0 | 221 | }; |
michael@0 | 222 | |
michael@0 | 223 | |
michael@0 | 224 | /* |
michael@0 | 225 | * the universal crypto/hash/sign/verify context structure |
michael@0 | 226 | */ |
michael@0 | 227 | typedef enum { |
michael@0 | 228 | SFTK_ENCRYPT, |
michael@0 | 229 | SFTK_DECRYPT, |
michael@0 | 230 | SFTK_HASH, |
michael@0 | 231 | SFTK_SIGN, |
michael@0 | 232 | SFTK_SIGN_RECOVER, |
michael@0 | 233 | SFTK_VERIFY, |
michael@0 | 234 | SFTK_VERIFY_RECOVER |
michael@0 | 235 | } SFTKContextType; |
michael@0 | 236 | |
michael@0 | 237 | /** max block size of supported block ciphers */ |
michael@0 | 238 | #define SFTK_MAX_BLOCK_SIZE 16 |
michael@0 | 239 | /** currently SHA512 is the biggest hash length */ |
michael@0 | 240 | #define SFTK_MAX_MAC_LENGTH 64 |
michael@0 | 241 | #define SFTK_INVALID_MAC_SIZE 0xffffffff |
michael@0 | 242 | |
michael@0 | 243 | /** Particular ongoing operation in session (sign/verify/digest/encrypt/...) |
michael@0 | 244 | * |
michael@0 | 245 | * Understanding sign/verify context: |
michael@0 | 246 | * multi=1 hashInfo=0 block (symmetric) cipher MACing |
michael@0 | 247 | * multi=1 hashInfo=X PKC S/V with prior hashing |
michael@0 | 248 | * multi=0 hashInfo=0 PKC S/V one shot (w/o hashing) |
michael@0 | 249 | * multi=0 hashInfo=X *** shouldn't happen *** |
michael@0 | 250 | */ |
michael@0 | 251 | struct SFTKSessionContextStr { |
michael@0 | 252 | SFTKContextType type; |
michael@0 | 253 | PRBool multi; /* is multipart */ |
michael@0 | 254 | PRBool rsa; /* is rsa */ |
michael@0 | 255 | PRBool doPad; /* use PKCS padding for block ciphers */ |
michael@0 | 256 | unsigned int blockSize; /* blocksize for padding */ |
michael@0 | 257 | unsigned int padDataLength; /* length of the valid data in padbuf */ |
michael@0 | 258 | /** latest incomplete block of data for block cipher */ |
michael@0 | 259 | unsigned char padBuf[SFTK_MAX_BLOCK_SIZE]; |
michael@0 | 260 | /** result of MAC'ing of latest full block of data with block cipher */ |
michael@0 | 261 | unsigned char macBuf[SFTK_MAX_BLOCK_SIZE]; |
michael@0 | 262 | CK_ULONG macSize; /* size of a general block cipher mac*/ |
michael@0 | 263 | void *cipherInfo; |
michael@0 | 264 | void *hashInfo; |
michael@0 | 265 | unsigned int cipherInfoLen; |
michael@0 | 266 | CK_MECHANISM_TYPE currentMech; |
michael@0 | 267 | SFTKCipher update; |
michael@0 | 268 | SFTKHash hashUpdate; |
michael@0 | 269 | SFTKEnd end; |
michael@0 | 270 | SFTKDestroy destroy; |
michael@0 | 271 | SFTKDestroy hashdestroy; |
michael@0 | 272 | SFTKVerify verify; |
michael@0 | 273 | unsigned int maxLen; |
michael@0 | 274 | SFTKObject *key; |
michael@0 | 275 | }; |
michael@0 | 276 | |
michael@0 | 277 | /* |
michael@0 | 278 | * Sessions (have objects) |
michael@0 | 279 | */ |
michael@0 | 280 | struct SFTKSessionStr { |
michael@0 | 281 | SFTKSession *next; |
michael@0 | 282 | SFTKSession *prev; |
michael@0 | 283 | CK_SESSION_HANDLE handle; |
michael@0 | 284 | int refCount; |
michael@0 | 285 | PZLock *objectLock; |
michael@0 | 286 | int objectIDCount; |
michael@0 | 287 | CK_SESSION_INFO info; |
michael@0 | 288 | CK_NOTIFY notify; |
michael@0 | 289 | CK_VOID_PTR appData; |
michael@0 | 290 | SFTKSlot *slot; |
michael@0 | 291 | SFTKSearchResults *search; |
michael@0 | 292 | SFTKSessionContext *enc_context; |
michael@0 | 293 | SFTKSessionContext *hash_context; |
michael@0 | 294 | SFTKSessionContext *sign_context; |
michael@0 | 295 | SFTKObjectList *objects[1]; |
michael@0 | 296 | }; |
michael@0 | 297 | |
michael@0 | 298 | /* |
michael@0 | 299 | * slots (have sessions and objects) |
michael@0 | 300 | * |
michael@0 | 301 | * The array of sessionLock's protect the session hash table (head[]) |
michael@0 | 302 | * as well as the reference count of session objects in that bucket |
michael@0 | 303 | * (head[]->refCount), objectLock protects all elements of the slot's |
michael@0 | 304 | * object hash tables (sessObjHashTable[] and tokObjHashTable), and |
michael@0 | 305 | * sessionObjectHandleCount. |
michael@0 | 306 | * slotLock protects the remaining protected elements: |
michael@0 | 307 | * password, isLoggedIn, ssoLoggedIn, and sessionCount, |
michael@0 | 308 | * and pwCheckLock serializes the key database password checks in |
michael@0 | 309 | * NSC_SetPIN and NSC_Login. |
michael@0 | 310 | * |
michael@0 | 311 | * Each of the fields below has the following lifetime as commented |
michael@0 | 312 | * next to the fields: |
michael@0 | 313 | * invariant - This value is set when the slot is first created and |
michael@0 | 314 | * never changed until it is destroyed. |
michael@0 | 315 | * per load - This value is set when the slot is first created, or |
michael@0 | 316 | * when the slot is used to open another directory. Between open and close |
michael@0 | 317 | * this field does not change. |
michael@0 | 318 | * variable - This value changes through the normal process of slot operation. |
michael@0 | 319 | * - reset. The value of this variable is cleared during an open/close |
michael@0 | 320 | * cycles. |
michael@0 | 321 | * - preserved. The value of this variable is preserved over open/close |
michael@0 | 322 | * cycles. |
michael@0 | 323 | */ |
michael@0 | 324 | struct SFTKSlotStr { |
michael@0 | 325 | CK_SLOT_ID slotID; /* invariant */ |
michael@0 | 326 | PZLock *slotLock; /* invariant */ |
michael@0 | 327 | PZLock **sessionLock; /* invariant */ |
michael@0 | 328 | unsigned int numSessionLocks; /* invariant */ |
michael@0 | 329 | unsigned long sessionLockMask; /* invariant */ |
michael@0 | 330 | PZLock *objectLock; /* invariant */ |
michael@0 | 331 | PRLock *pwCheckLock; /* invariant */ |
michael@0 | 332 | PRBool present; /* variable -set */ |
michael@0 | 333 | PRBool hasTokens; /* per load */ |
michael@0 | 334 | PRBool isLoggedIn; /* variable - reset */ |
michael@0 | 335 | PRBool ssoLoggedIn; /* variable - reset */ |
michael@0 | 336 | PRBool needLogin; /* per load */ |
michael@0 | 337 | PRBool DB_loaded; /* per load */ |
michael@0 | 338 | PRBool readOnly; /* per load */ |
michael@0 | 339 | PRBool optimizeSpace; /* invariant */ |
michael@0 | 340 | SFTKDBHandle *certDB; /* per load */ |
michael@0 | 341 | SFTKDBHandle *keyDB; /* per load */ |
michael@0 | 342 | int minimumPinLen; /* per load */ |
michael@0 | 343 | PRInt32 sessionIDCount; /* atomically incremented */ |
michael@0 | 344 | /* (preserved) */ |
michael@0 | 345 | int sessionIDConflict; /* not protected by a lock */ |
michael@0 | 346 | /* (preserved) */ |
michael@0 | 347 | int sessionCount; /* variable - reset */ |
michael@0 | 348 | PRInt32 rwSessionCount; /* set by atomic operations */ |
michael@0 | 349 | /* (reset) */ |
michael@0 | 350 | int sessionObjectHandleCount;/* variable - perserved */ |
michael@0 | 351 | int index; /* invariant */ |
michael@0 | 352 | PLHashTable *tokObjHashTable; /* invariant */ |
michael@0 | 353 | SFTKObject **sessObjHashTable; /* variable - reset */ |
michael@0 | 354 | unsigned int sessObjHashSize; /* invariant */ |
michael@0 | 355 | SFTKSession **head; /* variable -reset */ |
michael@0 | 356 | unsigned int sessHashSize; /* invariant */ |
michael@0 | 357 | char tokDescription[33]; /* per load */ |
michael@0 | 358 | char updateTokDescription[33]; /* per load */ |
michael@0 | 359 | char slotDescription[65]; /* invariant */ |
michael@0 | 360 | }; |
michael@0 | 361 | |
michael@0 | 362 | /* |
michael@0 | 363 | * special joint operations Contexts |
michael@0 | 364 | */ |
michael@0 | 365 | struct SFTKHashVerifyInfoStr { |
michael@0 | 366 | SECOidTag hashOid; |
michael@0 | 367 | void *params; |
michael@0 | 368 | NSSLOWKEYPublicKey *key; |
michael@0 | 369 | }; |
michael@0 | 370 | |
michael@0 | 371 | struct SFTKHashSignInfoStr { |
michael@0 | 372 | SECOidTag hashOid; |
michael@0 | 373 | void *params; |
michael@0 | 374 | NSSLOWKEYPrivateKey *key; |
michael@0 | 375 | }; |
michael@0 | 376 | |
michael@0 | 377 | /** |
michael@0 | 378 | * Contexts for RSA-OAEP |
michael@0 | 379 | */ |
michael@0 | 380 | struct SFTKOAEPEncryptInfoStr { |
michael@0 | 381 | CK_RSA_PKCS_OAEP_PARAMS *params; |
michael@0 | 382 | NSSLOWKEYPublicKey *key; |
michael@0 | 383 | }; |
michael@0 | 384 | |
michael@0 | 385 | struct SFTKOAEPDecryptInfoStr { |
michael@0 | 386 | CK_RSA_PKCS_OAEP_PARAMS *params; |
michael@0 | 387 | NSSLOWKEYPrivateKey *key; |
michael@0 | 388 | }; |
michael@0 | 389 | |
michael@0 | 390 | /* context for the Final SSLMAC message */ |
michael@0 | 391 | struct SFTKSSLMACInfoStr { |
michael@0 | 392 | void *hashContext; |
michael@0 | 393 | SFTKBegin begin; |
michael@0 | 394 | SFTKHash update; |
michael@0 | 395 | SFTKEnd end; |
michael@0 | 396 | CK_ULONG macSize; |
michael@0 | 397 | int padSize; |
michael@0 | 398 | unsigned char key[MAX_KEY_LEN]; |
michael@0 | 399 | unsigned int keySize; |
michael@0 | 400 | }; |
michael@0 | 401 | |
michael@0 | 402 | /* |
michael@0 | 403 | * Template based on SECItems, suitable for passing as arrays |
michael@0 | 404 | */ |
michael@0 | 405 | struct SFTKItemTemplateStr { |
michael@0 | 406 | CK_ATTRIBUTE_TYPE type; |
michael@0 | 407 | SECItem *item; |
michael@0 | 408 | }; |
michael@0 | 409 | |
michael@0 | 410 | /* macro for setting SFTKTemplates. */ |
michael@0 | 411 | #define SFTK_SET_ITEM_TEMPLATE(templ, count, itemPtr, attr) \ |
michael@0 | 412 | templ[count].type = attr; \ |
michael@0 | 413 | templ[count].item = itemPtr |
michael@0 | 414 | |
michael@0 | 415 | #define SFTK_MAX_ITEM_TEMPLATE 10 |
michael@0 | 416 | |
michael@0 | 417 | /* |
michael@0 | 418 | * session handle modifiers |
michael@0 | 419 | */ |
michael@0 | 420 | #define SFTK_SESSION_SLOT_MASK 0xff000000L |
michael@0 | 421 | |
michael@0 | 422 | /* |
michael@0 | 423 | * object handle modifiers |
michael@0 | 424 | */ |
michael@0 | 425 | #define SFTK_TOKEN_MASK 0x80000000L |
michael@0 | 426 | #define SFTK_TOKEN_MAGIC 0x80000000L |
michael@0 | 427 | #define SFTK_TOKEN_TYPE_MASK 0x70000000L |
michael@0 | 428 | /* keydb (high bit == 0) */ |
michael@0 | 429 | #define SFTK_TOKEN_TYPE_PRIV 0x10000000L |
michael@0 | 430 | #define SFTK_TOKEN_TYPE_PUB 0x20000000L |
michael@0 | 431 | #define SFTK_TOKEN_TYPE_KEY 0x30000000L |
michael@0 | 432 | /* certdb (high bit == 1) */ |
michael@0 | 433 | #define SFTK_TOKEN_TYPE_TRUST 0x40000000L |
michael@0 | 434 | #define SFTK_TOKEN_TYPE_CRL 0x50000000L |
michael@0 | 435 | #define SFTK_TOKEN_TYPE_SMIME 0x60000000L |
michael@0 | 436 | #define SFTK_TOKEN_TYPE_CERT 0x70000000L |
michael@0 | 437 | |
michael@0 | 438 | #define SFTK_TOKEN_KRL_HANDLE (SFTK_TOKEN_MAGIC|SFTK_TOKEN_TYPE_CRL|1) |
michael@0 | 439 | /* how big (in bytes) a password/pin we can deal with */ |
michael@0 | 440 | #define SFTK_MAX_PIN 255 |
michael@0 | 441 | /* minimum password/pin length (in Unicode characters) in FIPS mode */ |
michael@0 | 442 | #define FIPS_MIN_PIN 7 |
michael@0 | 443 | |
michael@0 | 444 | /* slot ID's */ |
michael@0 | 445 | #define NETSCAPE_SLOT_ID 1 |
michael@0 | 446 | #define PRIVATE_KEY_SLOT_ID 2 |
michael@0 | 447 | #define FIPS_SLOT_ID 3 |
michael@0 | 448 | |
michael@0 | 449 | /* slot helper macros */ |
michael@0 | 450 | #define sftk_SlotFromSession(sp) ((sp)->slot) |
michael@0 | 451 | #define sftk_isToken(id) (((id) & SFTK_TOKEN_MASK) == SFTK_TOKEN_MAGIC) |
michael@0 | 452 | |
michael@0 | 453 | /* the session hash multiplier (see bug 201081) */ |
michael@0 | 454 | #define SHMULTIPLIER 1791398085 |
michael@0 | 455 | |
michael@0 | 456 | /* queueing helper macros */ |
michael@0 | 457 | #define sftk_hash(value,size) \ |
michael@0 | 458 | ((PRUint32)((value) * SHMULTIPLIER) & (size-1)) |
michael@0 | 459 | #define sftkqueue_add(element,id,head,hash_size) \ |
michael@0 | 460 | { int tmp = sftk_hash(id,hash_size); \ |
michael@0 | 461 | (element)->next = (head)[tmp]; \ |
michael@0 | 462 | (element)->prev = NULL; \ |
michael@0 | 463 | if ((head)[tmp]) (head)[tmp]->prev = (element); \ |
michael@0 | 464 | (head)[tmp] = (element); } |
michael@0 | 465 | #define sftkqueue_find(element,id,head,hash_size) \ |
michael@0 | 466 | for( (element) = (head)[sftk_hash(id,hash_size)]; (element) != NULL; \ |
michael@0 | 467 | (element) = (element)->next) { \ |
michael@0 | 468 | if ((element)->handle == (id)) { break; } } |
michael@0 | 469 | #define sftkqueue_is_queued(element,id,head,hash_size) \ |
michael@0 | 470 | ( ((element)->next) || ((element)->prev) || \ |
michael@0 | 471 | ((head)[sftk_hash(id,hash_size)] == (element)) ) |
michael@0 | 472 | #define sftkqueue_delete(element,id,head,hash_size) \ |
michael@0 | 473 | if ((element)->next) (element)->next->prev = (element)->prev; \ |
michael@0 | 474 | if ((element)->prev) (element)->prev->next = (element)->next; \ |
michael@0 | 475 | else (head)[sftk_hash(id,hash_size)] = ((element)->next); \ |
michael@0 | 476 | (element)->next = NULL; \ |
michael@0 | 477 | (element)->prev = NULL; \ |
michael@0 | 478 | |
michael@0 | 479 | #define sftkqueue_init_element(element) \ |
michael@0 | 480 | (element)->prev = NULL; |
michael@0 | 481 | |
michael@0 | 482 | #define sftkqueue_add2(element, id, index, head) \ |
michael@0 | 483 | { \ |
michael@0 | 484 | (element)->next = (head)[index]; \ |
michael@0 | 485 | if ((head)[index]) \ |
michael@0 | 486 | (head)[index]->prev = (element); \ |
michael@0 | 487 | (head)[index] = (element); \ |
michael@0 | 488 | } |
michael@0 | 489 | |
michael@0 | 490 | #define sftkqueue_find2(element, id, index, head) \ |
michael@0 | 491 | for ( (element) = (head)[index]; \ |
michael@0 | 492 | (element) != NULL; \ |
michael@0 | 493 | (element) = (element)->next) { \ |
michael@0 | 494 | if ((element)->handle == (id)) { break; } \ |
michael@0 | 495 | } |
michael@0 | 496 | |
michael@0 | 497 | #define sftkqueue_delete2(element, id, index, head) \ |
michael@0 | 498 | if ((element)->next) (element)->next->prev = (element)->prev; \ |
michael@0 | 499 | if ((element)->prev) (element)->prev->next = (element)->next; \ |
michael@0 | 500 | else (head)[index] = ((element)->next); |
michael@0 | 501 | |
michael@0 | 502 | #define sftkqueue_clear_deleted_element(element) \ |
michael@0 | 503 | (element)->next = NULL; \ |
michael@0 | 504 | (element)->prev = NULL; \ |
michael@0 | 505 | |
michael@0 | 506 | |
michael@0 | 507 | /* sessionID (handle) is used to determine session lock bucket */ |
michael@0 | 508 | #ifdef NOSPREAD |
michael@0 | 509 | /* NOSPREAD: (ID>>L2LPB) & (perbucket-1) */ |
michael@0 | 510 | #define SFTK_SESSION_LOCK(slot,handle) \ |
michael@0 | 511 | ((slot)->sessionLock[((handle) >> LOG2_BUCKETS_PER_SESSION_LOCK) \ |
michael@0 | 512 | & (slot)->sessionLockMask]) |
michael@0 | 513 | #else |
michael@0 | 514 | /* SPREAD: ID & (perbucket-1) */ |
michael@0 | 515 | #define SFTK_SESSION_LOCK(slot,handle) \ |
michael@0 | 516 | ((slot)->sessionLock[(handle) & (slot)->sessionLockMask]) |
michael@0 | 517 | #endif |
michael@0 | 518 | |
michael@0 | 519 | /* expand an attribute & secitem structures out */ |
michael@0 | 520 | #define sftk_attr_expand(ap) (ap)->type,(ap)->pValue,(ap)->ulValueLen |
michael@0 | 521 | #define sftk_item_expand(ip) (ip)->data,(ip)->len |
michael@0 | 522 | |
michael@0 | 523 | typedef struct sftk_token_parametersStr { |
michael@0 | 524 | CK_SLOT_ID slotID; |
michael@0 | 525 | char *configdir; |
michael@0 | 526 | char *certPrefix; |
michael@0 | 527 | char *keyPrefix; |
michael@0 | 528 | char *updatedir; |
michael@0 | 529 | char *updCertPrefix; |
michael@0 | 530 | char *updKeyPrefix; |
michael@0 | 531 | char *updateID; |
michael@0 | 532 | char *tokdes; |
michael@0 | 533 | char *slotdes; |
michael@0 | 534 | char *updtokdes; |
michael@0 | 535 | int minPW; |
michael@0 | 536 | PRBool readOnly; |
michael@0 | 537 | PRBool noCertDB; |
michael@0 | 538 | PRBool noKeyDB; |
michael@0 | 539 | PRBool forceOpen; |
michael@0 | 540 | PRBool pwRequired; |
michael@0 | 541 | PRBool optimizeSpace; |
michael@0 | 542 | } sftk_token_parameters; |
michael@0 | 543 | |
michael@0 | 544 | typedef struct sftk_parametersStr { |
michael@0 | 545 | char *configdir; |
michael@0 | 546 | char *updatedir; |
michael@0 | 547 | char *updateID; |
michael@0 | 548 | char *secmodName; |
michael@0 | 549 | char *man; |
michael@0 | 550 | char *libdes; |
michael@0 | 551 | PRBool readOnly; |
michael@0 | 552 | PRBool noModDB; |
michael@0 | 553 | PRBool noCertDB; |
michael@0 | 554 | PRBool forceOpen; |
michael@0 | 555 | PRBool pwRequired; |
michael@0 | 556 | PRBool optimizeSpace; |
michael@0 | 557 | sftk_token_parameters *tokens; |
michael@0 | 558 | int token_count; |
michael@0 | 559 | } sftk_parameters; |
michael@0 | 560 | |
michael@0 | 561 | |
michael@0 | 562 | /* path stuff (was machine dependent) used by dbinit.c and pk11db.c */ |
michael@0 | 563 | #define CERT_DB_FMT "%scert%s.db" |
michael@0 | 564 | #define KEY_DB_FMT "%skey%s.db" |
michael@0 | 565 | |
michael@0 | 566 | SEC_BEGIN_PROTOS |
michael@0 | 567 | |
michael@0 | 568 | /* shared functions between pkcs11.c and fipstokn.c */ |
michael@0 | 569 | extern PRBool nsf_init; |
michael@0 | 570 | extern CK_RV nsc_CommonInitialize(CK_VOID_PTR pReserved, PRBool isFIPS); |
michael@0 | 571 | extern CK_RV nsc_CommonFinalize(CK_VOID_PTR pReserved, PRBool isFIPS); |
michael@0 | 572 | extern PRBool sftk_ForkReset(CK_VOID_PTR pReserved, CK_RV* crv); |
michael@0 | 573 | extern CK_RV nsc_CommonGetSlotList(CK_BBOOL tokPresent, |
michael@0 | 574 | CK_SLOT_ID_PTR pSlotList, CK_ULONG_PTR pulCount, int moduleIndex); |
michael@0 | 575 | |
michael@0 | 576 | /* slot initialization, reinit, shutdown and destruction */ |
michael@0 | 577 | extern CK_RV SFTK_SlotInit(char *configdir, char *updatedir, char *updateID, |
michael@0 | 578 | sftk_token_parameters *params, int moduleIndex); |
michael@0 | 579 | extern CK_RV SFTK_SlotReInit(SFTKSlot *slot, char *configdir, |
michael@0 | 580 | char *updatedir, char *updateID, |
michael@0 | 581 | sftk_token_parameters *params, int moduleIndex); |
michael@0 | 582 | extern CK_RV SFTK_DestroySlotData(SFTKSlot *slot); |
michael@0 | 583 | extern CK_RV SFTK_ShutdownSlot(SFTKSlot *slot); |
michael@0 | 584 | extern CK_RV sftk_CloseAllSessions(SFTKSlot *slot, PRBool logout); |
michael@0 | 585 | |
michael@0 | 586 | |
michael@0 | 587 | /* internal utility functions used by pkcs11.c */ |
michael@0 | 588 | extern SFTKAttribute *sftk_FindAttribute(SFTKObject *object, |
michael@0 | 589 | CK_ATTRIBUTE_TYPE type); |
michael@0 | 590 | extern void sftk_FreeAttribute(SFTKAttribute *attribute); |
michael@0 | 591 | extern CK_RV sftk_AddAttributeType(SFTKObject *object, CK_ATTRIBUTE_TYPE type, |
michael@0 | 592 | const void *valPtr, CK_ULONG length); |
michael@0 | 593 | extern CK_RV sftk_Attribute2SecItem(PLArenaPool *arena, SECItem *item, |
michael@0 | 594 | SFTKObject *object, CK_ATTRIBUTE_TYPE type); |
michael@0 | 595 | extern CK_RV sftk_MultipleAttribute2SecItem(PLArenaPool *arena, |
michael@0 | 596 | SFTKObject *object, SFTKItemTemplate *templ, int count); |
michael@0 | 597 | extern unsigned int sftk_GetLengthInBits(unsigned char *buf, |
michael@0 | 598 | unsigned int bufLen); |
michael@0 | 599 | extern CK_RV sftk_ConstrainAttribute(SFTKObject *object, |
michael@0 | 600 | CK_ATTRIBUTE_TYPE type, int minLength, int maxLength, int minMultiple); |
michael@0 | 601 | extern PRBool sftk_hasAttribute(SFTKObject *object, CK_ATTRIBUTE_TYPE type); |
michael@0 | 602 | extern PRBool sftk_isTrue(SFTKObject *object, CK_ATTRIBUTE_TYPE type); |
michael@0 | 603 | extern void sftk_DeleteAttributeType(SFTKObject *object, |
michael@0 | 604 | CK_ATTRIBUTE_TYPE type); |
michael@0 | 605 | extern CK_RV sftk_Attribute2SecItem(PLArenaPool *arena, SECItem *item, |
michael@0 | 606 | SFTKObject *object, CK_ATTRIBUTE_TYPE type); |
michael@0 | 607 | extern CK_RV sftk_Attribute2SSecItem(PLArenaPool *arena, SECItem *item, |
michael@0 | 608 | SFTKObject *object, |
michael@0 | 609 | CK_ATTRIBUTE_TYPE type); |
michael@0 | 610 | extern SFTKModifyType sftk_modifyType(CK_ATTRIBUTE_TYPE type, |
michael@0 | 611 | CK_OBJECT_CLASS inClass); |
michael@0 | 612 | extern PRBool sftk_isSensitive(CK_ATTRIBUTE_TYPE type, CK_OBJECT_CLASS inClass); |
michael@0 | 613 | extern char *sftk_getString(SFTKObject *object, CK_ATTRIBUTE_TYPE type); |
michael@0 | 614 | extern void sftk_nullAttribute(SFTKObject *object,CK_ATTRIBUTE_TYPE type); |
michael@0 | 615 | extern CK_RV sftk_GetULongAttribute(SFTKObject *object, CK_ATTRIBUTE_TYPE type, |
michael@0 | 616 | CK_ULONG *longData); |
michael@0 | 617 | extern CK_RV sftk_forceAttribute(SFTKObject *object, CK_ATTRIBUTE_TYPE type, |
michael@0 | 618 | const void *value, unsigned int len); |
michael@0 | 619 | extern CK_RV sftk_defaultAttribute(SFTKObject *object, CK_ATTRIBUTE_TYPE type, |
michael@0 | 620 | const void *value, unsigned int len); |
michael@0 | 621 | extern unsigned int sftk_MapTrust(CK_TRUST trust, PRBool clientAuth); |
michael@0 | 622 | |
michael@0 | 623 | extern SFTKObject *sftk_NewObject(SFTKSlot *slot); |
michael@0 | 624 | extern CK_RV sftk_CopyObject(SFTKObject *destObject, SFTKObject *srcObject); |
michael@0 | 625 | extern SFTKFreeStatus sftk_FreeObject(SFTKObject *object); |
michael@0 | 626 | extern CK_RV sftk_DeleteObject(SFTKSession *session, SFTKObject *object); |
michael@0 | 627 | extern void sftk_ReferenceObject(SFTKObject *object); |
michael@0 | 628 | extern SFTKObject *sftk_ObjectFromHandle(CK_OBJECT_HANDLE handle, |
michael@0 | 629 | SFTKSession *session); |
michael@0 | 630 | extern void sftk_AddSlotObject(SFTKSlot *slot, SFTKObject *object); |
michael@0 | 631 | extern void sftk_AddObject(SFTKSession *session, SFTKObject *object); |
michael@0 | 632 | /* clear out all the existing object ID to database key mappings. |
michael@0 | 633 | * used to reinit a token */ |
michael@0 | 634 | extern CK_RV SFTK_ClearTokenKeyHashTable(SFTKSlot *slot); |
michael@0 | 635 | |
michael@0 | 636 | extern CK_RV sftk_searchObjectList(SFTKSearchResults *search, |
michael@0 | 637 | SFTKObject **head, unsigned int size, |
michael@0 | 638 | PZLock *lock, CK_ATTRIBUTE_PTR inTemplate, |
michael@0 | 639 | int count, PRBool isLoggedIn); |
michael@0 | 640 | extern SFTKObjectListElement *sftk_FreeObjectListElement( |
michael@0 | 641 | SFTKObjectListElement *objectList); |
michael@0 | 642 | extern void sftk_FreeObjectList(SFTKObjectListElement *objectList); |
michael@0 | 643 | extern void sftk_FreeSearch(SFTKSearchResults *search); |
michael@0 | 644 | extern CK_RV sftk_handleObject(SFTKObject *object, SFTKSession *session); |
michael@0 | 645 | |
michael@0 | 646 | extern SFTKSlot *sftk_SlotFromID(CK_SLOT_ID slotID, PRBool all); |
michael@0 | 647 | extern SFTKSlot *sftk_SlotFromSessionHandle(CK_SESSION_HANDLE handle); |
michael@0 | 648 | extern SFTKSession *sftk_SessionFromHandle(CK_SESSION_HANDLE handle); |
michael@0 | 649 | extern void sftk_FreeSession(SFTKSession *session); |
michael@0 | 650 | extern SFTKSession *sftk_NewSession(CK_SLOT_ID slotID, CK_NOTIFY notify, |
michael@0 | 651 | CK_VOID_PTR pApplication, CK_FLAGS flags); |
michael@0 | 652 | extern void sftk_update_state(SFTKSlot *slot,SFTKSession *session); |
michael@0 | 653 | extern void sftk_update_all_states(SFTKSlot *slot); |
michael@0 | 654 | extern void sftk_FreeContext(SFTKSessionContext *context); |
michael@0 | 655 | extern void sftk_InitFreeLists(void); |
michael@0 | 656 | extern void sftk_CleanupFreeLists(void); |
michael@0 | 657 | |
michael@0 | 658 | extern NSSLOWKEYPublicKey *sftk_GetPubKey(SFTKObject *object, |
michael@0 | 659 | CK_KEY_TYPE key_type, CK_RV *crvp); |
michael@0 | 660 | extern NSSLOWKEYPrivateKey *sftk_GetPrivKey(SFTKObject *object, |
michael@0 | 661 | CK_KEY_TYPE key_type, CK_RV *crvp); |
michael@0 | 662 | extern void sftk_FormatDESKey(unsigned char *key, int length); |
michael@0 | 663 | extern PRBool sftk_CheckDESKey(unsigned char *key); |
michael@0 | 664 | extern PRBool sftk_IsWeakKey(unsigned char *key,CK_KEY_TYPE key_type); |
michael@0 | 665 | |
michael@0 | 666 | /* mechanism allows this operation */ |
michael@0 | 667 | extern CK_RV sftk_MechAllowsOperation(CK_MECHANISM_TYPE type, CK_ATTRIBUTE_TYPE op); |
michael@0 | 668 | |
michael@0 | 669 | /* helper function which calls nsslowkey_FindKeyByPublicKey after safely |
michael@0 | 670 | * acquiring a reference to the keydb from the slot */ |
michael@0 | 671 | NSSLOWKEYPrivateKey *sftk_FindKeyByPublicKey(SFTKSlot *slot, SECItem *dbKey); |
michael@0 | 672 | |
michael@0 | 673 | /* |
michael@0 | 674 | * parameter parsing functions |
michael@0 | 675 | */ |
michael@0 | 676 | CK_RV sftk_parseParameters(char *param, sftk_parameters *parsed, PRBool isFIPS); |
michael@0 | 677 | void sftk_freeParams(sftk_parameters *params); |
michael@0 | 678 | |
michael@0 | 679 | |
michael@0 | 680 | /* |
michael@0 | 681 | * narrow objects |
michael@0 | 682 | */ |
michael@0 | 683 | SFTKSessionObject * sftk_narrowToSessionObject(SFTKObject *); |
michael@0 | 684 | SFTKTokenObject * sftk_narrowToTokenObject(SFTKObject *); |
michael@0 | 685 | |
michael@0 | 686 | /* |
michael@0 | 687 | * token object utilities |
michael@0 | 688 | */ |
michael@0 | 689 | void sftk_addHandle(SFTKSearchResults *search, CK_OBJECT_HANDLE handle); |
michael@0 | 690 | PRBool sftk_poisonHandle(SFTKSlot *slot, SECItem *dbkey, |
michael@0 | 691 | CK_OBJECT_HANDLE handle); |
michael@0 | 692 | SFTKObject * sftk_NewTokenObject(SFTKSlot *slot, SECItem *dbKey, |
michael@0 | 693 | CK_OBJECT_HANDLE handle); |
michael@0 | 694 | SFTKTokenObject *sftk_convertSessionToToken(SFTKObject *so); |
michael@0 | 695 | |
michael@0 | 696 | |
michael@0 | 697 | /* J-PAKE (jpakesftk.c) */ |
michael@0 | 698 | extern |
michael@0 | 699 | CK_RV jpake_Round1(HASH_HashType hashType, |
michael@0 | 700 | CK_NSS_JPAKERound1Params * params, |
michael@0 | 701 | SFTKObject * key); |
michael@0 | 702 | extern |
michael@0 | 703 | CK_RV jpake_Round2(HASH_HashType hashType, |
michael@0 | 704 | CK_NSS_JPAKERound2Params * params, |
michael@0 | 705 | SFTKObject * sourceKey, SFTKObject * key); |
michael@0 | 706 | extern |
michael@0 | 707 | CK_RV jpake_Final(HASH_HashType hashType, |
michael@0 | 708 | const CK_NSS_JPAKEFinalParams * params, |
michael@0 | 709 | SFTKObject * sourceKey, SFTKObject * key); |
michael@0 | 710 | |
michael@0 | 711 | /* Constant time MAC functions (hmacct.c) */ |
michael@0 | 712 | |
michael@0 | 713 | struct sftk_MACConstantTimeCtxStr { |
michael@0 | 714 | const SECHashObject *hash; |
michael@0 | 715 | unsigned char mac[64]; |
michael@0 | 716 | unsigned char secret[64]; |
michael@0 | 717 | unsigned int headerLength; |
michael@0 | 718 | unsigned int secretLength; |
michael@0 | 719 | unsigned int totalLength; |
michael@0 | 720 | unsigned char header[75]; |
michael@0 | 721 | }; |
michael@0 | 722 | typedef struct sftk_MACConstantTimeCtxStr sftk_MACConstantTimeCtx; |
michael@0 | 723 | sftk_MACConstantTimeCtx* sftk_HMACConstantTime_New( |
michael@0 | 724 | CK_MECHANISM_PTR mech, SFTKObject *key); |
michael@0 | 725 | sftk_MACConstantTimeCtx* sftk_SSLv3MACConstantTime_New( |
michael@0 | 726 | CK_MECHANISM_PTR mech, SFTKObject *key); |
michael@0 | 727 | void sftk_HMACConstantTime_Update(void *pctx, void *data, unsigned int len); |
michael@0 | 728 | void sftk_SSLv3MACConstantTime_Update(void *pctx, void *data, unsigned int len); |
michael@0 | 729 | void sftk_MACConstantTime_EndHash( |
michael@0 | 730 | void *pctx, void *out, unsigned int *outLength, unsigned int maxLength); |
michael@0 | 731 | void sftk_MACConstantTime_DestroyContext(void *pctx, PRBool); |
michael@0 | 732 | |
michael@0 | 733 | /**************************************** |
michael@0 | 734 | * implement TLS Pseudo Random Function (PRF) |
michael@0 | 735 | */ |
michael@0 | 736 | |
michael@0 | 737 | extern CK_RV |
michael@0 | 738 | sftk_TLSPRFInit(SFTKSessionContext *context, |
michael@0 | 739 | SFTKObject * key, |
michael@0 | 740 | CK_KEY_TYPE key_type, |
michael@0 | 741 | HASH_HashType hash_alg); |
michael@0 | 742 | |
michael@0 | 743 | SEC_END_PROTOS |
michael@0 | 744 | |
michael@0 | 745 | #endif /* _PKCS11I_H_ */ |