pk11table.h (3475B)
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 #ifndef _PK11_TABLE_H_ 5 #define _PK11_TABLE_H_ 6 7 /* 8 * Supported functions.. 9 */ 10 #include <pkcs11.h> 11 #include "nspr.h" 12 #include "prtypes.h" 13 14 typedef enum { 15 F_No_Function, 16 #undef CK_NEED_ARG_LIST 17 #define CK_PKCS11_FUNCTION_INFO(func) F_##func, 18 #include "pkcs11f.h" 19 #undef CK_NEED_ARG_LISt 20 #undef CK_PKCS11_FUNCTION_INFO 21 F_SetVar, 22 F_SetStringVar, 23 F_NewArray, 24 F_NewInitializeArgs, 25 F_NewTemplate, 26 F_NewMechanism, 27 F_BuildTemplate, 28 F_SetTemplate, 29 F_Print, 30 F_SaveVar, 31 F_RestoreVar, 32 F_Increment, 33 F_Decrement, 34 F_Delete, 35 F_List, 36 F_Run, 37 F_Load, 38 F_Unload, 39 F_System, 40 F_Loop, 41 F_Time, 42 F_Help, 43 F_Quit, 44 F_QuitIf, 45 F_QuitIfString 46 } FunctionType; 47 48 /* 49 * Supported Argument Types 50 */ 51 typedef enum { 52 ArgNone, 53 ArgVar, 54 ArgULong, 55 ArgChar, 56 ArgUTF8, 57 ArgInfo, 58 ArgSlotInfo, 59 ArgTokenInfo, 60 ArgSessionInfo, 61 ArgAttribute, 62 ArgMechanism, 63 ArgMechanismInfo, 64 ArgInitializeArgs, 65 ArgFunctionList, 66 /* Modifier Flags */ 67 ArgMask = 0xff, 68 ArgOut = 0x100, 69 ArgArray = 0x200, 70 ArgNew = 0x400, 71 ArgFile = 0x800, 72 ArgStatic = 0x1000, 73 ArgOpt = 0x2000, 74 ArgFull = 0x4000 75 } ArgType; 76 77 typedef enum _constType { 78 ConstNone, 79 ConstBool, 80 ConstInfoFlags, 81 ConstSlotFlags, 82 ConstTokenFlags, 83 ConstSessionFlags, 84 ConstMechanismFlags, 85 ConstInitializeFlags, 86 ConstUsers, 87 ConstSessionState, 88 ConstObject, 89 ConstHardware, 90 ConstKeyType, 91 ConstCertType, 92 ConstAttribute, 93 ConstMechanism, 94 ConstResult, 95 ConstTrust, 96 ConstAvailableSizes, 97 ConstCertCategory, 98 ConstSecurityDomain, 99 ConstOTPFormat, 100 ConstOTPParam, 101 ConstCurrentSize 102 } ConstType; 103 104 typedef struct _constant { 105 const char *name; 106 CK_ULONG value; 107 ConstType type; 108 ConstType attrType; 109 } Constant; 110 111 /* 112 * Values structures. 113 */ 114 typedef struct _values { 115 ArgType type; 116 ConstType constType; 117 int size; 118 char *filename; 119 void *data; 120 int reference; 121 int arraySize; 122 } Value; 123 124 /* 125 * Variables 126 */ 127 typedef struct _variable Variable; 128 struct _variable { 129 Variable *next; 130 char *vname; 131 Value *value; 132 }; 133 134 /* NOTE: if you change MAX_ARGS, you need to change the commands array 135 * below as well. 136 */ 137 138 #define MAX_ARGS 10 139 /* 140 * structure for master command array 141 */ 142 typedef struct _commands { 143 char *fname; 144 FunctionType fType; 145 char *helpString; 146 ArgType args[MAX_ARGS]; 147 } Commands; 148 149 typedef struct _module { 150 PRLibrary *library; 151 CK_FUNCTION_LIST *functionList; 152 } Module; 153 154 typedef struct _topics { 155 char *name; 156 char *helpString; 157 } Topics; 158 159 /* 160 * the command array itself. Make name to function and it's arguments 161 */ 162 163 extern const char **valueString; 164 extern const int valueCount; 165 extern const char **constTypeString; 166 extern const int constTypeCount; 167 extern const Constant *consts; 168 extern const unsigned int constCount; 169 extern const Commands *commands; 170 extern const int commandCount; 171 extern const Topics *topics; 172 extern const int topicCount; 173 174 extern const char * 175 getName(CK_ULONG value, ConstType type); 176 177 extern const char * 178 getNameFromAttribute(CK_ATTRIBUTE_TYPE type); 179 180 extern unsigned int totalKnownType(ConstType type); 181 182 #endif /* _PK11_TABLE_H_ */