1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/nss/lib/pk11wrap/debug_module.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,2737 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 +#include "prlog.h" 1.8 +#include <stdio.h> 1.9 +#include "cert.h" /* for CERT_DerNameToAscii & CERT_Hexify */ 1.10 + 1.11 +static PRLogModuleInfo *modlog = NULL; 1.12 + 1.13 +static CK_FUNCTION_LIST_PTR module_functions; 1.14 + 1.15 +static CK_FUNCTION_LIST debug_functions; 1.16 + 1.17 +static void print_final_statistics(void); 1.18 + 1.19 +#define STRING static const char 1.20 + 1.21 +STRING fmt_flags[] = " flags = 0x%x"; 1.22 +STRING fmt_hKey[] = " hKey = 0x%x"; 1.23 +STRING fmt_hObject[] = " hObject = 0x%x"; 1.24 +STRING fmt_hSession[] = " hSession = 0x%x"; 1.25 +STRING fmt_manufacturerID[] = " manufacturerID = \"%.32s\""; 1.26 +STRING fmt_pData[] = " pData = 0x%p"; 1.27 +STRING fmt_pDigest[] = " pDigest = 0x%p"; 1.28 +STRING fmt_pEncryptedData[] = " pEncryptedData = 0x%p"; 1.29 +STRING fmt_pEncryptedPart[] = " pEncryptedPart = 0x%p"; 1.30 +STRING fmt_pInfo[] = " pInfo = 0x%p"; 1.31 +STRING fmt_pMechanism[] = " pMechanism = 0x%p"; 1.32 +STRING fmt_pOperationState[] = " pOperationState = 0x%p"; 1.33 +STRING fmt_pPart[] = " pPart = 0x%p"; 1.34 +STRING fmt_pPin[] = " pPin = 0x%p"; 1.35 +STRING fmt_pSignature[] = " pSignature = 0x%p"; 1.36 +STRING fmt_pTemplate[] = " pTemplate = 0x%p"; 1.37 +STRING fmt_pWrappedKey[] = " pWrappedKey = 0x%p"; 1.38 +STRING fmt_phKey[] = " phKey = 0x%p"; 1.39 +STRING fmt_phObject[] = " phObject = 0x%p"; 1.40 +STRING fmt_pulCount[] = " pulCount = 0x%p"; 1.41 +STRING fmt_pulDataLen[] = " pulDataLen = 0x%p"; 1.42 +STRING fmt_pulDigestLen[] = " pulDigestLen = 0x%p"; 1.43 +STRING fmt_pulEncryptedPartLen[] = " pulEncryptedPartLen = 0x%p"; 1.44 +STRING fmt_pulPartLen[] = " pulPartLen = 0x%p"; 1.45 +STRING fmt_pulSignatureLen[] = " pulSignatureLen = 0x%p"; 1.46 +STRING fmt_slotID[] = " slotID = 0x%x"; 1.47 +STRING fmt_sphKey[] = " *phKey = 0x%x"; 1.48 +STRING fmt_spulCount[] = " *pulCount = 0x%x"; 1.49 +STRING fmt_spulDataLen[] = " *pulDataLen = 0x%x"; 1.50 +STRING fmt_spulDigestLen[] = " *pulDigestLen = 0x%x"; 1.51 +STRING fmt_spulEncryptedPartLen[] = " *pulEncryptedPartLen = 0x%x"; 1.52 +STRING fmt_spulPartLen[] = " *pulPartLen = 0x%x"; 1.53 +STRING fmt_spulSignatureLen[] = " *pulSignatureLen = 0x%x"; 1.54 +STRING fmt_ulAttributeCount[] = " ulAttributeCount = %d"; 1.55 +STRING fmt_ulCount[] = " ulCount = %d"; 1.56 +STRING fmt_ulDataLen[] = " ulDataLen = %d"; 1.57 +STRING fmt_ulEncryptedPartLen[] = " ulEncryptedPartLen = %d"; 1.58 +STRING fmt_ulPartLen[] = " ulPartLen = %d"; 1.59 +STRING fmt_ulPinLen[] = " ulPinLen = %d"; 1.60 +STRING fmt_ulSignatureLen[] = " ulSignatureLen = %d"; 1.61 + 1.62 +STRING fmt_fwVersion[] = " firmware version: %d.%d"; 1.63 +STRING fmt_hwVersion[] = " hardware version: %d.%d"; 1.64 +STRING fmt_s_qsq_d[] = " %s = \"%s\" [%d]"; 1.65 +STRING fmt_s_s_d[] = " %s = %s [%d]"; 1.66 +STRING fmt_s_lu[] = " %s = %lu"; 1.67 +STRING fmt_invalid_handle[] = " (CK_INVALID_HANDLE)"; 1.68 + 1.69 + 1.70 +static void get_attr_type_str(CK_ATTRIBUTE_TYPE atype, char *str, int len) 1.71 +{ 1.72 +#define CASE(attr) case attr: a = #attr ; break 1.73 + 1.74 + const char * a = NULL; 1.75 + 1.76 + switch (atype) { 1.77 + CASE(CKA_CLASS); 1.78 + CASE(CKA_TOKEN); 1.79 + CASE(CKA_PRIVATE); 1.80 + CASE(CKA_LABEL); 1.81 + CASE(CKA_APPLICATION); 1.82 + CASE(CKA_VALUE); 1.83 + CASE(CKA_OBJECT_ID); 1.84 + CASE(CKA_CERTIFICATE_TYPE); 1.85 + CASE(CKA_CERTIFICATE_CATEGORY); 1.86 + CASE(CKA_ISSUER); 1.87 + CASE(CKA_SERIAL_NUMBER); 1.88 + CASE(CKA_AC_ISSUER); 1.89 + CASE(CKA_OWNER); 1.90 + CASE(CKA_ATTR_TYPES); 1.91 + CASE(CKA_TRUSTED); 1.92 + CASE(CKA_KEY_TYPE); 1.93 + CASE(CKA_SUBJECT); 1.94 + CASE(CKA_ID); 1.95 + CASE(CKA_SENSITIVE); 1.96 + CASE(CKA_ENCRYPT); 1.97 + CASE(CKA_DECRYPT); 1.98 + CASE(CKA_WRAP); 1.99 + CASE(CKA_UNWRAP); 1.100 + CASE(CKA_SIGN); 1.101 + CASE(CKA_SIGN_RECOVER); 1.102 + CASE(CKA_VERIFY); 1.103 + CASE(CKA_VERIFY_RECOVER); 1.104 + CASE(CKA_DERIVE); 1.105 + CASE(CKA_START_DATE); 1.106 + CASE(CKA_END_DATE); 1.107 + CASE(CKA_MODULUS); 1.108 + CASE(CKA_MODULUS_BITS); 1.109 + CASE(CKA_PUBLIC_EXPONENT); 1.110 + CASE(CKA_PRIVATE_EXPONENT); 1.111 + CASE(CKA_PRIME_1); 1.112 + CASE(CKA_PRIME_2); 1.113 + CASE(CKA_EXPONENT_1); 1.114 + CASE(CKA_EXPONENT_2); 1.115 + CASE(CKA_COEFFICIENT); 1.116 + CASE(CKA_PRIME); 1.117 + CASE(CKA_SUBPRIME); 1.118 + CASE(CKA_BASE); 1.119 + CASE(CKA_PRIME_BITS); 1.120 + CASE(CKA_SUBPRIME_BITS); 1.121 + CASE(CKA_VALUE_BITS); 1.122 + CASE(CKA_VALUE_LEN); 1.123 + CASE(CKA_EXTRACTABLE); 1.124 + CASE(CKA_LOCAL); 1.125 + CASE(CKA_NEVER_EXTRACTABLE); 1.126 + CASE(CKA_ALWAYS_SENSITIVE); 1.127 + CASE(CKA_KEY_GEN_MECHANISM); 1.128 + CASE(CKA_MODIFIABLE); 1.129 + CASE(CKA_ECDSA_PARAMS); 1.130 + CASE(CKA_EC_POINT); 1.131 + CASE(CKA_SECONDARY_AUTH); 1.132 + CASE(CKA_AUTH_PIN_FLAGS); 1.133 + CASE(CKA_HW_FEATURE_TYPE); 1.134 + CASE(CKA_RESET_ON_INIT); 1.135 + CASE(CKA_HAS_RESET); 1.136 + CASE(CKA_VENDOR_DEFINED); 1.137 + CASE(CKA_NSS_URL); 1.138 + CASE(CKA_NSS_EMAIL); 1.139 + CASE(CKA_NSS_SMIME_INFO); 1.140 + CASE(CKA_NSS_SMIME_TIMESTAMP); 1.141 + CASE(CKA_NSS_PKCS8_SALT); 1.142 + CASE(CKA_NSS_PASSWORD_CHECK); 1.143 + CASE(CKA_NSS_EXPIRES); 1.144 + CASE(CKA_NSS_KRL); 1.145 + CASE(CKA_NSS_PQG_COUNTER); 1.146 + CASE(CKA_NSS_PQG_SEED); 1.147 + CASE(CKA_NSS_PQG_H); 1.148 + CASE(CKA_NSS_PQG_SEED_BITS); 1.149 + CASE(CKA_TRUST); 1.150 + CASE(CKA_TRUST_DIGITAL_SIGNATURE); 1.151 + CASE(CKA_TRUST_NON_REPUDIATION); 1.152 + CASE(CKA_TRUST_KEY_ENCIPHERMENT); 1.153 + CASE(CKA_TRUST_DATA_ENCIPHERMENT); 1.154 + CASE(CKA_TRUST_KEY_AGREEMENT); 1.155 + CASE(CKA_TRUST_KEY_CERT_SIGN); 1.156 + CASE(CKA_TRUST_CRL_SIGN); 1.157 + CASE(CKA_TRUST_SERVER_AUTH); 1.158 + CASE(CKA_TRUST_CLIENT_AUTH); 1.159 + CASE(CKA_TRUST_CODE_SIGNING); 1.160 + CASE(CKA_TRUST_EMAIL_PROTECTION); 1.161 + CASE(CKA_TRUST_IPSEC_END_SYSTEM); 1.162 + CASE(CKA_TRUST_IPSEC_TUNNEL); 1.163 + CASE(CKA_TRUST_IPSEC_USER); 1.164 + CASE(CKA_TRUST_TIME_STAMPING); 1.165 + CASE(CKA_CERT_SHA1_HASH); 1.166 + CASE(CKA_CERT_MD5_HASH); 1.167 + CASE(CKA_NETSCAPE_DB); 1.168 + CASE(CKA_NETSCAPE_TRUST); 1.169 + default: break; 1.170 + } 1.171 + if (a) 1.172 + PR_snprintf(str, len, "%s", a); 1.173 + else 1.174 + PR_snprintf(str, len, "0x%p", atype); 1.175 +} 1.176 + 1.177 +static void get_obj_class(CK_OBJECT_CLASS objClass, char *str, int len) 1.178 +{ 1.179 + 1.180 + const char * a = NULL; 1.181 + 1.182 + switch (objClass) { 1.183 + CASE(CKO_DATA); 1.184 + CASE(CKO_CERTIFICATE); 1.185 + CASE(CKO_PUBLIC_KEY); 1.186 + CASE(CKO_PRIVATE_KEY); 1.187 + CASE(CKO_SECRET_KEY); 1.188 + CASE(CKO_HW_FEATURE); 1.189 + CASE(CKO_DOMAIN_PARAMETERS); 1.190 + CASE(CKO_NSS_CRL); 1.191 + CASE(CKO_NSS_SMIME); 1.192 + CASE(CKO_NSS_TRUST); 1.193 + CASE(CKO_NSS_BUILTIN_ROOT_LIST); 1.194 + default: break; 1.195 + } 1.196 + if (a) 1.197 + PR_snprintf(str, len, "%s", a); 1.198 + else 1.199 + PR_snprintf(str, len, "0x%p", objClass); 1.200 +} 1.201 + 1.202 +static void get_trust_val(CK_TRUST trust, char *str, int len) 1.203 +{ 1.204 + const char * a = NULL; 1.205 + 1.206 + switch (trust) { 1.207 + CASE(CKT_NSS_TRUSTED); 1.208 + CASE(CKT_NSS_TRUSTED_DELEGATOR); 1.209 + CASE(CKT_NSS_NOT_TRUSTED); 1.210 + CASE(CKT_NSS_MUST_VERIFY_TRUST); 1.211 + CASE(CKT_NSS_TRUST_UNKNOWN); 1.212 + CASE(CKT_NSS_VALID_DELEGATOR); 1.213 + default: break; 1.214 + } 1.215 + if (a) 1.216 + PR_snprintf(str, len, "%s", a); 1.217 + else 1.218 + PR_snprintf(str, len, "0x%p", trust); 1.219 +} 1.220 + 1.221 +static void log_rv(CK_RV rv) 1.222 +{ 1.223 + const char * a = NULL; 1.224 + 1.225 + switch (rv) { 1.226 + CASE(CKR_OK); 1.227 + CASE(CKR_CANCEL); 1.228 + CASE(CKR_HOST_MEMORY); 1.229 + CASE(CKR_SLOT_ID_INVALID); 1.230 + CASE(CKR_GENERAL_ERROR); 1.231 + CASE(CKR_FUNCTION_FAILED); 1.232 + CASE(CKR_ARGUMENTS_BAD); 1.233 + CASE(CKR_NO_EVENT); 1.234 + CASE(CKR_NEED_TO_CREATE_THREADS); 1.235 + CASE(CKR_CANT_LOCK); 1.236 + CASE(CKR_ATTRIBUTE_READ_ONLY); 1.237 + CASE(CKR_ATTRIBUTE_SENSITIVE); 1.238 + CASE(CKR_ATTRIBUTE_TYPE_INVALID); 1.239 + CASE(CKR_ATTRIBUTE_VALUE_INVALID); 1.240 + CASE(CKR_DATA_INVALID); 1.241 + CASE(CKR_DATA_LEN_RANGE); 1.242 + CASE(CKR_DEVICE_ERROR); 1.243 + CASE(CKR_DEVICE_MEMORY); 1.244 + CASE(CKR_DEVICE_REMOVED); 1.245 + CASE(CKR_ENCRYPTED_DATA_INVALID); 1.246 + CASE(CKR_ENCRYPTED_DATA_LEN_RANGE); 1.247 + CASE(CKR_FUNCTION_CANCELED); 1.248 + CASE(CKR_FUNCTION_NOT_PARALLEL); 1.249 + CASE(CKR_FUNCTION_NOT_SUPPORTED); 1.250 + CASE(CKR_KEY_HANDLE_INVALID); 1.251 + CASE(CKR_KEY_SIZE_RANGE); 1.252 + CASE(CKR_KEY_TYPE_INCONSISTENT); 1.253 + CASE(CKR_KEY_NOT_NEEDED); 1.254 + CASE(CKR_KEY_CHANGED); 1.255 + CASE(CKR_KEY_NEEDED); 1.256 + CASE(CKR_KEY_INDIGESTIBLE); 1.257 + CASE(CKR_KEY_FUNCTION_NOT_PERMITTED); 1.258 + CASE(CKR_KEY_NOT_WRAPPABLE); 1.259 + CASE(CKR_KEY_UNEXTRACTABLE); 1.260 + CASE(CKR_MECHANISM_INVALID); 1.261 + CASE(CKR_MECHANISM_PARAM_INVALID); 1.262 + CASE(CKR_OBJECT_HANDLE_INVALID); 1.263 + CASE(CKR_OPERATION_ACTIVE); 1.264 + CASE(CKR_OPERATION_NOT_INITIALIZED); 1.265 + CASE(CKR_PIN_INCORRECT); 1.266 + CASE(CKR_PIN_INVALID); 1.267 + CASE(CKR_PIN_LEN_RANGE); 1.268 + CASE(CKR_PIN_EXPIRED); 1.269 + CASE(CKR_PIN_LOCKED); 1.270 + CASE(CKR_SESSION_CLOSED); 1.271 + CASE(CKR_SESSION_COUNT); 1.272 + CASE(CKR_SESSION_HANDLE_INVALID); 1.273 + CASE(CKR_SESSION_PARALLEL_NOT_SUPPORTED); 1.274 + CASE(CKR_SESSION_READ_ONLY); 1.275 + CASE(CKR_SESSION_EXISTS); 1.276 + CASE(CKR_SESSION_READ_ONLY_EXISTS); 1.277 + CASE(CKR_SESSION_READ_WRITE_SO_EXISTS); 1.278 + CASE(CKR_SIGNATURE_INVALID); 1.279 + CASE(CKR_SIGNATURE_LEN_RANGE); 1.280 + CASE(CKR_TEMPLATE_INCOMPLETE); 1.281 + CASE(CKR_TEMPLATE_INCONSISTENT); 1.282 + CASE(CKR_TOKEN_NOT_PRESENT); 1.283 + CASE(CKR_TOKEN_NOT_RECOGNIZED); 1.284 + CASE(CKR_TOKEN_WRITE_PROTECTED); 1.285 + CASE(CKR_UNWRAPPING_KEY_HANDLE_INVALID); 1.286 + CASE(CKR_UNWRAPPING_KEY_SIZE_RANGE); 1.287 + CASE(CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT); 1.288 + CASE(CKR_USER_ALREADY_LOGGED_IN); 1.289 + CASE(CKR_USER_NOT_LOGGED_IN); 1.290 + CASE(CKR_USER_PIN_NOT_INITIALIZED); 1.291 + CASE(CKR_USER_TYPE_INVALID); 1.292 + CASE(CKR_USER_ANOTHER_ALREADY_LOGGED_IN); 1.293 + CASE(CKR_USER_TOO_MANY_TYPES); 1.294 + CASE(CKR_WRAPPED_KEY_INVALID); 1.295 + CASE(CKR_WRAPPED_KEY_LEN_RANGE); 1.296 + CASE(CKR_WRAPPING_KEY_HANDLE_INVALID); 1.297 + CASE(CKR_WRAPPING_KEY_SIZE_RANGE); 1.298 + CASE(CKR_WRAPPING_KEY_TYPE_INCONSISTENT); 1.299 + CASE(CKR_RANDOM_SEED_NOT_SUPPORTED); 1.300 + CASE(CKR_RANDOM_NO_RNG); 1.301 + CASE(CKR_DOMAIN_PARAMS_INVALID); 1.302 + CASE(CKR_BUFFER_TOO_SMALL); 1.303 + CASE(CKR_SAVED_STATE_INVALID); 1.304 + CASE(CKR_INFORMATION_SENSITIVE); 1.305 + CASE(CKR_STATE_UNSAVEABLE); 1.306 + CASE(CKR_CRYPTOKI_NOT_INITIALIZED); 1.307 + CASE(CKR_CRYPTOKI_ALREADY_INITIALIZED); 1.308 + CASE(CKR_MUTEX_BAD); 1.309 + CASE(CKR_MUTEX_NOT_LOCKED); 1.310 + CASE(CKR_FUNCTION_REJECTED); 1.311 + CASE(CKR_KEY_PARAMS_INVALID); 1.312 + default: break; 1.313 + } 1.314 + if (a) 1.315 + PR_LOG(modlog, 1, (" rv = %s\n", a)); 1.316 + else 1.317 + PR_LOG(modlog, 1, (" rv = 0x%x\n", rv)); 1.318 +} 1.319 + 1.320 +static void log_state(CK_STATE state) 1.321 +{ 1.322 + const char * a = NULL; 1.323 + 1.324 + switch (state) { 1.325 + CASE(CKS_RO_PUBLIC_SESSION); 1.326 + CASE(CKS_RO_USER_FUNCTIONS); 1.327 + CASE(CKS_RW_PUBLIC_SESSION); 1.328 + CASE(CKS_RW_USER_FUNCTIONS); 1.329 + CASE(CKS_RW_SO_FUNCTIONS); 1.330 + default: break; 1.331 + } 1.332 + if (a) 1.333 + PR_LOG(modlog, 1, (" state = %s\n", a)); 1.334 + else 1.335 + PR_LOG(modlog, 1, (" state = 0x%x\n", state)); 1.336 +} 1.337 + 1.338 +static void log_handle(int level, const char * format, CK_ULONG handle) 1.339 +{ 1.340 + char fmtBuf[80]; 1.341 + if (handle) 1.342 + PR_LOG(modlog, level, (format, handle)); 1.343 + else { 1.344 + PL_strncpyz(fmtBuf, format, sizeof fmtBuf); 1.345 + PL_strcatn(fmtBuf, sizeof fmtBuf, fmt_invalid_handle); 1.346 + PR_LOG(modlog, level, (fmtBuf, handle)); 1.347 + } 1.348 +} 1.349 + 1.350 +static void print_mechanism(CK_MECHANISM_PTR m) 1.351 +{ 1.352 + 1.353 + const char * a = NULL; 1.354 + 1.355 + switch (m->mechanism) { 1.356 + CASE(CKM_AES_CBC); 1.357 + CASE(CKM_AES_CBC_ENCRYPT_DATA); 1.358 + CASE(CKM_AES_CBC_PAD); 1.359 + CASE(CKM_AES_CCM); 1.360 + CASE(CKM_AES_CTR); 1.361 + CASE(CKM_AES_CTS); 1.362 + CASE(CKM_AES_GCM); 1.363 + CASE(CKM_AES_ECB); 1.364 + CASE(CKM_AES_ECB_ENCRYPT_DATA); 1.365 + CASE(CKM_AES_KEY_GEN); 1.366 + CASE(CKM_AES_MAC); 1.367 + CASE(CKM_AES_MAC_GENERAL); 1.368 + CASE(CKM_CAMELLIA_CBC); 1.369 + CASE(CKM_CAMELLIA_CBC_ENCRYPT_DATA); 1.370 + CASE(CKM_CAMELLIA_CBC_PAD); 1.371 + CASE(CKM_CAMELLIA_ECB); 1.372 + CASE(CKM_CAMELLIA_ECB_ENCRYPT_DATA); 1.373 + CASE(CKM_CAMELLIA_KEY_GEN); 1.374 + CASE(CKM_CAMELLIA_MAC); 1.375 + CASE(CKM_CAMELLIA_MAC_GENERAL); 1.376 + CASE(CKM_CDMF_CBC); 1.377 + CASE(CKM_CDMF_CBC_PAD); 1.378 + CASE(CKM_CDMF_ECB); 1.379 + CASE(CKM_CDMF_KEY_GEN); 1.380 + CASE(CKM_CDMF_MAC); 1.381 + CASE(CKM_CDMF_MAC_GENERAL); 1.382 + CASE(CKM_CMS_SIG); 1.383 + CASE(CKM_CONCATENATE_BASE_AND_DATA); 1.384 + CASE(CKM_CONCATENATE_BASE_AND_KEY); 1.385 + CASE(CKM_CONCATENATE_DATA_AND_BASE); 1.386 + CASE(CKM_DES2_KEY_GEN); 1.387 + CASE(CKM_DES3_CBC); 1.388 + CASE(CKM_DES3_CBC_ENCRYPT_DATA); 1.389 + CASE(CKM_DES3_CBC_PAD); 1.390 + CASE(CKM_DES3_ECB); 1.391 + CASE(CKM_DES3_ECB_ENCRYPT_DATA); 1.392 + CASE(CKM_DES3_KEY_GEN); 1.393 + CASE(CKM_DES3_MAC); 1.394 + CASE(CKM_DES3_MAC_GENERAL); 1.395 + CASE(CKM_DES_CBC); 1.396 + CASE(CKM_DES_CBC_ENCRYPT_DATA); 1.397 + CASE(CKM_DES_CBC_PAD); 1.398 + CASE(CKM_DES_CFB64); 1.399 + CASE(CKM_DES_CFB8); 1.400 + CASE(CKM_DES_ECB); 1.401 + CASE(CKM_DES_ECB_ENCRYPT_DATA); 1.402 + CASE(CKM_DES_KEY_GEN); 1.403 + CASE(CKM_DES_MAC); 1.404 + CASE(CKM_DES_MAC_GENERAL); 1.405 + CASE(CKM_DES_OFB64); 1.406 + CASE(CKM_DES_OFB8); 1.407 + CASE(CKM_DH_PKCS_DERIVE); 1.408 + CASE(CKM_DH_PKCS_KEY_PAIR_GEN); 1.409 + CASE(CKM_DH_PKCS_PARAMETER_GEN); 1.410 + CASE(CKM_DSA); 1.411 + CASE(CKM_DSA_KEY_PAIR_GEN); 1.412 + CASE(CKM_DSA_PARAMETER_GEN); 1.413 + CASE(CKM_DSA_SHA1); 1.414 + CASE(CKM_ECDH1_COFACTOR_DERIVE); 1.415 + CASE(CKM_ECDH1_DERIVE); 1.416 + CASE(CKM_ECDSA); 1.417 + CASE(CKM_ECDSA_SHA1); 1.418 + CASE(CKM_ECMQV_DERIVE); 1.419 + CASE(CKM_EC_KEY_PAIR_GEN); /* also CASE(CKM_ECDSA_KEY_PAIR_GEN); */ 1.420 + CASE(CKM_EXTRACT_KEY_FROM_KEY); 1.421 + CASE(CKM_FASTHASH); 1.422 + CASE(CKM_FORTEZZA_TIMESTAMP); 1.423 + CASE(CKM_GENERIC_SECRET_KEY_GEN); 1.424 + CASE(CKM_IDEA_CBC); 1.425 + CASE(CKM_IDEA_CBC_PAD); 1.426 + CASE(CKM_IDEA_ECB); 1.427 + CASE(CKM_IDEA_KEY_GEN); 1.428 + CASE(CKM_IDEA_MAC); 1.429 + CASE(CKM_IDEA_MAC_GENERAL); 1.430 + CASE(CKM_KEA_KEY_DERIVE); 1.431 + CASE(CKM_KEA_KEY_PAIR_GEN); 1.432 + CASE(CKM_KEY_WRAP_LYNKS); 1.433 + CASE(CKM_KEY_WRAP_SET_OAEP); 1.434 + CASE(CKM_MD2); 1.435 + CASE(CKM_MD2_HMAC); 1.436 + CASE(CKM_MD2_HMAC_GENERAL); 1.437 + CASE(CKM_MD2_KEY_DERIVATION); 1.438 + CASE(CKM_MD2_RSA_PKCS); 1.439 + CASE(CKM_MD5); 1.440 + CASE(CKM_MD5_HMAC); 1.441 + CASE(CKM_MD5_HMAC_GENERAL); 1.442 + CASE(CKM_MD5_KEY_DERIVATION); 1.443 + CASE(CKM_MD5_RSA_PKCS); 1.444 + CASE(CKM_PBA_SHA1_WITH_SHA1_HMAC); 1.445 + CASE(CKM_PBE_MD2_DES_CBC); 1.446 + CASE(CKM_PBE_MD5_DES_CBC); 1.447 + CASE(CKM_PBE_SHA1_DES2_EDE_CBC); 1.448 + CASE(CKM_PBE_SHA1_DES3_EDE_CBC); 1.449 + CASE(CKM_PBE_SHA1_RC2_128_CBC); 1.450 + CASE(CKM_PBE_SHA1_RC2_40_CBC); 1.451 + CASE(CKM_PBE_SHA1_RC4_128); 1.452 + CASE(CKM_PBE_SHA1_RC4_40); 1.453 + CASE(CKM_PKCS5_PBKD2); 1.454 + CASE(CKM_RC2_CBC); 1.455 + CASE(CKM_RC2_CBC_PAD); 1.456 + CASE(CKM_RC2_ECB); 1.457 + CASE(CKM_RC2_KEY_GEN); 1.458 + CASE(CKM_RC2_MAC); 1.459 + CASE(CKM_RC2_MAC_GENERAL); 1.460 + CASE(CKM_RC4); 1.461 + CASE(CKM_RC4_KEY_GEN); 1.462 + CASE(CKM_RC5_CBC); 1.463 + CASE(CKM_RC5_CBC_PAD); 1.464 + CASE(CKM_RC5_ECB); 1.465 + CASE(CKM_RC5_KEY_GEN); 1.466 + CASE(CKM_RC5_MAC); 1.467 + CASE(CKM_RC5_MAC_GENERAL); 1.468 + CASE(CKM_RIPEMD128); 1.469 + CASE(CKM_RIPEMD128_HMAC); 1.470 + CASE(CKM_RIPEMD128_HMAC_GENERAL); 1.471 + CASE(CKM_RIPEMD128_RSA_PKCS); 1.472 + CASE(CKM_RIPEMD160); 1.473 + CASE(CKM_RIPEMD160_HMAC); 1.474 + CASE(CKM_RIPEMD160_HMAC_GENERAL); 1.475 + CASE(CKM_RIPEMD160_RSA_PKCS); 1.476 + CASE(CKM_RSA_9796); 1.477 + CASE(CKM_RSA_PKCS); 1.478 + CASE(CKM_RSA_PKCS_KEY_PAIR_GEN); 1.479 + CASE(CKM_RSA_PKCS_OAEP); 1.480 + CASE(CKM_RSA_PKCS_PSS); 1.481 + CASE(CKM_RSA_X9_31); 1.482 + CASE(CKM_RSA_X9_31_KEY_PAIR_GEN); 1.483 + CASE(CKM_RSA_X_509); 1.484 + CASE(CKM_SHA1_KEY_DERIVATION); 1.485 + CASE(CKM_SHA1_RSA_PKCS); 1.486 + CASE(CKM_SHA1_RSA_PKCS_PSS); 1.487 + CASE(CKM_SHA1_RSA_X9_31); 1.488 + CASE(CKM_SHA224); 1.489 + CASE(CKM_SHA224_HMAC); 1.490 + CASE(CKM_SHA224_HMAC_GENERAL); 1.491 + CASE(CKM_SHA224_KEY_DERIVATION); 1.492 + CASE(CKM_SHA224_RSA_PKCS); 1.493 + CASE(CKM_SHA224_RSA_PKCS_PSS); 1.494 + CASE(CKM_SHA256); 1.495 + CASE(CKM_SHA256_HMAC); 1.496 + CASE(CKM_SHA256_HMAC_GENERAL); 1.497 + CASE(CKM_SHA256_KEY_DERIVATION); 1.498 + CASE(CKM_SHA256_RSA_PKCS); 1.499 + CASE(CKM_SHA256_RSA_PKCS_PSS); 1.500 + CASE(CKM_SHA384); 1.501 + CASE(CKM_SHA384_HMAC); 1.502 + CASE(CKM_SHA384_HMAC_GENERAL); 1.503 + CASE(CKM_SHA384_KEY_DERIVATION); 1.504 + CASE(CKM_SHA384_RSA_PKCS); 1.505 + CASE(CKM_SHA384_RSA_PKCS_PSS); 1.506 + CASE(CKM_SHA512); 1.507 + CASE(CKM_SHA512_HMAC); 1.508 + CASE(CKM_SHA512_HMAC_GENERAL); 1.509 + CASE(CKM_SHA512_KEY_DERIVATION); 1.510 + CASE(CKM_SHA512_RSA_PKCS); 1.511 + CASE(CKM_SHA512_RSA_PKCS_PSS); 1.512 + CASE(CKM_SHA_1); 1.513 + CASE(CKM_SHA_1_HMAC); 1.514 + CASE(CKM_SHA_1_HMAC_GENERAL); 1.515 + CASE(CKM_SKIPJACK_CBC64); 1.516 + CASE(CKM_SKIPJACK_CFB16); 1.517 + CASE(CKM_SKIPJACK_CFB32); 1.518 + CASE(CKM_SKIPJACK_CFB64); 1.519 + CASE(CKM_SKIPJACK_CFB8); 1.520 + CASE(CKM_SKIPJACK_ECB64); 1.521 + CASE(CKM_SKIPJACK_KEY_GEN); 1.522 + CASE(CKM_SKIPJACK_OFB64); 1.523 + CASE(CKM_SKIPJACK_PRIVATE_WRAP); 1.524 + CASE(CKM_SKIPJACK_RELAYX); 1.525 + CASE(CKM_SKIPJACK_WRAP); 1.526 + CASE(CKM_SSL3_KEY_AND_MAC_DERIVE); 1.527 + CASE(CKM_SSL3_MASTER_KEY_DERIVE); 1.528 + CASE(CKM_SSL3_MASTER_KEY_DERIVE_DH); 1.529 + CASE(CKM_SSL3_MD5_MAC); 1.530 + CASE(CKM_SSL3_PRE_MASTER_KEY_GEN); 1.531 + CASE(CKM_SSL3_SHA1_MAC); 1.532 + CASE(CKM_TLS_KEY_AND_MAC_DERIVE); 1.533 + CASE(CKM_TLS_MASTER_KEY_DERIVE); 1.534 + CASE(CKM_TLS_MASTER_KEY_DERIVE_DH); 1.535 + CASE(CKM_TLS_PRE_MASTER_KEY_GEN); 1.536 + CASE(CKM_TLS_PRF); 1.537 + CASE(CKM_TWOFISH_CBC); 1.538 + CASE(CKM_TWOFISH_KEY_GEN); 1.539 + CASE(CKM_X9_42_DH_DERIVE); 1.540 + CASE(CKM_X9_42_DH_HYBRID_DERIVE); 1.541 + CASE(CKM_X9_42_DH_KEY_PAIR_GEN); 1.542 + CASE(CKM_X9_42_DH_PARAMETER_GEN); 1.543 + CASE(CKM_X9_42_MQV_DERIVE); 1.544 + CASE(CKM_XOR_BASE_AND_DATA); 1.545 + default: break; 1.546 + } 1.547 + if (a) 1.548 + PR_LOG(modlog, 4, (" mechanism = %s", a)); 1.549 + else 1.550 + PR_LOG(modlog, 4, (" mechanism = 0x%p", m->mechanism)); 1.551 +} 1.552 + 1.553 +static void get_key_type(CK_KEY_TYPE keyType, char *str, int len) 1.554 +{ 1.555 + 1.556 + const char * a = NULL; 1.557 + 1.558 + switch (keyType) { 1.559 + CASE(CKK_AES); 1.560 + CASE(CKK_CAMELLIA); 1.561 + CASE(CKK_CDMF); 1.562 + CASE(CKK_DES); 1.563 + CASE(CKK_DES2); 1.564 + CASE(CKK_DES3); 1.565 + CASE(CKK_DH); 1.566 + CASE(CKK_DSA); 1.567 + CASE(CKK_EC); /* also CASE(CKK_ECDSA); */ 1.568 + CASE(CKK_GENERIC_SECRET); 1.569 + CASE(CKK_IDEA); 1.570 + CASE(CKK_INVALID_KEY_TYPE); 1.571 + CASE(CKK_KEA); 1.572 + CASE(CKK_RC2); 1.573 + CASE(CKK_RC4); 1.574 + CASE(CKK_RC5); 1.575 + CASE(CKK_RSA); 1.576 + CASE(CKK_SKIPJACK); 1.577 + CASE(CKK_TWOFISH); 1.578 + CASE(CKK_X9_42_DH); 1.579 + default: break; 1.580 + } 1.581 + if (a) 1.582 + PR_snprintf(str, len, "%s", a); 1.583 + else 1.584 + PR_snprintf(str, len, "0x%p", keyType); 1.585 +} 1.586 + 1.587 +static void print_attr_value(CK_ATTRIBUTE_PTR attr) 1.588 +{ 1.589 + char atype[48]; 1.590 + char valstr[49]; 1.591 + int len; 1.592 + 1.593 + get_attr_type_str(attr->type, atype, sizeof atype); 1.594 + switch (attr->type) { 1.595 + case CKA_ALWAYS_SENSITIVE: 1.596 + case CKA_DECRYPT: 1.597 + case CKA_DERIVE: 1.598 + case CKA_ENCRYPT: 1.599 + case CKA_EXTRACTABLE: 1.600 + case CKA_LOCAL: 1.601 + case CKA_MODIFIABLE: 1.602 + case CKA_NEVER_EXTRACTABLE: 1.603 + case CKA_PRIVATE: 1.604 + case CKA_SENSITIVE: 1.605 + case CKA_SIGN: 1.606 + case CKA_SIGN_RECOVER: 1.607 + case CKA_TOKEN: 1.608 + case CKA_UNWRAP: 1.609 + case CKA_VERIFY: 1.610 + case CKA_VERIFY_RECOVER: 1.611 + case CKA_WRAP: 1.612 + if (attr->ulValueLen > 0 && attr->pValue) { 1.613 + CK_BBOOL tf = *((CK_BBOOL *)attr->pValue); 1.614 + PR_LOG(modlog, 4, (fmt_s_s_d, 1.615 + atype, tf ? "CK_TRUE" : "CK_FALSE", attr->ulValueLen)); 1.616 + break; 1.617 + } 1.618 + case CKA_CLASS: 1.619 + if (attr->ulValueLen > 0 && attr->pValue) { 1.620 + CK_OBJECT_CLASS objClass = *((CK_OBJECT_CLASS *)attr->pValue); 1.621 + get_obj_class(objClass, valstr, sizeof valstr); 1.622 + PR_LOG(modlog, 4, (fmt_s_s_d, 1.623 + atype, valstr, attr->ulValueLen)); 1.624 + break; 1.625 + } 1.626 + case CKA_TRUST_CLIENT_AUTH: 1.627 + case CKA_TRUST_CODE_SIGNING: 1.628 + case CKA_TRUST_EMAIL_PROTECTION: 1.629 + case CKA_TRUST_SERVER_AUTH: 1.630 + if (attr->ulValueLen > 0 && attr->pValue) { 1.631 + CK_TRUST trust = *((CK_TRUST *)attr->pValue); 1.632 + get_trust_val(trust, valstr, sizeof valstr); 1.633 + PR_LOG(modlog, 4, (fmt_s_s_d, 1.634 + atype, valstr, attr->ulValueLen)); 1.635 + break; 1.636 + } 1.637 + case CKA_KEY_TYPE: 1.638 + if (attr->ulValueLen > 0 && attr->pValue) { 1.639 + CK_KEY_TYPE keyType = *((CK_KEY_TYPE *)attr->pValue); 1.640 + get_key_type(keyType, valstr, sizeof valstr); 1.641 + PR_LOG(modlog, 4, (fmt_s_s_d, 1.642 + atype, valstr, attr->ulValueLen)); 1.643 + break; 1.644 + } 1.645 + case CKA_PIXEL_X: 1.646 + case CKA_PIXEL_Y: 1.647 + case CKA_RESOLUTION: 1.648 + case CKA_CHAR_ROWS: 1.649 + case CKA_CHAR_COLUMNS: 1.650 + case CKA_BITS_PER_PIXEL: 1.651 + case CKA_CERTIFICATE_CATEGORY: /* should print as enum/string */ 1.652 + case CKA_JAVA_MIDP_SECURITY_DOMAIN: /* should print as enum/string */ 1.653 + case CKA_MODULUS_BITS: 1.654 + case CKA_PRIME_BITS: 1.655 + case CKA_SUBPRIME_BITS: 1.656 + case CKA_VALUE_BITS: 1.657 + case CKA_VALUE_LEN: 1.658 + if (attr->ulValueLen > 0 && attr->pValue) { 1.659 + CK_ULONG valueLen = *((CK_ULONG *)attr->pValue); 1.660 + /* XXX check for the special value CK_UNAVAILABLE_INFORMATION */ 1.661 + PR_LOG(modlog, 4, (fmt_s_lu, atype, (PRUint32)valueLen)); 1.662 + break; 1.663 + } 1.664 + case CKA_LABEL: 1.665 + case CKA_NSS_EMAIL: 1.666 + case CKA_NSS_URL: 1.667 + if (attr->ulValueLen > 0 && attr->pValue) { 1.668 + len = PR_MIN(attr->ulValueLen + 1, sizeof valstr); 1.669 + PR_snprintf(valstr, len, "%s", attr->pValue); 1.670 + PR_LOG(modlog, 4, (fmt_s_qsq_d, 1.671 + atype, valstr, attr->ulValueLen)); 1.672 + break; 1.673 + } 1.674 + case CKA_ISSUER: 1.675 + case CKA_SUBJECT: 1.676 + if (attr->ulValueLen > 0 && attr->pValue) { 1.677 + char * asciiName; 1.678 + SECItem derName; 1.679 + derName.type = siDERNameBuffer; 1.680 + derName.data = attr->pValue; 1.681 + derName.len = attr->ulValueLen; 1.682 + asciiName = CERT_DerNameToAscii(&derName); 1.683 + if (asciiName) { 1.684 + PR_LOG(modlog, 4, (fmt_s_s_d, 1.685 + atype, asciiName, attr->ulValueLen)); 1.686 + PORT_Free(asciiName); 1.687 + break; 1.688 + } 1.689 + /* else treat like a binary buffer */ 1.690 + goto binary_buffer; 1.691 + } 1.692 + case CKA_ID: 1.693 + if (attr->ulValueLen > 0 && attr->pValue) { 1.694 + unsigned char * pV = attr->pValue; 1.695 + for (len = (int)attr->ulValueLen; len > 0; --len) { 1.696 + unsigned int ch = *pV++; 1.697 + if (ch >= 0x20 && ch < 0x7f) 1.698 + continue; 1.699 + if (!ch && len == 1) /* will ignore NUL if last character */ 1.700 + continue; 1.701 + break; 1.702 + } 1.703 + if (!len) { /* entire string is printable */ 1.704 + len = PR_MIN(attr->ulValueLen + 1, sizeof valstr); 1.705 + PR_snprintf(valstr, len, "%s", attr->pValue); 1.706 + PR_LOG(modlog, 4, (fmt_s_qsq_d, 1.707 + atype, valstr, attr->ulValueLen)); 1.708 + break; 1.709 + } 1.710 + /* else fall through and treat like a binary buffer */ 1.711 + } 1.712 +binary_buffer: 1.713 + case CKA_SERIAL_NUMBER: 1.714 + default: 1.715 + if (attr->ulValueLen > 0 && attr->pValue) { 1.716 + char * hexBuf; 1.717 + SECItem attrBuf; 1.718 + attrBuf.type = siDERNameBuffer; 1.719 + attrBuf.data = attr->pValue; 1.720 + attrBuf.len = PR_MIN(attr->ulValueLen, (sizeof valstr)/2); 1.721 + 1.722 + hexBuf = CERT_Hexify(&attrBuf, PR_FALSE); 1.723 + if (hexBuf) { 1.724 + PR_LOG(modlog, 4, (fmt_s_s_d, 1.725 + atype, hexBuf, attr->ulValueLen)); 1.726 + PORT_Free(hexBuf); 1.727 + break; 1.728 + } 1.729 + /* else fall through and show only the address. :( */ 1.730 + } 1.731 + PR_LOG(modlog, 4, (" %s = [0x%p] [%d]", 1.732 + atype, attr->pValue, attr->ulValueLen)); 1.733 + break; 1.734 + } 1.735 +} 1.736 + 1.737 +static void print_template(CK_ATTRIBUTE_PTR templ, CK_ULONG tlen) 1.738 +{ 1.739 + CK_ULONG i; 1.740 + for (i=0; i<tlen; i++) { 1.741 + print_attr_value(&templ[i]); 1.742 + } 1.743 +} 1.744 + 1.745 +struct nssdbg_prof_str { 1.746 + PRUint32 time; 1.747 + PRUint32 calls; 1.748 + char *function; 1.749 +}; 1.750 + 1.751 +#define NSSDBG_DEFINE(func) { 0, 0, #func } 1.752 + 1.753 +struct nssdbg_prof_str nssdbg_prof_data[] = { 1.754 +#define FUNC_C_INITIALIZE 0 1.755 + NSSDBG_DEFINE(C_Initialize), 1.756 +#define FUNC_C_FINALIZE 1 1.757 + NSSDBG_DEFINE(C_Finalize), 1.758 +#define FUNC_C_GETINFO 2 1.759 + NSSDBG_DEFINE(C_GetInfo), 1.760 +#define FUNC_C_GETFUNCITONLIST 3 1.761 + NSSDBG_DEFINE(C_GetFunctionList), 1.762 +#define FUNC_C_GETSLOTLIST 4 1.763 + NSSDBG_DEFINE(C_GetSlotList), 1.764 +#define FUNC_C_GETSLOTINFO 5 1.765 + NSSDBG_DEFINE(C_GetSlotInfo), 1.766 +#define FUNC_C_GETTOKENINFO 6 1.767 + NSSDBG_DEFINE(C_GetTokenInfo), 1.768 +#define FUNC_C_GETMECHANISMLIST 7 1.769 + NSSDBG_DEFINE(C_GetMechanismList), 1.770 +#define FUNC_C_GETMECHANISMINFO 8 1.771 + NSSDBG_DEFINE(C_GetMechanismInfo), 1.772 +#define FUNC_C_INITTOKEN 9 1.773 + NSSDBG_DEFINE(C_InitToken), 1.774 +#define FUNC_C_INITPIN 10 1.775 + NSSDBG_DEFINE(C_InitPIN), 1.776 +#define FUNC_C_SETPIN 11 1.777 + NSSDBG_DEFINE(C_SetPIN), 1.778 +#define FUNC_C_OPENSESSION 12 1.779 + NSSDBG_DEFINE(C_OpenSession), 1.780 +#define FUNC_C_CLOSESESSION 13 1.781 + NSSDBG_DEFINE(C_CloseSession), 1.782 +#define FUNC_C_CLOSEALLSESSIONS 14 1.783 + NSSDBG_DEFINE(C_CloseAllSessions), 1.784 +#define FUNC_C_GETSESSIONINFO 15 1.785 + NSSDBG_DEFINE(C_GetSessionInfo), 1.786 +#define FUNC_C_GETOPERATIONSTATE 16 1.787 + NSSDBG_DEFINE(C_GetOperationState), 1.788 +#define FUNC_C_SETOPERATIONSTATE 17 1.789 + NSSDBG_DEFINE(C_SetOperationState), 1.790 +#define FUNC_C_LOGIN 18 1.791 + NSSDBG_DEFINE(C_Login), 1.792 +#define FUNC_C_LOGOUT 19 1.793 + NSSDBG_DEFINE(C_Logout), 1.794 +#define FUNC_C_CREATEOBJECT 20 1.795 + NSSDBG_DEFINE(C_CreateObject), 1.796 +#define FUNC_C_COPYOBJECT 21 1.797 + NSSDBG_DEFINE(C_CopyObject), 1.798 +#define FUNC_C_DESTROYOBJECT 22 1.799 + NSSDBG_DEFINE(C_DestroyObject), 1.800 +#define FUNC_C_GETOBJECTSIZE 23 1.801 + NSSDBG_DEFINE(C_GetObjectSize), 1.802 +#define FUNC_C_GETATTRIBUTEVALUE 24 1.803 + NSSDBG_DEFINE(C_GetAttributeValue), 1.804 +#define FUNC_C_SETATTRIBUTEVALUE 25 1.805 + NSSDBG_DEFINE(C_SetAttributeValue), 1.806 +#define FUNC_C_FINDOBJECTSINIT 26 1.807 + NSSDBG_DEFINE(C_FindObjectsInit), 1.808 +#define FUNC_C_FINDOBJECTS 27 1.809 + NSSDBG_DEFINE(C_FindObjects), 1.810 +#define FUNC_C_FINDOBJECTSFINAL 28 1.811 + NSSDBG_DEFINE(C_FindObjectsFinal), 1.812 +#define FUNC_C_ENCRYPTINIT 29 1.813 + NSSDBG_DEFINE(C_EncryptInit), 1.814 +#define FUNC_C_ENCRYPT 30 1.815 + NSSDBG_DEFINE(C_Encrypt), 1.816 +#define FUNC_C_ENCRYPTUPDATE 31 1.817 + NSSDBG_DEFINE(C_EncryptUpdate), 1.818 +#define FUNC_C_ENCRYPTFINAL 32 1.819 + NSSDBG_DEFINE(C_EncryptFinal), 1.820 +#define FUNC_C_DECRYPTINIT 33 1.821 + NSSDBG_DEFINE(C_DecryptInit), 1.822 +#define FUNC_C_DECRYPT 34 1.823 + NSSDBG_DEFINE(C_Decrypt), 1.824 +#define FUNC_C_DECRYPTUPDATE 35 1.825 + NSSDBG_DEFINE(C_DecryptUpdate), 1.826 +#define FUNC_C_DECRYPTFINAL 36 1.827 + NSSDBG_DEFINE(C_DecryptFinal), 1.828 +#define FUNC_C_DIGESTINIT 37 1.829 + NSSDBG_DEFINE(C_DigestInit), 1.830 +#define FUNC_C_DIGEST 38 1.831 + NSSDBG_DEFINE(C_Digest), 1.832 +#define FUNC_C_DIGESTUPDATE 39 1.833 + NSSDBG_DEFINE(C_DigestUpdate), 1.834 +#define FUNC_C_DIGESTKEY 40 1.835 + NSSDBG_DEFINE(C_DigestKey), 1.836 +#define FUNC_C_DIGESTFINAL 41 1.837 + NSSDBG_DEFINE(C_DigestFinal), 1.838 +#define FUNC_C_SIGNINIT 42 1.839 + NSSDBG_DEFINE(C_SignInit), 1.840 +#define FUNC_C_SIGN 43 1.841 + NSSDBG_DEFINE(C_Sign), 1.842 +#define FUNC_C_SIGNUPDATE 44 1.843 + NSSDBG_DEFINE(C_SignUpdate), 1.844 +#define FUNC_C_SIGNFINAL 45 1.845 + NSSDBG_DEFINE(C_SignFinal), 1.846 +#define FUNC_C_SIGNRECOVERINIT 46 1.847 + NSSDBG_DEFINE(C_SignRecoverInit), 1.848 +#define FUNC_C_SIGNRECOVER 47 1.849 + NSSDBG_DEFINE(C_SignRecover), 1.850 +#define FUNC_C_VERIFYINIT 48 1.851 + NSSDBG_DEFINE(C_VerifyInit), 1.852 +#define FUNC_C_VERIFY 49 1.853 + NSSDBG_DEFINE(C_Verify), 1.854 +#define FUNC_C_VERIFYUPDATE 50 1.855 + NSSDBG_DEFINE(C_VerifyUpdate), 1.856 +#define FUNC_C_VERIFYFINAL 51 1.857 + NSSDBG_DEFINE(C_VerifyFinal), 1.858 +#define FUNC_C_VERIFYRECOVERINIT 52 1.859 + NSSDBG_DEFINE(C_VerifyRecoverInit), 1.860 +#define FUNC_C_VERIFYRECOVER 53 1.861 + NSSDBG_DEFINE(C_VerifyRecover), 1.862 +#define FUNC_C_DIGESTENCRYPTUPDATE 54 1.863 + NSSDBG_DEFINE(C_DigestEncryptUpdate), 1.864 +#define FUNC_C_DECRYPTDIGESTUPDATE 55 1.865 + NSSDBG_DEFINE(C_DecryptDigestUpdate), 1.866 +#define FUNC_C_SIGNENCRYPTUPDATE 56 1.867 + NSSDBG_DEFINE(C_SignEncryptUpdate), 1.868 +#define FUNC_C_DECRYPTVERIFYUPDATE 57 1.869 + NSSDBG_DEFINE(C_DecryptVerifyUpdate), 1.870 +#define FUNC_C_GENERATEKEY 58 1.871 + NSSDBG_DEFINE(C_GenerateKey), 1.872 +#define FUNC_C_GENERATEKEYPAIR 59 1.873 + NSSDBG_DEFINE(C_GenerateKeyPair), 1.874 +#define FUNC_C_WRAPKEY 60 1.875 + NSSDBG_DEFINE(C_WrapKey), 1.876 +#define FUNC_C_UNWRAPKEY 61 1.877 + NSSDBG_DEFINE(C_UnWrapKey), 1.878 +#define FUNC_C_DERIVEKEY 62 1.879 + NSSDBG_DEFINE(C_DeriveKey), 1.880 +#define FUNC_C_SEEDRANDOM 63 1.881 + NSSDBG_DEFINE(C_SeedRandom), 1.882 +#define FUNC_C_GENERATERANDOM 64 1.883 + NSSDBG_DEFINE(C_GenerateRandom), 1.884 +#define FUNC_C_GETFUNCTIONSTATUS 65 1.885 + NSSDBG_DEFINE(C_GetFunctionStatus), 1.886 +#define FUNC_C_CANCELFUNCTION 66 1.887 + NSSDBG_DEFINE(C_CancelFunction), 1.888 +#define FUNC_C_WAITFORSLOTEVENT 67 1.889 + NSSDBG_DEFINE(C_WaitForSlotEvent) 1.890 +}; 1.891 + 1.892 +int nssdbg_prof_size = sizeof(nssdbg_prof_data)/sizeof(nssdbg_prof_data[0]); 1.893 + 1.894 + 1.895 +static void nssdbg_finish_time(PRInt32 fun_number, PRIntervalTime start) 1.896 +{ 1.897 + PRIntervalTime ival; 1.898 + PRIntervalTime end = PR_IntervalNow(); 1.899 + 1.900 + ival = end-start; 1.901 + /* sigh, lie to PRAtomic add and say we are using signed values */ 1.902 + PR_ATOMIC_ADD((PRInt32 *)&nssdbg_prof_data[fun_number].time, (PRInt32)ival); 1.903 +} 1.904 + 1.905 +static void nssdbg_start_time(PRInt32 fun_number, PRIntervalTime *start) 1.906 +{ 1.907 + PR_ATOMIC_INCREMENT((PRInt32 *)&nssdbg_prof_data[fun_number].calls); 1.908 + *start = PR_IntervalNow(); 1.909 +} 1.910 + 1.911 +#define COMMON_DEFINITIONS \ 1.912 + CK_RV rv; \ 1.913 + PRIntervalTime start 1.914 + 1.915 +CK_RV NSSDBGC_Initialize( 1.916 + CK_VOID_PTR pInitArgs 1.917 +) 1.918 +{ 1.919 + COMMON_DEFINITIONS; 1.920 + 1.921 + PR_LOG(modlog, 1, ("C_Initialize")); 1.922 + PR_LOG(modlog, 3, (" pInitArgs = 0x%p", pInitArgs)); 1.923 + nssdbg_start_time(FUNC_C_INITIALIZE,&start); 1.924 + rv = module_functions->C_Initialize(pInitArgs); 1.925 + nssdbg_finish_time(FUNC_C_INITIALIZE,start); 1.926 + log_rv(rv); 1.927 + return rv; 1.928 +} 1.929 + 1.930 +CK_RV NSSDBGC_Finalize( 1.931 + CK_VOID_PTR pReserved 1.932 +) 1.933 +{ 1.934 + COMMON_DEFINITIONS; 1.935 + 1.936 + PR_LOG(modlog, 1, ("C_Finalize")); 1.937 + PR_LOG(modlog, 3, (" pReserved = 0x%p", pReserved)); 1.938 + nssdbg_start_time(FUNC_C_FINALIZE,&start); 1.939 + rv = module_functions->C_Finalize(pReserved); 1.940 + nssdbg_finish_time(FUNC_C_FINALIZE,start); 1.941 + log_rv(rv); 1.942 + return rv; 1.943 +} 1.944 + 1.945 +CK_RV NSSDBGC_GetInfo( 1.946 + CK_INFO_PTR pInfo 1.947 +) 1.948 +{ 1.949 + COMMON_DEFINITIONS; 1.950 + 1.951 + PR_LOG(modlog, 1, ("C_GetInfo")); 1.952 + PR_LOG(modlog, 3, (fmt_pInfo, pInfo)); 1.953 + nssdbg_start_time(FUNC_C_GETINFO,&start); 1.954 + rv = module_functions->C_GetInfo(pInfo); 1.955 + nssdbg_finish_time(FUNC_C_GETINFO,start); 1.956 + if (rv == CKR_OK) { 1.957 + PR_LOG(modlog, 4, (" cryptoki version: %d.%d", 1.958 + pInfo->cryptokiVersion.major, 1.959 + pInfo->cryptokiVersion.minor)); 1.960 + PR_LOG(modlog, 4, (fmt_manufacturerID, pInfo->manufacturerID)); 1.961 + PR_LOG(modlog, 4, (" library description = \"%.32s\"", 1.962 + pInfo->libraryDescription)); 1.963 + PR_LOG(modlog, 4, (" library version: %d.%d", 1.964 + pInfo->libraryVersion.major, 1.965 + pInfo->libraryVersion.minor)); 1.966 + } 1.967 + log_rv(rv); 1.968 + return rv; 1.969 +} 1.970 + 1.971 +CK_RV NSSDBGC_GetFunctionList( 1.972 + CK_FUNCTION_LIST_PTR_PTR ppFunctionList 1.973 +) 1.974 +{ 1.975 + COMMON_DEFINITIONS; 1.976 + 1.977 + PR_LOG(modlog, 1, ("C_GetFunctionList")); 1.978 + PR_LOG(modlog, 3, (" ppFunctionList = 0x%p", ppFunctionList)); 1.979 + nssdbg_start_time(FUNC_C_GETFUNCITONLIST,&start); 1.980 + rv = module_functions->C_GetFunctionList(ppFunctionList); 1.981 + nssdbg_finish_time(FUNC_C_GETFUNCITONLIST,start); 1.982 + log_rv(rv); 1.983 + return rv; 1.984 +} 1.985 + 1.986 +CK_RV NSSDBGC_GetSlotList( 1.987 + CK_BBOOL tokenPresent, 1.988 + CK_SLOT_ID_PTR pSlotList, 1.989 + CK_ULONG_PTR pulCount 1.990 +) 1.991 +{ 1.992 + COMMON_DEFINITIONS; 1.993 + 1.994 + CK_ULONG i; 1.995 + PR_LOG(modlog, 1, ("C_GetSlotList")); 1.996 + PR_LOG(modlog, 3, (" tokenPresent = 0x%x", tokenPresent)); 1.997 + PR_LOG(modlog, 3, (" pSlotList = 0x%p", pSlotList)); 1.998 + PR_LOG(modlog, 3, (fmt_pulCount, pulCount)); 1.999 + nssdbg_start_time(FUNC_C_GETSLOTLIST,&start); 1.1000 + rv = module_functions->C_GetSlotList(tokenPresent, pSlotList, pulCount); 1.1001 + nssdbg_finish_time(FUNC_C_GETSLOTLIST,start); 1.1002 + PR_LOG(modlog, 4, (fmt_spulCount, *pulCount)); 1.1003 + if (pSlotList) { 1.1004 + for (i=0; i<*pulCount; i++) { 1.1005 + PR_LOG(modlog, 4, (" slotID[%d] = %x", i, pSlotList[i])); 1.1006 + } 1.1007 + } 1.1008 + log_rv(rv); 1.1009 + return rv; 1.1010 +} 1.1011 + 1.1012 +CK_RV NSSDBGC_GetSlotInfo( 1.1013 + CK_SLOT_ID slotID, 1.1014 + CK_SLOT_INFO_PTR pInfo 1.1015 +) 1.1016 +{ 1.1017 + COMMON_DEFINITIONS; 1.1018 + 1.1019 + PR_LOG(modlog, 1, ("C_GetSlotInfo")); 1.1020 + PR_LOG(modlog, 3, (fmt_slotID, slotID)); 1.1021 + PR_LOG(modlog, 3, (fmt_pInfo, pInfo)); 1.1022 + nssdbg_start_time(FUNC_C_GETSLOTINFO,&start); 1.1023 + rv = module_functions->C_GetSlotInfo(slotID, pInfo); 1.1024 + nssdbg_finish_time(FUNC_C_GETSLOTINFO,start); 1.1025 + if (rv == CKR_OK) { 1.1026 + PR_LOG(modlog, 4, (" slotDescription = \"%.64s\"", 1.1027 + pInfo->slotDescription)); 1.1028 + PR_LOG(modlog, 4, (fmt_manufacturerID, pInfo->manufacturerID)); 1.1029 + PR_LOG(modlog, 4, (" flags = %s %s %s", 1.1030 + pInfo->flags & CKF_HW_SLOT ? "CKF_HW_SLOT" : "", 1.1031 + pInfo->flags & CKF_REMOVABLE_DEVICE ? "CKF_REMOVABLE_DEVICE" : "", 1.1032 + pInfo->flags & CKF_TOKEN_PRESENT ? "CKF_TOKEN_PRESENT" : "")); 1.1033 + PR_LOG(modlog, 4, (fmt_hwVersion, 1.1034 + pInfo->hardwareVersion.major, 1.1035 + pInfo->hardwareVersion.minor)); 1.1036 + PR_LOG(modlog, 4, (fmt_fwVersion, 1.1037 + pInfo->firmwareVersion.major, 1.1038 + pInfo->firmwareVersion.minor)); 1.1039 + } 1.1040 + log_rv(rv); 1.1041 + return rv; 1.1042 +} 1.1043 + 1.1044 +CK_RV NSSDBGC_GetTokenInfo( 1.1045 + CK_SLOT_ID slotID, 1.1046 + CK_TOKEN_INFO_PTR pInfo 1.1047 +) 1.1048 +{ 1.1049 + COMMON_DEFINITIONS; 1.1050 + 1.1051 + PR_LOG(modlog, 1, ("C_GetTokenInfo")); 1.1052 + PR_LOG(modlog, 3, (fmt_slotID, slotID)); 1.1053 + PR_LOG(modlog, 3, (fmt_pInfo, pInfo)); 1.1054 + nssdbg_start_time(FUNC_C_GETTOKENINFO,&start); 1.1055 + rv = module_functions->C_GetTokenInfo(slotID, pInfo); 1.1056 + nssdbg_finish_time(FUNC_C_GETTOKENINFO,start); 1.1057 + if (rv == CKR_OK) { 1.1058 + PR_LOG(modlog, 4, (" label = \"%.32s\"", pInfo->label)); 1.1059 + PR_LOG(modlog, 4, (fmt_manufacturerID, pInfo->manufacturerID)); 1.1060 + PR_LOG(modlog, 4, (" model = \"%.16s\"", pInfo->model)); 1.1061 + PR_LOG(modlog, 4, (" serial = \"%.16s\"", pInfo->serialNumber)); 1.1062 + PR_LOG(modlog, 4, (" flags = %s %s %s %s", 1.1063 + pInfo->flags & CKF_RNG ? "CKF_RNG" : "", 1.1064 + pInfo->flags & CKF_WRITE_PROTECTED ? "CKF_WRITE_PROTECTED" : "", 1.1065 + pInfo->flags & CKF_LOGIN_REQUIRED ? "CKF_LOGIN_REQUIRED" : "", 1.1066 + pInfo->flags & CKF_USER_PIN_INITIALIZED ? "CKF_USER_PIN_INIT" : "")); 1.1067 + PR_LOG(modlog, 4, (" maxSessions = %u, Sessions = %u", 1.1068 + pInfo->ulMaxSessionCount, pInfo->ulSessionCount)); 1.1069 + PR_LOG(modlog, 4, (" maxRwSessions = %u, RwSessions = %u", 1.1070 + pInfo->ulMaxRwSessionCount, 1.1071 + pInfo->ulRwSessionCount)); 1.1072 + /* ignore Max & Min Pin Len, Public and Private Memory */ 1.1073 + PR_LOG(modlog, 4, (fmt_hwVersion, 1.1074 + pInfo->hardwareVersion.major, 1.1075 + pInfo->hardwareVersion.minor)); 1.1076 + PR_LOG(modlog, 4, (fmt_fwVersion, 1.1077 + pInfo->firmwareVersion.major, 1.1078 + pInfo->firmwareVersion.minor)); 1.1079 + } 1.1080 + log_rv(rv); 1.1081 + return rv; 1.1082 +} 1.1083 + 1.1084 +CK_RV NSSDBGC_GetMechanismList( 1.1085 + CK_SLOT_ID slotID, 1.1086 + CK_MECHANISM_TYPE_PTR pMechanismList, 1.1087 + CK_ULONG_PTR pulCount 1.1088 +) 1.1089 +{ 1.1090 + COMMON_DEFINITIONS; 1.1091 + 1.1092 + PR_LOG(modlog, 1, ("C_GetMechanismList")); 1.1093 + PR_LOG(modlog, 3, (fmt_slotID, slotID)); 1.1094 + PR_LOG(modlog, 3, (" pMechanismList = 0x%p", pMechanismList)); 1.1095 + PR_LOG(modlog, 3, (fmt_pulCount, pulCount)); 1.1096 + nssdbg_start_time(FUNC_C_GETMECHANISMLIST,&start); 1.1097 + rv = module_functions->C_GetMechanismList(slotID, 1.1098 + pMechanismList, 1.1099 + pulCount); 1.1100 + nssdbg_finish_time(FUNC_C_GETMECHANISMLIST,start); 1.1101 + PR_LOG(modlog, 4, (fmt_spulCount, *pulCount)); 1.1102 + log_rv(rv); 1.1103 + return rv; 1.1104 +} 1.1105 + 1.1106 +CK_RV NSSDBGC_GetMechanismInfo( 1.1107 + CK_SLOT_ID slotID, 1.1108 + CK_MECHANISM_TYPE type, 1.1109 + CK_MECHANISM_INFO_PTR pInfo 1.1110 +) 1.1111 +{ 1.1112 + COMMON_DEFINITIONS; 1.1113 + 1.1114 + PR_LOG(modlog, 1, ("C_GetMechanismInfo")); 1.1115 + PR_LOG(modlog, 3, (fmt_slotID, slotID)); 1.1116 + PR_LOG(modlog, 3, (" type = 0x%x", type)); 1.1117 + PR_LOG(modlog, 3, (fmt_pInfo, pInfo)); 1.1118 + nssdbg_start_time(FUNC_C_GETMECHANISMINFO,&start); 1.1119 + rv = module_functions->C_GetMechanismInfo(slotID, 1.1120 + type, 1.1121 + pInfo); 1.1122 + nssdbg_finish_time(FUNC_C_GETMECHANISMINFO,start); 1.1123 + log_rv(rv); 1.1124 + return rv; 1.1125 +} 1.1126 + 1.1127 +CK_RV NSSDBGC_InitToken( 1.1128 + CK_SLOT_ID slotID, 1.1129 + CK_CHAR_PTR pPin, 1.1130 + CK_ULONG ulPinLen, 1.1131 + CK_CHAR_PTR pLabel 1.1132 +) 1.1133 +{ 1.1134 + COMMON_DEFINITIONS; 1.1135 + 1.1136 + PR_LOG(modlog, 1, ("C_InitToken")); 1.1137 + PR_LOG(modlog, 3, (fmt_slotID, slotID)); 1.1138 + PR_LOG(modlog, 3, (fmt_pPin, pPin)); 1.1139 + PR_LOG(modlog, 3, (fmt_ulPinLen, ulPinLen)); 1.1140 + PR_LOG(modlog, 3, (" pLabel = 0x%p", pLabel)); 1.1141 + nssdbg_start_time(FUNC_C_INITTOKEN,&start); 1.1142 + rv = module_functions->C_InitToken(slotID, 1.1143 + pPin, 1.1144 + ulPinLen, 1.1145 + pLabel); 1.1146 + nssdbg_finish_time(FUNC_C_INITTOKEN,start); 1.1147 + log_rv(rv); 1.1148 + return rv; 1.1149 +} 1.1150 + 1.1151 +CK_RV NSSDBGC_InitPIN( 1.1152 + CK_SESSION_HANDLE hSession, 1.1153 + CK_CHAR_PTR pPin, 1.1154 + CK_ULONG ulPinLen 1.1155 +) 1.1156 +{ 1.1157 + COMMON_DEFINITIONS; 1.1158 + 1.1159 + PR_LOG(modlog, 1, ("C_InitPIN")); 1.1160 + log_handle(3, fmt_hSession, hSession); 1.1161 + PR_LOG(modlog, 3, (fmt_pPin, pPin)); 1.1162 + PR_LOG(modlog, 3, (fmt_ulPinLen, ulPinLen)); 1.1163 + nssdbg_start_time(FUNC_C_INITPIN,&start); 1.1164 + rv = module_functions->C_InitPIN(hSession, 1.1165 + pPin, 1.1166 + ulPinLen); 1.1167 + nssdbg_finish_time(FUNC_C_INITPIN,start); 1.1168 + log_rv(rv); 1.1169 + return rv; 1.1170 +} 1.1171 + 1.1172 +CK_RV NSSDBGC_SetPIN( 1.1173 + CK_SESSION_HANDLE hSession, 1.1174 + CK_CHAR_PTR pOldPin, 1.1175 + CK_ULONG ulOldLen, 1.1176 + CK_CHAR_PTR pNewPin, 1.1177 + CK_ULONG ulNewLen 1.1178 +) 1.1179 +{ 1.1180 + COMMON_DEFINITIONS; 1.1181 + 1.1182 + PR_LOG(modlog, 1, ("C_SetPIN")); 1.1183 + log_handle(3, fmt_hSession, hSession); 1.1184 + PR_LOG(modlog, 3, (" pOldPin = 0x%p", pOldPin)); 1.1185 + PR_LOG(modlog, 3, (" ulOldLen = %d", ulOldLen)); 1.1186 + PR_LOG(modlog, 3, (" pNewPin = 0x%p", pNewPin)); 1.1187 + PR_LOG(modlog, 3, (" ulNewLen = %d", ulNewLen)); 1.1188 + nssdbg_start_time(FUNC_C_SETPIN,&start); 1.1189 + rv = module_functions->C_SetPIN(hSession, 1.1190 + pOldPin, 1.1191 + ulOldLen, 1.1192 + pNewPin, 1.1193 + ulNewLen); 1.1194 + nssdbg_finish_time(FUNC_C_SETPIN,start); 1.1195 + log_rv(rv); 1.1196 + return rv; 1.1197 +} 1.1198 + 1.1199 +static PRUint32 numOpenSessions = 0; 1.1200 +static PRUint32 maxOpenSessions = 0; 1.1201 + 1.1202 +CK_RV NSSDBGC_OpenSession( 1.1203 + CK_SLOT_ID slotID, 1.1204 + CK_FLAGS flags, 1.1205 + CK_VOID_PTR pApplication, 1.1206 + CK_NOTIFY Notify, 1.1207 + CK_SESSION_HANDLE_PTR phSession 1.1208 +) 1.1209 +{ 1.1210 + COMMON_DEFINITIONS; 1.1211 + 1.1212 + PR_ATOMIC_INCREMENT((PRInt32 *)&numOpenSessions); 1.1213 + maxOpenSessions = PR_MAX(numOpenSessions, maxOpenSessions); 1.1214 + PR_LOG(modlog, 1, ("C_OpenSession")); 1.1215 + PR_LOG(modlog, 3, (fmt_slotID, slotID)); 1.1216 + PR_LOG(modlog, 3, (fmt_flags, flags)); 1.1217 + PR_LOG(modlog, 3, (" pApplication = 0x%p", pApplication)); 1.1218 + PR_LOG(modlog, 3, (" Notify = 0x%x", Notify)); 1.1219 + PR_LOG(modlog, 3, (" phSession = 0x%p", phSession)); 1.1220 + nssdbg_start_time(FUNC_C_OPENSESSION,&start); 1.1221 + rv = module_functions->C_OpenSession(slotID, 1.1222 + flags, 1.1223 + pApplication, 1.1224 + Notify, 1.1225 + phSession); 1.1226 + nssdbg_finish_time(FUNC_C_OPENSESSION,start); 1.1227 + log_handle(4, " *phSession = 0x%x", *phSession); 1.1228 + log_rv(rv); 1.1229 + return rv; 1.1230 +} 1.1231 + 1.1232 +CK_RV NSSDBGC_CloseSession( 1.1233 + CK_SESSION_HANDLE hSession 1.1234 +) 1.1235 +{ 1.1236 + COMMON_DEFINITIONS; 1.1237 + 1.1238 + PR_ATOMIC_DECREMENT((PRInt32 *)&numOpenSessions); 1.1239 + PR_LOG(modlog, 1, ("C_CloseSession")); 1.1240 + log_handle(3, fmt_hSession, hSession); 1.1241 + nssdbg_start_time(FUNC_C_CLOSESESSION,&start); 1.1242 + rv = module_functions->C_CloseSession(hSession); 1.1243 + nssdbg_finish_time(FUNC_C_CLOSESESSION,start); 1.1244 + log_rv(rv); 1.1245 + return rv; 1.1246 +} 1.1247 + 1.1248 +CK_RV NSSDBGC_CloseAllSessions( 1.1249 + CK_SLOT_ID slotID 1.1250 +) 1.1251 +{ 1.1252 + COMMON_DEFINITIONS; 1.1253 + 1.1254 + PR_LOG(modlog, 1, ("C_CloseAllSessions")); 1.1255 + PR_LOG(modlog, 3, (fmt_slotID, slotID)); 1.1256 + nssdbg_start_time(FUNC_C_CLOSEALLSESSIONS,&start); 1.1257 + rv = module_functions->C_CloseAllSessions(slotID); 1.1258 + nssdbg_finish_time(FUNC_C_CLOSEALLSESSIONS,start); 1.1259 + log_rv(rv); 1.1260 + return rv; 1.1261 +} 1.1262 + 1.1263 +CK_RV NSSDBGC_GetSessionInfo( 1.1264 + CK_SESSION_HANDLE hSession, 1.1265 + CK_SESSION_INFO_PTR pInfo 1.1266 +) 1.1267 +{ 1.1268 + COMMON_DEFINITIONS; 1.1269 + 1.1270 + PR_LOG(modlog, 1, ("C_GetSessionInfo")); 1.1271 + log_handle(3, fmt_hSession, hSession); 1.1272 + PR_LOG(modlog, 3, (fmt_pInfo, pInfo)); 1.1273 + nssdbg_start_time(FUNC_C_GETSESSIONINFO,&start); 1.1274 + rv = module_functions->C_GetSessionInfo(hSession, 1.1275 + pInfo); 1.1276 + nssdbg_finish_time(FUNC_C_GETSESSIONINFO,start); 1.1277 + if (rv == CKR_OK) { 1.1278 + PR_LOG(modlog, 4, (fmt_slotID, pInfo->slotID)); 1.1279 + log_state(pInfo->state); 1.1280 + PR_LOG(modlog, 4, (" flags = %s %s", 1.1281 + pInfo->flags & CKF_RW_SESSION ? "CKF_RW_SESSION" : "", 1.1282 + pInfo->flags & CKF_SERIAL_SESSION ? "CKF_SERIAL_SESSION" : "")); 1.1283 + PR_LOG(modlog, 4, (" deviceError = 0x%x", pInfo->ulDeviceError)); 1.1284 + } 1.1285 + log_rv(rv); 1.1286 + return rv; 1.1287 +} 1.1288 + 1.1289 +CK_RV NSSDBGC_GetOperationState( 1.1290 + CK_SESSION_HANDLE hSession, 1.1291 + CK_BYTE_PTR pOperationState, 1.1292 + CK_ULONG_PTR pulOperationStateLen 1.1293 +) 1.1294 +{ 1.1295 + COMMON_DEFINITIONS; 1.1296 + 1.1297 + PR_LOG(modlog, 1, ("C_GetOperationState")); 1.1298 + log_handle(3, fmt_hSession, hSession); 1.1299 + PR_LOG(modlog, 3, (fmt_pOperationState, pOperationState)); 1.1300 + PR_LOG(modlog, 3, (" pulOperationStateLen = 0x%p", pulOperationStateLen)); 1.1301 + nssdbg_start_time(FUNC_C_GETOPERATIONSTATE,&start); 1.1302 + rv = module_functions->C_GetOperationState(hSession, 1.1303 + pOperationState, 1.1304 + pulOperationStateLen); 1.1305 + nssdbg_finish_time(FUNC_C_GETOPERATIONSTATE,start); 1.1306 + PR_LOG(modlog, 4, (" *pulOperationStateLen = 0x%x", *pulOperationStateLen)); 1.1307 + log_rv(rv); 1.1308 + return rv; 1.1309 +} 1.1310 + 1.1311 +CK_RV NSSDBGC_SetOperationState( 1.1312 + CK_SESSION_HANDLE hSession, 1.1313 + CK_BYTE_PTR pOperationState, 1.1314 + CK_ULONG ulOperationStateLen, 1.1315 + CK_OBJECT_HANDLE hEncryptionKey, 1.1316 + CK_OBJECT_HANDLE hAuthenticationKey 1.1317 +) 1.1318 +{ 1.1319 + COMMON_DEFINITIONS; 1.1320 + 1.1321 + PR_LOG(modlog, 1, ("C_SetOperationState")); 1.1322 + log_handle(3, fmt_hSession, hSession); 1.1323 + PR_LOG(modlog, 3, (fmt_pOperationState, pOperationState)); 1.1324 + PR_LOG(modlog, 3, (" ulOperationStateLen = %d", ulOperationStateLen)); 1.1325 + log_handle(3, " hEncryptionKey = 0x%x", hEncryptionKey); 1.1326 + log_handle(3, " hAuthenticationKey = 0x%x", hAuthenticationKey); 1.1327 + nssdbg_start_time(FUNC_C_SETOPERATIONSTATE,&start); 1.1328 + rv = module_functions->C_SetOperationState(hSession, 1.1329 + pOperationState, 1.1330 + ulOperationStateLen, 1.1331 + hEncryptionKey, 1.1332 + hAuthenticationKey); 1.1333 + nssdbg_finish_time(FUNC_C_SETOPERATIONSTATE,start); 1.1334 + log_rv(rv); 1.1335 + return rv; 1.1336 +} 1.1337 + 1.1338 +CK_RV NSSDBGC_Login( 1.1339 + CK_SESSION_HANDLE hSession, 1.1340 + CK_USER_TYPE userType, 1.1341 + CK_CHAR_PTR pPin, 1.1342 + CK_ULONG ulPinLen 1.1343 +) 1.1344 +{ 1.1345 + COMMON_DEFINITIONS; 1.1346 + 1.1347 + PR_LOG(modlog, 1, ("C_Login")); 1.1348 + log_handle(3, fmt_hSession, hSession); 1.1349 + PR_LOG(modlog, 3, (" userType = 0x%x", userType)); 1.1350 + PR_LOG(modlog, 3, (fmt_pPin, pPin)); 1.1351 + PR_LOG(modlog, 3, (fmt_ulPinLen, ulPinLen)); 1.1352 + nssdbg_start_time(FUNC_C_LOGIN,&start); 1.1353 + rv = module_functions->C_Login(hSession, 1.1354 + userType, 1.1355 + pPin, 1.1356 + ulPinLen); 1.1357 + nssdbg_finish_time(FUNC_C_LOGIN,start); 1.1358 + log_rv(rv); 1.1359 + return rv; 1.1360 +} 1.1361 + 1.1362 +CK_RV NSSDBGC_Logout( 1.1363 + CK_SESSION_HANDLE hSession 1.1364 +) 1.1365 +{ 1.1366 + COMMON_DEFINITIONS; 1.1367 + 1.1368 + PR_LOG(modlog, 1, ("C_Logout")); 1.1369 + log_handle(3, fmt_hSession, hSession); 1.1370 + nssdbg_start_time(FUNC_C_LOGOUT,&start); 1.1371 + rv = module_functions->C_Logout(hSession); 1.1372 + nssdbg_finish_time(FUNC_C_LOGOUT,start); 1.1373 + log_rv(rv); 1.1374 + return rv; 1.1375 +} 1.1376 + 1.1377 +CK_RV NSSDBGC_CreateObject( 1.1378 + CK_SESSION_HANDLE hSession, 1.1379 + CK_ATTRIBUTE_PTR pTemplate, 1.1380 + CK_ULONG ulCount, 1.1381 + CK_OBJECT_HANDLE_PTR phObject 1.1382 +) 1.1383 +{ 1.1384 + COMMON_DEFINITIONS; 1.1385 + 1.1386 + PR_LOG(modlog, 1, ("C_CreateObject")); 1.1387 + log_handle(3, fmt_hSession, hSession); 1.1388 + PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); 1.1389 + PR_LOG(modlog, 3, (fmt_ulCount, ulCount)); 1.1390 + PR_LOG(modlog, 3, (fmt_phObject, phObject)); 1.1391 + print_template(pTemplate, ulCount); 1.1392 + nssdbg_start_time(FUNC_C_CREATEOBJECT,&start); 1.1393 + rv = module_functions->C_CreateObject(hSession, 1.1394 + pTemplate, 1.1395 + ulCount, 1.1396 + phObject); 1.1397 + nssdbg_finish_time(FUNC_C_CREATEOBJECT,start); 1.1398 + log_handle(4, " *phObject = 0x%x", *phObject); 1.1399 + log_rv(rv); 1.1400 + return rv; 1.1401 +} 1.1402 + 1.1403 +CK_RV NSSDBGC_CopyObject( 1.1404 + CK_SESSION_HANDLE hSession, 1.1405 + CK_OBJECT_HANDLE hObject, 1.1406 + CK_ATTRIBUTE_PTR pTemplate, 1.1407 + CK_ULONG ulCount, 1.1408 + CK_OBJECT_HANDLE_PTR phNewObject 1.1409 +) 1.1410 +{ 1.1411 + COMMON_DEFINITIONS; 1.1412 + 1.1413 + PR_LOG(modlog, 1, ("C_CopyObject")); 1.1414 + log_handle(3, fmt_hSession, hSession); 1.1415 + log_handle(3, fmt_hObject, hObject); 1.1416 + PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); 1.1417 + PR_LOG(modlog, 3, (fmt_ulCount, ulCount)); 1.1418 + PR_LOG(modlog, 3, (" phNewObject = 0x%p", phNewObject)); 1.1419 + print_template(pTemplate, ulCount); 1.1420 + nssdbg_start_time(FUNC_C_COPYOBJECT,&start); 1.1421 + rv = module_functions->C_CopyObject(hSession, 1.1422 + hObject, 1.1423 + pTemplate, 1.1424 + ulCount, 1.1425 + phNewObject); 1.1426 + nssdbg_finish_time(FUNC_C_COPYOBJECT,start); 1.1427 + log_handle(4, " *phNewObject = 0x%x", *phNewObject); 1.1428 + log_rv(rv); 1.1429 + return rv; 1.1430 +} 1.1431 + 1.1432 +CK_RV NSSDBGC_DestroyObject( 1.1433 + CK_SESSION_HANDLE hSession, 1.1434 + CK_OBJECT_HANDLE hObject 1.1435 +) 1.1436 +{ 1.1437 + COMMON_DEFINITIONS; 1.1438 + 1.1439 + PR_LOG(modlog, 1, ("C_DestroyObject")); 1.1440 + log_handle(3, fmt_hSession, hSession); 1.1441 + log_handle(3, fmt_hObject, hObject); 1.1442 + nssdbg_start_time(FUNC_C_DESTROYOBJECT,&start); 1.1443 + rv = module_functions->C_DestroyObject(hSession, 1.1444 + hObject); 1.1445 + nssdbg_finish_time(FUNC_C_DESTROYOBJECT,start); 1.1446 + log_rv(rv); 1.1447 + return rv; 1.1448 +} 1.1449 + 1.1450 +CK_RV NSSDBGC_GetObjectSize( 1.1451 + CK_SESSION_HANDLE hSession, 1.1452 + CK_OBJECT_HANDLE hObject, 1.1453 + CK_ULONG_PTR pulSize 1.1454 +) 1.1455 +{ 1.1456 + COMMON_DEFINITIONS; 1.1457 + 1.1458 + PR_LOG(modlog, 1, ("C_GetObjectSize")); 1.1459 + log_handle(3, fmt_hSession, hSession); 1.1460 + log_handle(3, fmt_hObject, hObject); 1.1461 + PR_LOG(modlog, 3, (" pulSize = 0x%p", pulSize)); 1.1462 + nssdbg_start_time(FUNC_C_GETOBJECTSIZE,&start); 1.1463 + rv = module_functions->C_GetObjectSize(hSession, 1.1464 + hObject, 1.1465 + pulSize); 1.1466 + nssdbg_finish_time(FUNC_C_GETOBJECTSIZE,start); 1.1467 + PR_LOG(modlog, 4, (" *pulSize = 0x%x", *pulSize)); 1.1468 + log_rv(rv); 1.1469 + return rv; 1.1470 +} 1.1471 + 1.1472 +CK_RV NSSDBGC_GetAttributeValue( 1.1473 + CK_SESSION_HANDLE hSession, 1.1474 + CK_OBJECT_HANDLE hObject, 1.1475 + CK_ATTRIBUTE_PTR pTemplate, 1.1476 + CK_ULONG ulCount 1.1477 +) 1.1478 +{ 1.1479 + COMMON_DEFINITIONS; 1.1480 + 1.1481 + PR_LOG(modlog, 1, ("C_GetAttributeValue")); 1.1482 + log_handle(3, fmt_hSession, hSession); 1.1483 + log_handle(3, fmt_hObject, hObject); 1.1484 + PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); 1.1485 + PR_LOG(modlog, 3, (fmt_ulCount, ulCount)); 1.1486 + nssdbg_start_time(FUNC_C_GETATTRIBUTEVALUE,&start); 1.1487 + rv = module_functions->C_GetAttributeValue(hSession, 1.1488 + hObject, 1.1489 + pTemplate, 1.1490 + ulCount); 1.1491 + nssdbg_finish_time(FUNC_C_GETATTRIBUTEVALUE,start); 1.1492 + print_template(pTemplate, ulCount); 1.1493 + log_rv(rv); 1.1494 + return rv; 1.1495 +} 1.1496 + 1.1497 +CK_RV NSSDBGC_SetAttributeValue( 1.1498 + CK_SESSION_HANDLE hSession, 1.1499 + CK_OBJECT_HANDLE hObject, 1.1500 + CK_ATTRIBUTE_PTR pTemplate, 1.1501 + CK_ULONG ulCount 1.1502 +) 1.1503 +{ 1.1504 + COMMON_DEFINITIONS; 1.1505 + 1.1506 + PR_LOG(modlog, 1, ("C_SetAttributeValue")); 1.1507 + log_handle(3, fmt_hSession, hSession); 1.1508 + log_handle(3, fmt_hObject, hObject); 1.1509 + PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); 1.1510 + PR_LOG(modlog, 3, (fmt_ulCount, ulCount)); 1.1511 + print_template(pTemplate, ulCount); 1.1512 + nssdbg_start_time(FUNC_C_SETATTRIBUTEVALUE,&start); 1.1513 + rv = module_functions->C_SetAttributeValue(hSession, 1.1514 + hObject, 1.1515 + pTemplate, 1.1516 + ulCount); 1.1517 + nssdbg_finish_time(FUNC_C_SETATTRIBUTEVALUE,start); 1.1518 + log_rv(rv); 1.1519 + return rv; 1.1520 +} 1.1521 + 1.1522 +CK_RV NSSDBGC_FindObjectsInit( 1.1523 + CK_SESSION_HANDLE hSession, 1.1524 + CK_ATTRIBUTE_PTR pTemplate, 1.1525 + CK_ULONG ulCount 1.1526 +) 1.1527 +{ 1.1528 + COMMON_DEFINITIONS; 1.1529 + 1.1530 + PR_LOG(modlog, 1, ("C_FindObjectsInit")); 1.1531 + log_handle(3, fmt_hSession, hSession); 1.1532 + PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); 1.1533 + PR_LOG(modlog, 3, (fmt_ulCount, ulCount)); 1.1534 + print_template(pTemplate, ulCount); 1.1535 + nssdbg_start_time(FUNC_C_FINDOBJECTSINIT,&start); 1.1536 + rv = module_functions->C_FindObjectsInit(hSession, 1.1537 + pTemplate, 1.1538 + ulCount); 1.1539 + nssdbg_finish_time(FUNC_C_FINDOBJECTSINIT,start); 1.1540 + log_rv(rv); 1.1541 + return rv; 1.1542 +} 1.1543 + 1.1544 +CK_RV NSSDBGC_FindObjects( 1.1545 + CK_SESSION_HANDLE hSession, 1.1546 + CK_OBJECT_HANDLE_PTR phObject, 1.1547 + CK_ULONG ulMaxObjectCount, 1.1548 + CK_ULONG_PTR pulObjectCount 1.1549 +) 1.1550 +{ 1.1551 + COMMON_DEFINITIONS; 1.1552 + CK_ULONG i; 1.1553 + 1.1554 + PR_LOG(modlog, 1, ("C_FindObjects")); 1.1555 + log_handle(3, fmt_hSession, hSession); 1.1556 + PR_LOG(modlog, 3, (fmt_phObject, phObject)); 1.1557 + PR_LOG(modlog, 3, (" ulMaxObjectCount = %d", ulMaxObjectCount)); 1.1558 + PR_LOG(modlog, 3, (" pulObjectCount = 0x%p", pulObjectCount)); 1.1559 + nssdbg_start_time(FUNC_C_FINDOBJECTS,&start); 1.1560 + rv = module_functions->C_FindObjects(hSession, 1.1561 + phObject, 1.1562 + ulMaxObjectCount, 1.1563 + pulObjectCount); 1.1564 + nssdbg_finish_time(FUNC_C_FINDOBJECTS,start); 1.1565 + PR_LOG(modlog, 4, (" *pulObjectCount = 0x%x", *pulObjectCount)); 1.1566 + for (i=0; i<*pulObjectCount; i++) { 1.1567 + PR_LOG(modlog, 4, (" phObject[%d] = 0x%x%s", i, phObject[i], 1.1568 + phObject[i] ? "" : fmt_invalid_handle)); 1.1569 + } 1.1570 + log_rv(rv); 1.1571 + return rv; 1.1572 +} 1.1573 + 1.1574 +CK_RV NSSDBGC_FindObjectsFinal( 1.1575 + CK_SESSION_HANDLE hSession 1.1576 +) 1.1577 +{ 1.1578 + COMMON_DEFINITIONS; 1.1579 + 1.1580 + PR_LOG(modlog, 1, ("C_FindObjectsFinal")); 1.1581 + log_handle(3, fmt_hSession, hSession); 1.1582 + nssdbg_start_time(FUNC_C_FINDOBJECTSFINAL,&start); 1.1583 + rv = module_functions->C_FindObjectsFinal(hSession); 1.1584 + nssdbg_finish_time(FUNC_C_FINDOBJECTSFINAL,start); 1.1585 + log_rv(rv); 1.1586 + return rv; 1.1587 +} 1.1588 + 1.1589 +CK_RV NSSDBGC_EncryptInit( 1.1590 + CK_SESSION_HANDLE hSession, 1.1591 + CK_MECHANISM_PTR pMechanism, 1.1592 + CK_OBJECT_HANDLE hKey 1.1593 +) 1.1594 +{ 1.1595 + COMMON_DEFINITIONS; 1.1596 + 1.1597 + PR_LOG(modlog, 1, ("C_EncryptInit")); 1.1598 + log_handle(3, fmt_hSession, hSession); 1.1599 + PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); 1.1600 + log_handle(3, fmt_hKey, hKey); 1.1601 + print_mechanism(pMechanism); 1.1602 + nssdbg_start_time(FUNC_C_ENCRYPTINIT,&start); 1.1603 + rv = module_functions->C_EncryptInit(hSession, 1.1604 + pMechanism, 1.1605 + hKey); 1.1606 + nssdbg_finish_time(FUNC_C_ENCRYPTINIT,start); 1.1607 + log_rv(rv); 1.1608 + return rv; 1.1609 +} 1.1610 + 1.1611 +CK_RV NSSDBGC_Encrypt( 1.1612 + CK_SESSION_HANDLE hSession, 1.1613 + CK_BYTE_PTR pData, 1.1614 + CK_ULONG ulDataLen, 1.1615 + CK_BYTE_PTR pEncryptedData, 1.1616 + CK_ULONG_PTR pulEncryptedDataLen 1.1617 +) 1.1618 +{ 1.1619 + COMMON_DEFINITIONS; 1.1620 + 1.1621 + PR_LOG(modlog, 1, ("C_Encrypt")); 1.1622 + log_handle(3, fmt_hSession, hSession); 1.1623 + PR_LOG(modlog, 3, (fmt_pData, pData)); 1.1624 + PR_LOG(modlog, 3, (fmt_ulDataLen, ulDataLen)); 1.1625 + PR_LOG(modlog, 3, (fmt_pEncryptedData, pEncryptedData)); 1.1626 + PR_LOG(modlog, 3, (" pulEncryptedDataLen = 0x%p", pulEncryptedDataLen)); 1.1627 + nssdbg_start_time(FUNC_C_ENCRYPT,&start); 1.1628 + rv = module_functions->C_Encrypt(hSession, 1.1629 + pData, 1.1630 + ulDataLen, 1.1631 + pEncryptedData, 1.1632 + pulEncryptedDataLen); 1.1633 + nssdbg_finish_time(FUNC_C_ENCRYPT,start); 1.1634 + PR_LOG(modlog, 4, (" *pulEncryptedDataLen = 0x%x", *pulEncryptedDataLen)); 1.1635 + log_rv(rv); 1.1636 + return rv; 1.1637 +} 1.1638 + 1.1639 +CK_RV NSSDBGC_EncryptUpdate( 1.1640 + CK_SESSION_HANDLE hSession, 1.1641 + CK_BYTE_PTR pPart, 1.1642 + CK_ULONG ulPartLen, 1.1643 + CK_BYTE_PTR pEncryptedPart, 1.1644 + CK_ULONG_PTR pulEncryptedPartLen 1.1645 +) 1.1646 +{ 1.1647 + COMMON_DEFINITIONS; 1.1648 + 1.1649 + PR_LOG(modlog, 1, ("C_EncryptUpdate")); 1.1650 + log_handle(3, fmt_hSession, hSession); 1.1651 + PR_LOG(modlog, 3, (fmt_pPart, pPart)); 1.1652 + PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen)); 1.1653 + PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart)); 1.1654 + PR_LOG(modlog, 3, (fmt_pulEncryptedPartLen, pulEncryptedPartLen)); 1.1655 + nssdbg_start_time(FUNC_C_ENCRYPTUPDATE,&start); 1.1656 + rv = module_functions->C_EncryptUpdate(hSession, 1.1657 + pPart, 1.1658 + ulPartLen, 1.1659 + pEncryptedPart, 1.1660 + pulEncryptedPartLen); 1.1661 + nssdbg_finish_time(FUNC_C_ENCRYPTUPDATE,start); 1.1662 + PR_LOG(modlog, 4, (fmt_spulEncryptedPartLen, *pulEncryptedPartLen)); 1.1663 + log_rv(rv); 1.1664 + return rv; 1.1665 +} 1.1666 + 1.1667 +CK_RV NSSDBGC_EncryptFinal( 1.1668 + CK_SESSION_HANDLE hSession, 1.1669 + CK_BYTE_PTR pLastEncryptedPart, 1.1670 + CK_ULONG_PTR pulLastEncryptedPartLen 1.1671 +) 1.1672 +{ 1.1673 + COMMON_DEFINITIONS; 1.1674 + 1.1675 + PR_LOG(modlog, 1, ("C_EncryptFinal")); 1.1676 + log_handle(3, fmt_hSession, hSession); 1.1677 + PR_LOG(modlog, 3, (" pLastEncryptedPart = 0x%p", pLastEncryptedPart)); 1.1678 + PR_LOG(modlog, 3, (" pulLastEncryptedPartLen = 0x%p", pulLastEncryptedPartLen)); 1.1679 + nssdbg_start_time(FUNC_C_ENCRYPTFINAL,&start); 1.1680 + rv = module_functions->C_EncryptFinal(hSession, 1.1681 + pLastEncryptedPart, 1.1682 + pulLastEncryptedPartLen); 1.1683 + nssdbg_finish_time(FUNC_C_ENCRYPTFINAL,start); 1.1684 + PR_LOG(modlog, 4, (" *pulLastEncryptedPartLen = 0x%x", *pulLastEncryptedPartLen)); 1.1685 + log_rv(rv); 1.1686 + return rv; 1.1687 +} 1.1688 + 1.1689 +CK_RV NSSDBGC_DecryptInit( 1.1690 + CK_SESSION_HANDLE hSession, 1.1691 + CK_MECHANISM_PTR pMechanism, 1.1692 + CK_OBJECT_HANDLE hKey 1.1693 +) 1.1694 +{ 1.1695 + COMMON_DEFINITIONS; 1.1696 + 1.1697 + PR_LOG(modlog, 1, ("C_DecryptInit")); 1.1698 + log_handle(3, fmt_hSession, hSession); 1.1699 + PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); 1.1700 + log_handle(3, fmt_hKey, hKey); 1.1701 + print_mechanism(pMechanism); 1.1702 + nssdbg_start_time(FUNC_C_DECRYPTINIT,&start); 1.1703 + rv = module_functions->C_DecryptInit(hSession, 1.1704 + pMechanism, 1.1705 + hKey); 1.1706 + nssdbg_finish_time(FUNC_C_DECRYPTINIT,start); 1.1707 + log_rv(rv); 1.1708 + return rv; 1.1709 +} 1.1710 + 1.1711 +CK_RV NSSDBGC_Decrypt( 1.1712 + CK_SESSION_HANDLE hSession, 1.1713 + CK_BYTE_PTR pEncryptedData, 1.1714 + CK_ULONG ulEncryptedDataLen, 1.1715 + CK_BYTE_PTR pData, 1.1716 + CK_ULONG_PTR pulDataLen 1.1717 +) 1.1718 +{ 1.1719 + COMMON_DEFINITIONS; 1.1720 + 1.1721 + PR_LOG(modlog, 1, ("C_Decrypt")); 1.1722 + log_handle(3, fmt_hSession, hSession); 1.1723 + PR_LOG(modlog, 3, (fmt_pEncryptedData, pEncryptedData)); 1.1724 + PR_LOG(modlog, 3, (" ulEncryptedDataLen = %d", ulEncryptedDataLen)); 1.1725 + PR_LOG(modlog, 3, (fmt_pData, pData)); 1.1726 + PR_LOG(modlog, 3, (fmt_pulDataLen, pulDataLen)); 1.1727 + nssdbg_start_time(FUNC_C_DECRYPT,&start); 1.1728 + rv = module_functions->C_Decrypt(hSession, 1.1729 + pEncryptedData, 1.1730 + ulEncryptedDataLen, 1.1731 + pData, 1.1732 + pulDataLen); 1.1733 + nssdbg_finish_time(FUNC_C_DECRYPT,start); 1.1734 + PR_LOG(modlog, 4, (fmt_spulDataLen, *pulDataLen)); 1.1735 + log_rv(rv); 1.1736 + return rv; 1.1737 +} 1.1738 + 1.1739 +CK_RV NSSDBGC_DecryptUpdate( 1.1740 + CK_SESSION_HANDLE hSession, 1.1741 + CK_BYTE_PTR pEncryptedPart, 1.1742 + CK_ULONG ulEncryptedPartLen, 1.1743 + CK_BYTE_PTR pPart, 1.1744 + CK_ULONG_PTR pulPartLen 1.1745 +) 1.1746 +{ 1.1747 + COMMON_DEFINITIONS; 1.1748 + 1.1749 + PR_LOG(modlog, 1, ("C_DecryptUpdate")); 1.1750 + log_handle(3, fmt_hSession, hSession); 1.1751 + PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart)); 1.1752 + PR_LOG(modlog, 3, (fmt_ulEncryptedPartLen, ulEncryptedPartLen)); 1.1753 + PR_LOG(modlog, 3, (fmt_pPart, pPart)); 1.1754 + PR_LOG(modlog, 3, (fmt_pulPartLen, pulPartLen)); 1.1755 + nssdbg_start_time(FUNC_C_DECRYPTUPDATE,&start); 1.1756 + rv = module_functions->C_DecryptUpdate(hSession, 1.1757 + pEncryptedPart, 1.1758 + ulEncryptedPartLen, 1.1759 + pPart, 1.1760 + pulPartLen); 1.1761 + nssdbg_finish_time(FUNC_C_DECRYPTUPDATE,start); 1.1762 + PR_LOG(modlog, 4, (fmt_spulPartLen, *pulPartLen)); 1.1763 + log_rv(rv); 1.1764 + return rv; 1.1765 +} 1.1766 + 1.1767 +CK_RV NSSDBGC_DecryptFinal( 1.1768 + CK_SESSION_HANDLE hSession, 1.1769 + CK_BYTE_PTR pLastPart, 1.1770 + CK_ULONG_PTR pulLastPartLen 1.1771 +) 1.1772 +{ 1.1773 + COMMON_DEFINITIONS; 1.1774 + 1.1775 + PR_LOG(modlog, 1, ("C_DecryptFinal")); 1.1776 + log_handle(3, fmt_hSession, hSession); 1.1777 + PR_LOG(modlog, 3, (" pLastPart = 0x%p", pLastPart)); 1.1778 + PR_LOG(modlog, 3, (" pulLastPartLen = 0x%p", pulLastPartLen)); 1.1779 + nssdbg_start_time(FUNC_C_DECRYPTFINAL,&start); 1.1780 + rv = module_functions->C_DecryptFinal(hSession, 1.1781 + pLastPart, 1.1782 + pulLastPartLen); 1.1783 + nssdbg_finish_time(FUNC_C_DECRYPTFINAL,start); 1.1784 + PR_LOG(modlog, 4, (" *pulLastPartLen = 0x%x", *pulLastPartLen)); 1.1785 + log_rv(rv); 1.1786 + return rv; 1.1787 +} 1.1788 + 1.1789 +CK_RV NSSDBGC_DigestInit( 1.1790 + CK_SESSION_HANDLE hSession, 1.1791 + CK_MECHANISM_PTR pMechanism 1.1792 +) 1.1793 +{ 1.1794 + COMMON_DEFINITIONS; 1.1795 + 1.1796 + PR_LOG(modlog, 1, ("C_DigestInit")); 1.1797 + log_handle(3, fmt_hSession, hSession); 1.1798 + PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); 1.1799 + print_mechanism(pMechanism); 1.1800 + nssdbg_start_time(FUNC_C_DIGESTINIT,&start); 1.1801 + rv = module_functions->C_DigestInit(hSession, 1.1802 + pMechanism); 1.1803 + nssdbg_finish_time(FUNC_C_DIGESTINIT,start); 1.1804 + log_rv(rv); 1.1805 + return rv; 1.1806 +} 1.1807 + 1.1808 +CK_RV NSSDBGC_Digest( 1.1809 + CK_SESSION_HANDLE hSession, 1.1810 + CK_BYTE_PTR pData, 1.1811 + CK_ULONG ulDataLen, 1.1812 + CK_BYTE_PTR pDigest, 1.1813 + CK_ULONG_PTR pulDigestLen 1.1814 +) 1.1815 +{ 1.1816 + COMMON_DEFINITIONS; 1.1817 + 1.1818 + PR_LOG(modlog, 1, ("C_Digest")); 1.1819 + log_handle(3, fmt_hSession, hSession); 1.1820 + PR_LOG(modlog, 3, (fmt_pData, pData)); 1.1821 + PR_LOG(modlog, 3, (fmt_ulDataLen, ulDataLen)); 1.1822 + PR_LOG(modlog, 3, (fmt_pDigest, pDigest)); 1.1823 + PR_LOG(modlog, 3, (fmt_pulDigestLen, pulDigestLen)); 1.1824 + nssdbg_start_time(FUNC_C_DIGEST,&start); 1.1825 + rv = module_functions->C_Digest(hSession, 1.1826 + pData, 1.1827 + ulDataLen, 1.1828 + pDigest, 1.1829 + pulDigestLen); 1.1830 + nssdbg_finish_time(FUNC_C_DIGEST,start); 1.1831 + PR_LOG(modlog, 4, (fmt_spulDigestLen, *pulDigestLen)); 1.1832 + log_rv(rv); 1.1833 + return rv; 1.1834 +} 1.1835 + 1.1836 +CK_RV NSSDBGC_DigestUpdate( 1.1837 + CK_SESSION_HANDLE hSession, 1.1838 + CK_BYTE_PTR pPart, 1.1839 + CK_ULONG ulPartLen 1.1840 +) 1.1841 +{ 1.1842 + COMMON_DEFINITIONS; 1.1843 + 1.1844 + PR_LOG(modlog, 1, ("C_DigestUpdate")); 1.1845 + log_handle(3, fmt_hSession, hSession); 1.1846 + PR_LOG(modlog, 3, (fmt_pPart, pPart)); 1.1847 + PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen)); 1.1848 + nssdbg_start_time(FUNC_C_DIGESTUPDATE,&start); 1.1849 + rv = module_functions->C_DigestUpdate(hSession, 1.1850 + pPart, 1.1851 + ulPartLen); 1.1852 + nssdbg_finish_time(FUNC_C_DIGESTUPDATE,start); 1.1853 + log_rv(rv); 1.1854 + return rv; 1.1855 +} 1.1856 + 1.1857 +CK_RV NSSDBGC_DigestKey( 1.1858 + CK_SESSION_HANDLE hSession, 1.1859 + CK_OBJECT_HANDLE hKey 1.1860 +) 1.1861 +{ 1.1862 + COMMON_DEFINITIONS; 1.1863 + 1.1864 + PR_LOG(modlog, 1, ("C_DigestKey")); 1.1865 + log_handle(3, fmt_hSession, hSession); 1.1866 + nssdbg_start_time(FUNC_C_DIGESTKEY,&start); 1.1867 + rv = module_functions->C_DigestKey(hSession, 1.1868 + hKey); 1.1869 + nssdbg_finish_time(FUNC_C_DIGESTKEY,start); 1.1870 + log_rv(rv); 1.1871 + return rv; 1.1872 +} 1.1873 + 1.1874 +CK_RV NSSDBGC_DigestFinal( 1.1875 + CK_SESSION_HANDLE hSession, 1.1876 + CK_BYTE_PTR pDigest, 1.1877 + CK_ULONG_PTR pulDigestLen 1.1878 +) 1.1879 +{ 1.1880 + COMMON_DEFINITIONS; 1.1881 + 1.1882 + PR_LOG(modlog, 1, ("C_DigestFinal")); 1.1883 + log_handle(3, fmt_hSession, hSession); 1.1884 + PR_LOG(modlog, 3, (fmt_pDigest, pDigest)); 1.1885 + PR_LOG(modlog, 3, (fmt_pulDigestLen, pulDigestLen)); 1.1886 + nssdbg_start_time(FUNC_C_DIGESTFINAL,&start); 1.1887 + rv = module_functions->C_DigestFinal(hSession, 1.1888 + pDigest, 1.1889 + pulDigestLen); 1.1890 + nssdbg_finish_time(FUNC_C_DIGESTFINAL,start); 1.1891 + PR_LOG(modlog, 4, (fmt_spulDigestLen, *pulDigestLen)); 1.1892 + log_rv(rv); 1.1893 + return rv; 1.1894 +} 1.1895 + 1.1896 +CK_RV NSSDBGC_SignInit( 1.1897 + CK_SESSION_HANDLE hSession, 1.1898 + CK_MECHANISM_PTR pMechanism, 1.1899 + CK_OBJECT_HANDLE hKey 1.1900 +) 1.1901 +{ 1.1902 + COMMON_DEFINITIONS; 1.1903 + 1.1904 + PR_LOG(modlog, 1, ("C_SignInit")); 1.1905 + log_handle(3, fmt_hSession, hSession); 1.1906 + PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); 1.1907 + log_handle(3, fmt_hKey, hKey); 1.1908 + print_mechanism(pMechanism); 1.1909 + nssdbg_start_time(FUNC_C_SIGNINIT,&start); 1.1910 + rv = module_functions->C_SignInit(hSession, 1.1911 + pMechanism, 1.1912 + hKey); 1.1913 + nssdbg_finish_time(FUNC_C_SIGNINIT,start); 1.1914 + log_rv(rv); 1.1915 + return rv; 1.1916 +} 1.1917 + 1.1918 +CK_RV NSSDBGC_Sign( 1.1919 + CK_SESSION_HANDLE hSession, 1.1920 + CK_BYTE_PTR pData, 1.1921 + CK_ULONG ulDataLen, 1.1922 + CK_BYTE_PTR pSignature, 1.1923 + CK_ULONG_PTR pulSignatureLen 1.1924 +) 1.1925 +{ 1.1926 + COMMON_DEFINITIONS; 1.1927 + 1.1928 + PR_LOG(modlog, 1, ("C_Sign")); 1.1929 + log_handle(3, fmt_hSession, hSession); 1.1930 + PR_LOG(modlog, 3, (fmt_pData, pData)); 1.1931 + PR_LOG(modlog, 3, (fmt_ulDataLen, ulDataLen)); 1.1932 + PR_LOG(modlog, 3, (fmt_pSignature, pSignature)); 1.1933 + PR_LOG(modlog, 3, (fmt_pulSignatureLen, pulSignatureLen)); 1.1934 + nssdbg_start_time(FUNC_C_SIGN,&start); 1.1935 + rv = module_functions->C_Sign(hSession, 1.1936 + pData, 1.1937 + ulDataLen, 1.1938 + pSignature, 1.1939 + pulSignatureLen); 1.1940 + nssdbg_finish_time(FUNC_C_SIGN,start); 1.1941 + PR_LOG(modlog, 4, (fmt_spulSignatureLen, *pulSignatureLen)); 1.1942 + log_rv(rv); 1.1943 + return rv; 1.1944 +} 1.1945 + 1.1946 +CK_RV NSSDBGC_SignUpdate( 1.1947 + CK_SESSION_HANDLE hSession, 1.1948 + CK_BYTE_PTR pPart, 1.1949 + CK_ULONG ulPartLen 1.1950 +) 1.1951 +{ 1.1952 + COMMON_DEFINITIONS; 1.1953 + 1.1954 + PR_LOG(modlog, 1, ("C_SignUpdate")); 1.1955 + log_handle(3, fmt_hSession, hSession); 1.1956 + PR_LOG(modlog, 3, (fmt_pPart, pPart)); 1.1957 + PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen)); 1.1958 + nssdbg_start_time(FUNC_C_SIGNUPDATE,&start); 1.1959 + rv = module_functions->C_SignUpdate(hSession, 1.1960 + pPart, 1.1961 + ulPartLen); 1.1962 + nssdbg_finish_time(FUNC_C_SIGNUPDATE,start); 1.1963 + log_rv(rv); 1.1964 + return rv; 1.1965 +} 1.1966 + 1.1967 +CK_RV NSSDBGC_SignFinal( 1.1968 + CK_SESSION_HANDLE hSession, 1.1969 + CK_BYTE_PTR pSignature, 1.1970 + CK_ULONG_PTR pulSignatureLen 1.1971 +) 1.1972 +{ 1.1973 + COMMON_DEFINITIONS; 1.1974 + 1.1975 + PR_LOG(modlog, 1, ("C_SignFinal")); 1.1976 + log_handle(3, fmt_hSession, hSession); 1.1977 + PR_LOG(modlog, 3, (fmt_pSignature, pSignature)); 1.1978 + PR_LOG(modlog, 3, (fmt_pulSignatureLen, pulSignatureLen)); 1.1979 + nssdbg_start_time(FUNC_C_SIGNFINAL,&start); 1.1980 + rv = module_functions->C_SignFinal(hSession, 1.1981 + pSignature, 1.1982 + pulSignatureLen); 1.1983 + nssdbg_finish_time(FUNC_C_SIGNFINAL,start); 1.1984 + PR_LOG(modlog, 4, (fmt_spulSignatureLen, *pulSignatureLen)); 1.1985 + log_rv(rv); 1.1986 + return rv; 1.1987 +} 1.1988 + 1.1989 +CK_RV NSSDBGC_SignRecoverInit( 1.1990 + CK_SESSION_HANDLE hSession, 1.1991 + CK_MECHANISM_PTR pMechanism, 1.1992 + CK_OBJECT_HANDLE hKey 1.1993 +) 1.1994 +{ 1.1995 + COMMON_DEFINITIONS; 1.1996 + 1.1997 + PR_LOG(modlog, 1, ("C_SignRecoverInit")); 1.1998 + log_handle(3, fmt_hSession, hSession); 1.1999 + PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); 1.2000 + log_handle(3, fmt_hKey, hKey); 1.2001 + print_mechanism(pMechanism); 1.2002 + nssdbg_start_time(FUNC_C_SIGNRECOVERINIT,&start); 1.2003 + rv = module_functions->C_SignRecoverInit(hSession, 1.2004 + pMechanism, 1.2005 + hKey); 1.2006 + nssdbg_finish_time(FUNC_C_SIGNRECOVERINIT,start); 1.2007 + log_rv(rv); 1.2008 + return rv; 1.2009 +} 1.2010 + 1.2011 +CK_RV NSSDBGC_SignRecover( 1.2012 + CK_SESSION_HANDLE hSession, 1.2013 + CK_BYTE_PTR pData, 1.2014 + CK_ULONG ulDataLen, 1.2015 + CK_BYTE_PTR pSignature, 1.2016 + CK_ULONG_PTR pulSignatureLen 1.2017 +) 1.2018 +{ 1.2019 + COMMON_DEFINITIONS; 1.2020 + 1.2021 + PR_LOG(modlog, 1, ("C_SignRecover")); 1.2022 + log_handle(3, fmt_hSession, hSession); 1.2023 + PR_LOG(modlog, 3, (fmt_pData, pData)); 1.2024 + PR_LOG(modlog, 3, (fmt_ulDataLen, ulDataLen)); 1.2025 + PR_LOG(modlog, 3, (fmt_pSignature, pSignature)); 1.2026 + PR_LOG(modlog, 3, (fmt_pulSignatureLen, pulSignatureLen)); 1.2027 + nssdbg_start_time(FUNC_C_SIGNRECOVER,&start); 1.2028 + rv = module_functions->C_SignRecover(hSession, 1.2029 + pData, 1.2030 + ulDataLen, 1.2031 + pSignature, 1.2032 + pulSignatureLen); 1.2033 + nssdbg_finish_time(FUNC_C_SIGNRECOVER,start); 1.2034 + PR_LOG(modlog, 4, (fmt_spulSignatureLen, *pulSignatureLen)); 1.2035 + log_rv(rv); 1.2036 + return rv; 1.2037 +} 1.2038 + 1.2039 +CK_RV NSSDBGC_VerifyInit( 1.2040 + CK_SESSION_HANDLE hSession, 1.2041 + CK_MECHANISM_PTR pMechanism, 1.2042 + CK_OBJECT_HANDLE hKey 1.2043 +) 1.2044 +{ 1.2045 + COMMON_DEFINITIONS; 1.2046 + 1.2047 + PR_LOG(modlog, 1, ("C_VerifyInit")); 1.2048 + log_handle(3, fmt_hSession, hSession); 1.2049 + PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); 1.2050 + log_handle(3, fmt_hKey, hKey); 1.2051 + print_mechanism(pMechanism); 1.2052 + nssdbg_start_time(FUNC_C_VERIFYINIT,&start); 1.2053 + rv = module_functions->C_VerifyInit(hSession, 1.2054 + pMechanism, 1.2055 + hKey); 1.2056 + nssdbg_finish_time(FUNC_C_VERIFYINIT,start); 1.2057 + log_rv(rv); 1.2058 + return rv; 1.2059 +} 1.2060 + 1.2061 +CK_RV NSSDBGC_Verify( 1.2062 + CK_SESSION_HANDLE hSession, 1.2063 + CK_BYTE_PTR pData, 1.2064 + CK_ULONG ulDataLen, 1.2065 + CK_BYTE_PTR pSignature, 1.2066 + CK_ULONG ulSignatureLen 1.2067 +) 1.2068 +{ 1.2069 + COMMON_DEFINITIONS; 1.2070 + 1.2071 + PR_LOG(modlog, 1, ("C_Verify")); 1.2072 + log_handle(3, fmt_hSession, hSession); 1.2073 + PR_LOG(modlog, 3, (fmt_pData, pData)); 1.2074 + PR_LOG(modlog, 3, (fmt_ulDataLen, ulDataLen)); 1.2075 + PR_LOG(modlog, 3, (fmt_pSignature, pSignature)); 1.2076 + PR_LOG(modlog, 3, (fmt_ulSignatureLen, ulSignatureLen)); 1.2077 + nssdbg_start_time(FUNC_C_VERIFY,&start); 1.2078 + rv = module_functions->C_Verify(hSession, 1.2079 + pData, 1.2080 + ulDataLen, 1.2081 + pSignature, 1.2082 + ulSignatureLen); 1.2083 + nssdbg_finish_time(FUNC_C_VERIFY,start); 1.2084 + log_rv(rv); 1.2085 + return rv; 1.2086 +} 1.2087 + 1.2088 +CK_RV NSSDBGC_VerifyUpdate( 1.2089 + CK_SESSION_HANDLE hSession, 1.2090 + CK_BYTE_PTR pPart, 1.2091 + CK_ULONG ulPartLen 1.2092 +) 1.2093 +{ 1.2094 + COMMON_DEFINITIONS; 1.2095 + 1.2096 + PR_LOG(modlog, 1, ("C_VerifyUpdate")); 1.2097 + log_handle(3, fmt_hSession, hSession); 1.2098 + PR_LOG(modlog, 3, (fmt_pPart, pPart)); 1.2099 + PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen)); 1.2100 + nssdbg_start_time(FUNC_C_VERIFYUPDATE,&start); 1.2101 + rv = module_functions->C_VerifyUpdate(hSession, 1.2102 + pPart, 1.2103 + ulPartLen); 1.2104 + nssdbg_finish_time(FUNC_C_VERIFYUPDATE,start); 1.2105 + log_rv(rv); 1.2106 + return rv; 1.2107 +} 1.2108 + 1.2109 +CK_RV NSSDBGC_VerifyFinal( 1.2110 + CK_SESSION_HANDLE hSession, 1.2111 + CK_BYTE_PTR pSignature, 1.2112 + CK_ULONG ulSignatureLen 1.2113 +) 1.2114 +{ 1.2115 + COMMON_DEFINITIONS; 1.2116 + 1.2117 + PR_LOG(modlog, 1, ("C_VerifyFinal")); 1.2118 + log_handle(3, fmt_hSession, hSession); 1.2119 + PR_LOG(modlog, 3, (fmt_pSignature, pSignature)); 1.2120 + PR_LOG(modlog, 3, (fmt_ulSignatureLen, ulSignatureLen)); 1.2121 + nssdbg_start_time(FUNC_C_VERIFYFINAL,&start); 1.2122 + rv = module_functions->C_VerifyFinal(hSession, 1.2123 + pSignature, 1.2124 + ulSignatureLen); 1.2125 + nssdbg_finish_time(FUNC_C_VERIFYFINAL,start); 1.2126 + log_rv(rv); 1.2127 + return rv; 1.2128 +} 1.2129 + 1.2130 +CK_RV NSSDBGC_VerifyRecoverInit( 1.2131 + CK_SESSION_HANDLE hSession, 1.2132 + CK_MECHANISM_PTR pMechanism, 1.2133 + CK_OBJECT_HANDLE hKey 1.2134 +) 1.2135 +{ 1.2136 + COMMON_DEFINITIONS; 1.2137 + 1.2138 + PR_LOG(modlog, 1, ("C_VerifyRecoverInit")); 1.2139 + log_handle(3, fmt_hSession, hSession); 1.2140 + PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); 1.2141 + log_handle(3, fmt_hKey, hKey); 1.2142 + print_mechanism(pMechanism); 1.2143 + nssdbg_start_time(FUNC_C_VERIFYRECOVERINIT,&start); 1.2144 + rv = module_functions->C_VerifyRecoverInit(hSession, 1.2145 + pMechanism, 1.2146 + hKey); 1.2147 + nssdbg_finish_time(FUNC_C_VERIFYRECOVERINIT,start); 1.2148 + log_rv(rv); 1.2149 + return rv; 1.2150 +} 1.2151 + 1.2152 +CK_RV NSSDBGC_VerifyRecover( 1.2153 + CK_SESSION_HANDLE hSession, 1.2154 + CK_BYTE_PTR pSignature, 1.2155 + CK_ULONG ulSignatureLen, 1.2156 + CK_BYTE_PTR pData, 1.2157 + CK_ULONG_PTR pulDataLen 1.2158 +) 1.2159 +{ 1.2160 + COMMON_DEFINITIONS; 1.2161 + 1.2162 + PR_LOG(modlog, 1, ("C_VerifyRecover")); 1.2163 + log_handle(3, fmt_hSession, hSession); 1.2164 + PR_LOG(modlog, 3, (fmt_pSignature, pSignature)); 1.2165 + PR_LOG(modlog, 3, (fmt_ulSignatureLen, ulSignatureLen)); 1.2166 + PR_LOG(modlog, 3, (fmt_pData, pData)); 1.2167 + PR_LOG(modlog, 3, (fmt_pulDataLen, pulDataLen)); 1.2168 + nssdbg_start_time(FUNC_C_VERIFYRECOVER,&start); 1.2169 + rv = module_functions->C_VerifyRecover(hSession, 1.2170 + pSignature, 1.2171 + ulSignatureLen, 1.2172 + pData, 1.2173 + pulDataLen); 1.2174 + nssdbg_finish_time(FUNC_C_VERIFYRECOVER,start); 1.2175 + PR_LOG(modlog, 4, (fmt_spulDataLen, *pulDataLen)); 1.2176 + log_rv(rv); 1.2177 + return rv; 1.2178 +} 1.2179 + 1.2180 +CK_RV NSSDBGC_DigestEncryptUpdate( 1.2181 + CK_SESSION_HANDLE hSession, 1.2182 + CK_BYTE_PTR pPart, 1.2183 + CK_ULONG ulPartLen, 1.2184 + CK_BYTE_PTR pEncryptedPart, 1.2185 + CK_ULONG_PTR pulEncryptedPartLen 1.2186 +) 1.2187 +{ 1.2188 + COMMON_DEFINITIONS; 1.2189 + 1.2190 + PR_LOG(modlog, 1, ("C_DigestEncryptUpdate")); 1.2191 + log_handle(3, fmt_hSession, hSession); 1.2192 + PR_LOG(modlog, 3, (fmt_pPart, pPart)); 1.2193 + PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen)); 1.2194 + PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart)); 1.2195 + PR_LOG(modlog, 3, (fmt_pulEncryptedPartLen, pulEncryptedPartLen)); 1.2196 + nssdbg_start_time(FUNC_C_DIGESTENCRYPTUPDATE,&start); 1.2197 + rv = module_functions->C_DigestEncryptUpdate(hSession, 1.2198 + pPart, 1.2199 + ulPartLen, 1.2200 + pEncryptedPart, 1.2201 + pulEncryptedPartLen); 1.2202 + nssdbg_finish_time(FUNC_C_DIGESTENCRYPTUPDATE,start); 1.2203 + PR_LOG(modlog, 4, (fmt_spulEncryptedPartLen, *pulEncryptedPartLen)); 1.2204 + log_rv(rv); 1.2205 + return rv; 1.2206 +} 1.2207 + 1.2208 +CK_RV NSSDBGC_DecryptDigestUpdate( 1.2209 + CK_SESSION_HANDLE hSession, 1.2210 + CK_BYTE_PTR pEncryptedPart, 1.2211 + CK_ULONG ulEncryptedPartLen, 1.2212 + CK_BYTE_PTR pPart, 1.2213 + CK_ULONG_PTR pulPartLen 1.2214 +) 1.2215 +{ 1.2216 + COMMON_DEFINITIONS; 1.2217 + 1.2218 + PR_LOG(modlog, 1, ("C_DecryptDigestUpdate")); 1.2219 + log_handle(3, fmt_hSession, hSession); 1.2220 + PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart)); 1.2221 + PR_LOG(modlog, 3, (fmt_ulEncryptedPartLen, ulEncryptedPartLen)); 1.2222 + PR_LOG(modlog, 3, (fmt_pPart, pPart)); 1.2223 + PR_LOG(modlog, 3, (fmt_pulPartLen, pulPartLen)); 1.2224 + nssdbg_start_time(FUNC_C_DECRYPTDIGESTUPDATE,&start); 1.2225 + rv = module_functions->C_DecryptDigestUpdate(hSession, 1.2226 + pEncryptedPart, 1.2227 + ulEncryptedPartLen, 1.2228 + pPart, 1.2229 + pulPartLen); 1.2230 + nssdbg_finish_time(FUNC_C_DECRYPTDIGESTUPDATE,start); 1.2231 + PR_LOG(modlog, 4, (fmt_spulPartLen, *pulPartLen)); 1.2232 + log_rv(rv); 1.2233 + return rv; 1.2234 +} 1.2235 + 1.2236 +CK_RV NSSDBGC_SignEncryptUpdate( 1.2237 + CK_SESSION_HANDLE hSession, 1.2238 + CK_BYTE_PTR pPart, 1.2239 + CK_ULONG ulPartLen, 1.2240 + CK_BYTE_PTR pEncryptedPart, 1.2241 + CK_ULONG_PTR pulEncryptedPartLen 1.2242 +) 1.2243 +{ 1.2244 + COMMON_DEFINITIONS; 1.2245 + 1.2246 + PR_LOG(modlog, 1, ("C_SignEncryptUpdate")); 1.2247 + log_handle(3, fmt_hSession, hSession); 1.2248 + PR_LOG(modlog, 3, (fmt_pPart, pPart)); 1.2249 + PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen)); 1.2250 + PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart)); 1.2251 + PR_LOG(modlog, 3, (fmt_pulEncryptedPartLen, pulEncryptedPartLen)); 1.2252 + nssdbg_start_time(FUNC_C_SIGNENCRYPTUPDATE,&start); 1.2253 + rv = module_functions->C_SignEncryptUpdate(hSession, 1.2254 + pPart, 1.2255 + ulPartLen, 1.2256 + pEncryptedPart, 1.2257 + pulEncryptedPartLen); 1.2258 + nssdbg_finish_time(FUNC_C_SIGNENCRYPTUPDATE,start); 1.2259 + PR_LOG(modlog, 4, (fmt_spulEncryptedPartLen, *pulEncryptedPartLen)); 1.2260 + log_rv(rv); 1.2261 + return rv; 1.2262 +} 1.2263 + 1.2264 +CK_RV NSSDBGC_DecryptVerifyUpdate( 1.2265 + CK_SESSION_HANDLE hSession, 1.2266 + CK_BYTE_PTR pEncryptedPart, 1.2267 + CK_ULONG ulEncryptedPartLen, 1.2268 + CK_BYTE_PTR pPart, 1.2269 + CK_ULONG_PTR pulPartLen 1.2270 +) 1.2271 +{ 1.2272 + COMMON_DEFINITIONS; 1.2273 + 1.2274 + PR_LOG(modlog, 1, ("C_DecryptVerifyUpdate")); 1.2275 + log_handle(3, fmt_hSession, hSession); 1.2276 + PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart)); 1.2277 + PR_LOG(modlog, 3, (fmt_ulEncryptedPartLen, ulEncryptedPartLen)); 1.2278 + PR_LOG(modlog, 3, (fmt_pPart, pPart)); 1.2279 + PR_LOG(modlog, 3, (fmt_pulPartLen, pulPartLen)); 1.2280 + nssdbg_start_time(FUNC_C_DECRYPTVERIFYUPDATE,&start); 1.2281 + rv = module_functions->C_DecryptVerifyUpdate(hSession, 1.2282 + pEncryptedPart, 1.2283 + ulEncryptedPartLen, 1.2284 + pPart, 1.2285 + pulPartLen); 1.2286 + nssdbg_finish_time(FUNC_C_DECRYPTVERIFYUPDATE,start); 1.2287 + PR_LOG(modlog, 4, (fmt_spulPartLen, *pulPartLen)); 1.2288 + log_rv(rv); 1.2289 + return rv; 1.2290 +} 1.2291 + 1.2292 +CK_RV NSSDBGC_GenerateKey( 1.2293 + CK_SESSION_HANDLE hSession, 1.2294 + CK_MECHANISM_PTR pMechanism, 1.2295 + CK_ATTRIBUTE_PTR pTemplate, 1.2296 + CK_ULONG ulCount, 1.2297 + CK_OBJECT_HANDLE_PTR phKey 1.2298 +) 1.2299 +{ 1.2300 + COMMON_DEFINITIONS; 1.2301 + 1.2302 + PR_LOG(modlog, 1, ("C_GenerateKey")); 1.2303 + log_handle(3, fmt_hSession, hSession); 1.2304 + PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); 1.2305 + PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); 1.2306 + PR_LOG(modlog, 3, (fmt_ulCount, ulCount)); 1.2307 + PR_LOG(modlog, 3, (fmt_phKey, phKey)); 1.2308 + print_template(pTemplate, ulCount); 1.2309 + print_mechanism(pMechanism); 1.2310 + nssdbg_start_time(FUNC_C_GENERATEKEY,&start); 1.2311 + rv = module_functions->C_GenerateKey(hSession, 1.2312 + pMechanism, 1.2313 + pTemplate, 1.2314 + ulCount, 1.2315 + phKey); 1.2316 + nssdbg_finish_time(FUNC_C_GENERATEKEY,start); 1.2317 + log_handle(4, fmt_sphKey, *phKey); 1.2318 + log_rv(rv); 1.2319 + return rv; 1.2320 +} 1.2321 + 1.2322 +CK_RV NSSDBGC_GenerateKeyPair( 1.2323 + CK_SESSION_HANDLE hSession, 1.2324 + CK_MECHANISM_PTR pMechanism, 1.2325 + CK_ATTRIBUTE_PTR pPublicKeyTemplate, 1.2326 + CK_ULONG ulPublicKeyAttributeCount, 1.2327 + CK_ATTRIBUTE_PTR pPrivateKeyTemplate, 1.2328 + CK_ULONG ulPrivateKeyAttributeCount, 1.2329 + CK_OBJECT_HANDLE_PTR phPublicKey, 1.2330 + CK_OBJECT_HANDLE_PTR phPrivateKey 1.2331 +) 1.2332 +{ 1.2333 + COMMON_DEFINITIONS; 1.2334 + 1.2335 + PR_LOG(modlog, 1, ("C_GenerateKeyPair")); 1.2336 + log_handle(3, fmt_hSession, hSession); 1.2337 + PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); 1.2338 + PR_LOG(modlog, 3, (" pPublicKeyTemplate = 0x%p", pPublicKeyTemplate)); 1.2339 + PR_LOG(modlog, 3, (" ulPublicKeyAttributeCount = %d", ulPublicKeyAttributeCount)); 1.2340 + PR_LOG(modlog, 3, (" pPrivateKeyTemplate = 0x%p", pPrivateKeyTemplate)); 1.2341 + PR_LOG(modlog, 3, (" ulPrivateKeyAttributeCount = %d", ulPrivateKeyAttributeCount)); 1.2342 + PR_LOG(modlog, 3, (" phPublicKey = 0x%p", phPublicKey)); 1.2343 + print_template(pPublicKeyTemplate, ulPublicKeyAttributeCount); 1.2344 + PR_LOG(modlog, 3, (" phPrivateKey = 0x%p", phPrivateKey)); 1.2345 + print_template(pPrivateKeyTemplate, ulPrivateKeyAttributeCount); 1.2346 + print_mechanism(pMechanism); 1.2347 + nssdbg_start_time(FUNC_C_GENERATEKEYPAIR,&start); 1.2348 + rv = module_functions->C_GenerateKeyPair(hSession, 1.2349 + pMechanism, 1.2350 + pPublicKeyTemplate, 1.2351 + ulPublicKeyAttributeCount, 1.2352 + pPrivateKeyTemplate, 1.2353 + ulPrivateKeyAttributeCount, 1.2354 + phPublicKey, 1.2355 + phPrivateKey); 1.2356 + nssdbg_finish_time(FUNC_C_GENERATEKEYPAIR,start); 1.2357 + log_handle(4, " *phPublicKey = 0x%x", *phPublicKey); 1.2358 + log_handle(4, " *phPrivateKey = 0x%x", *phPrivateKey); 1.2359 + log_rv(rv); 1.2360 + return rv; 1.2361 +} 1.2362 + 1.2363 +CK_RV NSSDBGC_WrapKey( 1.2364 + CK_SESSION_HANDLE hSession, 1.2365 + CK_MECHANISM_PTR pMechanism, 1.2366 + CK_OBJECT_HANDLE hWrappingKey, 1.2367 + CK_OBJECT_HANDLE hKey, 1.2368 + CK_BYTE_PTR pWrappedKey, 1.2369 + CK_ULONG_PTR pulWrappedKeyLen 1.2370 +) 1.2371 +{ 1.2372 + COMMON_DEFINITIONS; 1.2373 + 1.2374 + PR_LOG(modlog, 1, ("C_WrapKey")); 1.2375 + log_handle(3, fmt_hSession, hSession); 1.2376 + PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); 1.2377 + log_handle(3, " hWrappingKey = 0x%x", hWrappingKey); 1.2378 + log_handle(3, fmt_hKey, hKey); 1.2379 + PR_LOG(modlog, 3, (fmt_pWrappedKey, pWrappedKey)); 1.2380 + PR_LOG(modlog, 3, (" pulWrappedKeyLen = 0x%p", pulWrappedKeyLen)); 1.2381 + print_mechanism(pMechanism); 1.2382 + nssdbg_start_time(FUNC_C_WRAPKEY,&start); 1.2383 + rv = module_functions->C_WrapKey(hSession, 1.2384 + pMechanism, 1.2385 + hWrappingKey, 1.2386 + hKey, 1.2387 + pWrappedKey, 1.2388 + pulWrappedKeyLen); 1.2389 + nssdbg_finish_time(FUNC_C_WRAPKEY,start); 1.2390 + PR_LOG(modlog, 4, (" *pulWrappedKeyLen = 0x%x", *pulWrappedKeyLen)); 1.2391 + log_rv(rv); 1.2392 + return rv; 1.2393 +} 1.2394 + 1.2395 +CK_RV NSSDBGC_UnwrapKey( 1.2396 + CK_SESSION_HANDLE hSession, 1.2397 + CK_MECHANISM_PTR pMechanism, 1.2398 + CK_OBJECT_HANDLE hUnwrappingKey, 1.2399 + CK_BYTE_PTR pWrappedKey, 1.2400 + CK_ULONG ulWrappedKeyLen, 1.2401 + CK_ATTRIBUTE_PTR pTemplate, 1.2402 + CK_ULONG ulAttributeCount, 1.2403 + CK_OBJECT_HANDLE_PTR phKey 1.2404 +) 1.2405 +{ 1.2406 + COMMON_DEFINITIONS; 1.2407 + 1.2408 + PR_LOG(modlog, 1, ("C_UnwrapKey")); 1.2409 + log_handle(3, fmt_hSession, hSession); 1.2410 + PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); 1.2411 + log_handle(3, " hUnwrappingKey = 0x%x", hUnwrappingKey); 1.2412 + PR_LOG(modlog, 3, (fmt_pWrappedKey, pWrappedKey)); 1.2413 + PR_LOG(modlog, 3, (" ulWrappedKeyLen = %d", ulWrappedKeyLen)); 1.2414 + PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); 1.2415 + PR_LOG(modlog, 3, (fmt_ulAttributeCount, ulAttributeCount)); 1.2416 + PR_LOG(modlog, 3, (fmt_phKey, phKey)); 1.2417 + print_template(pTemplate, ulAttributeCount); 1.2418 + print_mechanism(pMechanism); 1.2419 + nssdbg_start_time(FUNC_C_UNWRAPKEY,&start); 1.2420 + rv = module_functions->C_UnwrapKey(hSession, 1.2421 + pMechanism, 1.2422 + hUnwrappingKey, 1.2423 + pWrappedKey, 1.2424 + ulWrappedKeyLen, 1.2425 + pTemplate, 1.2426 + ulAttributeCount, 1.2427 + phKey); 1.2428 + nssdbg_finish_time(FUNC_C_UNWRAPKEY,start); 1.2429 + log_handle(4, fmt_sphKey, *phKey); 1.2430 + log_rv(rv); 1.2431 + return rv; 1.2432 +} 1.2433 + 1.2434 +CK_RV NSSDBGC_DeriveKey( 1.2435 + CK_SESSION_HANDLE hSession, 1.2436 + CK_MECHANISM_PTR pMechanism, 1.2437 + CK_OBJECT_HANDLE hBaseKey, 1.2438 + CK_ATTRIBUTE_PTR pTemplate, 1.2439 + CK_ULONG ulAttributeCount, 1.2440 + CK_OBJECT_HANDLE_PTR phKey 1.2441 +) 1.2442 +{ 1.2443 + COMMON_DEFINITIONS; 1.2444 + 1.2445 + PR_LOG(modlog, 1, ("C_DeriveKey")); 1.2446 + log_handle(3, fmt_hSession, hSession); 1.2447 + PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); 1.2448 + log_handle(3, " hBaseKey = 0x%x", hBaseKey); 1.2449 + PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); 1.2450 + PR_LOG(modlog, 3, (fmt_ulAttributeCount, ulAttributeCount)); 1.2451 + PR_LOG(modlog, 3, (fmt_phKey, phKey)); 1.2452 + print_template(pTemplate, ulAttributeCount); 1.2453 + print_mechanism(pMechanism); 1.2454 + nssdbg_start_time(FUNC_C_DERIVEKEY,&start); 1.2455 + rv = module_functions->C_DeriveKey(hSession, 1.2456 + pMechanism, 1.2457 + hBaseKey, 1.2458 + pTemplate, 1.2459 + ulAttributeCount, 1.2460 + phKey); 1.2461 + nssdbg_finish_time(FUNC_C_DERIVEKEY,start); 1.2462 + log_handle(4, fmt_sphKey, *phKey); 1.2463 + log_rv(rv); 1.2464 + return rv; 1.2465 +} 1.2466 + 1.2467 +CK_RV NSSDBGC_SeedRandom( 1.2468 + CK_SESSION_HANDLE hSession, 1.2469 + CK_BYTE_PTR pSeed, 1.2470 + CK_ULONG ulSeedLen 1.2471 +) 1.2472 +{ 1.2473 + COMMON_DEFINITIONS; 1.2474 + 1.2475 + PR_LOG(modlog, 1, ("C_SeedRandom")); 1.2476 + log_handle(3, fmt_hSession, hSession); 1.2477 + PR_LOG(modlog, 3, (" pSeed = 0x%p", pSeed)); 1.2478 + PR_LOG(modlog, 3, (" ulSeedLen = %d", ulSeedLen)); 1.2479 + nssdbg_start_time(FUNC_C_SEEDRANDOM,&start); 1.2480 + rv = module_functions->C_SeedRandom(hSession, 1.2481 + pSeed, 1.2482 + ulSeedLen); 1.2483 + nssdbg_finish_time(FUNC_C_SEEDRANDOM,start); 1.2484 + log_rv(rv); 1.2485 + return rv; 1.2486 +} 1.2487 + 1.2488 +CK_RV NSSDBGC_GenerateRandom( 1.2489 + CK_SESSION_HANDLE hSession, 1.2490 + CK_BYTE_PTR RandomData, 1.2491 + CK_ULONG ulRandomLen 1.2492 +) 1.2493 +{ 1.2494 + COMMON_DEFINITIONS; 1.2495 + 1.2496 + PR_LOG(modlog, 1, ("C_GenerateRandom")); 1.2497 + log_handle(3, fmt_hSession, hSession); 1.2498 + PR_LOG(modlog, 3, (" RandomData = 0x%p", RandomData)); 1.2499 + PR_LOG(modlog, 3, (" ulRandomLen = %d", ulRandomLen)); 1.2500 + nssdbg_start_time(FUNC_C_GENERATERANDOM,&start); 1.2501 + rv = module_functions->C_GenerateRandom(hSession, 1.2502 + RandomData, 1.2503 + ulRandomLen); 1.2504 + nssdbg_finish_time(FUNC_C_GENERATERANDOM,start); 1.2505 + log_rv(rv); 1.2506 + return rv; 1.2507 +} 1.2508 + 1.2509 +CK_RV NSSDBGC_GetFunctionStatus( 1.2510 + CK_SESSION_HANDLE hSession 1.2511 +) 1.2512 +{ 1.2513 + COMMON_DEFINITIONS; 1.2514 + 1.2515 + PR_LOG(modlog, 1, ("C_GetFunctionStatus")); 1.2516 + log_handle(3, fmt_hSession, hSession); 1.2517 + nssdbg_start_time(FUNC_C_GETFUNCTIONSTATUS,&start); 1.2518 + rv = module_functions->C_GetFunctionStatus(hSession); 1.2519 + nssdbg_finish_time(FUNC_C_GETFUNCTIONSTATUS,start); 1.2520 + log_rv(rv); 1.2521 + return rv; 1.2522 +} 1.2523 + 1.2524 +CK_RV NSSDBGC_CancelFunction( 1.2525 + CK_SESSION_HANDLE hSession 1.2526 +) 1.2527 +{ 1.2528 + COMMON_DEFINITIONS; 1.2529 + 1.2530 + PR_LOG(modlog, 1, ("C_CancelFunction")); 1.2531 + log_handle(3, fmt_hSession, hSession); 1.2532 + nssdbg_start_time(FUNC_C_CANCELFUNCTION,&start); 1.2533 + rv = module_functions->C_CancelFunction(hSession); 1.2534 + nssdbg_finish_time(FUNC_C_CANCELFUNCTION,start); 1.2535 + log_rv(rv); 1.2536 + return rv; 1.2537 +} 1.2538 + 1.2539 +CK_RV NSSDBGC_WaitForSlotEvent( 1.2540 + CK_FLAGS flags, 1.2541 + CK_SLOT_ID_PTR pSlot, 1.2542 + CK_VOID_PTR pRserved 1.2543 +) 1.2544 +{ 1.2545 + COMMON_DEFINITIONS; 1.2546 + 1.2547 + PR_LOG(modlog, 1, ("C_WaitForSlotEvent")); 1.2548 + PR_LOG(modlog, 3, (fmt_flags, flags)); 1.2549 + PR_LOG(modlog, 3, (" pSlot = 0x%p", pSlot)); 1.2550 + PR_LOG(modlog, 3, (" pRserved = 0x%p", pRserved)); 1.2551 + nssdbg_start_time(FUNC_C_WAITFORSLOTEVENT,&start); 1.2552 + rv = module_functions->C_WaitForSlotEvent(flags, 1.2553 + pSlot, 1.2554 + pRserved); 1.2555 + nssdbg_finish_time(FUNC_C_WAITFORSLOTEVENT,start); 1.2556 + log_rv(rv); 1.2557 + return rv; 1.2558 +} 1.2559 + 1.2560 +CK_FUNCTION_LIST_PTR nss_InsertDeviceLog( 1.2561 + CK_FUNCTION_LIST_PTR devEPV 1.2562 +) 1.2563 +{ 1.2564 + module_functions = devEPV; 1.2565 + modlog = PR_NewLogModule("nss_mod_log"); 1.2566 + debug_functions.C_Initialize = NSSDBGC_Initialize; 1.2567 + debug_functions.C_Finalize = NSSDBGC_Finalize; 1.2568 + debug_functions.C_GetInfo = NSSDBGC_GetInfo; 1.2569 + debug_functions.C_GetFunctionList = NSSDBGC_GetFunctionList; 1.2570 + debug_functions.C_GetSlotList = NSSDBGC_GetSlotList; 1.2571 + debug_functions.C_GetSlotInfo = NSSDBGC_GetSlotInfo; 1.2572 + debug_functions.C_GetTokenInfo = NSSDBGC_GetTokenInfo; 1.2573 + debug_functions.C_GetMechanismList = NSSDBGC_GetMechanismList; 1.2574 + debug_functions.C_GetMechanismInfo = NSSDBGC_GetMechanismInfo; 1.2575 + debug_functions.C_InitToken = NSSDBGC_InitToken; 1.2576 + debug_functions.C_InitPIN = NSSDBGC_InitPIN; 1.2577 + debug_functions.C_SetPIN = NSSDBGC_SetPIN; 1.2578 + debug_functions.C_OpenSession = NSSDBGC_OpenSession; 1.2579 + debug_functions.C_CloseSession = NSSDBGC_CloseSession; 1.2580 + debug_functions.C_CloseAllSessions = NSSDBGC_CloseAllSessions; 1.2581 + debug_functions.C_GetSessionInfo = NSSDBGC_GetSessionInfo; 1.2582 + debug_functions.C_GetOperationState = NSSDBGC_GetOperationState; 1.2583 + debug_functions.C_SetOperationState = NSSDBGC_SetOperationState; 1.2584 + debug_functions.C_Login = NSSDBGC_Login; 1.2585 + debug_functions.C_Logout = NSSDBGC_Logout; 1.2586 + debug_functions.C_CreateObject = NSSDBGC_CreateObject; 1.2587 + debug_functions.C_CopyObject = NSSDBGC_CopyObject; 1.2588 + debug_functions.C_DestroyObject = NSSDBGC_DestroyObject; 1.2589 + debug_functions.C_GetObjectSize = NSSDBGC_GetObjectSize; 1.2590 + debug_functions.C_GetAttributeValue = NSSDBGC_GetAttributeValue; 1.2591 + debug_functions.C_SetAttributeValue = NSSDBGC_SetAttributeValue; 1.2592 + debug_functions.C_FindObjectsInit = NSSDBGC_FindObjectsInit; 1.2593 + debug_functions.C_FindObjects = NSSDBGC_FindObjects; 1.2594 + debug_functions.C_FindObjectsFinal = NSSDBGC_FindObjectsFinal; 1.2595 + debug_functions.C_EncryptInit = NSSDBGC_EncryptInit; 1.2596 + debug_functions.C_Encrypt = NSSDBGC_Encrypt; 1.2597 + debug_functions.C_EncryptUpdate = NSSDBGC_EncryptUpdate; 1.2598 + debug_functions.C_EncryptFinal = NSSDBGC_EncryptFinal; 1.2599 + debug_functions.C_DecryptInit = NSSDBGC_DecryptInit; 1.2600 + debug_functions.C_Decrypt = NSSDBGC_Decrypt; 1.2601 + debug_functions.C_DecryptUpdate = NSSDBGC_DecryptUpdate; 1.2602 + debug_functions.C_DecryptFinal = NSSDBGC_DecryptFinal; 1.2603 + debug_functions.C_DigestInit = NSSDBGC_DigestInit; 1.2604 + debug_functions.C_Digest = NSSDBGC_Digest; 1.2605 + debug_functions.C_DigestUpdate = NSSDBGC_DigestUpdate; 1.2606 + debug_functions.C_DigestKey = NSSDBGC_DigestKey; 1.2607 + debug_functions.C_DigestFinal = NSSDBGC_DigestFinal; 1.2608 + debug_functions.C_SignInit = NSSDBGC_SignInit; 1.2609 + debug_functions.C_Sign = NSSDBGC_Sign; 1.2610 + debug_functions.C_SignUpdate = NSSDBGC_SignUpdate; 1.2611 + debug_functions.C_SignFinal = NSSDBGC_SignFinal; 1.2612 + debug_functions.C_SignRecoverInit = NSSDBGC_SignRecoverInit; 1.2613 + debug_functions.C_SignRecover = NSSDBGC_SignRecover; 1.2614 + debug_functions.C_VerifyInit = NSSDBGC_VerifyInit; 1.2615 + debug_functions.C_Verify = NSSDBGC_Verify; 1.2616 + debug_functions.C_VerifyUpdate = NSSDBGC_VerifyUpdate; 1.2617 + debug_functions.C_VerifyFinal = NSSDBGC_VerifyFinal; 1.2618 + debug_functions.C_VerifyRecoverInit = NSSDBGC_VerifyRecoverInit; 1.2619 + debug_functions.C_VerifyRecover = NSSDBGC_VerifyRecover; 1.2620 + debug_functions.C_DigestEncryptUpdate = NSSDBGC_DigestEncryptUpdate; 1.2621 + debug_functions.C_DecryptDigestUpdate = NSSDBGC_DecryptDigestUpdate; 1.2622 + debug_functions.C_SignEncryptUpdate = NSSDBGC_SignEncryptUpdate; 1.2623 + debug_functions.C_DecryptVerifyUpdate = NSSDBGC_DecryptVerifyUpdate; 1.2624 + debug_functions.C_GenerateKey = NSSDBGC_GenerateKey; 1.2625 + debug_functions.C_GenerateKeyPair = NSSDBGC_GenerateKeyPair; 1.2626 + debug_functions.C_WrapKey = NSSDBGC_WrapKey; 1.2627 + debug_functions.C_UnwrapKey = NSSDBGC_UnwrapKey; 1.2628 + debug_functions.C_DeriveKey = NSSDBGC_DeriveKey; 1.2629 + debug_functions.C_SeedRandom = NSSDBGC_SeedRandom; 1.2630 + debug_functions.C_GenerateRandom = NSSDBGC_GenerateRandom; 1.2631 + debug_functions.C_GetFunctionStatus = NSSDBGC_GetFunctionStatus; 1.2632 + debug_functions.C_CancelFunction = NSSDBGC_CancelFunction; 1.2633 + debug_functions.C_WaitForSlotEvent = NSSDBGC_WaitForSlotEvent; 1.2634 + return &debug_functions; 1.2635 +} 1.2636 + 1.2637 +/* 1.2638 + * scale the time factor up accordingly. 1.2639 + * This routine tries to keep at least 2 significant figures on output. 1.2640 + * If the time is 0, then indicate that with a 'z' for units. 1.2641 + * If the time is greater than 10 minutes, output the time in minutes. 1.2642 + * If the time is less than 10 minutes but greater than 10 seconds output 1.2643 + * the time in second. 1.2644 + * If the time is less than 10 seconds but greater than 10 milliseconds 1.2645 + * output * the time in millisecond. 1.2646 + * If the time is less than 10 milliseconds but greater than 0 ticks output 1.2647 + * the time in microsecond. 1.2648 + * 1.2649 + */ 1.2650 +static PRUint32 getPrintTime(PRIntervalTime time ,char **type) 1.2651 +{ 1.2652 + PRUint32 prTime; 1.2653 + 1.2654 + /* detect a programming error by outputting 'bu' to the output stream 1.2655 + * rather than crashing */ 1.2656 + *type = "bug"; 1.2657 + if (time == 0) { 1.2658 + *type = "z"; 1.2659 + return 0; 1.2660 + } 1.2661 + 1.2662 + prTime = PR_IntervalToSeconds(time); 1.2663 + 1.2664 + if (prTime >= 600) { 1.2665 + *type="m"; 1.2666 + return prTime/60; 1.2667 + } 1.2668 + if (prTime >= 10) { 1.2669 + *type="s"; 1.2670 + return prTime; 1.2671 + } 1.2672 + prTime = PR_IntervalToMilliseconds(time); 1.2673 + if (prTime >= 10) { 1.2674 + *type="ms"; 1.2675 + return prTime; 1.2676 + } 1.2677 + *type = "us"; 1.2678 + return PR_IntervalToMicroseconds(time); 1.2679 +} 1.2680 + 1.2681 +static void print_final_statistics(void) 1.2682 +{ 1.2683 + int total_calls = 0; 1.2684 + PRIntervalTime total_time = 0; 1.2685 + PRUint32 pr_total_time; 1.2686 + char *type; 1.2687 + char *fname; 1.2688 + FILE *outfile = NULL; 1.2689 + int i; 1.2690 + 1.2691 + fname = PR_GetEnv("NSS_OUTPUT_FILE"); 1.2692 + if (fname) { 1.2693 + /* need to add an optional process id to the filename */ 1.2694 + outfile = fopen(fname,"w+"); 1.2695 + } 1.2696 + if (!outfile) { 1.2697 + outfile = stdout; 1.2698 + } 1.2699 + 1.2700 + 1.2701 + fprintf(outfile,"%-25s %10s %12s %12s %10s\n", "Function", "# Calls", 1.2702 + "Time", "Avg.", "% Time"); 1.2703 + fprintf(outfile,"\n"); 1.2704 + for (i=0; i < nssdbg_prof_size; i++) { 1.2705 + total_calls += nssdbg_prof_data[i].calls; 1.2706 + total_time += nssdbg_prof_data[i].time; 1.2707 + } 1.2708 + for (i=0; i < nssdbg_prof_size; i++) { 1.2709 + PRIntervalTime time = nssdbg_prof_data[i].time; 1.2710 + PRUint32 usTime = PR_IntervalToMicroseconds(time); 1.2711 + PRUint32 prTime = 0; 1.2712 + PRUint32 calls = nssdbg_prof_data[i].calls; 1.2713 + /* don't print out functions that weren't even called */ 1.2714 + if (calls == 0) { 1.2715 + continue; 1.2716 + } 1.2717 + 1.2718 + prTime = getPrintTime(time,&type); 1.2719 + 1.2720 + fprintf(outfile,"%-25s %10d %10d%2s ", nssdbg_prof_data[i].function, 1.2721 + calls, prTime, type); 1.2722 + /* for now always output the average in microseconds */ 1.2723 + fprintf(outfile,"%10.2f%2s", (float)usTime / (float)calls, "us" ); 1.2724 + fprintf(outfile,"%10.2f%%", ((float)time / (float)total_time) * 100); 1.2725 + fprintf(outfile,"\n"); 1.2726 + } 1.2727 + fprintf(outfile,"\n"); 1.2728 + 1.2729 + pr_total_time = getPrintTime(total_time,&type); 1.2730 + 1.2731 + fprintf(outfile,"%25s %10d %10d%2s\n", "Totals", total_calls, 1.2732 + pr_total_time, type); 1.2733 + fprintf(outfile,"\n\nMaximum number of concurrent open sessions: %d\n\n", 1.2734 + maxOpenSessions); 1.2735 + fflush (outfile); 1.2736 + if (outfile != stdout) { 1.2737 + fclose(outfile); 1.2738 + } 1.2739 +} 1.2740 +