1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
14 * The Original Code is the Netscape security libraries.
16 * The Initial Developer of the Original Code is
17 * Netscape Communications Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 1994-2000
19 * the Initial Developer. All Rights Reserved.
23 * Alternatively, the contents of this file may be used under the terms of
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 * in which case the provisions of the GPL or the LGPL are applicable instead
27 * of those above. If you wish to allow use of your version of this file only
28 * under the terms of either the GPL or the LGPL, and not to allow others to
29 * use your version of this file under the terms of the MPL, indicate your
30 * decision by deleting the provisions above and replace them with the notice
31 * and other provisions required by the GPL or the LGPL. If you do not delete
32 * the provisions above, a recipient may use your version of this file under
33 * the terms of any one of the MPL, the GPL or the LGPL.
35 * ***** END LICENSE BLOCK ***** */
37 * Internal data structures and functions used by pkcs11.c
52 * Configuration Defines
54 * The following defines affect the space verse speed trade offs of
55 * the PKCS #11 module. For the most part the current settings are optimized
56 * for web servers, where we want faster speed and lower lock contention at
57 * the expense of space.
61 * The attribute allocation strategy is static allocation:
62 * Attributes are pre-allocated as part of the session object and used from
65 #define MAX_OBJS_ATTRS 45 /* number of attributes to preallocate in
66 * the object (must me the absolute max) */
67 #define ATTR_SPACE 50 /* Maximum size of attribute data before extra
68 * data needs to be allocated. This is set to
69 * enough space to hold an SSL MASTER secret */
71 #define NSC_STRICT PR_FALSE /* forces the code to do strict template
72 * matching when doing C_FindObject on token
73 * objects. This will slow down search in
75 /* default search block allocations and increments */
76 #define NSC_CERT_BLOCK_SIZE 50
77 #define NSC_SEARCH_BLOCK_SIZE 5
78 #define NSC_SLOT_LIST_BLOCK_SIZE 10
80 #define NSC_FIPS_MODULE 1
81 #define NSC_NON_FIPS_MODULE 0
83 /* these are data base storage hashes, not cryptographic hashes.. The define
84 * the effective size of the various object hash tables */
85 /* clients care more about memory usage than lookup performance on
86 * cyrptographic objects. Clients also have less objects around to play with
88 * we eventually should make this configurable at runtime! Especially now that
89 * NSS is a shared library.
91 #define SPACE_ATTRIBUTE_HASH_SIZE 32
92 #define SPACE_SESSION_OBJECT_HASH_SIZE 32
93 #define SPACE_SESSION_HASH_SIZE 32
94 #define TIME_ATTRIBUTE_HASH_SIZE 32
95 #define TIME_SESSION_OBJECT_HASH_SIZE 1024
96 #define TIME_SESSION_HASH_SIZE 1024
97 #define MAX_OBJECT_LIST_SIZE 800
98 /* how many objects to keep on the free list
99 * before we start freeing them */
100 #define MAX_KEY_LEN 256 /* maximum symmetric key length in bytes */
102 #define MULTIACCESS "multiaccess:"
105 * LOG2_BUCKETS_PER_SESSION_LOCK must be a prime number.
106 * With SESSION_HASH_SIZE=1024, LOG2 can be 9, 5, 1, or 0.
107 * With SESSION_HASH_SIZE=4096, LOG2 can be 11, 9, 5, 1, or 0.
109 * HASH_SIZE LOG2_BUCKETS_PER BUCKETS_PER_LOCK NUMBER_OF_BUCKETS
120 #define LOG2_BUCKETS_PER_SESSION_LOCK 1
121 #define BUCKETS_PER_SESSION_LOCK (1 << (LOG2_BUCKETS_PER_SESSION_LOCK))
122 /* NOSPREAD sessionID to hash table index macro has been slower. */
124 /* define typedefs, double as forward declarations as well */
125 typedef struct SFTKAttributeStr SFTKAttribute
;
126 typedef struct SFTKObjectListStr SFTKObjectList
;
127 typedef struct SFTKObjectFreeListStr SFTKObjectFreeList
;
128 typedef struct SFTKObjectListElementStr SFTKObjectListElement
;
129 typedef struct SFTKObjectStr SFTKObject
;
130 typedef struct SFTKSessionObjectStr SFTKSessionObject
;
131 typedef struct SFTKTokenObjectStr SFTKTokenObject
;
132 typedef struct SFTKSessionStr SFTKSession
;
133 typedef struct SFTKSlotStr SFTKSlot
;
134 typedef struct SFTKSessionContextStr SFTKSessionContext
;
135 typedef struct SFTKSearchResultsStr SFTKSearchResults
;
136 typedef struct SFTKHashVerifyInfoStr SFTKHashVerifyInfo
;
137 typedef struct SFTKHashSignInfoStr SFTKHashSignInfo
;
138 typedef struct SFTKSSLMACInfoStr SFTKSSLMACInfo
;
140 /* define function pointer typdefs for pointer tables */
141 typedef void (*SFTKDestroy
)(void *, PRBool
);
142 typedef void (*SFTKBegin
)(void *);
143 typedef SECStatus (*SFTKCipher
)(void *,void *,unsigned int *,unsigned int,
144 void *, unsigned int);
145 typedef SECStatus (*SFTKVerify
)(void *,void *,unsigned int,void *,unsigned int);
146 typedef void (*SFTKHash
)(void *,void *,unsigned int);
147 typedef void (*SFTKEnd
)(void *,void *,unsigned int *,unsigned int);
148 typedef void (*SFTKFree
)(void *);
150 /* Value to tell if an attribute is modifiable or not.
151 * NEVER: attribute is only set on creation.
152 * ONCOPY: attribute is set on creation and can only be changed on copy.
153 * SENSITIVE: attribute can only be changed to TRUE.
154 * ALWAYS: attribute can always be changed.
164 * Free Status Enum... tell us more information when we think we're
165 * deleting an object.
174 * attribute values of an object.
176 struct SFTKAttributeStr
{
181 /*must be called handle to make sftkqueue_find work */
182 CK_ATTRIBUTE_TYPE handle
;
184 unsigned char space
[ATTR_SPACE
];
189 * doubly link list of objects
191 struct SFTKObjectListStr
{
192 SFTKObjectList
*next
;
193 SFTKObjectList
*prev
;
197 struct SFTKObjectFreeListStr
{
204 * PKCS 11 crypto object structure
206 struct SFTKObjectStr
{
209 CK_OBJECT_CLASS objclass
;
210 CK_OBJECT_HANDLE handle
;
218 struct SFTKTokenObjectStr
{
223 struct SFTKSessionObjectStr
{
225 SFTKObjectList sessionList
;
226 PZLock
*attributeLock
;
227 SFTKSession
*session
;
230 SFTKAttribute attrList
[MAX_OBJS_ATTRS
];
231 PRBool optimizeSpace
;
232 unsigned int hashSize
;
233 SFTKAttribute
*head
[1];
237 * struct to deal with a temparary list of objects
239 struct SFTKObjectListElementStr
{
240 SFTKObjectListElement
*next
;
245 * Area to hold Search results
247 struct SFTKSearchResultsStr
{
248 CK_OBJECT_HANDLE
*handles
;
256 * the universal crypto/hash/sign/verify context structure
269 #define SFTK_MAX_BLOCK_SIZE 16
270 /* currently SHA512 is the biggest hash length */
271 #define SFTK_MAX_MAC_LENGTH 64
272 #define SFTK_INVALID_MAC_SIZE 0xffffffff
274 struct SFTKSessionContextStr
{
275 SFTKContextType type
;
276 PRBool multi
; /* is multipart */
277 PRBool doPad
; /* use PKCS padding for block ciphers */
278 unsigned int blockSize
; /* blocksize for padding */
279 unsigned int padDataLength
; /* length of the valid data in padbuf */
280 unsigned char padBuf
[SFTK_MAX_BLOCK_SIZE
];
281 unsigned char macBuf
[SFTK_MAX_BLOCK_SIZE
];
282 CK_ULONG macSize
; /* size of a general block cipher mac*/
285 unsigned int cipherInfoLen
;
286 CK_MECHANISM_TYPE currentMech
;
291 SFTKDestroy hashdestroy
;
298 * Sessions (have objects)
300 struct SFTKSessionStr
{
303 CK_SESSION_HANDLE handle
;
307 CK_SESSION_INFO info
;
311 SFTKSearchResults
*search
;
312 SFTKSessionContext
*enc_context
;
313 SFTKSessionContext
*hash_context
;
314 SFTKSessionContext
*sign_context
;
315 SFTKObjectList
*objects
[1];
319 * slots (have sessions and objects)
321 * The array of sessionLock's protect the session hash table (head[])
322 * as well as the reference count of session objects in that bucket
323 * (head[]->refCount), objectLock protects all elements of the slot's
324 * object hash tables (sessObjHashTable[] and tokObjHashTable), and
325 * sessionObjectHandleCount.
326 * slotLock protects the remaining protected elements:
327 * password, isLoggedIn, ssoLoggedIn, and sessionCount,
328 * and pwCheckLock serializes the key database password checks in
329 * NSC_SetPIN and NSC_Login.
331 * Each of the fields below has the following lifetime as commented
332 * next to the fields:
333 * invariant - This value is set when the slot is first created and
334 * never changed until it is destroyed.
335 * per load - This value is set when the slot is first created, or
336 * when the slot is used to open another directory. Between open and close
337 * this field does not change.
338 * variable - This value changes through the normal process of slot operation.
339 * - reset. The value of this variable is cleared during an open/close
341 * - preserved. The value of this variable is preserved over open/close
345 CK_SLOT_ID slotID
; /* invariant */
346 PZLock
*slotLock
; /* invariant */
347 PZLock
**sessionLock
; /* invariant */
348 unsigned int numSessionLocks
; /* invariant */
349 unsigned long sessionLockMask
; /* invariant */
350 PZLock
*objectLock
; /* invariant */
351 PRLock
*pwCheckLock
; /* invariant */
352 PRBool present
; /* variable -set */
353 PRBool hasTokens
; /* per load */
354 PRBool isLoggedIn
; /* variable - reset */
355 PRBool ssoLoggedIn
; /* variable - reset */
356 PRBool needLogin
; /* per load */
357 PRBool DB_loaded
; /* per load */
358 PRBool readOnly
; /* per load */
359 PRBool optimizeSpace
; /* invariant */
360 SFTKDBHandle
*certDB
; /* per load */
361 SFTKDBHandle
*keyDB
; /* per load */
362 int minimumPinLen
; /* per load */
363 PRInt32 sessionIDCount
; /* atomically incremented */
365 int sessionIDConflict
; /* not protected by a lock */
367 int sessionCount
; /* variable - reset */
368 PRInt32 rwSessionCount
; /* set by atomic operations */
370 int sessionObjectHandleCount
;/* variable - perserved */
371 int index
; /* invariant */
372 PLHashTable
*tokObjHashTable
; /* invariant */
373 SFTKObject
**sessObjHashTable
; /* variable - reset */
374 unsigned int sessObjHashSize
; /* invariant */
375 SFTKSession
**head
; /* variable -reset */
376 unsigned int sessHashSize
; /* invariant */
377 char tokDescription
[33]; /* per load */
378 char slotDescription
[64]; /* invariant */
382 * special joint operations Contexts
384 struct SFTKHashVerifyInfoStr
{
386 NSSLOWKEYPublicKey
*key
;
389 struct SFTKHashSignInfoStr
{
391 NSSLOWKEYPrivateKey
*key
;
394 /* context for the Final SSLMAC message */
395 struct SFTKSSLMACInfoStr
{
402 unsigned char key
[MAX_KEY_LEN
];
403 unsigned int keySize
;
407 * session handle modifiers
409 #define SFTK_SESSION_SLOT_MASK 0xff000000L
412 * object handle modifiers
414 #define SFTK_TOKEN_MASK 0x80000000L
415 #define SFTK_TOKEN_MAGIC 0x80000000L
416 #define SFTK_TOKEN_TYPE_MASK 0x70000000L
417 /* keydb (high bit == 0) */
418 #define SFTK_TOKEN_TYPE_PRIV 0x10000000L
419 #define SFTK_TOKEN_TYPE_PUB 0x20000000L
420 #define SFTK_TOKEN_TYPE_KEY 0x30000000L
421 /* certdb (high bit == 1) */
422 #define SFTK_TOKEN_TYPE_TRUST 0x40000000L
423 #define SFTK_TOKEN_TYPE_CRL 0x50000000L
424 #define SFTK_TOKEN_TYPE_SMIME 0x60000000L
425 #define SFTK_TOKEN_TYPE_CERT 0x70000000L
427 #define SFTK_TOKEN_KRL_HANDLE (SFTK_TOKEN_MAGIC|SFTK_TOKEN_TYPE_CRL|1)
428 /* how big (in bytes) a password/pin we can deal with */
429 #define SFTK_MAX_PIN 255
430 /* minimum password/pin length (in Unicode characters) in FIPS mode */
431 #define FIPS_MIN_PIN 7
434 #define NETSCAPE_SLOT_ID 1
435 #define PRIVATE_KEY_SLOT_ID 2
436 #define FIPS_SLOT_ID 3
438 /* slot helper macros */
439 #define sftk_SlotFromSession(sp) ((sp)->slot)
440 #define sftk_isToken(id) (((id) & SFTK_TOKEN_MASK) == SFTK_TOKEN_MAGIC)
442 /* the session hash multiplier (see bug 201081) */
443 #define SHMULTIPLIER 1791398085
445 /* queueing helper macros */
446 #define sftk_hash(value,size) \
447 ((PRUint32)((value) * SHMULTIPLIER) & (size-1))
448 #define sftkqueue_add(element,id,head,hash_size) \
449 { int tmp = sftk_hash(id,hash_size); \
450 (element)->next = (head)[tmp]; \
451 (element)->prev = NULL; \
452 if ((head)[tmp]) (head)[tmp]->prev = (element); \
453 (head)[tmp] = (element); }
454 #define sftkqueue_find(element,id,head,hash_size) \
455 for( (element) = (head)[sftk_hash(id,hash_size)]; (element) != NULL; \
456 (element) = (element)->next) { \
457 if ((element)->handle == (id)) { break; } }
458 #define sftkqueue_is_queued(element,id,head,hash_size) \
459 ( ((element)->next) || ((element)->prev) || \
460 ((head)[sftk_hash(id,hash_size)] == (element)) )
461 #define sftkqueue_delete(element,id,head,hash_size) \
462 if ((element)->next) (element)->next->prev = (element)->prev; \
463 if ((element)->prev) (element)->prev->next = (element)->next; \
464 else (head)[sftk_hash(id,hash_size)] = ((element)->next); \
465 (element)->next = NULL; \
466 (element)->prev = NULL; \
468 #define sftkqueue_init_element(element) \
469 (element)->prev = NULL;
471 #define sftkqueue_add2(element, id, index, head) \
473 (element)->next = (head)[index]; \
475 (head)[index]->prev = (element); \
476 (head)[index] = (element); \
479 #define sftkqueue_find2(element, id, index, head) \
480 for ( (element) = (head)[index]; \
482 (element) = (element)->next) { \
483 if ((element)->handle == (id)) { break; } \
486 #define sftkqueue_delete2(element, id, index, head) \
487 if ((element)->next) (element)->next->prev = (element)->prev; \
488 if ((element)->prev) (element)->prev->next = (element)->next; \
489 else (head)[index] = ((element)->next);
491 #define sftkqueue_clear_deleted_element(element) \
492 (element)->next = NULL; \
493 (element)->prev = NULL; \
496 /* sessionID (handle) is used to determine session lock bucket */
498 /* NOSPREAD: (ID>>L2LPB) & (perbucket-1) */
499 #define SFTK_SESSION_LOCK(slot,handle) \
500 ((slot)->sessionLock[((handle) >> LOG2_BUCKETS_PER_SESSION_LOCK) \
501 & (slot)->sessionLockMask])
503 /* SPREAD: ID & (perbucket-1) */
504 #define SFTK_SESSION_LOCK(slot,handle) \
505 ((slot)->sessionLock[(handle) & (slot)->sessionLockMask])
508 /* expand an attribute & secitem structures out */
509 #define sftk_attr_expand(ap) (ap)->type,(ap)->pValue,(ap)->ulValueLen
510 #define sftk_item_expand(ip) (ip)->data,(ip)->len
512 typedef struct sftk_token_parametersStr
{
525 PRBool optimizeSpace
;
526 } sftk_token_parameters
;
528 typedef struct sftk_parametersStr
{
538 PRBool optimizeSpace
;
539 sftk_token_parameters
*tokens
;
544 /* machine dependent path stuff used by dbinit.c and pk11db.c */
546 #define PATH_SEPARATOR ":"
547 #define SECMOD_DB "Security Modules"
548 #define CERT_DB_FMT "%sCertificates%s"
549 #define KEY_DB_FMT "%sKey Database%s"
551 #define PATH_SEPARATOR "/"
552 #define SECMOD_DB "secmod.db"
553 #define CERT_DB_FMT "%scert%s.db"
554 #define KEY_DB_FMT "%skey%s.db"
559 /* shared functions between pkcs11.c and fipstokn.c */
560 extern PRBool nsf_init
;
561 extern CK_RV
nsc_CommonInitialize(CK_VOID_PTR pReserved
, PRBool isFIPS
);
562 extern CK_RV
nsc_CommonFinalize(CK_VOID_PTR pReserved
, PRBool isFIPS
);
563 extern CK_RV
nsc_CommonGetSlotList(CK_BBOOL tokPresent
,
564 CK_SLOT_ID_PTR pSlotList
, CK_ULONG_PTR pulCount
, int moduleIndex
);
566 /* slot initialization, reinit, shutdown and destruction */
567 extern CK_RV
SFTK_SlotInit(char *configdir
,
568 sftk_token_parameters
*params
, int moduleIndex
);
569 extern CK_RV
SFTK_SlotReInit(SFTKSlot
*slot
, char *configdir
,
570 sftk_token_parameters
*params
, int moduleIndex
);
571 extern CK_RV
SFTK_DestroySlotData(SFTKSlot
*slot
);
572 extern CK_RV
SFTK_ShutdownSlot(SFTKSlot
*slot
);
575 /* internal utility functions used by pkcs11.c */
576 extern SFTKAttribute
*sftk_FindAttribute(SFTKObject
*object
,
577 CK_ATTRIBUTE_TYPE type
);
578 extern void sftk_FreeAttribute(SFTKAttribute
*attribute
);
579 extern CK_RV
sftk_AddAttributeType(SFTKObject
*object
, CK_ATTRIBUTE_TYPE type
,
582 extern CK_RV
sftk_Attribute2SecItem(PLArenaPool
*arena
, SECItem
*item
,
583 SFTKObject
*object
, CK_ATTRIBUTE_TYPE type
);
584 extern unsigned int sftk_GetLengthInBits(unsigned char *buf
,
585 unsigned int bufLen
);
586 extern CK_RV
sftk_ConstrainAttribute(SFTKObject
*object
,
587 CK_ATTRIBUTE_TYPE type
, int minLength
, int maxLength
, int minMultiple
);
588 extern PRBool
sftk_hasAttribute(SFTKObject
*object
, CK_ATTRIBUTE_TYPE type
);
589 extern PRBool
sftk_isTrue(SFTKObject
*object
, CK_ATTRIBUTE_TYPE type
);
590 extern void sftk_DeleteAttributeType(SFTKObject
*object
,
591 CK_ATTRIBUTE_TYPE type
);
592 extern CK_RV
sftk_Attribute2SecItem(PLArenaPool
*arena
, SECItem
*item
,
593 SFTKObject
*object
, CK_ATTRIBUTE_TYPE type
);
594 extern CK_RV
sftk_Attribute2SSecItem(PLArenaPool
*arena
, SECItem
*item
,
596 CK_ATTRIBUTE_TYPE type
);
597 extern SFTKModifyType
sftk_modifyType(CK_ATTRIBUTE_TYPE type
,
598 CK_OBJECT_CLASS inClass
);
599 extern PRBool
sftk_isSensitive(CK_ATTRIBUTE_TYPE type
, CK_OBJECT_CLASS inClass
);
600 extern char *sftk_getString(SFTKObject
*object
, CK_ATTRIBUTE_TYPE type
);
601 extern void sftk_nullAttribute(SFTKObject
*object
,CK_ATTRIBUTE_TYPE type
);
602 extern CK_RV
sftk_GetULongAttribute(SFTKObject
*object
, CK_ATTRIBUTE_TYPE type
,
604 extern CK_RV
sftk_forceAttribute(SFTKObject
*object
, CK_ATTRIBUTE_TYPE type
,
605 void *value
, unsigned int len
);
606 extern CK_RV
sftk_defaultAttribute(SFTKObject
*object
, CK_ATTRIBUTE_TYPE type
,
607 void *value
, unsigned int len
);
608 extern unsigned int sftk_MapTrust(CK_TRUST trust
, PRBool clientAuth
);
610 extern SFTKObject
*sftk_NewObject(SFTKSlot
*slot
);
611 extern CK_RV
sftk_CopyObject(SFTKObject
*destObject
, SFTKObject
*srcObject
);
612 extern SFTKFreeStatus
sftk_FreeObject(SFTKObject
*object
);
613 extern CK_RV
sftk_DeleteObject(SFTKSession
*session
, SFTKObject
*object
);
614 extern void sftk_ReferenceObject(SFTKObject
*object
);
615 extern SFTKObject
*sftk_ObjectFromHandle(CK_OBJECT_HANDLE handle
,
616 SFTKSession
*session
);
617 extern void sftk_AddSlotObject(SFTKSlot
*slot
, SFTKObject
*object
);
618 extern void sftk_AddObject(SFTKSession
*session
, SFTKObject
*object
);
619 /* clear out all the existing object ID to database key mappings.
620 * used to reinit a token */
621 extern CK_RV
SFTK_ClearTokenKeyHashTable(SFTKSlot
*slot
);
623 extern CK_RV
sftk_searchObjectList(SFTKSearchResults
*search
,
624 SFTKObject
**head
, unsigned int size
,
625 PZLock
*lock
, CK_ATTRIBUTE_PTR inTemplate
,
626 int count
, PRBool isLoggedIn
);
627 extern SFTKObjectListElement
*sftk_FreeObjectListElement(
628 SFTKObjectListElement
*objectList
);
629 extern void sftk_FreeObjectList(SFTKObjectListElement
*objectList
);
630 extern void sftk_FreeSearch(SFTKSearchResults
*search
);
631 extern CK_RV
sftk_handleObject(SFTKObject
*object
, SFTKSession
*session
);
633 extern SFTKSlot
*sftk_SlotFromID(CK_SLOT_ID slotID
, PRBool all
);
634 extern SFTKSlot
*sftk_SlotFromSessionHandle(CK_SESSION_HANDLE handle
);
635 extern SFTKSession
*sftk_SessionFromHandle(CK_SESSION_HANDLE handle
);
636 extern void sftk_FreeSession(SFTKSession
*session
);
637 extern SFTKSession
*sftk_NewSession(CK_SLOT_ID slotID
, CK_NOTIFY notify
,
638 CK_VOID_PTR pApplication
, CK_FLAGS flags
);
639 extern void sftk_update_state(SFTKSlot
*slot
,SFTKSession
*session
);
640 extern void sftk_update_all_states(SFTKSlot
*slot
);
641 extern void sftk_FreeContext(SFTKSessionContext
*context
);
642 extern void sftk_InitFreeLists(void);
643 extern void sftk_CleanupFreeLists(void);
645 extern NSSLOWKEYPublicKey
*sftk_GetPubKey(SFTKObject
*object
,
646 CK_KEY_TYPE key_type
, CK_RV
*crvp
);
647 extern NSSLOWKEYPrivateKey
*sftk_GetPrivKey(SFTKObject
*object
,
648 CK_KEY_TYPE key_type
, CK_RV
*crvp
);
649 extern void sftk_FormatDESKey(unsigned char *key
, int length
);
650 extern PRBool
sftk_CheckDESKey(unsigned char *key
);
651 extern PRBool
sftk_IsWeakKey(unsigned char *key
,CK_KEY_TYPE key_type
);
653 /* mechanism allows this operation */
654 extern CK_RV
sftk_MechAllowsOperation(CK_MECHANISM_TYPE type
, CK_ATTRIBUTE_TYPE op
);
656 /* helper function which calls nsslowkey_FindKeyByPublicKey after safely
657 * acquiring a reference to the keydb from the slot */
658 NSSLOWKEYPrivateKey
*sftk_FindKeyByPublicKey(SFTKSlot
*slot
, SECItem
*dbKey
);
663 SFTKSessionObject
* sftk_narrowToSessionObject(SFTKObject
*);
664 SFTKTokenObject
* sftk_narrowToTokenObject(SFTKObject
*);
667 * token object utilities
669 void sftk_addHandle(SFTKSearchResults
*search
, CK_OBJECT_HANDLE handle
);
670 PRBool
sftk_poisonHandle(SFTKSlot
*slot
, SECItem
*dbkey
,
671 CK_OBJECT_HANDLE handle
);
672 SFTKObject
* sftk_NewTokenObject(SFTKSlot
*slot
, SECItem
*dbKey
,
673 CK_OBJECT_HANDLE handle
);
674 SFTKTokenObject
*sftk_convertSessionToToken(SFTKObject
*so
);
676 /****************************************
677 * implement TLS Pseudo Random Function (PRF)
681 sftk_TLSPRFInit(SFTKSessionContext
*context
,
683 CK_KEY_TYPE key_type
);
687 #endif /* _PKCS11I_H_ */