1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #ifndef DEVM_H 6 #define DEVM_H 7 8 #ifndef BASE_H 9 #include "base.h" 10 #endif /* BASE_H */ 11 12 #ifndef DEV_H 13 #include "dev.h" 14 #endif /* DEV_H */ 15 16 #ifndef DEVTM_H 17 #include "devtm.h" 18 #endif /* DEVTM_H */ 19 20 PR_BEGIN_EXTERN_C 21 22 /* Shortcut to cryptoki API functions. */ 23 #define CKAPI(epv) \ 24 ((CK_FUNCTION_LIST_PTR)(epv)) 25 26 NSS_EXTERN void 27 nssDevice_AddRef( 28 struct nssDeviceBaseStr *device); 29 30 NSS_EXTERN PRBool 31 nssDevice_Destroy( 32 struct nssDeviceBaseStr *device); 33 34 NSS_EXTERN PRBool 35 nssModule_IsThreadSafe( 36 NSSModule *module); 37 38 NSS_EXTERN PRBool 39 nssModule_IsInternal( 40 NSSModule *mod); 41 42 NSS_EXTERN PRBool 43 nssModule_IsModuleDBOnly( 44 NSSModule *mod); 45 46 NSS_EXTERN void * 47 nssModule_GetCryptokiEPV( 48 NSSModule *mod); 49 50 NSS_EXTERN NSSSlot * 51 nssSlot_Create( 52 CK_SLOT_ID slotId, 53 NSSModule *parent); 54 55 NSS_EXTERN void * 56 nssSlot_GetCryptokiEPV( 57 NSSSlot *slot); 58 59 NSS_EXTERN NSSToken * 60 nssToken_Create( 61 CK_SLOT_ID slotID, 62 NSSSlot *peer); 63 64 NSS_EXTERN void * 65 nssToken_GetCryptokiEPV( 66 NSSToken *token); 67 68 NSS_EXTERN nssSession * 69 nssToken_GetDefaultSession( 70 NSSToken *token); 71 72 NSS_EXTERN PRBool 73 nssToken_IsLoginRequired( 74 NSSToken *token); 75 76 NSS_EXTERN void 77 nssToken_Remove( 78 NSSToken *token); 79 80 NSS_EXTERN nssCryptokiObject * 81 nssCryptokiObject_Create( 82 NSSToken *t, 83 nssSession *session, 84 CK_OBJECT_HANDLE h); 85 86 NSS_EXTERN nssTokenObjectCache * 87 nssTokenObjectCache_Create( 88 NSSToken *token, 89 PRBool cacheCerts, 90 PRBool cacheTrust, 91 PRBool cacheCRLs); 92 93 NSS_EXTERN void 94 nssTokenObjectCache_Destroy( 95 nssTokenObjectCache *cache); 96 97 NSS_EXTERN void 98 nssTokenObjectCache_Clear( 99 nssTokenObjectCache *cache); 100 101 NSS_EXTERN PRBool 102 nssTokenObjectCache_HaveObjectClass( 103 nssTokenObjectCache *cache, 104 CK_OBJECT_CLASS objclass); 105 106 NSS_EXTERN nssCryptokiObject ** 107 nssTokenObjectCache_FindObjectsByTemplate( 108 nssTokenObjectCache *cache, 109 CK_OBJECT_CLASS objclass, 110 CK_ATTRIBUTE_PTR otemplate, 111 CK_ULONG otlen, 112 PRUint32 maximumOpt, 113 PRStatus *statusOpt); 114 115 NSS_EXTERN PRStatus 116 nssTokenObjectCache_GetObjectAttributes( 117 nssTokenObjectCache *cache, 118 NSSArena *arenaOpt, 119 nssCryptokiObject *object, 120 CK_OBJECT_CLASS objclass, 121 CK_ATTRIBUTE_PTR atemplate, 122 CK_ULONG atlen); 123 124 NSS_EXTERN PRStatus 125 nssTokenObjectCache_ImportObject( 126 nssTokenObjectCache *cache, 127 nssCryptokiObject *object, 128 CK_OBJECT_CLASS objclass, 129 CK_ATTRIBUTE_PTR ot, 130 CK_ULONG otlen); 131 132 NSS_EXTERN void 133 nssTokenObjectCache_RemoveObject( 134 nssTokenObjectCache *cache, 135 nssCryptokiObject *object); 136 137 /* XXX allows peek back into token */ 138 NSS_EXTERN PRStatus 139 nssToken_GetCachedObjectAttributes( 140 NSSToken *token, 141 NSSArena *arenaOpt, 142 nssCryptokiObject *object, 143 CK_OBJECT_CLASS objclass, 144 CK_ATTRIBUTE_PTR atemplate, 145 CK_ULONG atlen); 146 147 /* PKCS#11 stores strings in a fixed-length buffer padded with spaces. This 148 * function gets the length of the actual string. 149 */ 150 NSS_EXTERN PRUint32 151 nssPKCS11String_Length( 152 CK_CHAR *pkcs11str, 153 PRUint32 bufLen); 154 155 PR_END_EXTERN_C 156 157 #endif /* DEV_H */ 158