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 | #include "prlog.h" |
michael@0 | 5 | #include <stdio.h> |
michael@0 | 6 | #include "cert.h" /* for CERT_DerNameToAscii & CERT_Hexify */ |
michael@0 | 7 | |
michael@0 | 8 | static PRLogModuleInfo *modlog = NULL; |
michael@0 | 9 | |
michael@0 | 10 | static CK_FUNCTION_LIST_PTR module_functions; |
michael@0 | 11 | |
michael@0 | 12 | static CK_FUNCTION_LIST debug_functions; |
michael@0 | 13 | |
michael@0 | 14 | static void print_final_statistics(void); |
michael@0 | 15 | |
michael@0 | 16 | #define STRING static const char |
michael@0 | 17 | |
michael@0 | 18 | STRING fmt_flags[] = " flags = 0x%x"; |
michael@0 | 19 | STRING fmt_hKey[] = " hKey = 0x%x"; |
michael@0 | 20 | STRING fmt_hObject[] = " hObject = 0x%x"; |
michael@0 | 21 | STRING fmt_hSession[] = " hSession = 0x%x"; |
michael@0 | 22 | STRING fmt_manufacturerID[] = " manufacturerID = \"%.32s\""; |
michael@0 | 23 | STRING fmt_pData[] = " pData = 0x%p"; |
michael@0 | 24 | STRING fmt_pDigest[] = " pDigest = 0x%p"; |
michael@0 | 25 | STRING fmt_pEncryptedData[] = " pEncryptedData = 0x%p"; |
michael@0 | 26 | STRING fmt_pEncryptedPart[] = " pEncryptedPart = 0x%p"; |
michael@0 | 27 | STRING fmt_pInfo[] = " pInfo = 0x%p"; |
michael@0 | 28 | STRING fmt_pMechanism[] = " pMechanism = 0x%p"; |
michael@0 | 29 | STRING fmt_pOperationState[] = " pOperationState = 0x%p"; |
michael@0 | 30 | STRING fmt_pPart[] = " pPart = 0x%p"; |
michael@0 | 31 | STRING fmt_pPin[] = " pPin = 0x%p"; |
michael@0 | 32 | STRING fmt_pSignature[] = " pSignature = 0x%p"; |
michael@0 | 33 | STRING fmt_pTemplate[] = " pTemplate = 0x%p"; |
michael@0 | 34 | STRING fmt_pWrappedKey[] = " pWrappedKey = 0x%p"; |
michael@0 | 35 | STRING fmt_phKey[] = " phKey = 0x%p"; |
michael@0 | 36 | STRING fmt_phObject[] = " phObject = 0x%p"; |
michael@0 | 37 | STRING fmt_pulCount[] = " pulCount = 0x%p"; |
michael@0 | 38 | STRING fmt_pulDataLen[] = " pulDataLen = 0x%p"; |
michael@0 | 39 | STRING fmt_pulDigestLen[] = " pulDigestLen = 0x%p"; |
michael@0 | 40 | STRING fmt_pulEncryptedPartLen[] = " pulEncryptedPartLen = 0x%p"; |
michael@0 | 41 | STRING fmt_pulPartLen[] = " pulPartLen = 0x%p"; |
michael@0 | 42 | STRING fmt_pulSignatureLen[] = " pulSignatureLen = 0x%p"; |
michael@0 | 43 | STRING fmt_slotID[] = " slotID = 0x%x"; |
michael@0 | 44 | STRING fmt_sphKey[] = " *phKey = 0x%x"; |
michael@0 | 45 | STRING fmt_spulCount[] = " *pulCount = 0x%x"; |
michael@0 | 46 | STRING fmt_spulDataLen[] = " *pulDataLen = 0x%x"; |
michael@0 | 47 | STRING fmt_spulDigestLen[] = " *pulDigestLen = 0x%x"; |
michael@0 | 48 | STRING fmt_spulEncryptedPartLen[] = " *pulEncryptedPartLen = 0x%x"; |
michael@0 | 49 | STRING fmt_spulPartLen[] = " *pulPartLen = 0x%x"; |
michael@0 | 50 | STRING fmt_spulSignatureLen[] = " *pulSignatureLen = 0x%x"; |
michael@0 | 51 | STRING fmt_ulAttributeCount[] = " ulAttributeCount = %d"; |
michael@0 | 52 | STRING fmt_ulCount[] = " ulCount = %d"; |
michael@0 | 53 | STRING fmt_ulDataLen[] = " ulDataLen = %d"; |
michael@0 | 54 | STRING fmt_ulEncryptedPartLen[] = " ulEncryptedPartLen = %d"; |
michael@0 | 55 | STRING fmt_ulPartLen[] = " ulPartLen = %d"; |
michael@0 | 56 | STRING fmt_ulPinLen[] = " ulPinLen = %d"; |
michael@0 | 57 | STRING fmt_ulSignatureLen[] = " ulSignatureLen = %d"; |
michael@0 | 58 | |
michael@0 | 59 | STRING fmt_fwVersion[] = " firmware version: %d.%d"; |
michael@0 | 60 | STRING fmt_hwVersion[] = " hardware version: %d.%d"; |
michael@0 | 61 | STRING fmt_s_qsq_d[] = " %s = \"%s\" [%d]"; |
michael@0 | 62 | STRING fmt_s_s_d[] = " %s = %s [%d]"; |
michael@0 | 63 | STRING fmt_s_lu[] = " %s = %lu"; |
michael@0 | 64 | STRING fmt_invalid_handle[] = " (CK_INVALID_HANDLE)"; |
michael@0 | 65 | |
michael@0 | 66 | |
michael@0 | 67 | static void get_attr_type_str(CK_ATTRIBUTE_TYPE atype, char *str, int len) |
michael@0 | 68 | { |
michael@0 | 69 | #define CASE(attr) case attr: a = #attr ; break |
michael@0 | 70 | |
michael@0 | 71 | const char * a = NULL; |
michael@0 | 72 | |
michael@0 | 73 | switch (atype) { |
michael@0 | 74 | CASE(CKA_CLASS); |
michael@0 | 75 | CASE(CKA_TOKEN); |
michael@0 | 76 | CASE(CKA_PRIVATE); |
michael@0 | 77 | CASE(CKA_LABEL); |
michael@0 | 78 | CASE(CKA_APPLICATION); |
michael@0 | 79 | CASE(CKA_VALUE); |
michael@0 | 80 | CASE(CKA_OBJECT_ID); |
michael@0 | 81 | CASE(CKA_CERTIFICATE_TYPE); |
michael@0 | 82 | CASE(CKA_CERTIFICATE_CATEGORY); |
michael@0 | 83 | CASE(CKA_ISSUER); |
michael@0 | 84 | CASE(CKA_SERIAL_NUMBER); |
michael@0 | 85 | CASE(CKA_AC_ISSUER); |
michael@0 | 86 | CASE(CKA_OWNER); |
michael@0 | 87 | CASE(CKA_ATTR_TYPES); |
michael@0 | 88 | CASE(CKA_TRUSTED); |
michael@0 | 89 | CASE(CKA_KEY_TYPE); |
michael@0 | 90 | CASE(CKA_SUBJECT); |
michael@0 | 91 | CASE(CKA_ID); |
michael@0 | 92 | CASE(CKA_SENSITIVE); |
michael@0 | 93 | CASE(CKA_ENCRYPT); |
michael@0 | 94 | CASE(CKA_DECRYPT); |
michael@0 | 95 | CASE(CKA_WRAP); |
michael@0 | 96 | CASE(CKA_UNWRAP); |
michael@0 | 97 | CASE(CKA_SIGN); |
michael@0 | 98 | CASE(CKA_SIGN_RECOVER); |
michael@0 | 99 | CASE(CKA_VERIFY); |
michael@0 | 100 | CASE(CKA_VERIFY_RECOVER); |
michael@0 | 101 | CASE(CKA_DERIVE); |
michael@0 | 102 | CASE(CKA_START_DATE); |
michael@0 | 103 | CASE(CKA_END_DATE); |
michael@0 | 104 | CASE(CKA_MODULUS); |
michael@0 | 105 | CASE(CKA_MODULUS_BITS); |
michael@0 | 106 | CASE(CKA_PUBLIC_EXPONENT); |
michael@0 | 107 | CASE(CKA_PRIVATE_EXPONENT); |
michael@0 | 108 | CASE(CKA_PRIME_1); |
michael@0 | 109 | CASE(CKA_PRIME_2); |
michael@0 | 110 | CASE(CKA_EXPONENT_1); |
michael@0 | 111 | CASE(CKA_EXPONENT_2); |
michael@0 | 112 | CASE(CKA_COEFFICIENT); |
michael@0 | 113 | CASE(CKA_PRIME); |
michael@0 | 114 | CASE(CKA_SUBPRIME); |
michael@0 | 115 | CASE(CKA_BASE); |
michael@0 | 116 | CASE(CKA_PRIME_BITS); |
michael@0 | 117 | CASE(CKA_SUBPRIME_BITS); |
michael@0 | 118 | CASE(CKA_VALUE_BITS); |
michael@0 | 119 | CASE(CKA_VALUE_LEN); |
michael@0 | 120 | CASE(CKA_EXTRACTABLE); |
michael@0 | 121 | CASE(CKA_LOCAL); |
michael@0 | 122 | CASE(CKA_NEVER_EXTRACTABLE); |
michael@0 | 123 | CASE(CKA_ALWAYS_SENSITIVE); |
michael@0 | 124 | CASE(CKA_KEY_GEN_MECHANISM); |
michael@0 | 125 | CASE(CKA_MODIFIABLE); |
michael@0 | 126 | CASE(CKA_ECDSA_PARAMS); |
michael@0 | 127 | CASE(CKA_EC_POINT); |
michael@0 | 128 | CASE(CKA_SECONDARY_AUTH); |
michael@0 | 129 | CASE(CKA_AUTH_PIN_FLAGS); |
michael@0 | 130 | CASE(CKA_HW_FEATURE_TYPE); |
michael@0 | 131 | CASE(CKA_RESET_ON_INIT); |
michael@0 | 132 | CASE(CKA_HAS_RESET); |
michael@0 | 133 | CASE(CKA_VENDOR_DEFINED); |
michael@0 | 134 | CASE(CKA_NSS_URL); |
michael@0 | 135 | CASE(CKA_NSS_EMAIL); |
michael@0 | 136 | CASE(CKA_NSS_SMIME_INFO); |
michael@0 | 137 | CASE(CKA_NSS_SMIME_TIMESTAMP); |
michael@0 | 138 | CASE(CKA_NSS_PKCS8_SALT); |
michael@0 | 139 | CASE(CKA_NSS_PASSWORD_CHECK); |
michael@0 | 140 | CASE(CKA_NSS_EXPIRES); |
michael@0 | 141 | CASE(CKA_NSS_KRL); |
michael@0 | 142 | CASE(CKA_NSS_PQG_COUNTER); |
michael@0 | 143 | CASE(CKA_NSS_PQG_SEED); |
michael@0 | 144 | CASE(CKA_NSS_PQG_H); |
michael@0 | 145 | CASE(CKA_NSS_PQG_SEED_BITS); |
michael@0 | 146 | CASE(CKA_TRUST); |
michael@0 | 147 | CASE(CKA_TRUST_DIGITAL_SIGNATURE); |
michael@0 | 148 | CASE(CKA_TRUST_NON_REPUDIATION); |
michael@0 | 149 | CASE(CKA_TRUST_KEY_ENCIPHERMENT); |
michael@0 | 150 | CASE(CKA_TRUST_DATA_ENCIPHERMENT); |
michael@0 | 151 | CASE(CKA_TRUST_KEY_AGREEMENT); |
michael@0 | 152 | CASE(CKA_TRUST_KEY_CERT_SIGN); |
michael@0 | 153 | CASE(CKA_TRUST_CRL_SIGN); |
michael@0 | 154 | CASE(CKA_TRUST_SERVER_AUTH); |
michael@0 | 155 | CASE(CKA_TRUST_CLIENT_AUTH); |
michael@0 | 156 | CASE(CKA_TRUST_CODE_SIGNING); |
michael@0 | 157 | CASE(CKA_TRUST_EMAIL_PROTECTION); |
michael@0 | 158 | CASE(CKA_TRUST_IPSEC_END_SYSTEM); |
michael@0 | 159 | CASE(CKA_TRUST_IPSEC_TUNNEL); |
michael@0 | 160 | CASE(CKA_TRUST_IPSEC_USER); |
michael@0 | 161 | CASE(CKA_TRUST_TIME_STAMPING); |
michael@0 | 162 | CASE(CKA_CERT_SHA1_HASH); |
michael@0 | 163 | CASE(CKA_CERT_MD5_HASH); |
michael@0 | 164 | CASE(CKA_NETSCAPE_DB); |
michael@0 | 165 | CASE(CKA_NETSCAPE_TRUST); |
michael@0 | 166 | default: break; |
michael@0 | 167 | } |
michael@0 | 168 | if (a) |
michael@0 | 169 | PR_snprintf(str, len, "%s", a); |
michael@0 | 170 | else |
michael@0 | 171 | PR_snprintf(str, len, "0x%p", atype); |
michael@0 | 172 | } |
michael@0 | 173 | |
michael@0 | 174 | static void get_obj_class(CK_OBJECT_CLASS objClass, char *str, int len) |
michael@0 | 175 | { |
michael@0 | 176 | |
michael@0 | 177 | const char * a = NULL; |
michael@0 | 178 | |
michael@0 | 179 | switch (objClass) { |
michael@0 | 180 | CASE(CKO_DATA); |
michael@0 | 181 | CASE(CKO_CERTIFICATE); |
michael@0 | 182 | CASE(CKO_PUBLIC_KEY); |
michael@0 | 183 | CASE(CKO_PRIVATE_KEY); |
michael@0 | 184 | CASE(CKO_SECRET_KEY); |
michael@0 | 185 | CASE(CKO_HW_FEATURE); |
michael@0 | 186 | CASE(CKO_DOMAIN_PARAMETERS); |
michael@0 | 187 | CASE(CKO_NSS_CRL); |
michael@0 | 188 | CASE(CKO_NSS_SMIME); |
michael@0 | 189 | CASE(CKO_NSS_TRUST); |
michael@0 | 190 | CASE(CKO_NSS_BUILTIN_ROOT_LIST); |
michael@0 | 191 | default: break; |
michael@0 | 192 | } |
michael@0 | 193 | if (a) |
michael@0 | 194 | PR_snprintf(str, len, "%s", a); |
michael@0 | 195 | else |
michael@0 | 196 | PR_snprintf(str, len, "0x%p", objClass); |
michael@0 | 197 | } |
michael@0 | 198 | |
michael@0 | 199 | static void get_trust_val(CK_TRUST trust, char *str, int len) |
michael@0 | 200 | { |
michael@0 | 201 | const char * a = NULL; |
michael@0 | 202 | |
michael@0 | 203 | switch (trust) { |
michael@0 | 204 | CASE(CKT_NSS_TRUSTED); |
michael@0 | 205 | CASE(CKT_NSS_TRUSTED_DELEGATOR); |
michael@0 | 206 | CASE(CKT_NSS_NOT_TRUSTED); |
michael@0 | 207 | CASE(CKT_NSS_MUST_VERIFY_TRUST); |
michael@0 | 208 | CASE(CKT_NSS_TRUST_UNKNOWN); |
michael@0 | 209 | CASE(CKT_NSS_VALID_DELEGATOR); |
michael@0 | 210 | default: break; |
michael@0 | 211 | } |
michael@0 | 212 | if (a) |
michael@0 | 213 | PR_snprintf(str, len, "%s", a); |
michael@0 | 214 | else |
michael@0 | 215 | PR_snprintf(str, len, "0x%p", trust); |
michael@0 | 216 | } |
michael@0 | 217 | |
michael@0 | 218 | static void log_rv(CK_RV rv) |
michael@0 | 219 | { |
michael@0 | 220 | const char * a = NULL; |
michael@0 | 221 | |
michael@0 | 222 | switch (rv) { |
michael@0 | 223 | CASE(CKR_OK); |
michael@0 | 224 | CASE(CKR_CANCEL); |
michael@0 | 225 | CASE(CKR_HOST_MEMORY); |
michael@0 | 226 | CASE(CKR_SLOT_ID_INVALID); |
michael@0 | 227 | CASE(CKR_GENERAL_ERROR); |
michael@0 | 228 | CASE(CKR_FUNCTION_FAILED); |
michael@0 | 229 | CASE(CKR_ARGUMENTS_BAD); |
michael@0 | 230 | CASE(CKR_NO_EVENT); |
michael@0 | 231 | CASE(CKR_NEED_TO_CREATE_THREADS); |
michael@0 | 232 | CASE(CKR_CANT_LOCK); |
michael@0 | 233 | CASE(CKR_ATTRIBUTE_READ_ONLY); |
michael@0 | 234 | CASE(CKR_ATTRIBUTE_SENSITIVE); |
michael@0 | 235 | CASE(CKR_ATTRIBUTE_TYPE_INVALID); |
michael@0 | 236 | CASE(CKR_ATTRIBUTE_VALUE_INVALID); |
michael@0 | 237 | CASE(CKR_DATA_INVALID); |
michael@0 | 238 | CASE(CKR_DATA_LEN_RANGE); |
michael@0 | 239 | CASE(CKR_DEVICE_ERROR); |
michael@0 | 240 | CASE(CKR_DEVICE_MEMORY); |
michael@0 | 241 | CASE(CKR_DEVICE_REMOVED); |
michael@0 | 242 | CASE(CKR_ENCRYPTED_DATA_INVALID); |
michael@0 | 243 | CASE(CKR_ENCRYPTED_DATA_LEN_RANGE); |
michael@0 | 244 | CASE(CKR_FUNCTION_CANCELED); |
michael@0 | 245 | CASE(CKR_FUNCTION_NOT_PARALLEL); |
michael@0 | 246 | CASE(CKR_FUNCTION_NOT_SUPPORTED); |
michael@0 | 247 | CASE(CKR_KEY_HANDLE_INVALID); |
michael@0 | 248 | CASE(CKR_KEY_SIZE_RANGE); |
michael@0 | 249 | CASE(CKR_KEY_TYPE_INCONSISTENT); |
michael@0 | 250 | CASE(CKR_KEY_NOT_NEEDED); |
michael@0 | 251 | CASE(CKR_KEY_CHANGED); |
michael@0 | 252 | CASE(CKR_KEY_NEEDED); |
michael@0 | 253 | CASE(CKR_KEY_INDIGESTIBLE); |
michael@0 | 254 | CASE(CKR_KEY_FUNCTION_NOT_PERMITTED); |
michael@0 | 255 | CASE(CKR_KEY_NOT_WRAPPABLE); |
michael@0 | 256 | CASE(CKR_KEY_UNEXTRACTABLE); |
michael@0 | 257 | CASE(CKR_MECHANISM_INVALID); |
michael@0 | 258 | CASE(CKR_MECHANISM_PARAM_INVALID); |
michael@0 | 259 | CASE(CKR_OBJECT_HANDLE_INVALID); |
michael@0 | 260 | CASE(CKR_OPERATION_ACTIVE); |
michael@0 | 261 | CASE(CKR_OPERATION_NOT_INITIALIZED); |
michael@0 | 262 | CASE(CKR_PIN_INCORRECT); |
michael@0 | 263 | CASE(CKR_PIN_INVALID); |
michael@0 | 264 | CASE(CKR_PIN_LEN_RANGE); |
michael@0 | 265 | CASE(CKR_PIN_EXPIRED); |
michael@0 | 266 | CASE(CKR_PIN_LOCKED); |
michael@0 | 267 | CASE(CKR_SESSION_CLOSED); |
michael@0 | 268 | CASE(CKR_SESSION_COUNT); |
michael@0 | 269 | CASE(CKR_SESSION_HANDLE_INVALID); |
michael@0 | 270 | CASE(CKR_SESSION_PARALLEL_NOT_SUPPORTED); |
michael@0 | 271 | CASE(CKR_SESSION_READ_ONLY); |
michael@0 | 272 | CASE(CKR_SESSION_EXISTS); |
michael@0 | 273 | CASE(CKR_SESSION_READ_ONLY_EXISTS); |
michael@0 | 274 | CASE(CKR_SESSION_READ_WRITE_SO_EXISTS); |
michael@0 | 275 | CASE(CKR_SIGNATURE_INVALID); |
michael@0 | 276 | CASE(CKR_SIGNATURE_LEN_RANGE); |
michael@0 | 277 | CASE(CKR_TEMPLATE_INCOMPLETE); |
michael@0 | 278 | CASE(CKR_TEMPLATE_INCONSISTENT); |
michael@0 | 279 | CASE(CKR_TOKEN_NOT_PRESENT); |
michael@0 | 280 | CASE(CKR_TOKEN_NOT_RECOGNIZED); |
michael@0 | 281 | CASE(CKR_TOKEN_WRITE_PROTECTED); |
michael@0 | 282 | CASE(CKR_UNWRAPPING_KEY_HANDLE_INVALID); |
michael@0 | 283 | CASE(CKR_UNWRAPPING_KEY_SIZE_RANGE); |
michael@0 | 284 | CASE(CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT); |
michael@0 | 285 | CASE(CKR_USER_ALREADY_LOGGED_IN); |
michael@0 | 286 | CASE(CKR_USER_NOT_LOGGED_IN); |
michael@0 | 287 | CASE(CKR_USER_PIN_NOT_INITIALIZED); |
michael@0 | 288 | CASE(CKR_USER_TYPE_INVALID); |
michael@0 | 289 | CASE(CKR_USER_ANOTHER_ALREADY_LOGGED_IN); |
michael@0 | 290 | CASE(CKR_USER_TOO_MANY_TYPES); |
michael@0 | 291 | CASE(CKR_WRAPPED_KEY_INVALID); |
michael@0 | 292 | CASE(CKR_WRAPPED_KEY_LEN_RANGE); |
michael@0 | 293 | CASE(CKR_WRAPPING_KEY_HANDLE_INVALID); |
michael@0 | 294 | CASE(CKR_WRAPPING_KEY_SIZE_RANGE); |
michael@0 | 295 | CASE(CKR_WRAPPING_KEY_TYPE_INCONSISTENT); |
michael@0 | 296 | CASE(CKR_RANDOM_SEED_NOT_SUPPORTED); |
michael@0 | 297 | CASE(CKR_RANDOM_NO_RNG); |
michael@0 | 298 | CASE(CKR_DOMAIN_PARAMS_INVALID); |
michael@0 | 299 | CASE(CKR_BUFFER_TOO_SMALL); |
michael@0 | 300 | CASE(CKR_SAVED_STATE_INVALID); |
michael@0 | 301 | CASE(CKR_INFORMATION_SENSITIVE); |
michael@0 | 302 | CASE(CKR_STATE_UNSAVEABLE); |
michael@0 | 303 | CASE(CKR_CRYPTOKI_NOT_INITIALIZED); |
michael@0 | 304 | CASE(CKR_CRYPTOKI_ALREADY_INITIALIZED); |
michael@0 | 305 | CASE(CKR_MUTEX_BAD); |
michael@0 | 306 | CASE(CKR_MUTEX_NOT_LOCKED); |
michael@0 | 307 | CASE(CKR_FUNCTION_REJECTED); |
michael@0 | 308 | CASE(CKR_KEY_PARAMS_INVALID); |
michael@0 | 309 | default: break; |
michael@0 | 310 | } |
michael@0 | 311 | if (a) |
michael@0 | 312 | PR_LOG(modlog, 1, (" rv = %s\n", a)); |
michael@0 | 313 | else |
michael@0 | 314 | PR_LOG(modlog, 1, (" rv = 0x%x\n", rv)); |
michael@0 | 315 | } |
michael@0 | 316 | |
michael@0 | 317 | static void log_state(CK_STATE state) |
michael@0 | 318 | { |
michael@0 | 319 | const char * a = NULL; |
michael@0 | 320 | |
michael@0 | 321 | switch (state) { |
michael@0 | 322 | CASE(CKS_RO_PUBLIC_SESSION); |
michael@0 | 323 | CASE(CKS_RO_USER_FUNCTIONS); |
michael@0 | 324 | CASE(CKS_RW_PUBLIC_SESSION); |
michael@0 | 325 | CASE(CKS_RW_USER_FUNCTIONS); |
michael@0 | 326 | CASE(CKS_RW_SO_FUNCTIONS); |
michael@0 | 327 | default: break; |
michael@0 | 328 | } |
michael@0 | 329 | if (a) |
michael@0 | 330 | PR_LOG(modlog, 1, (" state = %s\n", a)); |
michael@0 | 331 | else |
michael@0 | 332 | PR_LOG(modlog, 1, (" state = 0x%x\n", state)); |
michael@0 | 333 | } |
michael@0 | 334 | |
michael@0 | 335 | static void log_handle(int level, const char * format, CK_ULONG handle) |
michael@0 | 336 | { |
michael@0 | 337 | char fmtBuf[80]; |
michael@0 | 338 | if (handle) |
michael@0 | 339 | PR_LOG(modlog, level, (format, handle)); |
michael@0 | 340 | else { |
michael@0 | 341 | PL_strncpyz(fmtBuf, format, sizeof fmtBuf); |
michael@0 | 342 | PL_strcatn(fmtBuf, sizeof fmtBuf, fmt_invalid_handle); |
michael@0 | 343 | PR_LOG(modlog, level, (fmtBuf, handle)); |
michael@0 | 344 | } |
michael@0 | 345 | } |
michael@0 | 346 | |
michael@0 | 347 | static void print_mechanism(CK_MECHANISM_PTR m) |
michael@0 | 348 | { |
michael@0 | 349 | |
michael@0 | 350 | const char * a = NULL; |
michael@0 | 351 | |
michael@0 | 352 | switch (m->mechanism) { |
michael@0 | 353 | CASE(CKM_AES_CBC); |
michael@0 | 354 | CASE(CKM_AES_CBC_ENCRYPT_DATA); |
michael@0 | 355 | CASE(CKM_AES_CBC_PAD); |
michael@0 | 356 | CASE(CKM_AES_CCM); |
michael@0 | 357 | CASE(CKM_AES_CTR); |
michael@0 | 358 | CASE(CKM_AES_CTS); |
michael@0 | 359 | CASE(CKM_AES_GCM); |
michael@0 | 360 | CASE(CKM_AES_ECB); |
michael@0 | 361 | CASE(CKM_AES_ECB_ENCRYPT_DATA); |
michael@0 | 362 | CASE(CKM_AES_KEY_GEN); |
michael@0 | 363 | CASE(CKM_AES_MAC); |
michael@0 | 364 | CASE(CKM_AES_MAC_GENERAL); |
michael@0 | 365 | CASE(CKM_CAMELLIA_CBC); |
michael@0 | 366 | CASE(CKM_CAMELLIA_CBC_ENCRYPT_DATA); |
michael@0 | 367 | CASE(CKM_CAMELLIA_CBC_PAD); |
michael@0 | 368 | CASE(CKM_CAMELLIA_ECB); |
michael@0 | 369 | CASE(CKM_CAMELLIA_ECB_ENCRYPT_DATA); |
michael@0 | 370 | CASE(CKM_CAMELLIA_KEY_GEN); |
michael@0 | 371 | CASE(CKM_CAMELLIA_MAC); |
michael@0 | 372 | CASE(CKM_CAMELLIA_MAC_GENERAL); |
michael@0 | 373 | CASE(CKM_CDMF_CBC); |
michael@0 | 374 | CASE(CKM_CDMF_CBC_PAD); |
michael@0 | 375 | CASE(CKM_CDMF_ECB); |
michael@0 | 376 | CASE(CKM_CDMF_KEY_GEN); |
michael@0 | 377 | CASE(CKM_CDMF_MAC); |
michael@0 | 378 | CASE(CKM_CDMF_MAC_GENERAL); |
michael@0 | 379 | CASE(CKM_CMS_SIG); |
michael@0 | 380 | CASE(CKM_CONCATENATE_BASE_AND_DATA); |
michael@0 | 381 | CASE(CKM_CONCATENATE_BASE_AND_KEY); |
michael@0 | 382 | CASE(CKM_CONCATENATE_DATA_AND_BASE); |
michael@0 | 383 | CASE(CKM_DES2_KEY_GEN); |
michael@0 | 384 | CASE(CKM_DES3_CBC); |
michael@0 | 385 | CASE(CKM_DES3_CBC_ENCRYPT_DATA); |
michael@0 | 386 | CASE(CKM_DES3_CBC_PAD); |
michael@0 | 387 | CASE(CKM_DES3_ECB); |
michael@0 | 388 | CASE(CKM_DES3_ECB_ENCRYPT_DATA); |
michael@0 | 389 | CASE(CKM_DES3_KEY_GEN); |
michael@0 | 390 | CASE(CKM_DES3_MAC); |
michael@0 | 391 | CASE(CKM_DES3_MAC_GENERAL); |
michael@0 | 392 | CASE(CKM_DES_CBC); |
michael@0 | 393 | CASE(CKM_DES_CBC_ENCRYPT_DATA); |
michael@0 | 394 | CASE(CKM_DES_CBC_PAD); |
michael@0 | 395 | CASE(CKM_DES_CFB64); |
michael@0 | 396 | CASE(CKM_DES_CFB8); |
michael@0 | 397 | CASE(CKM_DES_ECB); |
michael@0 | 398 | CASE(CKM_DES_ECB_ENCRYPT_DATA); |
michael@0 | 399 | CASE(CKM_DES_KEY_GEN); |
michael@0 | 400 | CASE(CKM_DES_MAC); |
michael@0 | 401 | CASE(CKM_DES_MAC_GENERAL); |
michael@0 | 402 | CASE(CKM_DES_OFB64); |
michael@0 | 403 | CASE(CKM_DES_OFB8); |
michael@0 | 404 | CASE(CKM_DH_PKCS_DERIVE); |
michael@0 | 405 | CASE(CKM_DH_PKCS_KEY_PAIR_GEN); |
michael@0 | 406 | CASE(CKM_DH_PKCS_PARAMETER_GEN); |
michael@0 | 407 | CASE(CKM_DSA); |
michael@0 | 408 | CASE(CKM_DSA_KEY_PAIR_GEN); |
michael@0 | 409 | CASE(CKM_DSA_PARAMETER_GEN); |
michael@0 | 410 | CASE(CKM_DSA_SHA1); |
michael@0 | 411 | CASE(CKM_ECDH1_COFACTOR_DERIVE); |
michael@0 | 412 | CASE(CKM_ECDH1_DERIVE); |
michael@0 | 413 | CASE(CKM_ECDSA); |
michael@0 | 414 | CASE(CKM_ECDSA_SHA1); |
michael@0 | 415 | CASE(CKM_ECMQV_DERIVE); |
michael@0 | 416 | CASE(CKM_EC_KEY_PAIR_GEN); /* also CASE(CKM_ECDSA_KEY_PAIR_GEN); */ |
michael@0 | 417 | CASE(CKM_EXTRACT_KEY_FROM_KEY); |
michael@0 | 418 | CASE(CKM_FASTHASH); |
michael@0 | 419 | CASE(CKM_FORTEZZA_TIMESTAMP); |
michael@0 | 420 | CASE(CKM_GENERIC_SECRET_KEY_GEN); |
michael@0 | 421 | CASE(CKM_IDEA_CBC); |
michael@0 | 422 | CASE(CKM_IDEA_CBC_PAD); |
michael@0 | 423 | CASE(CKM_IDEA_ECB); |
michael@0 | 424 | CASE(CKM_IDEA_KEY_GEN); |
michael@0 | 425 | CASE(CKM_IDEA_MAC); |
michael@0 | 426 | CASE(CKM_IDEA_MAC_GENERAL); |
michael@0 | 427 | CASE(CKM_KEA_KEY_DERIVE); |
michael@0 | 428 | CASE(CKM_KEA_KEY_PAIR_GEN); |
michael@0 | 429 | CASE(CKM_KEY_WRAP_LYNKS); |
michael@0 | 430 | CASE(CKM_KEY_WRAP_SET_OAEP); |
michael@0 | 431 | CASE(CKM_MD2); |
michael@0 | 432 | CASE(CKM_MD2_HMAC); |
michael@0 | 433 | CASE(CKM_MD2_HMAC_GENERAL); |
michael@0 | 434 | CASE(CKM_MD2_KEY_DERIVATION); |
michael@0 | 435 | CASE(CKM_MD2_RSA_PKCS); |
michael@0 | 436 | CASE(CKM_MD5); |
michael@0 | 437 | CASE(CKM_MD5_HMAC); |
michael@0 | 438 | CASE(CKM_MD5_HMAC_GENERAL); |
michael@0 | 439 | CASE(CKM_MD5_KEY_DERIVATION); |
michael@0 | 440 | CASE(CKM_MD5_RSA_PKCS); |
michael@0 | 441 | CASE(CKM_PBA_SHA1_WITH_SHA1_HMAC); |
michael@0 | 442 | CASE(CKM_PBE_MD2_DES_CBC); |
michael@0 | 443 | CASE(CKM_PBE_MD5_DES_CBC); |
michael@0 | 444 | CASE(CKM_PBE_SHA1_DES2_EDE_CBC); |
michael@0 | 445 | CASE(CKM_PBE_SHA1_DES3_EDE_CBC); |
michael@0 | 446 | CASE(CKM_PBE_SHA1_RC2_128_CBC); |
michael@0 | 447 | CASE(CKM_PBE_SHA1_RC2_40_CBC); |
michael@0 | 448 | CASE(CKM_PBE_SHA1_RC4_128); |
michael@0 | 449 | CASE(CKM_PBE_SHA1_RC4_40); |
michael@0 | 450 | CASE(CKM_PKCS5_PBKD2); |
michael@0 | 451 | CASE(CKM_RC2_CBC); |
michael@0 | 452 | CASE(CKM_RC2_CBC_PAD); |
michael@0 | 453 | CASE(CKM_RC2_ECB); |
michael@0 | 454 | CASE(CKM_RC2_KEY_GEN); |
michael@0 | 455 | CASE(CKM_RC2_MAC); |
michael@0 | 456 | CASE(CKM_RC2_MAC_GENERAL); |
michael@0 | 457 | CASE(CKM_RC4); |
michael@0 | 458 | CASE(CKM_RC4_KEY_GEN); |
michael@0 | 459 | CASE(CKM_RC5_CBC); |
michael@0 | 460 | CASE(CKM_RC5_CBC_PAD); |
michael@0 | 461 | CASE(CKM_RC5_ECB); |
michael@0 | 462 | CASE(CKM_RC5_KEY_GEN); |
michael@0 | 463 | CASE(CKM_RC5_MAC); |
michael@0 | 464 | CASE(CKM_RC5_MAC_GENERAL); |
michael@0 | 465 | CASE(CKM_RIPEMD128); |
michael@0 | 466 | CASE(CKM_RIPEMD128_HMAC); |
michael@0 | 467 | CASE(CKM_RIPEMD128_HMAC_GENERAL); |
michael@0 | 468 | CASE(CKM_RIPEMD128_RSA_PKCS); |
michael@0 | 469 | CASE(CKM_RIPEMD160); |
michael@0 | 470 | CASE(CKM_RIPEMD160_HMAC); |
michael@0 | 471 | CASE(CKM_RIPEMD160_HMAC_GENERAL); |
michael@0 | 472 | CASE(CKM_RIPEMD160_RSA_PKCS); |
michael@0 | 473 | CASE(CKM_RSA_9796); |
michael@0 | 474 | CASE(CKM_RSA_PKCS); |
michael@0 | 475 | CASE(CKM_RSA_PKCS_KEY_PAIR_GEN); |
michael@0 | 476 | CASE(CKM_RSA_PKCS_OAEP); |
michael@0 | 477 | CASE(CKM_RSA_PKCS_PSS); |
michael@0 | 478 | CASE(CKM_RSA_X9_31); |
michael@0 | 479 | CASE(CKM_RSA_X9_31_KEY_PAIR_GEN); |
michael@0 | 480 | CASE(CKM_RSA_X_509); |
michael@0 | 481 | CASE(CKM_SHA1_KEY_DERIVATION); |
michael@0 | 482 | CASE(CKM_SHA1_RSA_PKCS); |
michael@0 | 483 | CASE(CKM_SHA1_RSA_PKCS_PSS); |
michael@0 | 484 | CASE(CKM_SHA1_RSA_X9_31); |
michael@0 | 485 | CASE(CKM_SHA224); |
michael@0 | 486 | CASE(CKM_SHA224_HMAC); |
michael@0 | 487 | CASE(CKM_SHA224_HMAC_GENERAL); |
michael@0 | 488 | CASE(CKM_SHA224_KEY_DERIVATION); |
michael@0 | 489 | CASE(CKM_SHA224_RSA_PKCS); |
michael@0 | 490 | CASE(CKM_SHA224_RSA_PKCS_PSS); |
michael@0 | 491 | CASE(CKM_SHA256); |
michael@0 | 492 | CASE(CKM_SHA256_HMAC); |
michael@0 | 493 | CASE(CKM_SHA256_HMAC_GENERAL); |
michael@0 | 494 | CASE(CKM_SHA256_KEY_DERIVATION); |
michael@0 | 495 | CASE(CKM_SHA256_RSA_PKCS); |
michael@0 | 496 | CASE(CKM_SHA256_RSA_PKCS_PSS); |
michael@0 | 497 | CASE(CKM_SHA384); |
michael@0 | 498 | CASE(CKM_SHA384_HMAC); |
michael@0 | 499 | CASE(CKM_SHA384_HMAC_GENERAL); |
michael@0 | 500 | CASE(CKM_SHA384_KEY_DERIVATION); |
michael@0 | 501 | CASE(CKM_SHA384_RSA_PKCS); |
michael@0 | 502 | CASE(CKM_SHA384_RSA_PKCS_PSS); |
michael@0 | 503 | CASE(CKM_SHA512); |
michael@0 | 504 | CASE(CKM_SHA512_HMAC); |
michael@0 | 505 | CASE(CKM_SHA512_HMAC_GENERAL); |
michael@0 | 506 | CASE(CKM_SHA512_KEY_DERIVATION); |
michael@0 | 507 | CASE(CKM_SHA512_RSA_PKCS); |
michael@0 | 508 | CASE(CKM_SHA512_RSA_PKCS_PSS); |
michael@0 | 509 | CASE(CKM_SHA_1); |
michael@0 | 510 | CASE(CKM_SHA_1_HMAC); |
michael@0 | 511 | CASE(CKM_SHA_1_HMAC_GENERAL); |
michael@0 | 512 | CASE(CKM_SKIPJACK_CBC64); |
michael@0 | 513 | CASE(CKM_SKIPJACK_CFB16); |
michael@0 | 514 | CASE(CKM_SKIPJACK_CFB32); |
michael@0 | 515 | CASE(CKM_SKIPJACK_CFB64); |
michael@0 | 516 | CASE(CKM_SKIPJACK_CFB8); |
michael@0 | 517 | CASE(CKM_SKIPJACK_ECB64); |
michael@0 | 518 | CASE(CKM_SKIPJACK_KEY_GEN); |
michael@0 | 519 | CASE(CKM_SKIPJACK_OFB64); |
michael@0 | 520 | CASE(CKM_SKIPJACK_PRIVATE_WRAP); |
michael@0 | 521 | CASE(CKM_SKIPJACK_RELAYX); |
michael@0 | 522 | CASE(CKM_SKIPJACK_WRAP); |
michael@0 | 523 | CASE(CKM_SSL3_KEY_AND_MAC_DERIVE); |
michael@0 | 524 | CASE(CKM_SSL3_MASTER_KEY_DERIVE); |
michael@0 | 525 | CASE(CKM_SSL3_MASTER_KEY_DERIVE_DH); |
michael@0 | 526 | CASE(CKM_SSL3_MD5_MAC); |
michael@0 | 527 | CASE(CKM_SSL3_PRE_MASTER_KEY_GEN); |
michael@0 | 528 | CASE(CKM_SSL3_SHA1_MAC); |
michael@0 | 529 | CASE(CKM_TLS_KEY_AND_MAC_DERIVE); |
michael@0 | 530 | CASE(CKM_TLS_MASTER_KEY_DERIVE); |
michael@0 | 531 | CASE(CKM_TLS_MASTER_KEY_DERIVE_DH); |
michael@0 | 532 | CASE(CKM_TLS_PRE_MASTER_KEY_GEN); |
michael@0 | 533 | CASE(CKM_TLS_PRF); |
michael@0 | 534 | CASE(CKM_TWOFISH_CBC); |
michael@0 | 535 | CASE(CKM_TWOFISH_KEY_GEN); |
michael@0 | 536 | CASE(CKM_X9_42_DH_DERIVE); |
michael@0 | 537 | CASE(CKM_X9_42_DH_HYBRID_DERIVE); |
michael@0 | 538 | CASE(CKM_X9_42_DH_KEY_PAIR_GEN); |
michael@0 | 539 | CASE(CKM_X9_42_DH_PARAMETER_GEN); |
michael@0 | 540 | CASE(CKM_X9_42_MQV_DERIVE); |
michael@0 | 541 | CASE(CKM_XOR_BASE_AND_DATA); |
michael@0 | 542 | default: break; |
michael@0 | 543 | } |
michael@0 | 544 | if (a) |
michael@0 | 545 | PR_LOG(modlog, 4, (" mechanism = %s", a)); |
michael@0 | 546 | else |
michael@0 | 547 | PR_LOG(modlog, 4, (" mechanism = 0x%p", m->mechanism)); |
michael@0 | 548 | } |
michael@0 | 549 | |
michael@0 | 550 | static void get_key_type(CK_KEY_TYPE keyType, char *str, int len) |
michael@0 | 551 | { |
michael@0 | 552 | |
michael@0 | 553 | const char * a = NULL; |
michael@0 | 554 | |
michael@0 | 555 | switch (keyType) { |
michael@0 | 556 | CASE(CKK_AES); |
michael@0 | 557 | CASE(CKK_CAMELLIA); |
michael@0 | 558 | CASE(CKK_CDMF); |
michael@0 | 559 | CASE(CKK_DES); |
michael@0 | 560 | CASE(CKK_DES2); |
michael@0 | 561 | CASE(CKK_DES3); |
michael@0 | 562 | CASE(CKK_DH); |
michael@0 | 563 | CASE(CKK_DSA); |
michael@0 | 564 | CASE(CKK_EC); /* also CASE(CKK_ECDSA); */ |
michael@0 | 565 | CASE(CKK_GENERIC_SECRET); |
michael@0 | 566 | CASE(CKK_IDEA); |
michael@0 | 567 | CASE(CKK_INVALID_KEY_TYPE); |
michael@0 | 568 | CASE(CKK_KEA); |
michael@0 | 569 | CASE(CKK_RC2); |
michael@0 | 570 | CASE(CKK_RC4); |
michael@0 | 571 | CASE(CKK_RC5); |
michael@0 | 572 | CASE(CKK_RSA); |
michael@0 | 573 | CASE(CKK_SKIPJACK); |
michael@0 | 574 | CASE(CKK_TWOFISH); |
michael@0 | 575 | CASE(CKK_X9_42_DH); |
michael@0 | 576 | default: break; |
michael@0 | 577 | } |
michael@0 | 578 | if (a) |
michael@0 | 579 | PR_snprintf(str, len, "%s", a); |
michael@0 | 580 | else |
michael@0 | 581 | PR_snprintf(str, len, "0x%p", keyType); |
michael@0 | 582 | } |
michael@0 | 583 | |
michael@0 | 584 | static void print_attr_value(CK_ATTRIBUTE_PTR attr) |
michael@0 | 585 | { |
michael@0 | 586 | char atype[48]; |
michael@0 | 587 | char valstr[49]; |
michael@0 | 588 | int len; |
michael@0 | 589 | |
michael@0 | 590 | get_attr_type_str(attr->type, atype, sizeof atype); |
michael@0 | 591 | switch (attr->type) { |
michael@0 | 592 | case CKA_ALWAYS_SENSITIVE: |
michael@0 | 593 | case CKA_DECRYPT: |
michael@0 | 594 | case CKA_DERIVE: |
michael@0 | 595 | case CKA_ENCRYPT: |
michael@0 | 596 | case CKA_EXTRACTABLE: |
michael@0 | 597 | case CKA_LOCAL: |
michael@0 | 598 | case CKA_MODIFIABLE: |
michael@0 | 599 | case CKA_NEVER_EXTRACTABLE: |
michael@0 | 600 | case CKA_PRIVATE: |
michael@0 | 601 | case CKA_SENSITIVE: |
michael@0 | 602 | case CKA_SIGN: |
michael@0 | 603 | case CKA_SIGN_RECOVER: |
michael@0 | 604 | case CKA_TOKEN: |
michael@0 | 605 | case CKA_UNWRAP: |
michael@0 | 606 | case CKA_VERIFY: |
michael@0 | 607 | case CKA_VERIFY_RECOVER: |
michael@0 | 608 | case CKA_WRAP: |
michael@0 | 609 | if (attr->ulValueLen > 0 && attr->pValue) { |
michael@0 | 610 | CK_BBOOL tf = *((CK_BBOOL *)attr->pValue); |
michael@0 | 611 | PR_LOG(modlog, 4, (fmt_s_s_d, |
michael@0 | 612 | atype, tf ? "CK_TRUE" : "CK_FALSE", attr->ulValueLen)); |
michael@0 | 613 | break; |
michael@0 | 614 | } |
michael@0 | 615 | case CKA_CLASS: |
michael@0 | 616 | if (attr->ulValueLen > 0 && attr->pValue) { |
michael@0 | 617 | CK_OBJECT_CLASS objClass = *((CK_OBJECT_CLASS *)attr->pValue); |
michael@0 | 618 | get_obj_class(objClass, valstr, sizeof valstr); |
michael@0 | 619 | PR_LOG(modlog, 4, (fmt_s_s_d, |
michael@0 | 620 | atype, valstr, attr->ulValueLen)); |
michael@0 | 621 | break; |
michael@0 | 622 | } |
michael@0 | 623 | case CKA_TRUST_CLIENT_AUTH: |
michael@0 | 624 | case CKA_TRUST_CODE_SIGNING: |
michael@0 | 625 | case CKA_TRUST_EMAIL_PROTECTION: |
michael@0 | 626 | case CKA_TRUST_SERVER_AUTH: |
michael@0 | 627 | if (attr->ulValueLen > 0 && attr->pValue) { |
michael@0 | 628 | CK_TRUST trust = *((CK_TRUST *)attr->pValue); |
michael@0 | 629 | get_trust_val(trust, valstr, sizeof valstr); |
michael@0 | 630 | PR_LOG(modlog, 4, (fmt_s_s_d, |
michael@0 | 631 | atype, valstr, attr->ulValueLen)); |
michael@0 | 632 | break; |
michael@0 | 633 | } |
michael@0 | 634 | case CKA_KEY_TYPE: |
michael@0 | 635 | if (attr->ulValueLen > 0 && attr->pValue) { |
michael@0 | 636 | CK_KEY_TYPE keyType = *((CK_KEY_TYPE *)attr->pValue); |
michael@0 | 637 | get_key_type(keyType, valstr, sizeof valstr); |
michael@0 | 638 | PR_LOG(modlog, 4, (fmt_s_s_d, |
michael@0 | 639 | atype, valstr, attr->ulValueLen)); |
michael@0 | 640 | break; |
michael@0 | 641 | } |
michael@0 | 642 | case CKA_PIXEL_X: |
michael@0 | 643 | case CKA_PIXEL_Y: |
michael@0 | 644 | case CKA_RESOLUTION: |
michael@0 | 645 | case CKA_CHAR_ROWS: |
michael@0 | 646 | case CKA_CHAR_COLUMNS: |
michael@0 | 647 | case CKA_BITS_PER_PIXEL: |
michael@0 | 648 | case CKA_CERTIFICATE_CATEGORY: /* should print as enum/string */ |
michael@0 | 649 | case CKA_JAVA_MIDP_SECURITY_DOMAIN: /* should print as enum/string */ |
michael@0 | 650 | case CKA_MODULUS_BITS: |
michael@0 | 651 | case CKA_PRIME_BITS: |
michael@0 | 652 | case CKA_SUBPRIME_BITS: |
michael@0 | 653 | case CKA_VALUE_BITS: |
michael@0 | 654 | case CKA_VALUE_LEN: |
michael@0 | 655 | if (attr->ulValueLen > 0 && attr->pValue) { |
michael@0 | 656 | CK_ULONG valueLen = *((CK_ULONG *)attr->pValue); |
michael@0 | 657 | /* XXX check for the special value CK_UNAVAILABLE_INFORMATION */ |
michael@0 | 658 | PR_LOG(modlog, 4, (fmt_s_lu, atype, (PRUint32)valueLen)); |
michael@0 | 659 | break; |
michael@0 | 660 | } |
michael@0 | 661 | case CKA_LABEL: |
michael@0 | 662 | case CKA_NSS_EMAIL: |
michael@0 | 663 | case CKA_NSS_URL: |
michael@0 | 664 | if (attr->ulValueLen > 0 && attr->pValue) { |
michael@0 | 665 | len = PR_MIN(attr->ulValueLen + 1, sizeof valstr); |
michael@0 | 666 | PR_snprintf(valstr, len, "%s", attr->pValue); |
michael@0 | 667 | PR_LOG(modlog, 4, (fmt_s_qsq_d, |
michael@0 | 668 | atype, valstr, attr->ulValueLen)); |
michael@0 | 669 | break; |
michael@0 | 670 | } |
michael@0 | 671 | case CKA_ISSUER: |
michael@0 | 672 | case CKA_SUBJECT: |
michael@0 | 673 | if (attr->ulValueLen > 0 && attr->pValue) { |
michael@0 | 674 | char * asciiName; |
michael@0 | 675 | SECItem derName; |
michael@0 | 676 | derName.type = siDERNameBuffer; |
michael@0 | 677 | derName.data = attr->pValue; |
michael@0 | 678 | derName.len = attr->ulValueLen; |
michael@0 | 679 | asciiName = CERT_DerNameToAscii(&derName); |
michael@0 | 680 | if (asciiName) { |
michael@0 | 681 | PR_LOG(modlog, 4, (fmt_s_s_d, |
michael@0 | 682 | atype, asciiName, attr->ulValueLen)); |
michael@0 | 683 | PORT_Free(asciiName); |
michael@0 | 684 | break; |
michael@0 | 685 | } |
michael@0 | 686 | /* else treat like a binary buffer */ |
michael@0 | 687 | goto binary_buffer; |
michael@0 | 688 | } |
michael@0 | 689 | case CKA_ID: |
michael@0 | 690 | if (attr->ulValueLen > 0 && attr->pValue) { |
michael@0 | 691 | unsigned char * pV = attr->pValue; |
michael@0 | 692 | for (len = (int)attr->ulValueLen; len > 0; --len) { |
michael@0 | 693 | unsigned int ch = *pV++; |
michael@0 | 694 | if (ch >= 0x20 && ch < 0x7f) |
michael@0 | 695 | continue; |
michael@0 | 696 | if (!ch && len == 1) /* will ignore NUL if last character */ |
michael@0 | 697 | continue; |
michael@0 | 698 | break; |
michael@0 | 699 | } |
michael@0 | 700 | if (!len) { /* entire string is printable */ |
michael@0 | 701 | len = PR_MIN(attr->ulValueLen + 1, sizeof valstr); |
michael@0 | 702 | PR_snprintf(valstr, len, "%s", attr->pValue); |
michael@0 | 703 | PR_LOG(modlog, 4, (fmt_s_qsq_d, |
michael@0 | 704 | atype, valstr, attr->ulValueLen)); |
michael@0 | 705 | break; |
michael@0 | 706 | } |
michael@0 | 707 | /* else fall through and treat like a binary buffer */ |
michael@0 | 708 | } |
michael@0 | 709 | binary_buffer: |
michael@0 | 710 | case CKA_SERIAL_NUMBER: |
michael@0 | 711 | default: |
michael@0 | 712 | if (attr->ulValueLen > 0 && attr->pValue) { |
michael@0 | 713 | char * hexBuf; |
michael@0 | 714 | SECItem attrBuf; |
michael@0 | 715 | attrBuf.type = siDERNameBuffer; |
michael@0 | 716 | attrBuf.data = attr->pValue; |
michael@0 | 717 | attrBuf.len = PR_MIN(attr->ulValueLen, (sizeof valstr)/2); |
michael@0 | 718 | |
michael@0 | 719 | hexBuf = CERT_Hexify(&attrBuf, PR_FALSE); |
michael@0 | 720 | if (hexBuf) { |
michael@0 | 721 | PR_LOG(modlog, 4, (fmt_s_s_d, |
michael@0 | 722 | atype, hexBuf, attr->ulValueLen)); |
michael@0 | 723 | PORT_Free(hexBuf); |
michael@0 | 724 | break; |
michael@0 | 725 | } |
michael@0 | 726 | /* else fall through and show only the address. :( */ |
michael@0 | 727 | } |
michael@0 | 728 | PR_LOG(modlog, 4, (" %s = [0x%p] [%d]", |
michael@0 | 729 | atype, attr->pValue, attr->ulValueLen)); |
michael@0 | 730 | break; |
michael@0 | 731 | } |
michael@0 | 732 | } |
michael@0 | 733 | |
michael@0 | 734 | static void print_template(CK_ATTRIBUTE_PTR templ, CK_ULONG tlen) |
michael@0 | 735 | { |
michael@0 | 736 | CK_ULONG i; |
michael@0 | 737 | for (i=0; i<tlen; i++) { |
michael@0 | 738 | print_attr_value(&templ[i]); |
michael@0 | 739 | } |
michael@0 | 740 | } |
michael@0 | 741 | |
michael@0 | 742 | struct nssdbg_prof_str { |
michael@0 | 743 | PRUint32 time; |
michael@0 | 744 | PRUint32 calls; |
michael@0 | 745 | char *function; |
michael@0 | 746 | }; |
michael@0 | 747 | |
michael@0 | 748 | #define NSSDBG_DEFINE(func) { 0, 0, #func } |
michael@0 | 749 | |
michael@0 | 750 | struct nssdbg_prof_str nssdbg_prof_data[] = { |
michael@0 | 751 | #define FUNC_C_INITIALIZE 0 |
michael@0 | 752 | NSSDBG_DEFINE(C_Initialize), |
michael@0 | 753 | #define FUNC_C_FINALIZE 1 |
michael@0 | 754 | NSSDBG_DEFINE(C_Finalize), |
michael@0 | 755 | #define FUNC_C_GETINFO 2 |
michael@0 | 756 | NSSDBG_DEFINE(C_GetInfo), |
michael@0 | 757 | #define FUNC_C_GETFUNCITONLIST 3 |
michael@0 | 758 | NSSDBG_DEFINE(C_GetFunctionList), |
michael@0 | 759 | #define FUNC_C_GETSLOTLIST 4 |
michael@0 | 760 | NSSDBG_DEFINE(C_GetSlotList), |
michael@0 | 761 | #define FUNC_C_GETSLOTINFO 5 |
michael@0 | 762 | NSSDBG_DEFINE(C_GetSlotInfo), |
michael@0 | 763 | #define FUNC_C_GETTOKENINFO 6 |
michael@0 | 764 | NSSDBG_DEFINE(C_GetTokenInfo), |
michael@0 | 765 | #define FUNC_C_GETMECHANISMLIST 7 |
michael@0 | 766 | NSSDBG_DEFINE(C_GetMechanismList), |
michael@0 | 767 | #define FUNC_C_GETMECHANISMINFO 8 |
michael@0 | 768 | NSSDBG_DEFINE(C_GetMechanismInfo), |
michael@0 | 769 | #define FUNC_C_INITTOKEN 9 |
michael@0 | 770 | NSSDBG_DEFINE(C_InitToken), |
michael@0 | 771 | #define FUNC_C_INITPIN 10 |
michael@0 | 772 | NSSDBG_DEFINE(C_InitPIN), |
michael@0 | 773 | #define FUNC_C_SETPIN 11 |
michael@0 | 774 | NSSDBG_DEFINE(C_SetPIN), |
michael@0 | 775 | #define FUNC_C_OPENSESSION 12 |
michael@0 | 776 | NSSDBG_DEFINE(C_OpenSession), |
michael@0 | 777 | #define FUNC_C_CLOSESESSION 13 |
michael@0 | 778 | NSSDBG_DEFINE(C_CloseSession), |
michael@0 | 779 | #define FUNC_C_CLOSEALLSESSIONS 14 |
michael@0 | 780 | NSSDBG_DEFINE(C_CloseAllSessions), |
michael@0 | 781 | #define FUNC_C_GETSESSIONINFO 15 |
michael@0 | 782 | NSSDBG_DEFINE(C_GetSessionInfo), |
michael@0 | 783 | #define FUNC_C_GETOPERATIONSTATE 16 |
michael@0 | 784 | NSSDBG_DEFINE(C_GetOperationState), |
michael@0 | 785 | #define FUNC_C_SETOPERATIONSTATE 17 |
michael@0 | 786 | NSSDBG_DEFINE(C_SetOperationState), |
michael@0 | 787 | #define FUNC_C_LOGIN 18 |
michael@0 | 788 | NSSDBG_DEFINE(C_Login), |
michael@0 | 789 | #define FUNC_C_LOGOUT 19 |
michael@0 | 790 | NSSDBG_DEFINE(C_Logout), |
michael@0 | 791 | #define FUNC_C_CREATEOBJECT 20 |
michael@0 | 792 | NSSDBG_DEFINE(C_CreateObject), |
michael@0 | 793 | #define FUNC_C_COPYOBJECT 21 |
michael@0 | 794 | NSSDBG_DEFINE(C_CopyObject), |
michael@0 | 795 | #define FUNC_C_DESTROYOBJECT 22 |
michael@0 | 796 | NSSDBG_DEFINE(C_DestroyObject), |
michael@0 | 797 | #define FUNC_C_GETOBJECTSIZE 23 |
michael@0 | 798 | NSSDBG_DEFINE(C_GetObjectSize), |
michael@0 | 799 | #define FUNC_C_GETATTRIBUTEVALUE 24 |
michael@0 | 800 | NSSDBG_DEFINE(C_GetAttributeValue), |
michael@0 | 801 | #define FUNC_C_SETATTRIBUTEVALUE 25 |
michael@0 | 802 | NSSDBG_DEFINE(C_SetAttributeValue), |
michael@0 | 803 | #define FUNC_C_FINDOBJECTSINIT 26 |
michael@0 | 804 | NSSDBG_DEFINE(C_FindObjectsInit), |
michael@0 | 805 | #define FUNC_C_FINDOBJECTS 27 |
michael@0 | 806 | NSSDBG_DEFINE(C_FindObjects), |
michael@0 | 807 | #define FUNC_C_FINDOBJECTSFINAL 28 |
michael@0 | 808 | NSSDBG_DEFINE(C_FindObjectsFinal), |
michael@0 | 809 | #define FUNC_C_ENCRYPTINIT 29 |
michael@0 | 810 | NSSDBG_DEFINE(C_EncryptInit), |
michael@0 | 811 | #define FUNC_C_ENCRYPT 30 |
michael@0 | 812 | NSSDBG_DEFINE(C_Encrypt), |
michael@0 | 813 | #define FUNC_C_ENCRYPTUPDATE 31 |
michael@0 | 814 | NSSDBG_DEFINE(C_EncryptUpdate), |
michael@0 | 815 | #define FUNC_C_ENCRYPTFINAL 32 |
michael@0 | 816 | NSSDBG_DEFINE(C_EncryptFinal), |
michael@0 | 817 | #define FUNC_C_DECRYPTINIT 33 |
michael@0 | 818 | NSSDBG_DEFINE(C_DecryptInit), |
michael@0 | 819 | #define FUNC_C_DECRYPT 34 |
michael@0 | 820 | NSSDBG_DEFINE(C_Decrypt), |
michael@0 | 821 | #define FUNC_C_DECRYPTUPDATE 35 |
michael@0 | 822 | NSSDBG_DEFINE(C_DecryptUpdate), |
michael@0 | 823 | #define FUNC_C_DECRYPTFINAL 36 |
michael@0 | 824 | NSSDBG_DEFINE(C_DecryptFinal), |
michael@0 | 825 | #define FUNC_C_DIGESTINIT 37 |
michael@0 | 826 | NSSDBG_DEFINE(C_DigestInit), |
michael@0 | 827 | #define FUNC_C_DIGEST 38 |
michael@0 | 828 | NSSDBG_DEFINE(C_Digest), |
michael@0 | 829 | #define FUNC_C_DIGESTUPDATE 39 |
michael@0 | 830 | NSSDBG_DEFINE(C_DigestUpdate), |
michael@0 | 831 | #define FUNC_C_DIGESTKEY 40 |
michael@0 | 832 | NSSDBG_DEFINE(C_DigestKey), |
michael@0 | 833 | #define FUNC_C_DIGESTFINAL 41 |
michael@0 | 834 | NSSDBG_DEFINE(C_DigestFinal), |
michael@0 | 835 | #define FUNC_C_SIGNINIT 42 |
michael@0 | 836 | NSSDBG_DEFINE(C_SignInit), |
michael@0 | 837 | #define FUNC_C_SIGN 43 |
michael@0 | 838 | NSSDBG_DEFINE(C_Sign), |
michael@0 | 839 | #define FUNC_C_SIGNUPDATE 44 |
michael@0 | 840 | NSSDBG_DEFINE(C_SignUpdate), |
michael@0 | 841 | #define FUNC_C_SIGNFINAL 45 |
michael@0 | 842 | NSSDBG_DEFINE(C_SignFinal), |
michael@0 | 843 | #define FUNC_C_SIGNRECOVERINIT 46 |
michael@0 | 844 | NSSDBG_DEFINE(C_SignRecoverInit), |
michael@0 | 845 | #define FUNC_C_SIGNRECOVER 47 |
michael@0 | 846 | NSSDBG_DEFINE(C_SignRecover), |
michael@0 | 847 | #define FUNC_C_VERIFYINIT 48 |
michael@0 | 848 | NSSDBG_DEFINE(C_VerifyInit), |
michael@0 | 849 | #define FUNC_C_VERIFY 49 |
michael@0 | 850 | NSSDBG_DEFINE(C_Verify), |
michael@0 | 851 | #define FUNC_C_VERIFYUPDATE 50 |
michael@0 | 852 | NSSDBG_DEFINE(C_VerifyUpdate), |
michael@0 | 853 | #define FUNC_C_VERIFYFINAL 51 |
michael@0 | 854 | NSSDBG_DEFINE(C_VerifyFinal), |
michael@0 | 855 | #define FUNC_C_VERIFYRECOVERINIT 52 |
michael@0 | 856 | NSSDBG_DEFINE(C_VerifyRecoverInit), |
michael@0 | 857 | #define FUNC_C_VERIFYRECOVER 53 |
michael@0 | 858 | NSSDBG_DEFINE(C_VerifyRecover), |
michael@0 | 859 | #define FUNC_C_DIGESTENCRYPTUPDATE 54 |
michael@0 | 860 | NSSDBG_DEFINE(C_DigestEncryptUpdate), |
michael@0 | 861 | #define FUNC_C_DECRYPTDIGESTUPDATE 55 |
michael@0 | 862 | NSSDBG_DEFINE(C_DecryptDigestUpdate), |
michael@0 | 863 | #define FUNC_C_SIGNENCRYPTUPDATE 56 |
michael@0 | 864 | NSSDBG_DEFINE(C_SignEncryptUpdate), |
michael@0 | 865 | #define FUNC_C_DECRYPTVERIFYUPDATE 57 |
michael@0 | 866 | NSSDBG_DEFINE(C_DecryptVerifyUpdate), |
michael@0 | 867 | #define FUNC_C_GENERATEKEY 58 |
michael@0 | 868 | NSSDBG_DEFINE(C_GenerateKey), |
michael@0 | 869 | #define FUNC_C_GENERATEKEYPAIR 59 |
michael@0 | 870 | NSSDBG_DEFINE(C_GenerateKeyPair), |
michael@0 | 871 | #define FUNC_C_WRAPKEY 60 |
michael@0 | 872 | NSSDBG_DEFINE(C_WrapKey), |
michael@0 | 873 | #define FUNC_C_UNWRAPKEY 61 |
michael@0 | 874 | NSSDBG_DEFINE(C_UnWrapKey), |
michael@0 | 875 | #define FUNC_C_DERIVEKEY 62 |
michael@0 | 876 | NSSDBG_DEFINE(C_DeriveKey), |
michael@0 | 877 | #define FUNC_C_SEEDRANDOM 63 |
michael@0 | 878 | NSSDBG_DEFINE(C_SeedRandom), |
michael@0 | 879 | #define FUNC_C_GENERATERANDOM 64 |
michael@0 | 880 | NSSDBG_DEFINE(C_GenerateRandom), |
michael@0 | 881 | #define FUNC_C_GETFUNCTIONSTATUS 65 |
michael@0 | 882 | NSSDBG_DEFINE(C_GetFunctionStatus), |
michael@0 | 883 | #define FUNC_C_CANCELFUNCTION 66 |
michael@0 | 884 | NSSDBG_DEFINE(C_CancelFunction), |
michael@0 | 885 | #define FUNC_C_WAITFORSLOTEVENT 67 |
michael@0 | 886 | NSSDBG_DEFINE(C_WaitForSlotEvent) |
michael@0 | 887 | }; |
michael@0 | 888 | |
michael@0 | 889 | int nssdbg_prof_size = sizeof(nssdbg_prof_data)/sizeof(nssdbg_prof_data[0]); |
michael@0 | 890 | |
michael@0 | 891 | |
michael@0 | 892 | static void nssdbg_finish_time(PRInt32 fun_number, PRIntervalTime start) |
michael@0 | 893 | { |
michael@0 | 894 | PRIntervalTime ival; |
michael@0 | 895 | PRIntervalTime end = PR_IntervalNow(); |
michael@0 | 896 | |
michael@0 | 897 | ival = end-start; |
michael@0 | 898 | /* sigh, lie to PRAtomic add and say we are using signed values */ |
michael@0 | 899 | PR_ATOMIC_ADD((PRInt32 *)&nssdbg_prof_data[fun_number].time, (PRInt32)ival); |
michael@0 | 900 | } |
michael@0 | 901 | |
michael@0 | 902 | static void nssdbg_start_time(PRInt32 fun_number, PRIntervalTime *start) |
michael@0 | 903 | { |
michael@0 | 904 | PR_ATOMIC_INCREMENT((PRInt32 *)&nssdbg_prof_data[fun_number].calls); |
michael@0 | 905 | *start = PR_IntervalNow(); |
michael@0 | 906 | } |
michael@0 | 907 | |
michael@0 | 908 | #define COMMON_DEFINITIONS \ |
michael@0 | 909 | CK_RV rv; \ |
michael@0 | 910 | PRIntervalTime start |
michael@0 | 911 | |
michael@0 | 912 | CK_RV NSSDBGC_Initialize( |
michael@0 | 913 | CK_VOID_PTR pInitArgs |
michael@0 | 914 | ) |
michael@0 | 915 | { |
michael@0 | 916 | COMMON_DEFINITIONS; |
michael@0 | 917 | |
michael@0 | 918 | PR_LOG(modlog, 1, ("C_Initialize")); |
michael@0 | 919 | PR_LOG(modlog, 3, (" pInitArgs = 0x%p", pInitArgs)); |
michael@0 | 920 | nssdbg_start_time(FUNC_C_INITIALIZE,&start); |
michael@0 | 921 | rv = module_functions->C_Initialize(pInitArgs); |
michael@0 | 922 | nssdbg_finish_time(FUNC_C_INITIALIZE,start); |
michael@0 | 923 | log_rv(rv); |
michael@0 | 924 | return rv; |
michael@0 | 925 | } |
michael@0 | 926 | |
michael@0 | 927 | CK_RV NSSDBGC_Finalize( |
michael@0 | 928 | CK_VOID_PTR pReserved |
michael@0 | 929 | ) |
michael@0 | 930 | { |
michael@0 | 931 | COMMON_DEFINITIONS; |
michael@0 | 932 | |
michael@0 | 933 | PR_LOG(modlog, 1, ("C_Finalize")); |
michael@0 | 934 | PR_LOG(modlog, 3, (" pReserved = 0x%p", pReserved)); |
michael@0 | 935 | nssdbg_start_time(FUNC_C_FINALIZE,&start); |
michael@0 | 936 | rv = module_functions->C_Finalize(pReserved); |
michael@0 | 937 | nssdbg_finish_time(FUNC_C_FINALIZE,start); |
michael@0 | 938 | log_rv(rv); |
michael@0 | 939 | return rv; |
michael@0 | 940 | } |
michael@0 | 941 | |
michael@0 | 942 | CK_RV NSSDBGC_GetInfo( |
michael@0 | 943 | CK_INFO_PTR pInfo |
michael@0 | 944 | ) |
michael@0 | 945 | { |
michael@0 | 946 | COMMON_DEFINITIONS; |
michael@0 | 947 | |
michael@0 | 948 | PR_LOG(modlog, 1, ("C_GetInfo")); |
michael@0 | 949 | PR_LOG(modlog, 3, (fmt_pInfo, pInfo)); |
michael@0 | 950 | nssdbg_start_time(FUNC_C_GETINFO,&start); |
michael@0 | 951 | rv = module_functions->C_GetInfo(pInfo); |
michael@0 | 952 | nssdbg_finish_time(FUNC_C_GETINFO,start); |
michael@0 | 953 | if (rv == CKR_OK) { |
michael@0 | 954 | PR_LOG(modlog, 4, (" cryptoki version: %d.%d", |
michael@0 | 955 | pInfo->cryptokiVersion.major, |
michael@0 | 956 | pInfo->cryptokiVersion.minor)); |
michael@0 | 957 | PR_LOG(modlog, 4, (fmt_manufacturerID, pInfo->manufacturerID)); |
michael@0 | 958 | PR_LOG(modlog, 4, (" library description = \"%.32s\"", |
michael@0 | 959 | pInfo->libraryDescription)); |
michael@0 | 960 | PR_LOG(modlog, 4, (" library version: %d.%d", |
michael@0 | 961 | pInfo->libraryVersion.major, |
michael@0 | 962 | pInfo->libraryVersion.minor)); |
michael@0 | 963 | } |
michael@0 | 964 | log_rv(rv); |
michael@0 | 965 | return rv; |
michael@0 | 966 | } |
michael@0 | 967 | |
michael@0 | 968 | CK_RV NSSDBGC_GetFunctionList( |
michael@0 | 969 | CK_FUNCTION_LIST_PTR_PTR ppFunctionList |
michael@0 | 970 | ) |
michael@0 | 971 | { |
michael@0 | 972 | COMMON_DEFINITIONS; |
michael@0 | 973 | |
michael@0 | 974 | PR_LOG(modlog, 1, ("C_GetFunctionList")); |
michael@0 | 975 | PR_LOG(modlog, 3, (" ppFunctionList = 0x%p", ppFunctionList)); |
michael@0 | 976 | nssdbg_start_time(FUNC_C_GETFUNCITONLIST,&start); |
michael@0 | 977 | rv = module_functions->C_GetFunctionList(ppFunctionList); |
michael@0 | 978 | nssdbg_finish_time(FUNC_C_GETFUNCITONLIST,start); |
michael@0 | 979 | log_rv(rv); |
michael@0 | 980 | return rv; |
michael@0 | 981 | } |
michael@0 | 982 | |
michael@0 | 983 | CK_RV NSSDBGC_GetSlotList( |
michael@0 | 984 | CK_BBOOL tokenPresent, |
michael@0 | 985 | CK_SLOT_ID_PTR pSlotList, |
michael@0 | 986 | CK_ULONG_PTR pulCount |
michael@0 | 987 | ) |
michael@0 | 988 | { |
michael@0 | 989 | COMMON_DEFINITIONS; |
michael@0 | 990 | |
michael@0 | 991 | CK_ULONG i; |
michael@0 | 992 | PR_LOG(modlog, 1, ("C_GetSlotList")); |
michael@0 | 993 | PR_LOG(modlog, 3, (" tokenPresent = 0x%x", tokenPresent)); |
michael@0 | 994 | PR_LOG(modlog, 3, (" pSlotList = 0x%p", pSlotList)); |
michael@0 | 995 | PR_LOG(modlog, 3, (fmt_pulCount, pulCount)); |
michael@0 | 996 | nssdbg_start_time(FUNC_C_GETSLOTLIST,&start); |
michael@0 | 997 | rv = module_functions->C_GetSlotList(tokenPresent, pSlotList, pulCount); |
michael@0 | 998 | nssdbg_finish_time(FUNC_C_GETSLOTLIST,start); |
michael@0 | 999 | PR_LOG(modlog, 4, (fmt_spulCount, *pulCount)); |
michael@0 | 1000 | if (pSlotList) { |
michael@0 | 1001 | for (i=0; i<*pulCount; i++) { |
michael@0 | 1002 | PR_LOG(modlog, 4, (" slotID[%d] = %x", i, pSlotList[i])); |
michael@0 | 1003 | } |
michael@0 | 1004 | } |
michael@0 | 1005 | log_rv(rv); |
michael@0 | 1006 | return rv; |
michael@0 | 1007 | } |
michael@0 | 1008 | |
michael@0 | 1009 | CK_RV NSSDBGC_GetSlotInfo( |
michael@0 | 1010 | CK_SLOT_ID slotID, |
michael@0 | 1011 | CK_SLOT_INFO_PTR pInfo |
michael@0 | 1012 | ) |
michael@0 | 1013 | { |
michael@0 | 1014 | COMMON_DEFINITIONS; |
michael@0 | 1015 | |
michael@0 | 1016 | PR_LOG(modlog, 1, ("C_GetSlotInfo")); |
michael@0 | 1017 | PR_LOG(modlog, 3, (fmt_slotID, slotID)); |
michael@0 | 1018 | PR_LOG(modlog, 3, (fmt_pInfo, pInfo)); |
michael@0 | 1019 | nssdbg_start_time(FUNC_C_GETSLOTINFO,&start); |
michael@0 | 1020 | rv = module_functions->C_GetSlotInfo(slotID, pInfo); |
michael@0 | 1021 | nssdbg_finish_time(FUNC_C_GETSLOTINFO,start); |
michael@0 | 1022 | if (rv == CKR_OK) { |
michael@0 | 1023 | PR_LOG(modlog, 4, (" slotDescription = \"%.64s\"", |
michael@0 | 1024 | pInfo->slotDescription)); |
michael@0 | 1025 | PR_LOG(modlog, 4, (fmt_manufacturerID, pInfo->manufacturerID)); |
michael@0 | 1026 | PR_LOG(modlog, 4, (" flags = %s %s %s", |
michael@0 | 1027 | pInfo->flags & CKF_HW_SLOT ? "CKF_HW_SLOT" : "", |
michael@0 | 1028 | pInfo->flags & CKF_REMOVABLE_DEVICE ? "CKF_REMOVABLE_DEVICE" : "", |
michael@0 | 1029 | pInfo->flags & CKF_TOKEN_PRESENT ? "CKF_TOKEN_PRESENT" : "")); |
michael@0 | 1030 | PR_LOG(modlog, 4, (fmt_hwVersion, |
michael@0 | 1031 | pInfo->hardwareVersion.major, |
michael@0 | 1032 | pInfo->hardwareVersion.minor)); |
michael@0 | 1033 | PR_LOG(modlog, 4, (fmt_fwVersion, |
michael@0 | 1034 | pInfo->firmwareVersion.major, |
michael@0 | 1035 | pInfo->firmwareVersion.minor)); |
michael@0 | 1036 | } |
michael@0 | 1037 | log_rv(rv); |
michael@0 | 1038 | return rv; |
michael@0 | 1039 | } |
michael@0 | 1040 | |
michael@0 | 1041 | CK_RV NSSDBGC_GetTokenInfo( |
michael@0 | 1042 | CK_SLOT_ID slotID, |
michael@0 | 1043 | CK_TOKEN_INFO_PTR pInfo |
michael@0 | 1044 | ) |
michael@0 | 1045 | { |
michael@0 | 1046 | COMMON_DEFINITIONS; |
michael@0 | 1047 | |
michael@0 | 1048 | PR_LOG(modlog, 1, ("C_GetTokenInfo")); |
michael@0 | 1049 | PR_LOG(modlog, 3, (fmt_slotID, slotID)); |
michael@0 | 1050 | PR_LOG(modlog, 3, (fmt_pInfo, pInfo)); |
michael@0 | 1051 | nssdbg_start_time(FUNC_C_GETTOKENINFO,&start); |
michael@0 | 1052 | rv = module_functions->C_GetTokenInfo(slotID, pInfo); |
michael@0 | 1053 | nssdbg_finish_time(FUNC_C_GETTOKENINFO,start); |
michael@0 | 1054 | if (rv == CKR_OK) { |
michael@0 | 1055 | PR_LOG(modlog, 4, (" label = \"%.32s\"", pInfo->label)); |
michael@0 | 1056 | PR_LOG(modlog, 4, (fmt_manufacturerID, pInfo->manufacturerID)); |
michael@0 | 1057 | PR_LOG(modlog, 4, (" model = \"%.16s\"", pInfo->model)); |
michael@0 | 1058 | PR_LOG(modlog, 4, (" serial = \"%.16s\"", pInfo->serialNumber)); |
michael@0 | 1059 | PR_LOG(modlog, 4, (" flags = %s %s %s %s", |
michael@0 | 1060 | pInfo->flags & CKF_RNG ? "CKF_RNG" : "", |
michael@0 | 1061 | pInfo->flags & CKF_WRITE_PROTECTED ? "CKF_WRITE_PROTECTED" : "", |
michael@0 | 1062 | pInfo->flags & CKF_LOGIN_REQUIRED ? "CKF_LOGIN_REQUIRED" : "", |
michael@0 | 1063 | pInfo->flags & CKF_USER_PIN_INITIALIZED ? "CKF_USER_PIN_INIT" : "")); |
michael@0 | 1064 | PR_LOG(modlog, 4, (" maxSessions = %u, Sessions = %u", |
michael@0 | 1065 | pInfo->ulMaxSessionCount, pInfo->ulSessionCount)); |
michael@0 | 1066 | PR_LOG(modlog, 4, (" maxRwSessions = %u, RwSessions = %u", |
michael@0 | 1067 | pInfo->ulMaxRwSessionCount, |
michael@0 | 1068 | pInfo->ulRwSessionCount)); |
michael@0 | 1069 | /* ignore Max & Min Pin Len, Public and Private Memory */ |
michael@0 | 1070 | PR_LOG(modlog, 4, (fmt_hwVersion, |
michael@0 | 1071 | pInfo->hardwareVersion.major, |
michael@0 | 1072 | pInfo->hardwareVersion.minor)); |
michael@0 | 1073 | PR_LOG(modlog, 4, (fmt_fwVersion, |
michael@0 | 1074 | pInfo->firmwareVersion.major, |
michael@0 | 1075 | pInfo->firmwareVersion.minor)); |
michael@0 | 1076 | } |
michael@0 | 1077 | log_rv(rv); |
michael@0 | 1078 | return rv; |
michael@0 | 1079 | } |
michael@0 | 1080 | |
michael@0 | 1081 | CK_RV NSSDBGC_GetMechanismList( |
michael@0 | 1082 | CK_SLOT_ID slotID, |
michael@0 | 1083 | CK_MECHANISM_TYPE_PTR pMechanismList, |
michael@0 | 1084 | CK_ULONG_PTR pulCount |
michael@0 | 1085 | ) |
michael@0 | 1086 | { |
michael@0 | 1087 | COMMON_DEFINITIONS; |
michael@0 | 1088 | |
michael@0 | 1089 | PR_LOG(modlog, 1, ("C_GetMechanismList")); |
michael@0 | 1090 | PR_LOG(modlog, 3, (fmt_slotID, slotID)); |
michael@0 | 1091 | PR_LOG(modlog, 3, (" pMechanismList = 0x%p", pMechanismList)); |
michael@0 | 1092 | PR_LOG(modlog, 3, (fmt_pulCount, pulCount)); |
michael@0 | 1093 | nssdbg_start_time(FUNC_C_GETMECHANISMLIST,&start); |
michael@0 | 1094 | rv = module_functions->C_GetMechanismList(slotID, |
michael@0 | 1095 | pMechanismList, |
michael@0 | 1096 | pulCount); |
michael@0 | 1097 | nssdbg_finish_time(FUNC_C_GETMECHANISMLIST,start); |
michael@0 | 1098 | PR_LOG(modlog, 4, (fmt_spulCount, *pulCount)); |
michael@0 | 1099 | log_rv(rv); |
michael@0 | 1100 | return rv; |
michael@0 | 1101 | } |
michael@0 | 1102 | |
michael@0 | 1103 | CK_RV NSSDBGC_GetMechanismInfo( |
michael@0 | 1104 | CK_SLOT_ID slotID, |
michael@0 | 1105 | CK_MECHANISM_TYPE type, |
michael@0 | 1106 | CK_MECHANISM_INFO_PTR pInfo |
michael@0 | 1107 | ) |
michael@0 | 1108 | { |
michael@0 | 1109 | COMMON_DEFINITIONS; |
michael@0 | 1110 | |
michael@0 | 1111 | PR_LOG(modlog, 1, ("C_GetMechanismInfo")); |
michael@0 | 1112 | PR_LOG(modlog, 3, (fmt_slotID, slotID)); |
michael@0 | 1113 | PR_LOG(modlog, 3, (" type = 0x%x", type)); |
michael@0 | 1114 | PR_LOG(modlog, 3, (fmt_pInfo, pInfo)); |
michael@0 | 1115 | nssdbg_start_time(FUNC_C_GETMECHANISMINFO,&start); |
michael@0 | 1116 | rv = module_functions->C_GetMechanismInfo(slotID, |
michael@0 | 1117 | type, |
michael@0 | 1118 | pInfo); |
michael@0 | 1119 | nssdbg_finish_time(FUNC_C_GETMECHANISMINFO,start); |
michael@0 | 1120 | log_rv(rv); |
michael@0 | 1121 | return rv; |
michael@0 | 1122 | } |
michael@0 | 1123 | |
michael@0 | 1124 | CK_RV NSSDBGC_InitToken( |
michael@0 | 1125 | CK_SLOT_ID slotID, |
michael@0 | 1126 | CK_CHAR_PTR pPin, |
michael@0 | 1127 | CK_ULONG ulPinLen, |
michael@0 | 1128 | CK_CHAR_PTR pLabel |
michael@0 | 1129 | ) |
michael@0 | 1130 | { |
michael@0 | 1131 | COMMON_DEFINITIONS; |
michael@0 | 1132 | |
michael@0 | 1133 | PR_LOG(modlog, 1, ("C_InitToken")); |
michael@0 | 1134 | PR_LOG(modlog, 3, (fmt_slotID, slotID)); |
michael@0 | 1135 | PR_LOG(modlog, 3, (fmt_pPin, pPin)); |
michael@0 | 1136 | PR_LOG(modlog, 3, (fmt_ulPinLen, ulPinLen)); |
michael@0 | 1137 | PR_LOG(modlog, 3, (" pLabel = 0x%p", pLabel)); |
michael@0 | 1138 | nssdbg_start_time(FUNC_C_INITTOKEN,&start); |
michael@0 | 1139 | rv = module_functions->C_InitToken(slotID, |
michael@0 | 1140 | pPin, |
michael@0 | 1141 | ulPinLen, |
michael@0 | 1142 | pLabel); |
michael@0 | 1143 | nssdbg_finish_time(FUNC_C_INITTOKEN,start); |
michael@0 | 1144 | log_rv(rv); |
michael@0 | 1145 | return rv; |
michael@0 | 1146 | } |
michael@0 | 1147 | |
michael@0 | 1148 | CK_RV NSSDBGC_InitPIN( |
michael@0 | 1149 | CK_SESSION_HANDLE hSession, |
michael@0 | 1150 | CK_CHAR_PTR pPin, |
michael@0 | 1151 | CK_ULONG ulPinLen |
michael@0 | 1152 | ) |
michael@0 | 1153 | { |
michael@0 | 1154 | COMMON_DEFINITIONS; |
michael@0 | 1155 | |
michael@0 | 1156 | PR_LOG(modlog, 1, ("C_InitPIN")); |
michael@0 | 1157 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1158 | PR_LOG(modlog, 3, (fmt_pPin, pPin)); |
michael@0 | 1159 | PR_LOG(modlog, 3, (fmt_ulPinLen, ulPinLen)); |
michael@0 | 1160 | nssdbg_start_time(FUNC_C_INITPIN,&start); |
michael@0 | 1161 | rv = module_functions->C_InitPIN(hSession, |
michael@0 | 1162 | pPin, |
michael@0 | 1163 | ulPinLen); |
michael@0 | 1164 | nssdbg_finish_time(FUNC_C_INITPIN,start); |
michael@0 | 1165 | log_rv(rv); |
michael@0 | 1166 | return rv; |
michael@0 | 1167 | } |
michael@0 | 1168 | |
michael@0 | 1169 | CK_RV NSSDBGC_SetPIN( |
michael@0 | 1170 | CK_SESSION_HANDLE hSession, |
michael@0 | 1171 | CK_CHAR_PTR pOldPin, |
michael@0 | 1172 | CK_ULONG ulOldLen, |
michael@0 | 1173 | CK_CHAR_PTR pNewPin, |
michael@0 | 1174 | CK_ULONG ulNewLen |
michael@0 | 1175 | ) |
michael@0 | 1176 | { |
michael@0 | 1177 | COMMON_DEFINITIONS; |
michael@0 | 1178 | |
michael@0 | 1179 | PR_LOG(modlog, 1, ("C_SetPIN")); |
michael@0 | 1180 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1181 | PR_LOG(modlog, 3, (" pOldPin = 0x%p", pOldPin)); |
michael@0 | 1182 | PR_LOG(modlog, 3, (" ulOldLen = %d", ulOldLen)); |
michael@0 | 1183 | PR_LOG(modlog, 3, (" pNewPin = 0x%p", pNewPin)); |
michael@0 | 1184 | PR_LOG(modlog, 3, (" ulNewLen = %d", ulNewLen)); |
michael@0 | 1185 | nssdbg_start_time(FUNC_C_SETPIN,&start); |
michael@0 | 1186 | rv = module_functions->C_SetPIN(hSession, |
michael@0 | 1187 | pOldPin, |
michael@0 | 1188 | ulOldLen, |
michael@0 | 1189 | pNewPin, |
michael@0 | 1190 | ulNewLen); |
michael@0 | 1191 | nssdbg_finish_time(FUNC_C_SETPIN,start); |
michael@0 | 1192 | log_rv(rv); |
michael@0 | 1193 | return rv; |
michael@0 | 1194 | } |
michael@0 | 1195 | |
michael@0 | 1196 | static PRUint32 numOpenSessions = 0; |
michael@0 | 1197 | static PRUint32 maxOpenSessions = 0; |
michael@0 | 1198 | |
michael@0 | 1199 | CK_RV NSSDBGC_OpenSession( |
michael@0 | 1200 | CK_SLOT_ID slotID, |
michael@0 | 1201 | CK_FLAGS flags, |
michael@0 | 1202 | CK_VOID_PTR pApplication, |
michael@0 | 1203 | CK_NOTIFY Notify, |
michael@0 | 1204 | CK_SESSION_HANDLE_PTR phSession |
michael@0 | 1205 | ) |
michael@0 | 1206 | { |
michael@0 | 1207 | COMMON_DEFINITIONS; |
michael@0 | 1208 | |
michael@0 | 1209 | PR_ATOMIC_INCREMENT((PRInt32 *)&numOpenSessions); |
michael@0 | 1210 | maxOpenSessions = PR_MAX(numOpenSessions, maxOpenSessions); |
michael@0 | 1211 | PR_LOG(modlog, 1, ("C_OpenSession")); |
michael@0 | 1212 | PR_LOG(modlog, 3, (fmt_slotID, slotID)); |
michael@0 | 1213 | PR_LOG(modlog, 3, (fmt_flags, flags)); |
michael@0 | 1214 | PR_LOG(modlog, 3, (" pApplication = 0x%p", pApplication)); |
michael@0 | 1215 | PR_LOG(modlog, 3, (" Notify = 0x%x", Notify)); |
michael@0 | 1216 | PR_LOG(modlog, 3, (" phSession = 0x%p", phSession)); |
michael@0 | 1217 | nssdbg_start_time(FUNC_C_OPENSESSION,&start); |
michael@0 | 1218 | rv = module_functions->C_OpenSession(slotID, |
michael@0 | 1219 | flags, |
michael@0 | 1220 | pApplication, |
michael@0 | 1221 | Notify, |
michael@0 | 1222 | phSession); |
michael@0 | 1223 | nssdbg_finish_time(FUNC_C_OPENSESSION,start); |
michael@0 | 1224 | log_handle(4, " *phSession = 0x%x", *phSession); |
michael@0 | 1225 | log_rv(rv); |
michael@0 | 1226 | return rv; |
michael@0 | 1227 | } |
michael@0 | 1228 | |
michael@0 | 1229 | CK_RV NSSDBGC_CloseSession( |
michael@0 | 1230 | CK_SESSION_HANDLE hSession |
michael@0 | 1231 | ) |
michael@0 | 1232 | { |
michael@0 | 1233 | COMMON_DEFINITIONS; |
michael@0 | 1234 | |
michael@0 | 1235 | PR_ATOMIC_DECREMENT((PRInt32 *)&numOpenSessions); |
michael@0 | 1236 | PR_LOG(modlog, 1, ("C_CloseSession")); |
michael@0 | 1237 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1238 | nssdbg_start_time(FUNC_C_CLOSESESSION,&start); |
michael@0 | 1239 | rv = module_functions->C_CloseSession(hSession); |
michael@0 | 1240 | nssdbg_finish_time(FUNC_C_CLOSESESSION,start); |
michael@0 | 1241 | log_rv(rv); |
michael@0 | 1242 | return rv; |
michael@0 | 1243 | } |
michael@0 | 1244 | |
michael@0 | 1245 | CK_RV NSSDBGC_CloseAllSessions( |
michael@0 | 1246 | CK_SLOT_ID slotID |
michael@0 | 1247 | ) |
michael@0 | 1248 | { |
michael@0 | 1249 | COMMON_DEFINITIONS; |
michael@0 | 1250 | |
michael@0 | 1251 | PR_LOG(modlog, 1, ("C_CloseAllSessions")); |
michael@0 | 1252 | PR_LOG(modlog, 3, (fmt_slotID, slotID)); |
michael@0 | 1253 | nssdbg_start_time(FUNC_C_CLOSEALLSESSIONS,&start); |
michael@0 | 1254 | rv = module_functions->C_CloseAllSessions(slotID); |
michael@0 | 1255 | nssdbg_finish_time(FUNC_C_CLOSEALLSESSIONS,start); |
michael@0 | 1256 | log_rv(rv); |
michael@0 | 1257 | return rv; |
michael@0 | 1258 | } |
michael@0 | 1259 | |
michael@0 | 1260 | CK_RV NSSDBGC_GetSessionInfo( |
michael@0 | 1261 | CK_SESSION_HANDLE hSession, |
michael@0 | 1262 | CK_SESSION_INFO_PTR pInfo |
michael@0 | 1263 | ) |
michael@0 | 1264 | { |
michael@0 | 1265 | COMMON_DEFINITIONS; |
michael@0 | 1266 | |
michael@0 | 1267 | PR_LOG(modlog, 1, ("C_GetSessionInfo")); |
michael@0 | 1268 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1269 | PR_LOG(modlog, 3, (fmt_pInfo, pInfo)); |
michael@0 | 1270 | nssdbg_start_time(FUNC_C_GETSESSIONINFO,&start); |
michael@0 | 1271 | rv = module_functions->C_GetSessionInfo(hSession, |
michael@0 | 1272 | pInfo); |
michael@0 | 1273 | nssdbg_finish_time(FUNC_C_GETSESSIONINFO,start); |
michael@0 | 1274 | if (rv == CKR_OK) { |
michael@0 | 1275 | PR_LOG(modlog, 4, (fmt_slotID, pInfo->slotID)); |
michael@0 | 1276 | log_state(pInfo->state); |
michael@0 | 1277 | PR_LOG(modlog, 4, (" flags = %s %s", |
michael@0 | 1278 | pInfo->flags & CKF_RW_SESSION ? "CKF_RW_SESSION" : "", |
michael@0 | 1279 | pInfo->flags & CKF_SERIAL_SESSION ? "CKF_SERIAL_SESSION" : "")); |
michael@0 | 1280 | PR_LOG(modlog, 4, (" deviceError = 0x%x", pInfo->ulDeviceError)); |
michael@0 | 1281 | } |
michael@0 | 1282 | log_rv(rv); |
michael@0 | 1283 | return rv; |
michael@0 | 1284 | } |
michael@0 | 1285 | |
michael@0 | 1286 | CK_RV NSSDBGC_GetOperationState( |
michael@0 | 1287 | CK_SESSION_HANDLE hSession, |
michael@0 | 1288 | CK_BYTE_PTR pOperationState, |
michael@0 | 1289 | CK_ULONG_PTR pulOperationStateLen |
michael@0 | 1290 | ) |
michael@0 | 1291 | { |
michael@0 | 1292 | COMMON_DEFINITIONS; |
michael@0 | 1293 | |
michael@0 | 1294 | PR_LOG(modlog, 1, ("C_GetOperationState")); |
michael@0 | 1295 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1296 | PR_LOG(modlog, 3, (fmt_pOperationState, pOperationState)); |
michael@0 | 1297 | PR_LOG(modlog, 3, (" pulOperationStateLen = 0x%p", pulOperationStateLen)); |
michael@0 | 1298 | nssdbg_start_time(FUNC_C_GETOPERATIONSTATE,&start); |
michael@0 | 1299 | rv = module_functions->C_GetOperationState(hSession, |
michael@0 | 1300 | pOperationState, |
michael@0 | 1301 | pulOperationStateLen); |
michael@0 | 1302 | nssdbg_finish_time(FUNC_C_GETOPERATIONSTATE,start); |
michael@0 | 1303 | PR_LOG(modlog, 4, (" *pulOperationStateLen = 0x%x", *pulOperationStateLen)); |
michael@0 | 1304 | log_rv(rv); |
michael@0 | 1305 | return rv; |
michael@0 | 1306 | } |
michael@0 | 1307 | |
michael@0 | 1308 | CK_RV NSSDBGC_SetOperationState( |
michael@0 | 1309 | CK_SESSION_HANDLE hSession, |
michael@0 | 1310 | CK_BYTE_PTR pOperationState, |
michael@0 | 1311 | CK_ULONG ulOperationStateLen, |
michael@0 | 1312 | CK_OBJECT_HANDLE hEncryptionKey, |
michael@0 | 1313 | CK_OBJECT_HANDLE hAuthenticationKey |
michael@0 | 1314 | ) |
michael@0 | 1315 | { |
michael@0 | 1316 | COMMON_DEFINITIONS; |
michael@0 | 1317 | |
michael@0 | 1318 | PR_LOG(modlog, 1, ("C_SetOperationState")); |
michael@0 | 1319 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1320 | PR_LOG(modlog, 3, (fmt_pOperationState, pOperationState)); |
michael@0 | 1321 | PR_LOG(modlog, 3, (" ulOperationStateLen = %d", ulOperationStateLen)); |
michael@0 | 1322 | log_handle(3, " hEncryptionKey = 0x%x", hEncryptionKey); |
michael@0 | 1323 | log_handle(3, " hAuthenticationKey = 0x%x", hAuthenticationKey); |
michael@0 | 1324 | nssdbg_start_time(FUNC_C_SETOPERATIONSTATE,&start); |
michael@0 | 1325 | rv = module_functions->C_SetOperationState(hSession, |
michael@0 | 1326 | pOperationState, |
michael@0 | 1327 | ulOperationStateLen, |
michael@0 | 1328 | hEncryptionKey, |
michael@0 | 1329 | hAuthenticationKey); |
michael@0 | 1330 | nssdbg_finish_time(FUNC_C_SETOPERATIONSTATE,start); |
michael@0 | 1331 | log_rv(rv); |
michael@0 | 1332 | return rv; |
michael@0 | 1333 | } |
michael@0 | 1334 | |
michael@0 | 1335 | CK_RV NSSDBGC_Login( |
michael@0 | 1336 | CK_SESSION_HANDLE hSession, |
michael@0 | 1337 | CK_USER_TYPE userType, |
michael@0 | 1338 | CK_CHAR_PTR pPin, |
michael@0 | 1339 | CK_ULONG ulPinLen |
michael@0 | 1340 | ) |
michael@0 | 1341 | { |
michael@0 | 1342 | COMMON_DEFINITIONS; |
michael@0 | 1343 | |
michael@0 | 1344 | PR_LOG(modlog, 1, ("C_Login")); |
michael@0 | 1345 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1346 | PR_LOG(modlog, 3, (" userType = 0x%x", userType)); |
michael@0 | 1347 | PR_LOG(modlog, 3, (fmt_pPin, pPin)); |
michael@0 | 1348 | PR_LOG(modlog, 3, (fmt_ulPinLen, ulPinLen)); |
michael@0 | 1349 | nssdbg_start_time(FUNC_C_LOGIN,&start); |
michael@0 | 1350 | rv = module_functions->C_Login(hSession, |
michael@0 | 1351 | userType, |
michael@0 | 1352 | pPin, |
michael@0 | 1353 | ulPinLen); |
michael@0 | 1354 | nssdbg_finish_time(FUNC_C_LOGIN,start); |
michael@0 | 1355 | log_rv(rv); |
michael@0 | 1356 | return rv; |
michael@0 | 1357 | } |
michael@0 | 1358 | |
michael@0 | 1359 | CK_RV NSSDBGC_Logout( |
michael@0 | 1360 | CK_SESSION_HANDLE hSession |
michael@0 | 1361 | ) |
michael@0 | 1362 | { |
michael@0 | 1363 | COMMON_DEFINITIONS; |
michael@0 | 1364 | |
michael@0 | 1365 | PR_LOG(modlog, 1, ("C_Logout")); |
michael@0 | 1366 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1367 | nssdbg_start_time(FUNC_C_LOGOUT,&start); |
michael@0 | 1368 | rv = module_functions->C_Logout(hSession); |
michael@0 | 1369 | nssdbg_finish_time(FUNC_C_LOGOUT,start); |
michael@0 | 1370 | log_rv(rv); |
michael@0 | 1371 | return rv; |
michael@0 | 1372 | } |
michael@0 | 1373 | |
michael@0 | 1374 | CK_RV NSSDBGC_CreateObject( |
michael@0 | 1375 | CK_SESSION_HANDLE hSession, |
michael@0 | 1376 | CK_ATTRIBUTE_PTR pTemplate, |
michael@0 | 1377 | CK_ULONG ulCount, |
michael@0 | 1378 | CK_OBJECT_HANDLE_PTR phObject |
michael@0 | 1379 | ) |
michael@0 | 1380 | { |
michael@0 | 1381 | COMMON_DEFINITIONS; |
michael@0 | 1382 | |
michael@0 | 1383 | PR_LOG(modlog, 1, ("C_CreateObject")); |
michael@0 | 1384 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1385 | PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); |
michael@0 | 1386 | PR_LOG(modlog, 3, (fmt_ulCount, ulCount)); |
michael@0 | 1387 | PR_LOG(modlog, 3, (fmt_phObject, phObject)); |
michael@0 | 1388 | print_template(pTemplate, ulCount); |
michael@0 | 1389 | nssdbg_start_time(FUNC_C_CREATEOBJECT,&start); |
michael@0 | 1390 | rv = module_functions->C_CreateObject(hSession, |
michael@0 | 1391 | pTemplate, |
michael@0 | 1392 | ulCount, |
michael@0 | 1393 | phObject); |
michael@0 | 1394 | nssdbg_finish_time(FUNC_C_CREATEOBJECT,start); |
michael@0 | 1395 | log_handle(4, " *phObject = 0x%x", *phObject); |
michael@0 | 1396 | log_rv(rv); |
michael@0 | 1397 | return rv; |
michael@0 | 1398 | } |
michael@0 | 1399 | |
michael@0 | 1400 | CK_RV NSSDBGC_CopyObject( |
michael@0 | 1401 | CK_SESSION_HANDLE hSession, |
michael@0 | 1402 | CK_OBJECT_HANDLE hObject, |
michael@0 | 1403 | CK_ATTRIBUTE_PTR pTemplate, |
michael@0 | 1404 | CK_ULONG ulCount, |
michael@0 | 1405 | CK_OBJECT_HANDLE_PTR phNewObject |
michael@0 | 1406 | ) |
michael@0 | 1407 | { |
michael@0 | 1408 | COMMON_DEFINITIONS; |
michael@0 | 1409 | |
michael@0 | 1410 | PR_LOG(modlog, 1, ("C_CopyObject")); |
michael@0 | 1411 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1412 | log_handle(3, fmt_hObject, hObject); |
michael@0 | 1413 | PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); |
michael@0 | 1414 | PR_LOG(modlog, 3, (fmt_ulCount, ulCount)); |
michael@0 | 1415 | PR_LOG(modlog, 3, (" phNewObject = 0x%p", phNewObject)); |
michael@0 | 1416 | print_template(pTemplate, ulCount); |
michael@0 | 1417 | nssdbg_start_time(FUNC_C_COPYOBJECT,&start); |
michael@0 | 1418 | rv = module_functions->C_CopyObject(hSession, |
michael@0 | 1419 | hObject, |
michael@0 | 1420 | pTemplate, |
michael@0 | 1421 | ulCount, |
michael@0 | 1422 | phNewObject); |
michael@0 | 1423 | nssdbg_finish_time(FUNC_C_COPYOBJECT,start); |
michael@0 | 1424 | log_handle(4, " *phNewObject = 0x%x", *phNewObject); |
michael@0 | 1425 | log_rv(rv); |
michael@0 | 1426 | return rv; |
michael@0 | 1427 | } |
michael@0 | 1428 | |
michael@0 | 1429 | CK_RV NSSDBGC_DestroyObject( |
michael@0 | 1430 | CK_SESSION_HANDLE hSession, |
michael@0 | 1431 | CK_OBJECT_HANDLE hObject |
michael@0 | 1432 | ) |
michael@0 | 1433 | { |
michael@0 | 1434 | COMMON_DEFINITIONS; |
michael@0 | 1435 | |
michael@0 | 1436 | PR_LOG(modlog, 1, ("C_DestroyObject")); |
michael@0 | 1437 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1438 | log_handle(3, fmt_hObject, hObject); |
michael@0 | 1439 | nssdbg_start_time(FUNC_C_DESTROYOBJECT,&start); |
michael@0 | 1440 | rv = module_functions->C_DestroyObject(hSession, |
michael@0 | 1441 | hObject); |
michael@0 | 1442 | nssdbg_finish_time(FUNC_C_DESTROYOBJECT,start); |
michael@0 | 1443 | log_rv(rv); |
michael@0 | 1444 | return rv; |
michael@0 | 1445 | } |
michael@0 | 1446 | |
michael@0 | 1447 | CK_RV NSSDBGC_GetObjectSize( |
michael@0 | 1448 | CK_SESSION_HANDLE hSession, |
michael@0 | 1449 | CK_OBJECT_HANDLE hObject, |
michael@0 | 1450 | CK_ULONG_PTR pulSize |
michael@0 | 1451 | ) |
michael@0 | 1452 | { |
michael@0 | 1453 | COMMON_DEFINITIONS; |
michael@0 | 1454 | |
michael@0 | 1455 | PR_LOG(modlog, 1, ("C_GetObjectSize")); |
michael@0 | 1456 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1457 | log_handle(3, fmt_hObject, hObject); |
michael@0 | 1458 | PR_LOG(modlog, 3, (" pulSize = 0x%p", pulSize)); |
michael@0 | 1459 | nssdbg_start_time(FUNC_C_GETOBJECTSIZE,&start); |
michael@0 | 1460 | rv = module_functions->C_GetObjectSize(hSession, |
michael@0 | 1461 | hObject, |
michael@0 | 1462 | pulSize); |
michael@0 | 1463 | nssdbg_finish_time(FUNC_C_GETOBJECTSIZE,start); |
michael@0 | 1464 | PR_LOG(modlog, 4, (" *pulSize = 0x%x", *pulSize)); |
michael@0 | 1465 | log_rv(rv); |
michael@0 | 1466 | return rv; |
michael@0 | 1467 | } |
michael@0 | 1468 | |
michael@0 | 1469 | CK_RV NSSDBGC_GetAttributeValue( |
michael@0 | 1470 | CK_SESSION_HANDLE hSession, |
michael@0 | 1471 | CK_OBJECT_HANDLE hObject, |
michael@0 | 1472 | CK_ATTRIBUTE_PTR pTemplate, |
michael@0 | 1473 | CK_ULONG ulCount |
michael@0 | 1474 | ) |
michael@0 | 1475 | { |
michael@0 | 1476 | COMMON_DEFINITIONS; |
michael@0 | 1477 | |
michael@0 | 1478 | PR_LOG(modlog, 1, ("C_GetAttributeValue")); |
michael@0 | 1479 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1480 | log_handle(3, fmt_hObject, hObject); |
michael@0 | 1481 | PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); |
michael@0 | 1482 | PR_LOG(modlog, 3, (fmt_ulCount, ulCount)); |
michael@0 | 1483 | nssdbg_start_time(FUNC_C_GETATTRIBUTEVALUE,&start); |
michael@0 | 1484 | rv = module_functions->C_GetAttributeValue(hSession, |
michael@0 | 1485 | hObject, |
michael@0 | 1486 | pTemplate, |
michael@0 | 1487 | ulCount); |
michael@0 | 1488 | nssdbg_finish_time(FUNC_C_GETATTRIBUTEVALUE,start); |
michael@0 | 1489 | print_template(pTemplate, ulCount); |
michael@0 | 1490 | log_rv(rv); |
michael@0 | 1491 | return rv; |
michael@0 | 1492 | } |
michael@0 | 1493 | |
michael@0 | 1494 | CK_RV NSSDBGC_SetAttributeValue( |
michael@0 | 1495 | CK_SESSION_HANDLE hSession, |
michael@0 | 1496 | CK_OBJECT_HANDLE hObject, |
michael@0 | 1497 | CK_ATTRIBUTE_PTR pTemplate, |
michael@0 | 1498 | CK_ULONG ulCount |
michael@0 | 1499 | ) |
michael@0 | 1500 | { |
michael@0 | 1501 | COMMON_DEFINITIONS; |
michael@0 | 1502 | |
michael@0 | 1503 | PR_LOG(modlog, 1, ("C_SetAttributeValue")); |
michael@0 | 1504 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1505 | log_handle(3, fmt_hObject, hObject); |
michael@0 | 1506 | PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); |
michael@0 | 1507 | PR_LOG(modlog, 3, (fmt_ulCount, ulCount)); |
michael@0 | 1508 | print_template(pTemplate, ulCount); |
michael@0 | 1509 | nssdbg_start_time(FUNC_C_SETATTRIBUTEVALUE,&start); |
michael@0 | 1510 | rv = module_functions->C_SetAttributeValue(hSession, |
michael@0 | 1511 | hObject, |
michael@0 | 1512 | pTemplate, |
michael@0 | 1513 | ulCount); |
michael@0 | 1514 | nssdbg_finish_time(FUNC_C_SETATTRIBUTEVALUE,start); |
michael@0 | 1515 | log_rv(rv); |
michael@0 | 1516 | return rv; |
michael@0 | 1517 | } |
michael@0 | 1518 | |
michael@0 | 1519 | CK_RV NSSDBGC_FindObjectsInit( |
michael@0 | 1520 | CK_SESSION_HANDLE hSession, |
michael@0 | 1521 | CK_ATTRIBUTE_PTR pTemplate, |
michael@0 | 1522 | CK_ULONG ulCount |
michael@0 | 1523 | ) |
michael@0 | 1524 | { |
michael@0 | 1525 | COMMON_DEFINITIONS; |
michael@0 | 1526 | |
michael@0 | 1527 | PR_LOG(modlog, 1, ("C_FindObjectsInit")); |
michael@0 | 1528 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1529 | PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); |
michael@0 | 1530 | PR_LOG(modlog, 3, (fmt_ulCount, ulCount)); |
michael@0 | 1531 | print_template(pTemplate, ulCount); |
michael@0 | 1532 | nssdbg_start_time(FUNC_C_FINDOBJECTSINIT,&start); |
michael@0 | 1533 | rv = module_functions->C_FindObjectsInit(hSession, |
michael@0 | 1534 | pTemplate, |
michael@0 | 1535 | ulCount); |
michael@0 | 1536 | nssdbg_finish_time(FUNC_C_FINDOBJECTSINIT,start); |
michael@0 | 1537 | log_rv(rv); |
michael@0 | 1538 | return rv; |
michael@0 | 1539 | } |
michael@0 | 1540 | |
michael@0 | 1541 | CK_RV NSSDBGC_FindObjects( |
michael@0 | 1542 | CK_SESSION_HANDLE hSession, |
michael@0 | 1543 | CK_OBJECT_HANDLE_PTR phObject, |
michael@0 | 1544 | CK_ULONG ulMaxObjectCount, |
michael@0 | 1545 | CK_ULONG_PTR pulObjectCount |
michael@0 | 1546 | ) |
michael@0 | 1547 | { |
michael@0 | 1548 | COMMON_DEFINITIONS; |
michael@0 | 1549 | CK_ULONG i; |
michael@0 | 1550 | |
michael@0 | 1551 | PR_LOG(modlog, 1, ("C_FindObjects")); |
michael@0 | 1552 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1553 | PR_LOG(modlog, 3, (fmt_phObject, phObject)); |
michael@0 | 1554 | PR_LOG(modlog, 3, (" ulMaxObjectCount = %d", ulMaxObjectCount)); |
michael@0 | 1555 | PR_LOG(modlog, 3, (" pulObjectCount = 0x%p", pulObjectCount)); |
michael@0 | 1556 | nssdbg_start_time(FUNC_C_FINDOBJECTS,&start); |
michael@0 | 1557 | rv = module_functions->C_FindObjects(hSession, |
michael@0 | 1558 | phObject, |
michael@0 | 1559 | ulMaxObjectCount, |
michael@0 | 1560 | pulObjectCount); |
michael@0 | 1561 | nssdbg_finish_time(FUNC_C_FINDOBJECTS,start); |
michael@0 | 1562 | PR_LOG(modlog, 4, (" *pulObjectCount = 0x%x", *pulObjectCount)); |
michael@0 | 1563 | for (i=0; i<*pulObjectCount; i++) { |
michael@0 | 1564 | PR_LOG(modlog, 4, (" phObject[%d] = 0x%x%s", i, phObject[i], |
michael@0 | 1565 | phObject[i] ? "" : fmt_invalid_handle)); |
michael@0 | 1566 | } |
michael@0 | 1567 | log_rv(rv); |
michael@0 | 1568 | return rv; |
michael@0 | 1569 | } |
michael@0 | 1570 | |
michael@0 | 1571 | CK_RV NSSDBGC_FindObjectsFinal( |
michael@0 | 1572 | CK_SESSION_HANDLE hSession |
michael@0 | 1573 | ) |
michael@0 | 1574 | { |
michael@0 | 1575 | COMMON_DEFINITIONS; |
michael@0 | 1576 | |
michael@0 | 1577 | PR_LOG(modlog, 1, ("C_FindObjectsFinal")); |
michael@0 | 1578 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1579 | nssdbg_start_time(FUNC_C_FINDOBJECTSFINAL,&start); |
michael@0 | 1580 | rv = module_functions->C_FindObjectsFinal(hSession); |
michael@0 | 1581 | nssdbg_finish_time(FUNC_C_FINDOBJECTSFINAL,start); |
michael@0 | 1582 | log_rv(rv); |
michael@0 | 1583 | return rv; |
michael@0 | 1584 | } |
michael@0 | 1585 | |
michael@0 | 1586 | CK_RV NSSDBGC_EncryptInit( |
michael@0 | 1587 | CK_SESSION_HANDLE hSession, |
michael@0 | 1588 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 1589 | CK_OBJECT_HANDLE hKey |
michael@0 | 1590 | ) |
michael@0 | 1591 | { |
michael@0 | 1592 | COMMON_DEFINITIONS; |
michael@0 | 1593 | |
michael@0 | 1594 | PR_LOG(modlog, 1, ("C_EncryptInit")); |
michael@0 | 1595 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1596 | PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); |
michael@0 | 1597 | log_handle(3, fmt_hKey, hKey); |
michael@0 | 1598 | print_mechanism(pMechanism); |
michael@0 | 1599 | nssdbg_start_time(FUNC_C_ENCRYPTINIT,&start); |
michael@0 | 1600 | rv = module_functions->C_EncryptInit(hSession, |
michael@0 | 1601 | pMechanism, |
michael@0 | 1602 | hKey); |
michael@0 | 1603 | nssdbg_finish_time(FUNC_C_ENCRYPTINIT,start); |
michael@0 | 1604 | log_rv(rv); |
michael@0 | 1605 | return rv; |
michael@0 | 1606 | } |
michael@0 | 1607 | |
michael@0 | 1608 | CK_RV NSSDBGC_Encrypt( |
michael@0 | 1609 | CK_SESSION_HANDLE hSession, |
michael@0 | 1610 | CK_BYTE_PTR pData, |
michael@0 | 1611 | CK_ULONG ulDataLen, |
michael@0 | 1612 | CK_BYTE_PTR pEncryptedData, |
michael@0 | 1613 | CK_ULONG_PTR pulEncryptedDataLen |
michael@0 | 1614 | ) |
michael@0 | 1615 | { |
michael@0 | 1616 | COMMON_DEFINITIONS; |
michael@0 | 1617 | |
michael@0 | 1618 | PR_LOG(modlog, 1, ("C_Encrypt")); |
michael@0 | 1619 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1620 | PR_LOG(modlog, 3, (fmt_pData, pData)); |
michael@0 | 1621 | PR_LOG(modlog, 3, (fmt_ulDataLen, ulDataLen)); |
michael@0 | 1622 | PR_LOG(modlog, 3, (fmt_pEncryptedData, pEncryptedData)); |
michael@0 | 1623 | PR_LOG(modlog, 3, (" pulEncryptedDataLen = 0x%p", pulEncryptedDataLen)); |
michael@0 | 1624 | nssdbg_start_time(FUNC_C_ENCRYPT,&start); |
michael@0 | 1625 | rv = module_functions->C_Encrypt(hSession, |
michael@0 | 1626 | pData, |
michael@0 | 1627 | ulDataLen, |
michael@0 | 1628 | pEncryptedData, |
michael@0 | 1629 | pulEncryptedDataLen); |
michael@0 | 1630 | nssdbg_finish_time(FUNC_C_ENCRYPT,start); |
michael@0 | 1631 | PR_LOG(modlog, 4, (" *pulEncryptedDataLen = 0x%x", *pulEncryptedDataLen)); |
michael@0 | 1632 | log_rv(rv); |
michael@0 | 1633 | return rv; |
michael@0 | 1634 | } |
michael@0 | 1635 | |
michael@0 | 1636 | CK_RV NSSDBGC_EncryptUpdate( |
michael@0 | 1637 | CK_SESSION_HANDLE hSession, |
michael@0 | 1638 | CK_BYTE_PTR pPart, |
michael@0 | 1639 | CK_ULONG ulPartLen, |
michael@0 | 1640 | CK_BYTE_PTR pEncryptedPart, |
michael@0 | 1641 | CK_ULONG_PTR pulEncryptedPartLen |
michael@0 | 1642 | ) |
michael@0 | 1643 | { |
michael@0 | 1644 | COMMON_DEFINITIONS; |
michael@0 | 1645 | |
michael@0 | 1646 | PR_LOG(modlog, 1, ("C_EncryptUpdate")); |
michael@0 | 1647 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1648 | PR_LOG(modlog, 3, (fmt_pPart, pPart)); |
michael@0 | 1649 | PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen)); |
michael@0 | 1650 | PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart)); |
michael@0 | 1651 | PR_LOG(modlog, 3, (fmt_pulEncryptedPartLen, pulEncryptedPartLen)); |
michael@0 | 1652 | nssdbg_start_time(FUNC_C_ENCRYPTUPDATE,&start); |
michael@0 | 1653 | rv = module_functions->C_EncryptUpdate(hSession, |
michael@0 | 1654 | pPart, |
michael@0 | 1655 | ulPartLen, |
michael@0 | 1656 | pEncryptedPart, |
michael@0 | 1657 | pulEncryptedPartLen); |
michael@0 | 1658 | nssdbg_finish_time(FUNC_C_ENCRYPTUPDATE,start); |
michael@0 | 1659 | PR_LOG(modlog, 4, (fmt_spulEncryptedPartLen, *pulEncryptedPartLen)); |
michael@0 | 1660 | log_rv(rv); |
michael@0 | 1661 | return rv; |
michael@0 | 1662 | } |
michael@0 | 1663 | |
michael@0 | 1664 | CK_RV NSSDBGC_EncryptFinal( |
michael@0 | 1665 | CK_SESSION_HANDLE hSession, |
michael@0 | 1666 | CK_BYTE_PTR pLastEncryptedPart, |
michael@0 | 1667 | CK_ULONG_PTR pulLastEncryptedPartLen |
michael@0 | 1668 | ) |
michael@0 | 1669 | { |
michael@0 | 1670 | COMMON_DEFINITIONS; |
michael@0 | 1671 | |
michael@0 | 1672 | PR_LOG(modlog, 1, ("C_EncryptFinal")); |
michael@0 | 1673 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1674 | PR_LOG(modlog, 3, (" pLastEncryptedPart = 0x%p", pLastEncryptedPart)); |
michael@0 | 1675 | PR_LOG(modlog, 3, (" pulLastEncryptedPartLen = 0x%p", pulLastEncryptedPartLen)); |
michael@0 | 1676 | nssdbg_start_time(FUNC_C_ENCRYPTFINAL,&start); |
michael@0 | 1677 | rv = module_functions->C_EncryptFinal(hSession, |
michael@0 | 1678 | pLastEncryptedPart, |
michael@0 | 1679 | pulLastEncryptedPartLen); |
michael@0 | 1680 | nssdbg_finish_time(FUNC_C_ENCRYPTFINAL,start); |
michael@0 | 1681 | PR_LOG(modlog, 4, (" *pulLastEncryptedPartLen = 0x%x", *pulLastEncryptedPartLen)); |
michael@0 | 1682 | log_rv(rv); |
michael@0 | 1683 | return rv; |
michael@0 | 1684 | } |
michael@0 | 1685 | |
michael@0 | 1686 | CK_RV NSSDBGC_DecryptInit( |
michael@0 | 1687 | CK_SESSION_HANDLE hSession, |
michael@0 | 1688 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 1689 | CK_OBJECT_HANDLE hKey |
michael@0 | 1690 | ) |
michael@0 | 1691 | { |
michael@0 | 1692 | COMMON_DEFINITIONS; |
michael@0 | 1693 | |
michael@0 | 1694 | PR_LOG(modlog, 1, ("C_DecryptInit")); |
michael@0 | 1695 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1696 | PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); |
michael@0 | 1697 | log_handle(3, fmt_hKey, hKey); |
michael@0 | 1698 | print_mechanism(pMechanism); |
michael@0 | 1699 | nssdbg_start_time(FUNC_C_DECRYPTINIT,&start); |
michael@0 | 1700 | rv = module_functions->C_DecryptInit(hSession, |
michael@0 | 1701 | pMechanism, |
michael@0 | 1702 | hKey); |
michael@0 | 1703 | nssdbg_finish_time(FUNC_C_DECRYPTINIT,start); |
michael@0 | 1704 | log_rv(rv); |
michael@0 | 1705 | return rv; |
michael@0 | 1706 | } |
michael@0 | 1707 | |
michael@0 | 1708 | CK_RV NSSDBGC_Decrypt( |
michael@0 | 1709 | CK_SESSION_HANDLE hSession, |
michael@0 | 1710 | CK_BYTE_PTR pEncryptedData, |
michael@0 | 1711 | CK_ULONG ulEncryptedDataLen, |
michael@0 | 1712 | CK_BYTE_PTR pData, |
michael@0 | 1713 | CK_ULONG_PTR pulDataLen |
michael@0 | 1714 | ) |
michael@0 | 1715 | { |
michael@0 | 1716 | COMMON_DEFINITIONS; |
michael@0 | 1717 | |
michael@0 | 1718 | PR_LOG(modlog, 1, ("C_Decrypt")); |
michael@0 | 1719 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1720 | PR_LOG(modlog, 3, (fmt_pEncryptedData, pEncryptedData)); |
michael@0 | 1721 | PR_LOG(modlog, 3, (" ulEncryptedDataLen = %d", ulEncryptedDataLen)); |
michael@0 | 1722 | PR_LOG(modlog, 3, (fmt_pData, pData)); |
michael@0 | 1723 | PR_LOG(modlog, 3, (fmt_pulDataLen, pulDataLen)); |
michael@0 | 1724 | nssdbg_start_time(FUNC_C_DECRYPT,&start); |
michael@0 | 1725 | rv = module_functions->C_Decrypt(hSession, |
michael@0 | 1726 | pEncryptedData, |
michael@0 | 1727 | ulEncryptedDataLen, |
michael@0 | 1728 | pData, |
michael@0 | 1729 | pulDataLen); |
michael@0 | 1730 | nssdbg_finish_time(FUNC_C_DECRYPT,start); |
michael@0 | 1731 | PR_LOG(modlog, 4, (fmt_spulDataLen, *pulDataLen)); |
michael@0 | 1732 | log_rv(rv); |
michael@0 | 1733 | return rv; |
michael@0 | 1734 | } |
michael@0 | 1735 | |
michael@0 | 1736 | CK_RV NSSDBGC_DecryptUpdate( |
michael@0 | 1737 | CK_SESSION_HANDLE hSession, |
michael@0 | 1738 | CK_BYTE_PTR pEncryptedPart, |
michael@0 | 1739 | CK_ULONG ulEncryptedPartLen, |
michael@0 | 1740 | CK_BYTE_PTR pPart, |
michael@0 | 1741 | CK_ULONG_PTR pulPartLen |
michael@0 | 1742 | ) |
michael@0 | 1743 | { |
michael@0 | 1744 | COMMON_DEFINITIONS; |
michael@0 | 1745 | |
michael@0 | 1746 | PR_LOG(modlog, 1, ("C_DecryptUpdate")); |
michael@0 | 1747 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1748 | PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart)); |
michael@0 | 1749 | PR_LOG(modlog, 3, (fmt_ulEncryptedPartLen, ulEncryptedPartLen)); |
michael@0 | 1750 | PR_LOG(modlog, 3, (fmt_pPart, pPart)); |
michael@0 | 1751 | PR_LOG(modlog, 3, (fmt_pulPartLen, pulPartLen)); |
michael@0 | 1752 | nssdbg_start_time(FUNC_C_DECRYPTUPDATE,&start); |
michael@0 | 1753 | rv = module_functions->C_DecryptUpdate(hSession, |
michael@0 | 1754 | pEncryptedPart, |
michael@0 | 1755 | ulEncryptedPartLen, |
michael@0 | 1756 | pPart, |
michael@0 | 1757 | pulPartLen); |
michael@0 | 1758 | nssdbg_finish_time(FUNC_C_DECRYPTUPDATE,start); |
michael@0 | 1759 | PR_LOG(modlog, 4, (fmt_spulPartLen, *pulPartLen)); |
michael@0 | 1760 | log_rv(rv); |
michael@0 | 1761 | return rv; |
michael@0 | 1762 | } |
michael@0 | 1763 | |
michael@0 | 1764 | CK_RV NSSDBGC_DecryptFinal( |
michael@0 | 1765 | CK_SESSION_HANDLE hSession, |
michael@0 | 1766 | CK_BYTE_PTR pLastPart, |
michael@0 | 1767 | CK_ULONG_PTR pulLastPartLen |
michael@0 | 1768 | ) |
michael@0 | 1769 | { |
michael@0 | 1770 | COMMON_DEFINITIONS; |
michael@0 | 1771 | |
michael@0 | 1772 | PR_LOG(modlog, 1, ("C_DecryptFinal")); |
michael@0 | 1773 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1774 | PR_LOG(modlog, 3, (" pLastPart = 0x%p", pLastPart)); |
michael@0 | 1775 | PR_LOG(modlog, 3, (" pulLastPartLen = 0x%p", pulLastPartLen)); |
michael@0 | 1776 | nssdbg_start_time(FUNC_C_DECRYPTFINAL,&start); |
michael@0 | 1777 | rv = module_functions->C_DecryptFinal(hSession, |
michael@0 | 1778 | pLastPart, |
michael@0 | 1779 | pulLastPartLen); |
michael@0 | 1780 | nssdbg_finish_time(FUNC_C_DECRYPTFINAL,start); |
michael@0 | 1781 | PR_LOG(modlog, 4, (" *pulLastPartLen = 0x%x", *pulLastPartLen)); |
michael@0 | 1782 | log_rv(rv); |
michael@0 | 1783 | return rv; |
michael@0 | 1784 | } |
michael@0 | 1785 | |
michael@0 | 1786 | CK_RV NSSDBGC_DigestInit( |
michael@0 | 1787 | CK_SESSION_HANDLE hSession, |
michael@0 | 1788 | CK_MECHANISM_PTR pMechanism |
michael@0 | 1789 | ) |
michael@0 | 1790 | { |
michael@0 | 1791 | COMMON_DEFINITIONS; |
michael@0 | 1792 | |
michael@0 | 1793 | PR_LOG(modlog, 1, ("C_DigestInit")); |
michael@0 | 1794 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1795 | PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); |
michael@0 | 1796 | print_mechanism(pMechanism); |
michael@0 | 1797 | nssdbg_start_time(FUNC_C_DIGESTINIT,&start); |
michael@0 | 1798 | rv = module_functions->C_DigestInit(hSession, |
michael@0 | 1799 | pMechanism); |
michael@0 | 1800 | nssdbg_finish_time(FUNC_C_DIGESTINIT,start); |
michael@0 | 1801 | log_rv(rv); |
michael@0 | 1802 | return rv; |
michael@0 | 1803 | } |
michael@0 | 1804 | |
michael@0 | 1805 | CK_RV NSSDBGC_Digest( |
michael@0 | 1806 | CK_SESSION_HANDLE hSession, |
michael@0 | 1807 | CK_BYTE_PTR pData, |
michael@0 | 1808 | CK_ULONG ulDataLen, |
michael@0 | 1809 | CK_BYTE_PTR pDigest, |
michael@0 | 1810 | CK_ULONG_PTR pulDigestLen |
michael@0 | 1811 | ) |
michael@0 | 1812 | { |
michael@0 | 1813 | COMMON_DEFINITIONS; |
michael@0 | 1814 | |
michael@0 | 1815 | PR_LOG(modlog, 1, ("C_Digest")); |
michael@0 | 1816 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1817 | PR_LOG(modlog, 3, (fmt_pData, pData)); |
michael@0 | 1818 | PR_LOG(modlog, 3, (fmt_ulDataLen, ulDataLen)); |
michael@0 | 1819 | PR_LOG(modlog, 3, (fmt_pDigest, pDigest)); |
michael@0 | 1820 | PR_LOG(modlog, 3, (fmt_pulDigestLen, pulDigestLen)); |
michael@0 | 1821 | nssdbg_start_time(FUNC_C_DIGEST,&start); |
michael@0 | 1822 | rv = module_functions->C_Digest(hSession, |
michael@0 | 1823 | pData, |
michael@0 | 1824 | ulDataLen, |
michael@0 | 1825 | pDigest, |
michael@0 | 1826 | pulDigestLen); |
michael@0 | 1827 | nssdbg_finish_time(FUNC_C_DIGEST,start); |
michael@0 | 1828 | PR_LOG(modlog, 4, (fmt_spulDigestLen, *pulDigestLen)); |
michael@0 | 1829 | log_rv(rv); |
michael@0 | 1830 | return rv; |
michael@0 | 1831 | } |
michael@0 | 1832 | |
michael@0 | 1833 | CK_RV NSSDBGC_DigestUpdate( |
michael@0 | 1834 | CK_SESSION_HANDLE hSession, |
michael@0 | 1835 | CK_BYTE_PTR pPart, |
michael@0 | 1836 | CK_ULONG ulPartLen |
michael@0 | 1837 | ) |
michael@0 | 1838 | { |
michael@0 | 1839 | COMMON_DEFINITIONS; |
michael@0 | 1840 | |
michael@0 | 1841 | PR_LOG(modlog, 1, ("C_DigestUpdate")); |
michael@0 | 1842 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1843 | PR_LOG(modlog, 3, (fmt_pPart, pPart)); |
michael@0 | 1844 | PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen)); |
michael@0 | 1845 | nssdbg_start_time(FUNC_C_DIGESTUPDATE,&start); |
michael@0 | 1846 | rv = module_functions->C_DigestUpdate(hSession, |
michael@0 | 1847 | pPart, |
michael@0 | 1848 | ulPartLen); |
michael@0 | 1849 | nssdbg_finish_time(FUNC_C_DIGESTUPDATE,start); |
michael@0 | 1850 | log_rv(rv); |
michael@0 | 1851 | return rv; |
michael@0 | 1852 | } |
michael@0 | 1853 | |
michael@0 | 1854 | CK_RV NSSDBGC_DigestKey( |
michael@0 | 1855 | CK_SESSION_HANDLE hSession, |
michael@0 | 1856 | CK_OBJECT_HANDLE hKey |
michael@0 | 1857 | ) |
michael@0 | 1858 | { |
michael@0 | 1859 | COMMON_DEFINITIONS; |
michael@0 | 1860 | |
michael@0 | 1861 | PR_LOG(modlog, 1, ("C_DigestKey")); |
michael@0 | 1862 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1863 | nssdbg_start_time(FUNC_C_DIGESTKEY,&start); |
michael@0 | 1864 | rv = module_functions->C_DigestKey(hSession, |
michael@0 | 1865 | hKey); |
michael@0 | 1866 | nssdbg_finish_time(FUNC_C_DIGESTKEY,start); |
michael@0 | 1867 | log_rv(rv); |
michael@0 | 1868 | return rv; |
michael@0 | 1869 | } |
michael@0 | 1870 | |
michael@0 | 1871 | CK_RV NSSDBGC_DigestFinal( |
michael@0 | 1872 | CK_SESSION_HANDLE hSession, |
michael@0 | 1873 | CK_BYTE_PTR pDigest, |
michael@0 | 1874 | CK_ULONG_PTR pulDigestLen |
michael@0 | 1875 | ) |
michael@0 | 1876 | { |
michael@0 | 1877 | COMMON_DEFINITIONS; |
michael@0 | 1878 | |
michael@0 | 1879 | PR_LOG(modlog, 1, ("C_DigestFinal")); |
michael@0 | 1880 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1881 | PR_LOG(modlog, 3, (fmt_pDigest, pDigest)); |
michael@0 | 1882 | PR_LOG(modlog, 3, (fmt_pulDigestLen, pulDigestLen)); |
michael@0 | 1883 | nssdbg_start_time(FUNC_C_DIGESTFINAL,&start); |
michael@0 | 1884 | rv = module_functions->C_DigestFinal(hSession, |
michael@0 | 1885 | pDigest, |
michael@0 | 1886 | pulDigestLen); |
michael@0 | 1887 | nssdbg_finish_time(FUNC_C_DIGESTFINAL,start); |
michael@0 | 1888 | PR_LOG(modlog, 4, (fmt_spulDigestLen, *pulDigestLen)); |
michael@0 | 1889 | log_rv(rv); |
michael@0 | 1890 | return rv; |
michael@0 | 1891 | } |
michael@0 | 1892 | |
michael@0 | 1893 | CK_RV NSSDBGC_SignInit( |
michael@0 | 1894 | CK_SESSION_HANDLE hSession, |
michael@0 | 1895 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 1896 | CK_OBJECT_HANDLE hKey |
michael@0 | 1897 | ) |
michael@0 | 1898 | { |
michael@0 | 1899 | COMMON_DEFINITIONS; |
michael@0 | 1900 | |
michael@0 | 1901 | PR_LOG(modlog, 1, ("C_SignInit")); |
michael@0 | 1902 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1903 | PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); |
michael@0 | 1904 | log_handle(3, fmt_hKey, hKey); |
michael@0 | 1905 | print_mechanism(pMechanism); |
michael@0 | 1906 | nssdbg_start_time(FUNC_C_SIGNINIT,&start); |
michael@0 | 1907 | rv = module_functions->C_SignInit(hSession, |
michael@0 | 1908 | pMechanism, |
michael@0 | 1909 | hKey); |
michael@0 | 1910 | nssdbg_finish_time(FUNC_C_SIGNINIT,start); |
michael@0 | 1911 | log_rv(rv); |
michael@0 | 1912 | return rv; |
michael@0 | 1913 | } |
michael@0 | 1914 | |
michael@0 | 1915 | CK_RV NSSDBGC_Sign( |
michael@0 | 1916 | CK_SESSION_HANDLE hSession, |
michael@0 | 1917 | CK_BYTE_PTR pData, |
michael@0 | 1918 | CK_ULONG ulDataLen, |
michael@0 | 1919 | CK_BYTE_PTR pSignature, |
michael@0 | 1920 | CK_ULONG_PTR pulSignatureLen |
michael@0 | 1921 | ) |
michael@0 | 1922 | { |
michael@0 | 1923 | COMMON_DEFINITIONS; |
michael@0 | 1924 | |
michael@0 | 1925 | PR_LOG(modlog, 1, ("C_Sign")); |
michael@0 | 1926 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1927 | PR_LOG(modlog, 3, (fmt_pData, pData)); |
michael@0 | 1928 | PR_LOG(modlog, 3, (fmt_ulDataLen, ulDataLen)); |
michael@0 | 1929 | PR_LOG(modlog, 3, (fmt_pSignature, pSignature)); |
michael@0 | 1930 | PR_LOG(modlog, 3, (fmt_pulSignatureLen, pulSignatureLen)); |
michael@0 | 1931 | nssdbg_start_time(FUNC_C_SIGN,&start); |
michael@0 | 1932 | rv = module_functions->C_Sign(hSession, |
michael@0 | 1933 | pData, |
michael@0 | 1934 | ulDataLen, |
michael@0 | 1935 | pSignature, |
michael@0 | 1936 | pulSignatureLen); |
michael@0 | 1937 | nssdbg_finish_time(FUNC_C_SIGN,start); |
michael@0 | 1938 | PR_LOG(modlog, 4, (fmt_spulSignatureLen, *pulSignatureLen)); |
michael@0 | 1939 | log_rv(rv); |
michael@0 | 1940 | return rv; |
michael@0 | 1941 | } |
michael@0 | 1942 | |
michael@0 | 1943 | CK_RV NSSDBGC_SignUpdate( |
michael@0 | 1944 | CK_SESSION_HANDLE hSession, |
michael@0 | 1945 | CK_BYTE_PTR pPart, |
michael@0 | 1946 | CK_ULONG ulPartLen |
michael@0 | 1947 | ) |
michael@0 | 1948 | { |
michael@0 | 1949 | COMMON_DEFINITIONS; |
michael@0 | 1950 | |
michael@0 | 1951 | PR_LOG(modlog, 1, ("C_SignUpdate")); |
michael@0 | 1952 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1953 | PR_LOG(modlog, 3, (fmt_pPart, pPart)); |
michael@0 | 1954 | PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen)); |
michael@0 | 1955 | nssdbg_start_time(FUNC_C_SIGNUPDATE,&start); |
michael@0 | 1956 | rv = module_functions->C_SignUpdate(hSession, |
michael@0 | 1957 | pPart, |
michael@0 | 1958 | ulPartLen); |
michael@0 | 1959 | nssdbg_finish_time(FUNC_C_SIGNUPDATE,start); |
michael@0 | 1960 | log_rv(rv); |
michael@0 | 1961 | return rv; |
michael@0 | 1962 | } |
michael@0 | 1963 | |
michael@0 | 1964 | CK_RV NSSDBGC_SignFinal( |
michael@0 | 1965 | CK_SESSION_HANDLE hSession, |
michael@0 | 1966 | CK_BYTE_PTR pSignature, |
michael@0 | 1967 | CK_ULONG_PTR pulSignatureLen |
michael@0 | 1968 | ) |
michael@0 | 1969 | { |
michael@0 | 1970 | COMMON_DEFINITIONS; |
michael@0 | 1971 | |
michael@0 | 1972 | PR_LOG(modlog, 1, ("C_SignFinal")); |
michael@0 | 1973 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1974 | PR_LOG(modlog, 3, (fmt_pSignature, pSignature)); |
michael@0 | 1975 | PR_LOG(modlog, 3, (fmt_pulSignatureLen, pulSignatureLen)); |
michael@0 | 1976 | nssdbg_start_time(FUNC_C_SIGNFINAL,&start); |
michael@0 | 1977 | rv = module_functions->C_SignFinal(hSession, |
michael@0 | 1978 | pSignature, |
michael@0 | 1979 | pulSignatureLen); |
michael@0 | 1980 | nssdbg_finish_time(FUNC_C_SIGNFINAL,start); |
michael@0 | 1981 | PR_LOG(modlog, 4, (fmt_spulSignatureLen, *pulSignatureLen)); |
michael@0 | 1982 | log_rv(rv); |
michael@0 | 1983 | return rv; |
michael@0 | 1984 | } |
michael@0 | 1985 | |
michael@0 | 1986 | CK_RV NSSDBGC_SignRecoverInit( |
michael@0 | 1987 | CK_SESSION_HANDLE hSession, |
michael@0 | 1988 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 1989 | CK_OBJECT_HANDLE hKey |
michael@0 | 1990 | ) |
michael@0 | 1991 | { |
michael@0 | 1992 | COMMON_DEFINITIONS; |
michael@0 | 1993 | |
michael@0 | 1994 | PR_LOG(modlog, 1, ("C_SignRecoverInit")); |
michael@0 | 1995 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 1996 | PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); |
michael@0 | 1997 | log_handle(3, fmt_hKey, hKey); |
michael@0 | 1998 | print_mechanism(pMechanism); |
michael@0 | 1999 | nssdbg_start_time(FUNC_C_SIGNRECOVERINIT,&start); |
michael@0 | 2000 | rv = module_functions->C_SignRecoverInit(hSession, |
michael@0 | 2001 | pMechanism, |
michael@0 | 2002 | hKey); |
michael@0 | 2003 | nssdbg_finish_time(FUNC_C_SIGNRECOVERINIT,start); |
michael@0 | 2004 | log_rv(rv); |
michael@0 | 2005 | return rv; |
michael@0 | 2006 | } |
michael@0 | 2007 | |
michael@0 | 2008 | CK_RV NSSDBGC_SignRecover( |
michael@0 | 2009 | CK_SESSION_HANDLE hSession, |
michael@0 | 2010 | CK_BYTE_PTR pData, |
michael@0 | 2011 | CK_ULONG ulDataLen, |
michael@0 | 2012 | CK_BYTE_PTR pSignature, |
michael@0 | 2013 | CK_ULONG_PTR pulSignatureLen |
michael@0 | 2014 | ) |
michael@0 | 2015 | { |
michael@0 | 2016 | COMMON_DEFINITIONS; |
michael@0 | 2017 | |
michael@0 | 2018 | PR_LOG(modlog, 1, ("C_SignRecover")); |
michael@0 | 2019 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 2020 | PR_LOG(modlog, 3, (fmt_pData, pData)); |
michael@0 | 2021 | PR_LOG(modlog, 3, (fmt_ulDataLen, ulDataLen)); |
michael@0 | 2022 | PR_LOG(modlog, 3, (fmt_pSignature, pSignature)); |
michael@0 | 2023 | PR_LOG(modlog, 3, (fmt_pulSignatureLen, pulSignatureLen)); |
michael@0 | 2024 | nssdbg_start_time(FUNC_C_SIGNRECOVER,&start); |
michael@0 | 2025 | rv = module_functions->C_SignRecover(hSession, |
michael@0 | 2026 | pData, |
michael@0 | 2027 | ulDataLen, |
michael@0 | 2028 | pSignature, |
michael@0 | 2029 | pulSignatureLen); |
michael@0 | 2030 | nssdbg_finish_time(FUNC_C_SIGNRECOVER,start); |
michael@0 | 2031 | PR_LOG(modlog, 4, (fmt_spulSignatureLen, *pulSignatureLen)); |
michael@0 | 2032 | log_rv(rv); |
michael@0 | 2033 | return rv; |
michael@0 | 2034 | } |
michael@0 | 2035 | |
michael@0 | 2036 | CK_RV NSSDBGC_VerifyInit( |
michael@0 | 2037 | CK_SESSION_HANDLE hSession, |
michael@0 | 2038 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 2039 | CK_OBJECT_HANDLE hKey |
michael@0 | 2040 | ) |
michael@0 | 2041 | { |
michael@0 | 2042 | COMMON_DEFINITIONS; |
michael@0 | 2043 | |
michael@0 | 2044 | PR_LOG(modlog, 1, ("C_VerifyInit")); |
michael@0 | 2045 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 2046 | PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); |
michael@0 | 2047 | log_handle(3, fmt_hKey, hKey); |
michael@0 | 2048 | print_mechanism(pMechanism); |
michael@0 | 2049 | nssdbg_start_time(FUNC_C_VERIFYINIT,&start); |
michael@0 | 2050 | rv = module_functions->C_VerifyInit(hSession, |
michael@0 | 2051 | pMechanism, |
michael@0 | 2052 | hKey); |
michael@0 | 2053 | nssdbg_finish_time(FUNC_C_VERIFYINIT,start); |
michael@0 | 2054 | log_rv(rv); |
michael@0 | 2055 | return rv; |
michael@0 | 2056 | } |
michael@0 | 2057 | |
michael@0 | 2058 | CK_RV NSSDBGC_Verify( |
michael@0 | 2059 | CK_SESSION_HANDLE hSession, |
michael@0 | 2060 | CK_BYTE_PTR pData, |
michael@0 | 2061 | CK_ULONG ulDataLen, |
michael@0 | 2062 | CK_BYTE_PTR pSignature, |
michael@0 | 2063 | CK_ULONG ulSignatureLen |
michael@0 | 2064 | ) |
michael@0 | 2065 | { |
michael@0 | 2066 | COMMON_DEFINITIONS; |
michael@0 | 2067 | |
michael@0 | 2068 | PR_LOG(modlog, 1, ("C_Verify")); |
michael@0 | 2069 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 2070 | PR_LOG(modlog, 3, (fmt_pData, pData)); |
michael@0 | 2071 | PR_LOG(modlog, 3, (fmt_ulDataLen, ulDataLen)); |
michael@0 | 2072 | PR_LOG(modlog, 3, (fmt_pSignature, pSignature)); |
michael@0 | 2073 | PR_LOG(modlog, 3, (fmt_ulSignatureLen, ulSignatureLen)); |
michael@0 | 2074 | nssdbg_start_time(FUNC_C_VERIFY,&start); |
michael@0 | 2075 | rv = module_functions->C_Verify(hSession, |
michael@0 | 2076 | pData, |
michael@0 | 2077 | ulDataLen, |
michael@0 | 2078 | pSignature, |
michael@0 | 2079 | ulSignatureLen); |
michael@0 | 2080 | nssdbg_finish_time(FUNC_C_VERIFY,start); |
michael@0 | 2081 | log_rv(rv); |
michael@0 | 2082 | return rv; |
michael@0 | 2083 | } |
michael@0 | 2084 | |
michael@0 | 2085 | CK_RV NSSDBGC_VerifyUpdate( |
michael@0 | 2086 | CK_SESSION_HANDLE hSession, |
michael@0 | 2087 | CK_BYTE_PTR pPart, |
michael@0 | 2088 | CK_ULONG ulPartLen |
michael@0 | 2089 | ) |
michael@0 | 2090 | { |
michael@0 | 2091 | COMMON_DEFINITIONS; |
michael@0 | 2092 | |
michael@0 | 2093 | PR_LOG(modlog, 1, ("C_VerifyUpdate")); |
michael@0 | 2094 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 2095 | PR_LOG(modlog, 3, (fmt_pPart, pPart)); |
michael@0 | 2096 | PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen)); |
michael@0 | 2097 | nssdbg_start_time(FUNC_C_VERIFYUPDATE,&start); |
michael@0 | 2098 | rv = module_functions->C_VerifyUpdate(hSession, |
michael@0 | 2099 | pPart, |
michael@0 | 2100 | ulPartLen); |
michael@0 | 2101 | nssdbg_finish_time(FUNC_C_VERIFYUPDATE,start); |
michael@0 | 2102 | log_rv(rv); |
michael@0 | 2103 | return rv; |
michael@0 | 2104 | } |
michael@0 | 2105 | |
michael@0 | 2106 | CK_RV NSSDBGC_VerifyFinal( |
michael@0 | 2107 | CK_SESSION_HANDLE hSession, |
michael@0 | 2108 | CK_BYTE_PTR pSignature, |
michael@0 | 2109 | CK_ULONG ulSignatureLen |
michael@0 | 2110 | ) |
michael@0 | 2111 | { |
michael@0 | 2112 | COMMON_DEFINITIONS; |
michael@0 | 2113 | |
michael@0 | 2114 | PR_LOG(modlog, 1, ("C_VerifyFinal")); |
michael@0 | 2115 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 2116 | PR_LOG(modlog, 3, (fmt_pSignature, pSignature)); |
michael@0 | 2117 | PR_LOG(modlog, 3, (fmt_ulSignatureLen, ulSignatureLen)); |
michael@0 | 2118 | nssdbg_start_time(FUNC_C_VERIFYFINAL,&start); |
michael@0 | 2119 | rv = module_functions->C_VerifyFinal(hSession, |
michael@0 | 2120 | pSignature, |
michael@0 | 2121 | ulSignatureLen); |
michael@0 | 2122 | nssdbg_finish_time(FUNC_C_VERIFYFINAL,start); |
michael@0 | 2123 | log_rv(rv); |
michael@0 | 2124 | return rv; |
michael@0 | 2125 | } |
michael@0 | 2126 | |
michael@0 | 2127 | CK_RV NSSDBGC_VerifyRecoverInit( |
michael@0 | 2128 | CK_SESSION_HANDLE hSession, |
michael@0 | 2129 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 2130 | CK_OBJECT_HANDLE hKey |
michael@0 | 2131 | ) |
michael@0 | 2132 | { |
michael@0 | 2133 | COMMON_DEFINITIONS; |
michael@0 | 2134 | |
michael@0 | 2135 | PR_LOG(modlog, 1, ("C_VerifyRecoverInit")); |
michael@0 | 2136 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 2137 | PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); |
michael@0 | 2138 | log_handle(3, fmt_hKey, hKey); |
michael@0 | 2139 | print_mechanism(pMechanism); |
michael@0 | 2140 | nssdbg_start_time(FUNC_C_VERIFYRECOVERINIT,&start); |
michael@0 | 2141 | rv = module_functions->C_VerifyRecoverInit(hSession, |
michael@0 | 2142 | pMechanism, |
michael@0 | 2143 | hKey); |
michael@0 | 2144 | nssdbg_finish_time(FUNC_C_VERIFYRECOVERINIT,start); |
michael@0 | 2145 | log_rv(rv); |
michael@0 | 2146 | return rv; |
michael@0 | 2147 | } |
michael@0 | 2148 | |
michael@0 | 2149 | CK_RV NSSDBGC_VerifyRecover( |
michael@0 | 2150 | CK_SESSION_HANDLE hSession, |
michael@0 | 2151 | CK_BYTE_PTR pSignature, |
michael@0 | 2152 | CK_ULONG ulSignatureLen, |
michael@0 | 2153 | CK_BYTE_PTR pData, |
michael@0 | 2154 | CK_ULONG_PTR pulDataLen |
michael@0 | 2155 | ) |
michael@0 | 2156 | { |
michael@0 | 2157 | COMMON_DEFINITIONS; |
michael@0 | 2158 | |
michael@0 | 2159 | PR_LOG(modlog, 1, ("C_VerifyRecover")); |
michael@0 | 2160 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 2161 | PR_LOG(modlog, 3, (fmt_pSignature, pSignature)); |
michael@0 | 2162 | PR_LOG(modlog, 3, (fmt_ulSignatureLen, ulSignatureLen)); |
michael@0 | 2163 | PR_LOG(modlog, 3, (fmt_pData, pData)); |
michael@0 | 2164 | PR_LOG(modlog, 3, (fmt_pulDataLen, pulDataLen)); |
michael@0 | 2165 | nssdbg_start_time(FUNC_C_VERIFYRECOVER,&start); |
michael@0 | 2166 | rv = module_functions->C_VerifyRecover(hSession, |
michael@0 | 2167 | pSignature, |
michael@0 | 2168 | ulSignatureLen, |
michael@0 | 2169 | pData, |
michael@0 | 2170 | pulDataLen); |
michael@0 | 2171 | nssdbg_finish_time(FUNC_C_VERIFYRECOVER,start); |
michael@0 | 2172 | PR_LOG(modlog, 4, (fmt_spulDataLen, *pulDataLen)); |
michael@0 | 2173 | log_rv(rv); |
michael@0 | 2174 | return rv; |
michael@0 | 2175 | } |
michael@0 | 2176 | |
michael@0 | 2177 | CK_RV NSSDBGC_DigestEncryptUpdate( |
michael@0 | 2178 | CK_SESSION_HANDLE hSession, |
michael@0 | 2179 | CK_BYTE_PTR pPart, |
michael@0 | 2180 | CK_ULONG ulPartLen, |
michael@0 | 2181 | CK_BYTE_PTR pEncryptedPart, |
michael@0 | 2182 | CK_ULONG_PTR pulEncryptedPartLen |
michael@0 | 2183 | ) |
michael@0 | 2184 | { |
michael@0 | 2185 | COMMON_DEFINITIONS; |
michael@0 | 2186 | |
michael@0 | 2187 | PR_LOG(modlog, 1, ("C_DigestEncryptUpdate")); |
michael@0 | 2188 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 2189 | PR_LOG(modlog, 3, (fmt_pPart, pPart)); |
michael@0 | 2190 | PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen)); |
michael@0 | 2191 | PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart)); |
michael@0 | 2192 | PR_LOG(modlog, 3, (fmt_pulEncryptedPartLen, pulEncryptedPartLen)); |
michael@0 | 2193 | nssdbg_start_time(FUNC_C_DIGESTENCRYPTUPDATE,&start); |
michael@0 | 2194 | rv = module_functions->C_DigestEncryptUpdate(hSession, |
michael@0 | 2195 | pPart, |
michael@0 | 2196 | ulPartLen, |
michael@0 | 2197 | pEncryptedPart, |
michael@0 | 2198 | pulEncryptedPartLen); |
michael@0 | 2199 | nssdbg_finish_time(FUNC_C_DIGESTENCRYPTUPDATE,start); |
michael@0 | 2200 | PR_LOG(modlog, 4, (fmt_spulEncryptedPartLen, *pulEncryptedPartLen)); |
michael@0 | 2201 | log_rv(rv); |
michael@0 | 2202 | return rv; |
michael@0 | 2203 | } |
michael@0 | 2204 | |
michael@0 | 2205 | CK_RV NSSDBGC_DecryptDigestUpdate( |
michael@0 | 2206 | CK_SESSION_HANDLE hSession, |
michael@0 | 2207 | CK_BYTE_PTR pEncryptedPart, |
michael@0 | 2208 | CK_ULONG ulEncryptedPartLen, |
michael@0 | 2209 | CK_BYTE_PTR pPart, |
michael@0 | 2210 | CK_ULONG_PTR pulPartLen |
michael@0 | 2211 | ) |
michael@0 | 2212 | { |
michael@0 | 2213 | COMMON_DEFINITIONS; |
michael@0 | 2214 | |
michael@0 | 2215 | PR_LOG(modlog, 1, ("C_DecryptDigestUpdate")); |
michael@0 | 2216 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 2217 | PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart)); |
michael@0 | 2218 | PR_LOG(modlog, 3, (fmt_ulEncryptedPartLen, ulEncryptedPartLen)); |
michael@0 | 2219 | PR_LOG(modlog, 3, (fmt_pPart, pPart)); |
michael@0 | 2220 | PR_LOG(modlog, 3, (fmt_pulPartLen, pulPartLen)); |
michael@0 | 2221 | nssdbg_start_time(FUNC_C_DECRYPTDIGESTUPDATE,&start); |
michael@0 | 2222 | rv = module_functions->C_DecryptDigestUpdate(hSession, |
michael@0 | 2223 | pEncryptedPart, |
michael@0 | 2224 | ulEncryptedPartLen, |
michael@0 | 2225 | pPart, |
michael@0 | 2226 | pulPartLen); |
michael@0 | 2227 | nssdbg_finish_time(FUNC_C_DECRYPTDIGESTUPDATE,start); |
michael@0 | 2228 | PR_LOG(modlog, 4, (fmt_spulPartLen, *pulPartLen)); |
michael@0 | 2229 | log_rv(rv); |
michael@0 | 2230 | return rv; |
michael@0 | 2231 | } |
michael@0 | 2232 | |
michael@0 | 2233 | CK_RV NSSDBGC_SignEncryptUpdate( |
michael@0 | 2234 | CK_SESSION_HANDLE hSession, |
michael@0 | 2235 | CK_BYTE_PTR pPart, |
michael@0 | 2236 | CK_ULONG ulPartLen, |
michael@0 | 2237 | CK_BYTE_PTR pEncryptedPart, |
michael@0 | 2238 | CK_ULONG_PTR pulEncryptedPartLen |
michael@0 | 2239 | ) |
michael@0 | 2240 | { |
michael@0 | 2241 | COMMON_DEFINITIONS; |
michael@0 | 2242 | |
michael@0 | 2243 | PR_LOG(modlog, 1, ("C_SignEncryptUpdate")); |
michael@0 | 2244 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 2245 | PR_LOG(modlog, 3, (fmt_pPart, pPart)); |
michael@0 | 2246 | PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen)); |
michael@0 | 2247 | PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart)); |
michael@0 | 2248 | PR_LOG(modlog, 3, (fmt_pulEncryptedPartLen, pulEncryptedPartLen)); |
michael@0 | 2249 | nssdbg_start_time(FUNC_C_SIGNENCRYPTUPDATE,&start); |
michael@0 | 2250 | rv = module_functions->C_SignEncryptUpdate(hSession, |
michael@0 | 2251 | pPart, |
michael@0 | 2252 | ulPartLen, |
michael@0 | 2253 | pEncryptedPart, |
michael@0 | 2254 | pulEncryptedPartLen); |
michael@0 | 2255 | nssdbg_finish_time(FUNC_C_SIGNENCRYPTUPDATE,start); |
michael@0 | 2256 | PR_LOG(modlog, 4, (fmt_spulEncryptedPartLen, *pulEncryptedPartLen)); |
michael@0 | 2257 | log_rv(rv); |
michael@0 | 2258 | return rv; |
michael@0 | 2259 | } |
michael@0 | 2260 | |
michael@0 | 2261 | CK_RV NSSDBGC_DecryptVerifyUpdate( |
michael@0 | 2262 | CK_SESSION_HANDLE hSession, |
michael@0 | 2263 | CK_BYTE_PTR pEncryptedPart, |
michael@0 | 2264 | CK_ULONG ulEncryptedPartLen, |
michael@0 | 2265 | CK_BYTE_PTR pPart, |
michael@0 | 2266 | CK_ULONG_PTR pulPartLen |
michael@0 | 2267 | ) |
michael@0 | 2268 | { |
michael@0 | 2269 | COMMON_DEFINITIONS; |
michael@0 | 2270 | |
michael@0 | 2271 | PR_LOG(modlog, 1, ("C_DecryptVerifyUpdate")); |
michael@0 | 2272 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 2273 | PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart)); |
michael@0 | 2274 | PR_LOG(modlog, 3, (fmt_ulEncryptedPartLen, ulEncryptedPartLen)); |
michael@0 | 2275 | PR_LOG(modlog, 3, (fmt_pPart, pPart)); |
michael@0 | 2276 | PR_LOG(modlog, 3, (fmt_pulPartLen, pulPartLen)); |
michael@0 | 2277 | nssdbg_start_time(FUNC_C_DECRYPTVERIFYUPDATE,&start); |
michael@0 | 2278 | rv = module_functions->C_DecryptVerifyUpdate(hSession, |
michael@0 | 2279 | pEncryptedPart, |
michael@0 | 2280 | ulEncryptedPartLen, |
michael@0 | 2281 | pPart, |
michael@0 | 2282 | pulPartLen); |
michael@0 | 2283 | nssdbg_finish_time(FUNC_C_DECRYPTVERIFYUPDATE,start); |
michael@0 | 2284 | PR_LOG(modlog, 4, (fmt_spulPartLen, *pulPartLen)); |
michael@0 | 2285 | log_rv(rv); |
michael@0 | 2286 | return rv; |
michael@0 | 2287 | } |
michael@0 | 2288 | |
michael@0 | 2289 | CK_RV NSSDBGC_GenerateKey( |
michael@0 | 2290 | CK_SESSION_HANDLE hSession, |
michael@0 | 2291 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 2292 | CK_ATTRIBUTE_PTR pTemplate, |
michael@0 | 2293 | CK_ULONG ulCount, |
michael@0 | 2294 | CK_OBJECT_HANDLE_PTR phKey |
michael@0 | 2295 | ) |
michael@0 | 2296 | { |
michael@0 | 2297 | COMMON_DEFINITIONS; |
michael@0 | 2298 | |
michael@0 | 2299 | PR_LOG(modlog, 1, ("C_GenerateKey")); |
michael@0 | 2300 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 2301 | PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); |
michael@0 | 2302 | PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); |
michael@0 | 2303 | PR_LOG(modlog, 3, (fmt_ulCount, ulCount)); |
michael@0 | 2304 | PR_LOG(modlog, 3, (fmt_phKey, phKey)); |
michael@0 | 2305 | print_template(pTemplate, ulCount); |
michael@0 | 2306 | print_mechanism(pMechanism); |
michael@0 | 2307 | nssdbg_start_time(FUNC_C_GENERATEKEY,&start); |
michael@0 | 2308 | rv = module_functions->C_GenerateKey(hSession, |
michael@0 | 2309 | pMechanism, |
michael@0 | 2310 | pTemplate, |
michael@0 | 2311 | ulCount, |
michael@0 | 2312 | phKey); |
michael@0 | 2313 | nssdbg_finish_time(FUNC_C_GENERATEKEY,start); |
michael@0 | 2314 | log_handle(4, fmt_sphKey, *phKey); |
michael@0 | 2315 | log_rv(rv); |
michael@0 | 2316 | return rv; |
michael@0 | 2317 | } |
michael@0 | 2318 | |
michael@0 | 2319 | CK_RV NSSDBGC_GenerateKeyPair( |
michael@0 | 2320 | CK_SESSION_HANDLE hSession, |
michael@0 | 2321 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 2322 | CK_ATTRIBUTE_PTR pPublicKeyTemplate, |
michael@0 | 2323 | CK_ULONG ulPublicKeyAttributeCount, |
michael@0 | 2324 | CK_ATTRIBUTE_PTR pPrivateKeyTemplate, |
michael@0 | 2325 | CK_ULONG ulPrivateKeyAttributeCount, |
michael@0 | 2326 | CK_OBJECT_HANDLE_PTR phPublicKey, |
michael@0 | 2327 | CK_OBJECT_HANDLE_PTR phPrivateKey |
michael@0 | 2328 | ) |
michael@0 | 2329 | { |
michael@0 | 2330 | COMMON_DEFINITIONS; |
michael@0 | 2331 | |
michael@0 | 2332 | PR_LOG(modlog, 1, ("C_GenerateKeyPair")); |
michael@0 | 2333 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 2334 | PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); |
michael@0 | 2335 | PR_LOG(modlog, 3, (" pPublicKeyTemplate = 0x%p", pPublicKeyTemplate)); |
michael@0 | 2336 | PR_LOG(modlog, 3, (" ulPublicKeyAttributeCount = %d", ulPublicKeyAttributeCount)); |
michael@0 | 2337 | PR_LOG(modlog, 3, (" pPrivateKeyTemplate = 0x%p", pPrivateKeyTemplate)); |
michael@0 | 2338 | PR_LOG(modlog, 3, (" ulPrivateKeyAttributeCount = %d", ulPrivateKeyAttributeCount)); |
michael@0 | 2339 | PR_LOG(modlog, 3, (" phPublicKey = 0x%p", phPublicKey)); |
michael@0 | 2340 | print_template(pPublicKeyTemplate, ulPublicKeyAttributeCount); |
michael@0 | 2341 | PR_LOG(modlog, 3, (" phPrivateKey = 0x%p", phPrivateKey)); |
michael@0 | 2342 | print_template(pPrivateKeyTemplate, ulPrivateKeyAttributeCount); |
michael@0 | 2343 | print_mechanism(pMechanism); |
michael@0 | 2344 | nssdbg_start_time(FUNC_C_GENERATEKEYPAIR,&start); |
michael@0 | 2345 | rv = module_functions->C_GenerateKeyPair(hSession, |
michael@0 | 2346 | pMechanism, |
michael@0 | 2347 | pPublicKeyTemplate, |
michael@0 | 2348 | ulPublicKeyAttributeCount, |
michael@0 | 2349 | pPrivateKeyTemplate, |
michael@0 | 2350 | ulPrivateKeyAttributeCount, |
michael@0 | 2351 | phPublicKey, |
michael@0 | 2352 | phPrivateKey); |
michael@0 | 2353 | nssdbg_finish_time(FUNC_C_GENERATEKEYPAIR,start); |
michael@0 | 2354 | log_handle(4, " *phPublicKey = 0x%x", *phPublicKey); |
michael@0 | 2355 | log_handle(4, " *phPrivateKey = 0x%x", *phPrivateKey); |
michael@0 | 2356 | log_rv(rv); |
michael@0 | 2357 | return rv; |
michael@0 | 2358 | } |
michael@0 | 2359 | |
michael@0 | 2360 | CK_RV NSSDBGC_WrapKey( |
michael@0 | 2361 | CK_SESSION_HANDLE hSession, |
michael@0 | 2362 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 2363 | CK_OBJECT_HANDLE hWrappingKey, |
michael@0 | 2364 | CK_OBJECT_HANDLE hKey, |
michael@0 | 2365 | CK_BYTE_PTR pWrappedKey, |
michael@0 | 2366 | CK_ULONG_PTR pulWrappedKeyLen |
michael@0 | 2367 | ) |
michael@0 | 2368 | { |
michael@0 | 2369 | COMMON_DEFINITIONS; |
michael@0 | 2370 | |
michael@0 | 2371 | PR_LOG(modlog, 1, ("C_WrapKey")); |
michael@0 | 2372 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 2373 | PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); |
michael@0 | 2374 | log_handle(3, " hWrappingKey = 0x%x", hWrappingKey); |
michael@0 | 2375 | log_handle(3, fmt_hKey, hKey); |
michael@0 | 2376 | PR_LOG(modlog, 3, (fmt_pWrappedKey, pWrappedKey)); |
michael@0 | 2377 | PR_LOG(modlog, 3, (" pulWrappedKeyLen = 0x%p", pulWrappedKeyLen)); |
michael@0 | 2378 | print_mechanism(pMechanism); |
michael@0 | 2379 | nssdbg_start_time(FUNC_C_WRAPKEY,&start); |
michael@0 | 2380 | rv = module_functions->C_WrapKey(hSession, |
michael@0 | 2381 | pMechanism, |
michael@0 | 2382 | hWrappingKey, |
michael@0 | 2383 | hKey, |
michael@0 | 2384 | pWrappedKey, |
michael@0 | 2385 | pulWrappedKeyLen); |
michael@0 | 2386 | nssdbg_finish_time(FUNC_C_WRAPKEY,start); |
michael@0 | 2387 | PR_LOG(modlog, 4, (" *pulWrappedKeyLen = 0x%x", *pulWrappedKeyLen)); |
michael@0 | 2388 | log_rv(rv); |
michael@0 | 2389 | return rv; |
michael@0 | 2390 | } |
michael@0 | 2391 | |
michael@0 | 2392 | CK_RV NSSDBGC_UnwrapKey( |
michael@0 | 2393 | CK_SESSION_HANDLE hSession, |
michael@0 | 2394 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 2395 | CK_OBJECT_HANDLE hUnwrappingKey, |
michael@0 | 2396 | CK_BYTE_PTR pWrappedKey, |
michael@0 | 2397 | CK_ULONG ulWrappedKeyLen, |
michael@0 | 2398 | CK_ATTRIBUTE_PTR pTemplate, |
michael@0 | 2399 | CK_ULONG ulAttributeCount, |
michael@0 | 2400 | CK_OBJECT_HANDLE_PTR phKey |
michael@0 | 2401 | ) |
michael@0 | 2402 | { |
michael@0 | 2403 | COMMON_DEFINITIONS; |
michael@0 | 2404 | |
michael@0 | 2405 | PR_LOG(modlog, 1, ("C_UnwrapKey")); |
michael@0 | 2406 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 2407 | PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); |
michael@0 | 2408 | log_handle(3, " hUnwrappingKey = 0x%x", hUnwrappingKey); |
michael@0 | 2409 | PR_LOG(modlog, 3, (fmt_pWrappedKey, pWrappedKey)); |
michael@0 | 2410 | PR_LOG(modlog, 3, (" ulWrappedKeyLen = %d", ulWrappedKeyLen)); |
michael@0 | 2411 | PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); |
michael@0 | 2412 | PR_LOG(modlog, 3, (fmt_ulAttributeCount, ulAttributeCount)); |
michael@0 | 2413 | PR_LOG(modlog, 3, (fmt_phKey, phKey)); |
michael@0 | 2414 | print_template(pTemplate, ulAttributeCount); |
michael@0 | 2415 | print_mechanism(pMechanism); |
michael@0 | 2416 | nssdbg_start_time(FUNC_C_UNWRAPKEY,&start); |
michael@0 | 2417 | rv = module_functions->C_UnwrapKey(hSession, |
michael@0 | 2418 | pMechanism, |
michael@0 | 2419 | hUnwrappingKey, |
michael@0 | 2420 | pWrappedKey, |
michael@0 | 2421 | ulWrappedKeyLen, |
michael@0 | 2422 | pTemplate, |
michael@0 | 2423 | ulAttributeCount, |
michael@0 | 2424 | phKey); |
michael@0 | 2425 | nssdbg_finish_time(FUNC_C_UNWRAPKEY,start); |
michael@0 | 2426 | log_handle(4, fmt_sphKey, *phKey); |
michael@0 | 2427 | log_rv(rv); |
michael@0 | 2428 | return rv; |
michael@0 | 2429 | } |
michael@0 | 2430 | |
michael@0 | 2431 | CK_RV NSSDBGC_DeriveKey( |
michael@0 | 2432 | CK_SESSION_HANDLE hSession, |
michael@0 | 2433 | CK_MECHANISM_PTR pMechanism, |
michael@0 | 2434 | CK_OBJECT_HANDLE hBaseKey, |
michael@0 | 2435 | CK_ATTRIBUTE_PTR pTemplate, |
michael@0 | 2436 | CK_ULONG ulAttributeCount, |
michael@0 | 2437 | CK_OBJECT_HANDLE_PTR phKey |
michael@0 | 2438 | ) |
michael@0 | 2439 | { |
michael@0 | 2440 | COMMON_DEFINITIONS; |
michael@0 | 2441 | |
michael@0 | 2442 | PR_LOG(modlog, 1, ("C_DeriveKey")); |
michael@0 | 2443 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 2444 | PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); |
michael@0 | 2445 | log_handle(3, " hBaseKey = 0x%x", hBaseKey); |
michael@0 | 2446 | PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); |
michael@0 | 2447 | PR_LOG(modlog, 3, (fmt_ulAttributeCount, ulAttributeCount)); |
michael@0 | 2448 | PR_LOG(modlog, 3, (fmt_phKey, phKey)); |
michael@0 | 2449 | print_template(pTemplate, ulAttributeCount); |
michael@0 | 2450 | print_mechanism(pMechanism); |
michael@0 | 2451 | nssdbg_start_time(FUNC_C_DERIVEKEY,&start); |
michael@0 | 2452 | rv = module_functions->C_DeriveKey(hSession, |
michael@0 | 2453 | pMechanism, |
michael@0 | 2454 | hBaseKey, |
michael@0 | 2455 | pTemplate, |
michael@0 | 2456 | ulAttributeCount, |
michael@0 | 2457 | phKey); |
michael@0 | 2458 | nssdbg_finish_time(FUNC_C_DERIVEKEY,start); |
michael@0 | 2459 | log_handle(4, fmt_sphKey, *phKey); |
michael@0 | 2460 | log_rv(rv); |
michael@0 | 2461 | return rv; |
michael@0 | 2462 | } |
michael@0 | 2463 | |
michael@0 | 2464 | CK_RV NSSDBGC_SeedRandom( |
michael@0 | 2465 | CK_SESSION_HANDLE hSession, |
michael@0 | 2466 | CK_BYTE_PTR pSeed, |
michael@0 | 2467 | CK_ULONG ulSeedLen |
michael@0 | 2468 | ) |
michael@0 | 2469 | { |
michael@0 | 2470 | COMMON_DEFINITIONS; |
michael@0 | 2471 | |
michael@0 | 2472 | PR_LOG(modlog, 1, ("C_SeedRandom")); |
michael@0 | 2473 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 2474 | PR_LOG(modlog, 3, (" pSeed = 0x%p", pSeed)); |
michael@0 | 2475 | PR_LOG(modlog, 3, (" ulSeedLen = %d", ulSeedLen)); |
michael@0 | 2476 | nssdbg_start_time(FUNC_C_SEEDRANDOM,&start); |
michael@0 | 2477 | rv = module_functions->C_SeedRandom(hSession, |
michael@0 | 2478 | pSeed, |
michael@0 | 2479 | ulSeedLen); |
michael@0 | 2480 | nssdbg_finish_time(FUNC_C_SEEDRANDOM,start); |
michael@0 | 2481 | log_rv(rv); |
michael@0 | 2482 | return rv; |
michael@0 | 2483 | } |
michael@0 | 2484 | |
michael@0 | 2485 | CK_RV NSSDBGC_GenerateRandom( |
michael@0 | 2486 | CK_SESSION_HANDLE hSession, |
michael@0 | 2487 | CK_BYTE_PTR RandomData, |
michael@0 | 2488 | CK_ULONG ulRandomLen |
michael@0 | 2489 | ) |
michael@0 | 2490 | { |
michael@0 | 2491 | COMMON_DEFINITIONS; |
michael@0 | 2492 | |
michael@0 | 2493 | PR_LOG(modlog, 1, ("C_GenerateRandom")); |
michael@0 | 2494 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 2495 | PR_LOG(modlog, 3, (" RandomData = 0x%p", RandomData)); |
michael@0 | 2496 | PR_LOG(modlog, 3, (" ulRandomLen = %d", ulRandomLen)); |
michael@0 | 2497 | nssdbg_start_time(FUNC_C_GENERATERANDOM,&start); |
michael@0 | 2498 | rv = module_functions->C_GenerateRandom(hSession, |
michael@0 | 2499 | RandomData, |
michael@0 | 2500 | ulRandomLen); |
michael@0 | 2501 | nssdbg_finish_time(FUNC_C_GENERATERANDOM,start); |
michael@0 | 2502 | log_rv(rv); |
michael@0 | 2503 | return rv; |
michael@0 | 2504 | } |
michael@0 | 2505 | |
michael@0 | 2506 | CK_RV NSSDBGC_GetFunctionStatus( |
michael@0 | 2507 | CK_SESSION_HANDLE hSession |
michael@0 | 2508 | ) |
michael@0 | 2509 | { |
michael@0 | 2510 | COMMON_DEFINITIONS; |
michael@0 | 2511 | |
michael@0 | 2512 | PR_LOG(modlog, 1, ("C_GetFunctionStatus")); |
michael@0 | 2513 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 2514 | nssdbg_start_time(FUNC_C_GETFUNCTIONSTATUS,&start); |
michael@0 | 2515 | rv = module_functions->C_GetFunctionStatus(hSession); |
michael@0 | 2516 | nssdbg_finish_time(FUNC_C_GETFUNCTIONSTATUS,start); |
michael@0 | 2517 | log_rv(rv); |
michael@0 | 2518 | return rv; |
michael@0 | 2519 | } |
michael@0 | 2520 | |
michael@0 | 2521 | CK_RV NSSDBGC_CancelFunction( |
michael@0 | 2522 | CK_SESSION_HANDLE hSession |
michael@0 | 2523 | ) |
michael@0 | 2524 | { |
michael@0 | 2525 | COMMON_DEFINITIONS; |
michael@0 | 2526 | |
michael@0 | 2527 | PR_LOG(modlog, 1, ("C_CancelFunction")); |
michael@0 | 2528 | log_handle(3, fmt_hSession, hSession); |
michael@0 | 2529 | nssdbg_start_time(FUNC_C_CANCELFUNCTION,&start); |
michael@0 | 2530 | rv = module_functions->C_CancelFunction(hSession); |
michael@0 | 2531 | nssdbg_finish_time(FUNC_C_CANCELFUNCTION,start); |
michael@0 | 2532 | log_rv(rv); |
michael@0 | 2533 | return rv; |
michael@0 | 2534 | } |
michael@0 | 2535 | |
michael@0 | 2536 | CK_RV NSSDBGC_WaitForSlotEvent( |
michael@0 | 2537 | CK_FLAGS flags, |
michael@0 | 2538 | CK_SLOT_ID_PTR pSlot, |
michael@0 | 2539 | CK_VOID_PTR pRserved |
michael@0 | 2540 | ) |
michael@0 | 2541 | { |
michael@0 | 2542 | COMMON_DEFINITIONS; |
michael@0 | 2543 | |
michael@0 | 2544 | PR_LOG(modlog, 1, ("C_WaitForSlotEvent")); |
michael@0 | 2545 | PR_LOG(modlog, 3, (fmt_flags, flags)); |
michael@0 | 2546 | PR_LOG(modlog, 3, (" pSlot = 0x%p", pSlot)); |
michael@0 | 2547 | PR_LOG(modlog, 3, (" pRserved = 0x%p", pRserved)); |
michael@0 | 2548 | nssdbg_start_time(FUNC_C_WAITFORSLOTEVENT,&start); |
michael@0 | 2549 | rv = module_functions->C_WaitForSlotEvent(flags, |
michael@0 | 2550 | pSlot, |
michael@0 | 2551 | pRserved); |
michael@0 | 2552 | nssdbg_finish_time(FUNC_C_WAITFORSLOTEVENT,start); |
michael@0 | 2553 | log_rv(rv); |
michael@0 | 2554 | return rv; |
michael@0 | 2555 | } |
michael@0 | 2556 | |
michael@0 | 2557 | CK_FUNCTION_LIST_PTR nss_InsertDeviceLog( |
michael@0 | 2558 | CK_FUNCTION_LIST_PTR devEPV |
michael@0 | 2559 | ) |
michael@0 | 2560 | { |
michael@0 | 2561 | module_functions = devEPV; |
michael@0 | 2562 | modlog = PR_NewLogModule("nss_mod_log"); |
michael@0 | 2563 | debug_functions.C_Initialize = NSSDBGC_Initialize; |
michael@0 | 2564 | debug_functions.C_Finalize = NSSDBGC_Finalize; |
michael@0 | 2565 | debug_functions.C_GetInfo = NSSDBGC_GetInfo; |
michael@0 | 2566 | debug_functions.C_GetFunctionList = NSSDBGC_GetFunctionList; |
michael@0 | 2567 | debug_functions.C_GetSlotList = NSSDBGC_GetSlotList; |
michael@0 | 2568 | debug_functions.C_GetSlotInfo = NSSDBGC_GetSlotInfo; |
michael@0 | 2569 | debug_functions.C_GetTokenInfo = NSSDBGC_GetTokenInfo; |
michael@0 | 2570 | debug_functions.C_GetMechanismList = NSSDBGC_GetMechanismList; |
michael@0 | 2571 | debug_functions.C_GetMechanismInfo = NSSDBGC_GetMechanismInfo; |
michael@0 | 2572 | debug_functions.C_InitToken = NSSDBGC_InitToken; |
michael@0 | 2573 | debug_functions.C_InitPIN = NSSDBGC_InitPIN; |
michael@0 | 2574 | debug_functions.C_SetPIN = NSSDBGC_SetPIN; |
michael@0 | 2575 | debug_functions.C_OpenSession = NSSDBGC_OpenSession; |
michael@0 | 2576 | debug_functions.C_CloseSession = NSSDBGC_CloseSession; |
michael@0 | 2577 | debug_functions.C_CloseAllSessions = NSSDBGC_CloseAllSessions; |
michael@0 | 2578 | debug_functions.C_GetSessionInfo = NSSDBGC_GetSessionInfo; |
michael@0 | 2579 | debug_functions.C_GetOperationState = NSSDBGC_GetOperationState; |
michael@0 | 2580 | debug_functions.C_SetOperationState = NSSDBGC_SetOperationState; |
michael@0 | 2581 | debug_functions.C_Login = NSSDBGC_Login; |
michael@0 | 2582 | debug_functions.C_Logout = NSSDBGC_Logout; |
michael@0 | 2583 | debug_functions.C_CreateObject = NSSDBGC_CreateObject; |
michael@0 | 2584 | debug_functions.C_CopyObject = NSSDBGC_CopyObject; |
michael@0 | 2585 | debug_functions.C_DestroyObject = NSSDBGC_DestroyObject; |
michael@0 | 2586 | debug_functions.C_GetObjectSize = NSSDBGC_GetObjectSize; |
michael@0 | 2587 | debug_functions.C_GetAttributeValue = NSSDBGC_GetAttributeValue; |
michael@0 | 2588 | debug_functions.C_SetAttributeValue = NSSDBGC_SetAttributeValue; |
michael@0 | 2589 | debug_functions.C_FindObjectsInit = NSSDBGC_FindObjectsInit; |
michael@0 | 2590 | debug_functions.C_FindObjects = NSSDBGC_FindObjects; |
michael@0 | 2591 | debug_functions.C_FindObjectsFinal = NSSDBGC_FindObjectsFinal; |
michael@0 | 2592 | debug_functions.C_EncryptInit = NSSDBGC_EncryptInit; |
michael@0 | 2593 | debug_functions.C_Encrypt = NSSDBGC_Encrypt; |
michael@0 | 2594 | debug_functions.C_EncryptUpdate = NSSDBGC_EncryptUpdate; |
michael@0 | 2595 | debug_functions.C_EncryptFinal = NSSDBGC_EncryptFinal; |
michael@0 | 2596 | debug_functions.C_DecryptInit = NSSDBGC_DecryptInit; |
michael@0 | 2597 | debug_functions.C_Decrypt = NSSDBGC_Decrypt; |
michael@0 | 2598 | debug_functions.C_DecryptUpdate = NSSDBGC_DecryptUpdate; |
michael@0 | 2599 | debug_functions.C_DecryptFinal = NSSDBGC_DecryptFinal; |
michael@0 | 2600 | debug_functions.C_DigestInit = NSSDBGC_DigestInit; |
michael@0 | 2601 | debug_functions.C_Digest = NSSDBGC_Digest; |
michael@0 | 2602 | debug_functions.C_DigestUpdate = NSSDBGC_DigestUpdate; |
michael@0 | 2603 | debug_functions.C_DigestKey = NSSDBGC_DigestKey; |
michael@0 | 2604 | debug_functions.C_DigestFinal = NSSDBGC_DigestFinal; |
michael@0 | 2605 | debug_functions.C_SignInit = NSSDBGC_SignInit; |
michael@0 | 2606 | debug_functions.C_Sign = NSSDBGC_Sign; |
michael@0 | 2607 | debug_functions.C_SignUpdate = NSSDBGC_SignUpdate; |
michael@0 | 2608 | debug_functions.C_SignFinal = NSSDBGC_SignFinal; |
michael@0 | 2609 | debug_functions.C_SignRecoverInit = NSSDBGC_SignRecoverInit; |
michael@0 | 2610 | debug_functions.C_SignRecover = NSSDBGC_SignRecover; |
michael@0 | 2611 | debug_functions.C_VerifyInit = NSSDBGC_VerifyInit; |
michael@0 | 2612 | debug_functions.C_Verify = NSSDBGC_Verify; |
michael@0 | 2613 | debug_functions.C_VerifyUpdate = NSSDBGC_VerifyUpdate; |
michael@0 | 2614 | debug_functions.C_VerifyFinal = NSSDBGC_VerifyFinal; |
michael@0 | 2615 | debug_functions.C_VerifyRecoverInit = NSSDBGC_VerifyRecoverInit; |
michael@0 | 2616 | debug_functions.C_VerifyRecover = NSSDBGC_VerifyRecover; |
michael@0 | 2617 | debug_functions.C_DigestEncryptUpdate = NSSDBGC_DigestEncryptUpdate; |
michael@0 | 2618 | debug_functions.C_DecryptDigestUpdate = NSSDBGC_DecryptDigestUpdate; |
michael@0 | 2619 | debug_functions.C_SignEncryptUpdate = NSSDBGC_SignEncryptUpdate; |
michael@0 | 2620 | debug_functions.C_DecryptVerifyUpdate = NSSDBGC_DecryptVerifyUpdate; |
michael@0 | 2621 | debug_functions.C_GenerateKey = NSSDBGC_GenerateKey; |
michael@0 | 2622 | debug_functions.C_GenerateKeyPair = NSSDBGC_GenerateKeyPair; |
michael@0 | 2623 | debug_functions.C_WrapKey = NSSDBGC_WrapKey; |
michael@0 | 2624 | debug_functions.C_UnwrapKey = NSSDBGC_UnwrapKey; |
michael@0 | 2625 | debug_functions.C_DeriveKey = NSSDBGC_DeriveKey; |
michael@0 | 2626 | debug_functions.C_SeedRandom = NSSDBGC_SeedRandom; |
michael@0 | 2627 | debug_functions.C_GenerateRandom = NSSDBGC_GenerateRandom; |
michael@0 | 2628 | debug_functions.C_GetFunctionStatus = NSSDBGC_GetFunctionStatus; |
michael@0 | 2629 | debug_functions.C_CancelFunction = NSSDBGC_CancelFunction; |
michael@0 | 2630 | debug_functions.C_WaitForSlotEvent = NSSDBGC_WaitForSlotEvent; |
michael@0 | 2631 | return &debug_functions; |
michael@0 | 2632 | } |
michael@0 | 2633 | |
michael@0 | 2634 | /* |
michael@0 | 2635 | * scale the time factor up accordingly. |
michael@0 | 2636 | * This routine tries to keep at least 2 significant figures on output. |
michael@0 | 2637 | * If the time is 0, then indicate that with a 'z' for units. |
michael@0 | 2638 | * If the time is greater than 10 minutes, output the time in minutes. |
michael@0 | 2639 | * If the time is less than 10 minutes but greater than 10 seconds output |
michael@0 | 2640 | * the time in second. |
michael@0 | 2641 | * If the time is less than 10 seconds but greater than 10 milliseconds |
michael@0 | 2642 | * output * the time in millisecond. |
michael@0 | 2643 | * If the time is less than 10 milliseconds but greater than 0 ticks output |
michael@0 | 2644 | * the time in microsecond. |
michael@0 | 2645 | * |
michael@0 | 2646 | */ |
michael@0 | 2647 | static PRUint32 getPrintTime(PRIntervalTime time ,char **type) |
michael@0 | 2648 | { |
michael@0 | 2649 | PRUint32 prTime; |
michael@0 | 2650 | |
michael@0 | 2651 | /* detect a programming error by outputting 'bu' to the output stream |
michael@0 | 2652 | * rather than crashing */ |
michael@0 | 2653 | *type = "bug"; |
michael@0 | 2654 | if (time == 0) { |
michael@0 | 2655 | *type = "z"; |
michael@0 | 2656 | return 0; |
michael@0 | 2657 | } |
michael@0 | 2658 | |
michael@0 | 2659 | prTime = PR_IntervalToSeconds(time); |
michael@0 | 2660 | |
michael@0 | 2661 | if (prTime >= 600) { |
michael@0 | 2662 | *type="m"; |
michael@0 | 2663 | return prTime/60; |
michael@0 | 2664 | } |
michael@0 | 2665 | if (prTime >= 10) { |
michael@0 | 2666 | *type="s"; |
michael@0 | 2667 | return prTime; |
michael@0 | 2668 | } |
michael@0 | 2669 | prTime = PR_IntervalToMilliseconds(time); |
michael@0 | 2670 | if (prTime >= 10) { |
michael@0 | 2671 | *type="ms"; |
michael@0 | 2672 | return prTime; |
michael@0 | 2673 | } |
michael@0 | 2674 | *type = "us"; |
michael@0 | 2675 | return PR_IntervalToMicroseconds(time); |
michael@0 | 2676 | } |
michael@0 | 2677 | |
michael@0 | 2678 | static void print_final_statistics(void) |
michael@0 | 2679 | { |
michael@0 | 2680 | int total_calls = 0; |
michael@0 | 2681 | PRIntervalTime total_time = 0; |
michael@0 | 2682 | PRUint32 pr_total_time; |
michael@0 | 2683 | char *type; |
michael@0 | 2684 | char *fname; |
michael@0 | 2685 | FILE *outfile = NULL; |
michael@0 | 2686 | int i; |
michael@0 | 2687 | |
michael@0 | 2688 | fname = PR_GetEnv("NSS_OUTPUT_FILE"); |
michael@0 | 2689 | if (fname) { |
michael@0 | 2690 | /* need to add an optional process id to the filename */ |
michael@0 | 2691 | outfile = fopen(fname,"w+"); |
michael@0 | 2692 | } |
michael@0 | 2693 | if (!outfile) { |
michael@0 | 2694 | outfile = stdout; |
michael@0 | 2695 | } |
michael@0 | 2696 | |
michael@0 | 2697 | |
michael@0 | 2698 | fprintf(outfile,"%-25s %10s %12s %12s %10s\n", "Function", "# Calls", |
michael@0 | 2699 | "Time", "Avg.", "% Time"); |
michael@0 | 2700 | fprintf(outfile,"\n"); |
michael@0 | 2701 | for (i=0; i < nssdbg_prof_size; i++) { |
michael@0 | 2702 | total_calls += nssdbg_prof_data[i].calls; |
michael@0 | 2703 | total_time += nssdbg_prof_data[i].time; |
michael@0 | 2704 | } |
michael@0 | 2705 | for (i=0; i < nssdbg_prof_size; i++) { |
michael@0 | 2706 | PRIntervalTime time = nssdbg_prof_data[i].time; |
michael@0 | 2707 | PRUint32 usTime = PR_IntervalToMicroseconds(time); |
michael@0 | 2708 | PRUint32 prTime = 0; |
michael@0 | 2709 | PRUint32 calls = nssdbg_prof_data[i].calls; |
michael@0 | 2710 | /* don't print out functions that weren't even called */ |
michael@0 | 2711 | if (calls == 0) { |
michael@0 | 2712 | continue; |
michael@0 | 2713 | } |
michael@0 | 2714 | |
michael@0 | 2715 | prTime = getPrintTime(time,&type); |
michael@0 | 2716 | |
michael@0 | 2717 | fprintf(outfile,"%-25s %10d %10d%2s ", nssdbg_prof_data[i].function, |
michael@0 | 2718 | calls, prTime, type); |
michael@0 | 2719 | /* for now always output the average in microseconds */ |
michael@0 | 2720 | fprintf(outfile,"%10.2f%2s", (float)usTime / (float)calls, "us" ); |
michael@0 | 2721 | fprintf(outfile,"%10.2f%%", ((float)time / (float)total_time) * 100); |
michael@0 | 2722 | fprintf(outfile,"\n"); |
michael@0 | 2723 | } |
michael@0 | 2724 | fprintf(outfile,"\n"); |
michael@0 | 2725 | |
michael@0 | 2726 | pr_total_time = getPrintTime(total_time,&type); |
michael@0 | 2727 | |
michael@0 | 2728 | fprintf(outfile,"%25s %10d %10d%2s\n", "Totals", total_calls, |
michael@0 | 2729 | pr_total_time, type); |
michael@0 | 2730 | fprintf(outfile,"\n\nMaximum number of concurrent open sessions: %d\n\n", |
michael@0 | 2731 | maxOpenSessions); |
michael@0 | 2732 | fflush (outfile); |
michael@0 | 2733 | if (outfile != stdout) { |
michael@0 | 2734 | fclose(outfile); |
michael@0 | 2735 | } |
michael@0 | 2736 | } |
michael@0 | 2737 |