andre@0: /* This Source Code Form is subject to the terms of the Mozilla Public andre@0: * License, v. 2.0. If a copy of the MPL was not distributed with this andre@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ andre@0: #include "prlog.h" andre@0: #include andre@0: #include "cert.h" /* for CERT_DerNameToAscii & CERT_Hexify */ andre@0: andre@0: static PRLogModuleInfo *modlog = NULL; andre@0: andre@0: static CK_FUNCTION_LIST_PTR module_functions; andre@0: andre@0: static CK_FUNCTION_LIST debug_functions; andre@0: andre@0: static void print_final_statistics(void); andre@0: andre@0: #define STRING static const char andre@0: andre@0: STRING fmt_flags[] = " flags = 0x%x"; andre@0: STRING fmt_hKey[] = " hKey = 0x%x"; andre@0: STRING fmt_hObject[] = " hObject = 0x%x"; andre@0: STRING fmt_hSession[] = " hSession = 0x%x"; andre@0: STRING fmt_manufacturerID[] = " manufacturerID = \"%.32s\""; andre@0: STRING fmt_pData[] = " pData = 0x%p"; andre@0: STRING fmt_pDigest[] = " pDigest = 0x%p"; andre@0: STRING fmt_pEncryptedData[] = " pEncryptedData = 0x%p"; andre@0: STRING fmt_pEncryptedPart[] = " pEncryptedPart = 0x%p"; andre@0: STRING fmt_pInfo[] = " pInfo = 0x%p"; andre@0: STRING fmt_pMechanism[] = " pMechanism = 0x%p"; andre@0: STRING fmt_pOperationState[] = " pOperationState = 0x%p"; andre@0: STRING fmt_pPart[] = " pPart = 0x%p"; andre@0: STRING fmt_pPin[] = " pPin = 0x%p"; andre@0: STRING fmt_pSignature[] = " pSignature = 0x%p"; andre@0: STRING fmt_pTemplate[] = " pTemplate = 0x%p"; andre@0: STRING fmt_pWrappedKey[] = " pWrappedKey = 0x%p"; andre@0: STRING fmt_phKey[] = " phKey = 0x%p"; andre@0: STRING fmt_phObject[] = " phObject = 0x%p"; andre@0: STRING fmt_pulCount[] = " pulCount = 0x%p"; andre@0: STRING fmt_pulDataLen[] = " pulDataLen = 0x%p"; andre@0: STRING fmt_pulDigestLen[] = " pulDigestLen = 0x%p"; andre@0: STRING fmt_pulEncryptedPartLen[] = " pulEncryptedPartLen = 0x%p"; andre@0: STRING fmt_pulPartLen[] = " pulPartLen = 0x%p"; andre@0: STRING fmt_pulSignatureLen[] = " pulSignatureLen = 0x%p"; andre@0: STRING fmt_slotID[] = " slotID = 0x%x"; andre@0: STRING fmt_sphKey[] = " *phKey = 0x%x"; andre@0: STRING fmt_spulCount[] = " *pulCount = 0x%x"; andre@0: STRING fmt_spulDataLen[] = " *pulDataLen = 0x%x"; andre@0: STRING fmt_spulDigestLen[] = " *pulDigestLen = 0x%x"; andre@0: STRING fmt_spulEncryptedPartLen[] = " *pulEncryptedPartLen = 0x%x"; andre@0: STRING fmt_spulPartLen[] = " *pulPartLen = 0x%x"; andre@0: STRING fmt_spulSignatureLen[] = " *pulSignatureLen = 0x%x"; andre@0: STRING fmt_ulAttributeCount[] = " ulAttributeCount = %d"; andre@0: STRING fmt_ulCount[] = " ulCount = %d"; andre@0: STRING fmt_ulDataLen[] = " ulDataLen = %d"; andre@0: STRING fmt_ulEncryptedPartLen[] = " ulEncryptedPartLen = %d"; andre@0: STRING fmt_ulPartLen[] = " ulPartLen = %d"; andre@0: STRING fmt_ulPinLen[] = " ulPinLen = %d"; andre@0: STRING fmt_ulSignatureLen[] = " ulSignatureLen = %d"; andre@0: andre@0: STRING fmt_fwVersion[] = " firmware version: %d.%d"; andre@0: STRING fmt_hwVersion[] = " hardware version: %d.%d"; andre@0: STRING fmt_s_qsq_d[] = " %s = \"%s\" [%d]"; andre@0: STRING fmt_s_s_d[] = " %s = %s [%d]"; andre@0: STRING fmt_s_lu[] = " %s = %lu"; andre@0: STRING fmt_invalid_handle[] = " (CK_INVALID_HANDLE)"; andre@0: andre@0: andre@0: static void get_attr_type_str(CK_ATTRIBUTE_TYPE atype, char *str, int len) andre@0: { andre@0: #define CASE(attr) case attr: a = #attr ; break andre@0: andre@0: const char * a = NULL; andre@0: andre@0: switch (atype) { andre@0: CASE(CKA_CLASS); andre@0: CASE(CKA_TOKEN); andre@0: CASE(CKA_PRIVATE); andre@0: CASE(CKA_LABEL); andre@0: CASE(CKA_APPLICATION); andre@0: CASE(CKA_VALUE); andre@0: CASE(CKA_OBJECT_ID); andre@0: CASE(CKA_CERTIFICATE_TYPE); andre@0: CASE(CKA_CERTIFICATE_CATEGORY); andre@0: CASE(CKA_ISSUER); andre@0: CASE(CKA_SERIAL_NUMBER); andre@0: CASE(CKA_AC_ISSUER); andre@0: CASE(CKA_OWNER); andre@0: CASE(CKA_ATTR_TYPES); andre@0: CASE(CKA_TRUSTED); andre@0: CASE(CKA_KEY_TYPE); andre@0: CASE(CKA_SUBJECT); andre@0: CASE(CKA_ID); andre@0: CASE(CKA_SENSITIVE); andre@0: CASE(CKA_ENCRYPT); andre@0: CASE(CKA_DECRYPT); andre@0: CASE(CKA_WRAP); andre@0: CASE(CKA_UNWRAP); andre@0: CASE(CKA_SIGN); andre@0: CASE(CKA_SIGN_RECOVER); andre@0: CASE(CKA_VERIFY); andre@0: CASE(CKA_VERIFY_RECOVER); andre@0: CASE(CKA_DERIVE); andre@0: CASE(CKA_START_DATE); andre@0: CASE(CKA_END_DATE); andre@0: CASE(CKA_MODULUS); andre@0: CASE(CKA_MODULUS_BITS); andre@0: CASE(CKA_PUBLIC_EXPONENT); andre@0: CASE(CKA_PRIVATE_EXPONENT); andre@0: CASE(CKA_PRIME_1); andre@0: CASE(CKA_PRIME_2); andre@0: CASE(CKA_EXPONENT_1); andre@0: CASE(CKA_EXPONENT_2); andre@0: CASE(CKA_COEFFICIENT); andre@0: CASE(CKA_PRIME); andre@0: CASE(CKA_SUBPRIME); andre@0: CASE(CKA_BASE); andre@0: CASE(CKA_PRIME_BITS); andre@0: CASE(CKA_SUBPRIME_BITS); andre@0: CASE(CKA_VALUE_BITS); andre@0: CASE(CKA_VALUE_LEN); andre@0: CASE(CKA_EXTRACTABLE); andre@0: CASE(CKA_LOCAL); andre@0: CASE(CKA_NEVER_EXTRACTABLE); andre@0: CASE(CKA_ALWAYS_SENSITIVE); andre@0: CASE(CKA_KEY_GEN_MECHANISM); andre@0: CASE(CKA_MODIFIABLE); andre@0: CASE(CKA_ECDSA_PARAMS); andre@0: CASE(CKA_EC_POINT); andre@0: CASE(CKA_SECONDARY_AUTH); andre@0: CASE(CKA_AUTH_PIN_FLAGS); andre@0: CASE(CKA_HW_FEATURE_TYPE); andre@0: CASE(CKA_RESET_ON_INIT); andre@0: CASE(CKA_HAS_RESET); andre@0: CASE(CKA_VENDOR_DEFINED); andre@0: CASE(CKA_NSS_URL); andre@0: CASE(CKA_NSS_EMAIL); andre@0: CASE(CKA_NSS_SMIME_INFO); andre@0: CASE(CKA_NSS_SMIME_TIMESTAMP); andre@0: CASE(CKA_NSS_PKCS8_SALT); andre@0: CASE(CKA_NSS_PASSWORD_CHECK); andre@0: CASE(CKA_NSS_EXPIRES); andre@0: CASE(CKA_NSS_KRL); andre@0: CASE(CKA_NSS_PQG_COUNTER); andre@0: CASE(CKA_NSS_PQG_SEED); andre@0: CASE(CKA_NSS_PQG_H); andre@0: CASE(CKA_NSS_PQG_SEED_BITS); andre@0: CASE(CKA_TRUST); andre@0: CASE(CKA_TRUST_DIGITAL_SIGNATURE); andre@0: CASE(CKA_TRUST_NON_REPUDIATION); andre@0: CASE(CKA_TRUST_KEY_ENCIPHERMENT); andre@0: CASE(CKA_TRUST_DATA_ENCIPHERMENT); andre@0: CASE(CKA_TRUST_KEY_AGREEMENT); andre@0: CASE(CKA_TRUST_KEY_CERT_SIGN); andre@0: CASE(CKA_TRUST_CRL_SIGN); andre@0: CASE(CKA_TRUST_SERVER_AUTH); andre@0: CASE(CKA_TRUST_CLIENT_AUTH); andre@0: CASE(CKA_TRUST_CODE_SIGNING); andre@0: CASE(CKA_TRUST_EMAIL_PROTECTION); andre@0: CASE(CKA_TRUST_IPSEC_END_SYSTEM); andre@0: CASE(CKA_TRUST_IPSEC_TUNNEL); andre@0: CASE(CKA_TRUST_IPSEC_USER); andre@0: CASE(CKA_TRUST_TIME_STAMPING); andre@0: CASE(CKA_CERT_SHA1_HASH); andre@0: CASE(CKA_CERT_MD5_HASH); andre@0: CASE(CKA_NETSCAPE_DB); andre@0: CASE(CKA_NETSCAPE_TRUST); andre@0: default: break; andre@0: } andre@0: if (a) andre@0: PR_snprintf(str, len, "%s", a); andre@0: else andre@0: PR_snprintf(str, len, "0x%p", atype); andre@0: } andre@0: andre@0: static void get_obj_class(CK_OBJECT_CLASS objClass, char *str, int len) andre@0: { andre@0: andre@0: const char * a = NULL; andre@0: andre@0: switch (objClass) { andre@0: CASE(CKO_DATA); andre@0: CASE(CKO_CERTIFICATE); andre@0: CASE(CKO_PUBLIC_KEY); andre@0: CASE(CKO_PRIVATE_KEY); andre@0: CASE(CKO_SECRET_KEY); andre@0: CASE(CKO_HW_FEATURE); andre@0: CASE(CKO_DOMAIN_PARAMETERS); andre@0: CASE(CKO_NSS_CRL); andre@0: CASE(CKO_NSS_SMIME); andre@0: CASE(CKO_NSS_TRUST); andre@0: CASE(CKO_NSS_BUILTIN_ROOT_LIST); andre@0: default: break; andre@0: } andre@0: if (a) andre@0: PR_snprintf(str, len, "%s", a); andre@0: else andre@0: PR_snprintf(str, len, "0x%p", objClass); andre@0: } andre@0: andre@0: static void get_trust_val(CK_TRUST trust, char *str, int len) andre@0: { andre@0: const char * a = NULL; andre@0: andre@0: switch (trust) { andre@0: CASE(CKT_NSS_TRUSTED); andre@0: CASE(CKT_NSS_TRUSTED_DELEGATOR); andre@0: CASE(CKT_NSS_NOT_TRUSTED); andre@0: CASE(CKT_NSS_MUST_VERIFY_TRUST); andre@0: CASE(CKT_NSS_TRUST_UNKNOWN); andre@0: CASE(CKT_NSS_VALID_DELEGATOR); andre@0: default: break; andre@0: } andre@0: if (a) andre@0: PR_snprintf(str, len, "%s", a); andre@0: else andre@0: PR_snprintf(str, len, "0x%p", trust); andre@0: } andre@0: andre@0: static void log_rv(CK_RV rv) andre@0: { andre@0: const char * a = NULL; andre@0: andre@0: switch (rv) { andre@0: CASE(CKR_OK); andre@0: CASE(CKR_CANCEL); andre@0: CASE(CKR_HOST_MEMORY); andre@0: CASE(CKR_SLOT_ID_INVALID); andre@0: CASE(CKR_GENERAL_ERROR); andre@0: CASE(CKR_FUNCTION_FAILED); andre@0: CASE(CKR_ARGUMENTS_BAD); andre@0: CASE(CKR_NO_EVENT); andre@0: CASE(CKR_NEED_TO_CREATE_THREADS); andre@0: CASE(CKR_CANT_LOCK); andre@0: CASE(CKR_ATTRIBUTE_READ_ONLY); andre@0: CASE(CKR_ATTRIBUTE_SENSITIVE); andre@0: CASE(CKR_ATTRIBUTE_TYPE_INVALID); andre@0: CASE(CKR_ATTRIBUTE_VALUE_INVALID); andre@0: CASE(CKR_DATA_INVALID); andre@0: CASE(CKR_DATA_LEN_RANGE); andre@0: CASE(CKR_DEVICE_ERROR); andre@0: CASE(CKR_DEVICE_MEMORY); andre@0: CASE(CKR_DEVICE_REMOVED); andre@0: CASE(CKR_ENCRYPTED_DATA_INVALID); andre@0: CASE(CKR_ENCRYPTED_DATA_LEN_RANGE); andre@0: CASE(CKR_FUNCTION_CANCELED); andre@0: CASE(CKR_FUNCTION_NOT_PARALLEL); andre@0: CASE(CKR_FUNCTION_NOT_SUPPORTED); andre@0: CASE(CKR_KEY_HANDLE_INVALID); andre@0: CASE(CKR_KEY_SIZE_RANGE); andre@0: CASE(CKR_KEY_TYPE_INCONSISTENT); andre@0: CASE(CKR_KEY_NOT_NEEDED); andre@0: CASE(CKR_KEY_CHANGED); andre@0: CASE(CKR_KEY_NEEDED); andre@0: CASE(CKR_KEY_INDIGESTIBLE); andre@0: CASE(CKR_KEY_FUNCTION_NOT_PERMITTED); andre@0: CASE(CKR_KEY_NOT_WRAPPABLE); andre@0: CASE(CKR_KEY_UNEXTRACTABLE); andre@0: CASE(CKR_MECHANISM_INVALID); andre@0: CASE(CKR_MECHANISM_PARAM_INVALID); andre@0: CASE(CKR_OBJECT_HANDLE_INVALID); andre@0: CASE(CKR_OPERATION_ACTIVE); andre@0: CASE(CKR_OPERATION_NOT_INITIALIZED); andre@0: CASE(CKR_PIN_INCORRECT); andre@0: CASE(CKR_PIN_INVALID); andre@0: CASE(CKR_PIN_LEN_RANGE); andre@0: CASE(CKR_PIN_EXPIRED); andre@0: CASE(CKR_PIN_LOCKED); andre@0: CASE(CKR_SESSION_CLOSED); andre@0: CASE(CKR_SESSION_COUNT); andre@0: CASE(CKR_SESSION_HANDLE_INVALID); andre@0: CASE(CKR_SESSION_PARALLEL_NOT_SUPPORTED); andre@0: CASE(CKR_SESSION_READ_ONLY); andre@0: CASE(CKR_SESSION_EXISTS); andre@0: CASE(CKR_SESSION_READ_ONLY_EXISTS); andre@0: CASE(CKR_SESSION_READ_WRITE_SO_EXISTS); andre@0: CASE(CKR_SIGNATURE_INVALID); andre@0: CASE(CKR_SIGNATURE_LEN_RANGE); andre@0: CASE(CKR_TEMPLATE_INCOMPLETE); andre@0: CASE(CKR_TEMPLATE_INCONSISTENT); andre@0: CASE(CKR_TOKEN_NOT_PRESENT); andre@0: CASE(CKR_TOKEN_NOT_RECOGNIZED); andre@0: CASE(CKR_TOKEN_WRITE_PROTECTED); andre@0: CASE(CKR_UNWRAPPING_KEY_HANDLE_INVALID); andre@0: CASE(CKR_UNWRAPPING_KEY_SIZE_RANGE); andre@0: CASE(CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT); andre@0: CASE(CKR_USER_ALREADY_LOGGED_IN); andre@0: CASE(CKR_USER_NOT_LOGGED_IN); andre@0: CASE(CKR_USER_PIN_NOT_INITIALIZED); andre@0: CASE(CKR_USER_TYPE_INVALID); andre@0: CASE(CKR_USER_ANOTHER_ALREADY_LOGGED_IN); andre@0: CASE(CKR_USER_TOO_MANY_TYPES); andre@0: CASE(CKR_WRAPPED_KEY_INVALID); andre@0: CASE(CKR_WRAPPED_KEY_LEN_RANGE); andre@0: CASE(CKR_WRAPPING_KEY_HANDLE_INVALID); andre@0: CASE(CKR_WRAPPING_KEY_SIZE_RANGE); andre@0: CASE(CKR_WRAPPING_KEY_TYPE_INCONSISTENT); andre@0: CASE(CKR_RANDOM_SEED_NOT_SUPPORTED); andre@0: CASE(CKR_RANDOM_NO_RNG); andre@0: CASE(CKR_DOMAIN_PARAMS_INVALID); andre@0: CASE(CKR_BUFFER_TOO_SMALL); andre@0: CASE(CKR_SAVED_STATE_INVALID); andre@0: CASE(CKR_INFORMATION_SENSITIVE); andre@0: CASE(CKR_STATE_UNSAVEABLE); andre@0: CASE(CKR_CRYPTOKI_NOT_INITIALIZED); andre@0: CASE(CKR_CRYPTOKI_ALREADY_INITIALIZED); andre@0: CASE(CKR_MUTEX_BAD); andre@0: CASE(CKR_MUTEX_NOT_LOCKED); andre@0: CASE(CKR_FUNCTION_REJECTED); andre@0: CASE(CKR_KEY_PARAMS_INVALID); andre@0: default: break; andre@0: } andre@0: if (a) andre@0: PR_LOG(modlog, 1, (" rv = %s\n", a)); andre@0: else andre@0: PR_LOG(modlog, 1, (" rv = 0x%x\n", rv)); andre@0: } andre@0: andre@0: static void log_state(CK_STATE state) andre@0: { andre@0: const char * a = NULL; andre@0: andre@0: switch (state) { andre@0: CASE(CKS_RO_PUBLIC_SESSION); andre@0: CASE(CKS_RO_USER_FUNCTIONS); andre@0: CASE(CKS_RW_PUBLIC_SESSION); andre@0: CASE(CKS_RW_USER_FUNCTIONS); andre@0: CASE(CKS_RW_SO_FUNCTIONS); andre@0: default: break; andre@0: } andre@0: if (a) andre@0: PR_LOG(modlog, 1, (" state = %s\n", a)); andre@0: else andre@0: PR_LOG(modlog, 1, (" state = 0x%x\n", state)); andre@0: } andre@0: andre@0: static void log_handle(int level, const char * format, CK_ULONG handle) andre@0: { andre@0: char fmtBuf[80]; andre@0: if (handle) andre@0: PR_LOG(modlog, level, (format, handle)); andre@0: else { andre@0: PL_strncpyz(fmtBuf, format, sizeof fmtBuf); andre@0: PL_strcatn(fmtBuf, sizeof fmtBuf, fmt_invalid_handle); andre@0: PR_LOG(modlog, level, (fmtBuf, handle)); andre@0: } andre@0: } andre@0: andre@0: static void print_mechanism(CK_MECHANISM_PTR m) andre@0: { andre@0: andre@0: const char * a = NULL; andre@0: andre@0: switch (m->mechanism) { andre@0: CASE(CKM_AES_CBC); andre@0: CASE(CKM_AES_CBC_ENCRYPT_DATA); andre@0: CASE(CKM_AES_CBC_PAD); andre@0: CASE(CKM_AES_CCM); andre@0: CASE(CKM_AES_CTR); andre@0: CASE(CKM_AES_CTS); andre@0: CASE(CKM_AES_GCM); andre@0: CASE(CKM_AES_ECB); andre@0: CASE(CKM_AES_ECB_ENCRYPT_DATA); andre@0: CASE(CKM_AES_KEY_GEN); andre@0: CASE(CKM_AES_MAC); andre@0: CASE(CKM_AES_MAC_GENERAL); andre@0: CASE(CKM_CAMELLIA_CBC); andre@0: CASE(CKM_CAMELLIA_CBC_ENCRYPT_DATA); andre@0: CASE(CKM_CAMELLIA_CBC_PAD); andre@0: CASE(CKM_CAMELLIA_ECB); andre@0: CASE(CKM_CAMELLIA_ECB_ENCRYPT_DATA); andre@0: CASE(CKM_CAMELLIA_KEY_GEN); andre@0: CASE(CKM_CAMELLIA_MAC); andre@0: CASE(CKM_CAMELLIA_MAC_GENERAL); andre@0: CASE(CKM_CDMF_CBC); andre@0: CASE(CKM_CDMF_CBC_PAD); andre@0: CASE(CKM_CDMF_ECB); andre@0: CASE(CKM_CDMF_KEY_GEN); andre@0: CASE(CKM_CDMF_MAC); andre@0: CASE(CKM_CDMF_MAC_GENERAL); andre@0: CASE(CKM_CMS_SIG); andre@0: CASE(CKM_CONCATENATE_BASE_AND_DATA); andre@0: CASE(CKM_CONCATENATE_BASE_AND_KEY); andre@0: CASE(CKM_CONCATENATE_DATA_AND_BASE); andre@0: CASE(CKM_DES2_KEY_GEN); andre@0: CASE(CKM_DES3_CBC); andre@0: CASE(CKM_DES3_CBC_ENCRYPT_DATA); andre@0: CASE(CKM_DES3_CBC_PAD); andre@0: CASE(CKM_DES3_ECB); andre@0: CASE(CKM_DES3_ECB_ENCRYPT_DATA); andre@0: CASE(CKM_DES3_KEY_GEN); andre@0: CASE(CKM_DES3_MAC); andre@0: CASE(CKM_DES3_MAC_GENERAL); andre@0: CASE(CKM_DES_CBC); andre@0: CASE(CKM_DES_CBC_ENCRYPT_DATA); andre@0: CASE(CKM_DES_CBC_PAD); andre@0: CASE(CKM_DES_CFB64); andre@0: CASE(CKM_DES_CFB8); andre@0: CASE(CKM_DES_ECB); andre@0: CASE(CKM_DES_ECB_ENCRYPT_DATA); andre@0: CASE(CKM_DES_KEY_GEN); andre@0: CASE(CKM_DES_MAC); andre@0: CASE(CKM_DES_MAC_GENERAL); andre@0: CASE(CKM_DES_OFB64); andre@0: CASE(CKM_DES_OFB8); andre@0: CASE(CKM_DH_PKCS_DERIVE); andre@0: CASE(CKM_DH_PKCS_KEY_PAIR_GEN); andre@0: CASE(CKM_DH_PKCS_PARAMETER_GEN); andre@0: CASE(CKM_DSA); andre@0: CASE(CKM_DSA_KEY_PAIR_GEN); andre@0: CASE(CKM_DSA_PARAMETER_GEN); andre@0: CASE(CKM_DSA_SHA1); andre@0: CASE(CKM_ECDH1_COFACTOR_DERIVE); andre@0: CASE(CKM_ECDH1_DERIVE); andre@0: CASE(CKM_ECDSA); andre@0: CASE(CKM_ECDSA_SHA1); andre@0: CASE(CKM_ECMQV_DERIVE); andre@0: CASE(CKM_EC_KEY_PAIR_GEN); /* also CASE(CKM_ECDSA_KEY_PAIR_GEN); */ andre@0: CASE(CKM_EXTRACT_KEY_FROM_KEY); andre@0: CASE(CKM_FASTHASH); andre@0: CASE(CKM_FORTEZZA_TIMESTAMP); andre@0: CASE(CKM_GENERIC_SECRET_KEY_GEN); andre@0: CASE(CKM_IDEA_CBC); andre@0: CASE(CKM_IDEA_CBC_PAD); andre@0: CASE(CKM_IDEA_ECB); andre@0: CASE(CKM_IDEA_KEY_GEN); andre@0: CASE(CKM_IDEA_MAC); andre@0: CASE(CKM_IDEA_MAC_GENERAL); andre@0: CASE(CKM_KEA_KEY_DERIVE); andre@0: CASE(CKM_KEA_KEY_PAIR_GEN); andre@0: CASE(CKM_KEY_WRAP_LYNKS); andre@0: CASE(CKM_KEY_WRAP_SET_OAEP); andre@0: CASE(CKM_MD2); andre@0: CASE(CKM_MD2_HMAC); andre@0: CASE(CKM_MD2_HMAC_GENERAL); andre@0: CASE(CKM_MD2_KEY_DERIVATION); andre@0: CASE(CKM_MD2_RSA_PKCS); andre@0: CASE(CKM_MD5); andre@0: CASE(CKM_MD5_HMAC); andre@0: CASE(CKM_MD5_HMAC_GENERAL); andre@0: CASE(CKM_MD5_KEY_DERIVATION); andre@0: CASE(CKM_MD5_RSA_PKCS); andre@0: CASE(CKM_PBA_SHA1_WITH_SHA1_HMAC); andre@0: CASE(CKM_PBE_MD2_DES_CBC); andre@0: CASE(CKM_PBE_MD5_DES_CBC); andre@0: CASE(CKM_PBE_SHA1_DES2_EDE_CBC); andre@0: CASE(CKM_PBE_SHA1_DES3_EDE_CBC); andre@0: CASE(CKM_PBE_SHA1_RC2_128_CBC); andre@0: CASE(CKM_PBE_SHA1_RC2_40_CBC); andre@0: CASE(CKM_PBE_SHA1_RC4_128); andre@0: CASE(CKM_PBE_SHA1_RC4_40); andre@0: CASE(CKM_PKCS5_PBKD2); andre@0: CASE(CKM_RC2_CBC); andre@0: CASE(CKM_RC2_CBC_PAD); andre@0: CASE(CKM_RC2_ECB); andre@0: CASE(CKM_RC2_KEY_GEN); andre@0: CASE(CKM_RC2_MAC); andre@0: CASE(CKM_RC2_MAC_GENERAL); andre@0: CASE(CKM_RC4); andre@0: CASE(CKM_RC4_KEY_GEN); andre@0: CASE(CKM_RC5_CBC); andre@0: CASE(CKM_RC5_CBC_PAD); andre@0: CASE(CKM_RC5_ECB); andre@0: CASE(CKM_RC5_KEY_GEN); andre@0: CASE(CKM_RC5_MAC); andre@0: CASE(CKM_RC5_MAC_GENERAL); andre@0: CASE(CKM_RIPEMD128); andre@0: CASE(CKM_RIPEMD128_HMAC); andre@0: CASE(CKM_RIPEMD128_HMAC_GENERAL); andre@0: CASE(CKM_RIPEMD128_RSA_PKCS); andre@0: CASE(CKM_RIPEMD160); andre@0: CASE(CKM_RIPEMD160_HMAC); andre@0: CASE(CKM_RIPEMD160_HMAC_GENERAL); andre@0: CASE(CKM_RIPEMD160_RSA_PKCS); andre@0: CASE(CKM_RSA_9796); andre@0: CASE(CKM_RSA_PKCS); andre@0: CASE(CKM_RSA_PKCS_KEY_PAIR_GEN); andre@0: CASE(CKM_RSA_PKCS_OAEP); andre@0: CASE(CKM_RSA_PKCS_PSS); andre@0: CASE(CKM_RSA_X9_31); andre@0: CASE(CKM_RSA_X9_31_KEY_PAIR_GEN); andre@0: CASE(CKM_RSA_X_509); andre@0: CASE(CKM_SHA1_KEY_DERIVATION); andre@0: CASE(CKM_SHA1_RSA_PKCS); andre@0: CASE(CKM_SHA1_RSA_PKCS_PSS); andre@0: CASE(CKM_SHA1_RSA_X9_31); andre@0: CASE(CKM_SHA224); andre@0: CASE(CKM_SHA224_HMAC); andre@0: CASE(CKM_SHA224_HMAC_GENERAL); andre@0: CASE(CKM_SHA224_KEY_DERIVATION); andre@0: CASE(CKM_SHA224_RSA_PKCS); andre@0: CASE(CKM_SHA224_RSA_PKCS_PSS); andre@0: CASE(CKM_SHA256); andre@0: CASE(CKM_SHA256_HMAC); andre@0: CASE(CKM_SHA256_HMAC_GENERAL); andre@0: CASE(CKM_SHA256_KEY_DERIVATION); andre@0: CASE(CKM_SHA256_RSA_PKCS); andre@0: CASE(CKM_SHA256_RSA_PKCS_PSS); andre@0: CASE(CKM_SHA384); andre@0: CASE(CKM_SHA384_HMAC); andre@0: CASE(CKM_SHA384_HMAC_GENERAL); andre@0: CASE(CKM_SHA384_KEY_DERIVATION); andre@0: CASE(CKM_SHA384_RSA_PKCS); andre@0: CASE(CKM_SHA384_RSA_PKCS_PSS); andre@0: CASE(CKM_SHA512); andre@0: CASE(CKM_SHA512_HMAC); andre@0: CASE(CKM_SHA512_HMAC_GENERAL); andre@0: CASE(CKM_SHA512_KEY_DERIVATION); andre@0: CASE(CKM_SHA512_RSA_PKCS); andre@0: CASE(CKM_SHA512_RSA_PKCS_PSS); andre@0: CASE(CKM_SHA_1); andre@0: CASE(CKM_SHA_1_HMAC); andre@0: CASE(CKM_SHA_1_HMAC_GENERAL); andre@0: CASE(CKM_SKIPJACK_CBC64); andre@0: CASE(CKM_SKIPJACK_CFB16); andre@0: CASE(CKM_SKIPJACK_CFB32); andre@0: CASE(CKM_SKIPJACK_CFB64); andre@0: CASE(CKM_SKIPJACK_CFB8); andre@0: CASE(CKM_SKIPJACK_ECB64); andre@0: CASE(CKM_SKIPJACK_KEY_GEN); andre@0: CASE(CKM_SKIPJACK_OFB64); andre@0: CASE(CKM_SKIPJACK_PRIVATE_WRAP); andre@0: CASE(CKM_SKIPJACK_RELAYX); andre@0: CASE(CKM_SKIPJACK_WRAP); andre@0: CASE(CKM_SSL3_KEY_AND_MAC_DERIVE); andre@0: CASE(CKM_SSL3_MASTER_KEY_DERIVE); andre@0: CASE(CKM_SSL3_MASTER_KEY_DERIVE_DH); andre@0: CASE(CKM_SSL3_MD5_MAC); andre@0: CASE(CKM_SSL3_PRE_MASTER_KEY_GEN); andre@0: CASE(CKM_SSL3_SHA1_MAC); andre@0: CASE(CKM_TLS_KEY_AND_MAC_DERIVE); andre@0: CASE(CKM_TLS_MASTER_KEY_DERIVE); andre@0: CASE(CKM_TLS_MASTER_KEY_DERIVE_DH); andre@0: CASE(CKM_TLS_PRE_MASTER_KEY_GEN); andre@0: CASE(CKM_TLS_PRF); andre@0: CASE(CKM_TWOFISH_CBC); andre@0: CASE(CKM_TWOFISH_KEY_GEN); andre@0: CASE(CKM_X9_42_DH_DERIVE); andre@0: CASE(CKM_X9_42_DH_HYBRID_DERIVE); andre@0: CASE(CKM_X9_42_DH_KEY_PAIR_GEN); andre@0: CASE(CKM_X9_42_DH_PARAMETER_GEN); andre@0: CASE(CKM_X9_42_MQV_DERIVE); andre@0: CASE(CKM_XOR_BASE_AND_DATA); andre@0: default: break; andre@0: } andre@0: if (a) andre@0: PR_LOG(modlog, 4, (" mechanism = %s", a)); andre@0: else andre@0: PR_LOG(modlog, 4, (" mechanism = 0x%p", m->mechanism)); andre@0: } andre@0: andre@0: static void get_key_type(CK_KEY_TYPE keyType, char *str, int len) andre@0: { andre@0: andre@0: const char * a = NULL; andre@0: andre@0: switch (keyType) { andre@0: CASE(CKK_AES); andre@0: CASE(CKK_CAMELLIA); andre@0: CASE(CKK_CDMF); andre@0: CASE(CKK_DES); andre@0: CASE(CKK_DES2); andre@0: CASE(CKK_DES3); andre@0: CASE(CKK_DH); andre@0: CASE(CKK_DSA); andre@0: CASE(CKK_EC); /* also CASE(CKK_ECDSA); */ andre@0: CASE(CKK_GENERIC_SECRET); andre@0: CASE(CKK_IDEA); andre@0: CASE(CKK_INVALID_KEY_TYPE); andre@0: CASE(CKK_KEA); andre@0: CASE(CKK_RC2); andre@0: CASE(CKK_RC4); andre@0: CASE(CKK_RC5); andre@0: CASE(CKK_RSA); andre@0: CASE(CKK_SKIPJACK); andre@0: CASE(CKK_TWOFISH); andre@0: CASE(CKK_X9_42_DH); andre@0: default: break; andre@0: } andre@0: if (a) andre@0: PR_snprintf(str, len, "%s", a); andre@0: else andre@0: PR_snprintf(str, len, "0x%p", keyType); andre@0: } andre@0: andre@0: static void print_attr_value(CK_ATTRIBUTE_PTR attr) andre@0: { andre@0: char atype[48]; andre@0: char valstr[49]; andre@0: int len; andre@0: andre@0: get_attr_type_str(attr->type, atype, sizeof atype); andre@0: switch (attr->type) { andre@0: case CKA_ALWAYS_SENSITIVE: andre@0: case CKA_DECRYPT: andre@0: case CKA_DERIVE: andre@0: case CKA_ENCRYPT: andre@0: case CKA_EXTRACTABLE: andre@0: case CKA_LOCAL: andre@0: case CKA_MODIFIABLE: andre@0: case CKA_NEVER_EXTRACTABLE: andre@0: case CKA_PRIVATE: andre@0: case CKA_SENSITIVE: andre@0: case CKA_SIGN: andre@0: case CKA_SIGN_RECOVER: andre@0: case CKA_TOKEN: andre@0: case CKA_UNWRAP: andre@0: case CKA_VERIFY: andre@0: case CKA_VERIFY_RECOVER: andre@0: case CKA_WRAP: andre@0: if (attr->ulValueLen > 0 && attr->pValue) { andre@0: CK_BBOOL tf = *((CK_BBOOL *)attr->pValue); andre@0: PR_LOG(modlog, 4, (fmt_s_s_d, andre@0: atype, tf ? "CK_TRUE" : "CK_FALSE", attr->ulValueLen)); andre@0: break; andre@0: } andre@0: case CKA_CLASS: andre@0: if (attr->ulValueLen > 0 && attr->pValue) { andre@0: CK_OBJECT_CLASS objClass = *((CK_OBJECT_CLASS *)attr->pValue); andre@0: get_obj_class(objClass, valstr, sizeof valstr); andre@0: PR_LOG(modlog, 4, (fmt_s_s_d, andre@0: atype, valstr, attr->ulValueLen)); andre@0: break; andre@0: } andre@0: case CKA_TRUST_CLIENT_AUTH: andre@0: case CKA_TRUST_CODE_SIGNING: andre@0: case CKA_TRUST_EMAIL_PROTECTION: andre@0: case CKA_TRUST_SERVER_AUTH: andre@0: if (attr->ulValueLen > 0 && attr->pValue) { andre@0: CK_TRUST trust = *((CK_TRUST *)attr->pValue); andre@0: get_trust_val(trust, valstr, sizeof valstr); andre@0: PR_LOG(modlog, 4, (fmt_s_s_d, andre@0: atype, valstr, attr->ulValueLen)); andre@0: break; andre@0: } andre@0: case CKA_KEY_TYPE: andre@0: if (attr->ulValueLen > 0 && attr->pValue) { andre@0: CK_KEY_TYPE keyType = *((CK_KEY_TYPE *)attr->pValue); andre@0: get_key_type(keyType, valstr, sizeof valstr); andre@0: PR_LOG(modlog, 4, (fmt_s_s_d, andre@0: atype, valstr, attr->ulValueLen)); andre@0: break; andre@0: } andre@0: case CKA_PIXEL_X: andre@0: case CKA_PIXEL_Y: andre@0: case CKA_RESOLUTION: andre@0: case CKA_CHAR_ROWS: andre@0: case CKA_CHAR_COLUMNS: andre@0: case CKA_BITS_PER_PIXEL: andre@0: case CKA_CERTIFICATE_CATEGORY: /* should print as enum/string */ andre@0: case CKA_JAVA_MIDP_SECURITY_DOMAIN: /* should print as enum/string */ andre@0: case CKA_MODULUS_BITS: andre@0: case CKA_PRIME_BITS: andre@0: case CKA_SUBPRIME_BITS: andre@0: case CKA_VALUE_BITS: andre@0: case CKA_VALUE_LEN: andre@0: if (attr->ulValueLen > 0 && attr->pValue) { andre@0: CK_ULONG valueLen = *((CK_ULONG *)attr->pValue); andre@0: /* XXX check for the special value CK_UNAVAILABLE_INFORMATION */ andre@0: PR_LOG(modlog, 4, (fmt_s_lu, atype, (PRUint32)valueLen)); andre@0: break; andre@0: } andre@0: case CKA_LABEL: andre@0: case CKA_NSS_EMAIL: andre@0: case CKA_NSS_URL: andre@0: if (attr->ulValueLen > 0 && attr->pValue) { andre@0: len = PR_MIN(attr->ulValueLen + 1, sizeof valstr); andre@0: PR_snprintf(valstr, len, "%s", attr->pValue); andre@0: PR_LOG(modlog, 4, (fmt_s_qsq_d, andre@0: atype, valstr, attr->ulValueLen)); andre@0: break; andre@0: } andre@0: case CKA_ISSUER: andre@0: case CKA_SUBJECT: andre@0: if (attr->ulValueLen > 0 && attr->pValue) { andre@0: char * asciiName; andre@0: SECItem derName; andre@0: derName.type = siDERNameBuffer; andre@0: derName.data = attr->pValue; andre@0: derName.len = attr->ulValueLen; andre@0: asciiName = CERT_DerNameToAscii(&derName); andre@0: if (asciiName) { andre@0: PR_LOG(modlog, 4, (fmt_s_s_d, andre@0: atype, asciiName, attr->ulValueLen)); andre@0: PORT_Free(asciiName); andre@0: break; andre@0: } andre@0: /* else treat like a binary buffer */ andre@0: goto binary_buffer; andre@0: } andre@0: case CKA_ID: andre@0: if (attr->ulValueLen > 0 && attr->pValue) { andre@0: unsigned char * pV = attr->pValue; andre@0: for (len = (int)attr->ulValueLen; len > 0; --len) { andre@0: unsigned int ch = *pV++; andre@0: if (ch >= 0x20 && ch < 0x7f) andre@0: continue; andre@0: if (!ch && len == 1) /* will ignore NUL if last character */ andre@0: continue; andre@0: break; andre@0: } andre@0: if (!len) { /* entire string is printable */ andre@0: len = PR_MIN(attr->ulValueLen + 1, sizeof valstr); andre@0: PR_snprintf(valstr, len, "%s", attr->pValue); andre@0: PR_LOG(modlog, 4, (fmt_s_qsq_d, andre@0: atype, valstr, attr->ulValueLen)); andre@0: break; andre@0: } andre@0: /* else fall through and treat like a binary buffer */ andre@0: } andre@0: binary_buffer: andre@0: case CKA_SERIAL_NUMBER: andre@0: default: andre@0: if (attr->ulValueLen > 0 && attr->pValue) { andre@0: char * hexBuf; andre@0: SECItem attrBuf; andre@0: attrBuf.type = siDERNameBuffer; andre@0: attrBuf.data = attr->pValue; andre@0: attrBuf.len = PR_MIN(attr->ulValueLen, (sizeof valstr)/2); andre@0: andre@0: hexBuf = CERT_Hexify(&attrBuf, PR_FALSE); andre@0: if (hexBuf) { andre@0: PR_LOG(modlog, 4, (fmt_s_s_d, andre@0: atype, hexBuf, attr->ulValueLen)); andre@0: PORT_Free(hexBuf); andre@0: break; andre@0: } andre@0: /* else fall through and show only the address. :( */ andre@0: } andre@0: PR_LOG(modlog, 4, (" %s = [0x%p] [%d]", andre@0: atype, attr->pValue, attr->ulValueLen)); andre@0: break; andre@0: } andre@0: } andre@0: andre@0: static void print_template(CK_ATTRIBUTE_PTR templ, CK_ULONG tlen) andre@0: { andre@0: CK_ULONG i; andre@0: for (i=0; iC_Initialize(pInitArgs); andre@0: nssdbg_finish_time(FUNC_C_INITIALIZE,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_Finalize( andre@0: CK_VOID_PTR pReserved andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_Finalize")); andre@0: PR_LOG(modlog, 3, (" pReserved = 0x%p", pReserved)); andre@0: nssdbg_start_time(FUNC_C_FINALIZE,&start); andre@0: rv = module_functions->C_Finalize(pReserved); andre@0: nssdbg_finish_time(FUNC_C_FINALIZE,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_GetInfo( andre@0: CK_INFO_PTR pInfo andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_GetInfo")); andre@0: PR_LOG(modlog, 3, (fmt_pInfo, pInfo)); andre@0: nssdbg_start_time(FUNC_C_GETINFO,&start); andre@0: rv = module_functions->C_GetInfo(pInfo); andre@0: nssdbg_finish_time(FUNC_C_GETINFO,start); andre@0: if (rv == CKR_OK) { andre@0: PR_LOG(modlog, 4, (" cryptoki version: %d.%d", andre@0: pInfo->cryptokiVersion.major, andre@0: pInfo->cryptokiVersion.minor)); andre@0: PR_LOG(modlog, 4, (fmt_manufacturerID, pInfo->manufacturerID)); andre@0: PR_LOG(modlog, 4, (" library description = \"%.32s\"", andre@0: pInfo->libraryDescription)); andre@0: PR_LOG(modlog, 4, (" library version: %d.%d", andre@0: pInfo->libraryVersion.major, andre@0: pInfo->libraryVersion.minor)); andre@0: } andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_GetFunctionList( andre@0: CK_FUNCTION_LIST_PTR_PTR ppFunctionList andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_GetFunctionList")); andre@0: PR_LOG(modlog, 3, (" ppFunctionList = 0x%p", ppFunctionList)); andre@0: nssdbg_start_time(FUNC_C_GETFUNCITONLIST,&start); andre@0: rv = module_functions->C_GetFunctionList(ppFunctionList); andre@0: nssdbg_finish_time(FUNC_C_GETFUNCITONLIST,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_GetSlotList( andre@0: CK_BBOOL tokenPresent, andre@0: CK_SLOT_ID_PTR pSlotList, andre@0: CK_ULONG_PTR pulCount andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: CK_ULONG i; andre@0: PR_LOG(modlog, 1, ("C_GetSlotList")); andre@0: PR_LOG(modlog, 3, (" tokenPresent = 0x%x", tokenPresent)); andre@0: PR_LOG(modlog, 3, (" pSlotList = 0x%p", pSlotList)); andre@0: PR_LOG(modlog, 3, (fmt_pulCount, pulCount)); andre@0: nssdbg_start_time(FUNC_C_GETSLOTLIST,&start); andre@0: rv = module_functions->C_GetSlotList(tokenPresent, pSlotList, pulCount); andre@0: nssdbg_finish_time(FUNC_C_GETSLOTLIST,start); andre@0: PR_LOG(modlog, 4, (fmt_spulCount, *pulCount)); andre@0: if (pSlotList) { andre@0: for (i=0; i<*pulCount; i++) { andre@0: PR_LOG(modlog, 4, (" slotID[%d] = %x", i, pSlotList[i])); andre@0: } andre@0: } andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_GetSlotInfo( andre@0: CK_SLOT_ID slotID, andre@0: CK_SLOT_INFO_PTR pInfo andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_GetSlotInfo")); andre@0: PR_LOG(modlog, 3, (fmt_slotID, slotID)); andre@0: PR_LOG(modlog, 3, (fmt_pInfo, pInfo)); andre@0: nssdbg_start_time(FUNC_C_GETSLOTINFO,&start); andre@0: rv = module_functions->C_GetSlotInfo(slotID, pInfo); andre@0: nssdbg_finish_time(FUNC_C_GETSLOTINFO,start); andre@0: if (rv == CKR_OK) { andre@0: PR_LOG(modlog, 4, (" slotDescription = \"%.64s\"", andre@0: pInfo->slotDescription)); andre@0: PR_LOG(modlog, 4, (fmt_manufacturerID, pInfo->manufacturerID)); andre@0: PR_LOG(modlog, 4, (" flags = %s %s %s", andre@0: pInfo->flags & CKF_HW_SLOT ? "CKF_HW_SLOT" : "", andre@0: pInfo->flags & CKF_REMOVABLE_DEVICE ? "CKF_REMOVABLE_DEVICE" : "", andre@0: pInfo->flags & CKF_TOKEN_PRESENT ? "CKF_TOKEN_PRESENT" : "")); andre@0: PR_LOG(modlog, 4, (fmt_hwVersion, andre@0: pInfo->hardwareVersion.major, andre@0: pInfo->hardwareVersion.minor)); andre@0: PR_LOG(modlog, 4, (fmt_fwVersion, andre@0: pInfo->firmwareVersion.major, andre@0: pInfo->firmwareVersion.minor)); andre@0: } andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_GetTokenInfo( andre@0: CK_SLOT_ID slotID, andre@0: CK_TOKEN_INFO_PTR pInfo andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_GetTokenInfo")); andre@0: PR_LOG(modlog, 3, (fmt_slotID, slotID)); andre@0: PR_LOG(modlog, 3, (fmt_pInfo, pInfo)); andre@0: nssdbg_start_time(FUNC_C_GETTOKENINFO,&start); andre@0: rv = module_functions->C_GetTokenInfo(slotID, pInfo); andre@0: nssdbg_finish_time(FUNC_C_GETTOKENINFO,start); andre@0: if (rv == CKR_OK) { andre@0: PR_LOG(modlog, 4, (" label = \"%.32s\"", pInfo->label)); andre@0: PR_LOG(modlog, 4, (fmt_manufacturerID, pInfo->manufacturerID)); andre@0: PR_LOG(modlog, 4, (" model = \"%.16s\"", pInfo->model)); andre@0: PR_LOG(modlog, 4, (" serial = \"%.16s\"", pInfo->serialNumber)); andre@0: PR_LOG(modlog, 4, (" flags = %s %s %s %s", andre@0: pInfo->flags & CKF_RNG ? "CKF_RNG" : "", andre@0: pInfo->flags & CKF_WRITE_PROTECTED ? "CKF_WRITE_PROTECTED" : "", andre@0: pInfo->flags & CKF_LOGIN_REQUIRED ? "CKF_LOGIN_REQUIRED" : "", andre@0: pInfo->flags & CKF_USER_PIN_INITIALIZED ? "CKF_USER_PIN_INIT" : "")); andre@0: PR_LOG(modlog, 4, (" maxSessions = %u, Sessions = %u", andre@0: pInfo->ulMaxSessionCount, pInfo->ulSessionCount)); andre@0: PR_LOG(modlog, 4, (" maxRwSessions = %u, RwSessions = %u", andre@0: pInfo->ulMaxRwSessionCount, andre@0: pInfo->ulRwSessionCount)); andre@0: /* ignore Max & Min Pin Len, Public and Private Memory */ andre@0: PR_LOG(modlog, 4, (fmt_hwVersion, andre@0: pInfo->hardwareVersion.major, andre@0: pInfo->hardwareVersion.minor)); andre@0: PR_LOG(modlog, 4, (fmt_fwVersion, andre@0: pInfo->firmwareVersion.major, andre@0: pInfo->firmwareVersion.minor)); andre@0: } andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_GetMechanismList( andre@0: CK_SLOT_ID slotID, andre@0: CK_MECHANISM_TYPE_PTR pMechanismList, andre@0: CK_ULONG_PTR pulCount andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_GetMechanismList")); andre@0: PR_LOG(modlog, 3, (fmt_slotID, slotID)); andre@0: PR_LOG(modlog, 3, (" pMechanismList = 0x%p", pMechanismList)); andre@0: PR_LOG(modlog, 3, (fmt_pulCount, pulCount)); andre@0: nssdbg_start_time(FUNC_C_GETMECHANISMLIST,&start); andre@0: rv = module_functions->C_GetMechanismList(slotID, andre@0: pMechanismList, andre@0: pulCount); andre@0: nssdbg_finish_time(FUNC_C_GETMECHANISMLIST,start); andre@0: PR_LOG(modlog, 4, (fmt_spulCount, *pulCount)); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_GetMechanismInfo( andre@0: CK_SLOT_ID slotID, andre@0: CK_MECHANISM_TYPE type, andre@0: CK_MECHANISM_INFO_PTR pInfo andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_GetMechanismInfo")); andre@0: PR_LOG(modlog, 3, (fmt_slotID, slotID)); andre@0: PR_LOG(modlog, 3, (" type = 0x%x", type)); andre@0: PR_LOG(modlog, 3, (fmt_pInfo, pInfo)); andre@0: nssdbg_start_time(FUNC_C_GETMECHANISMINFO,&start); andre@0: rv = module_functions->C_GetMechanismInfo(slotID, andre@0: type, andre@0: pInfo); andre@0: nssdbg_finish_time(FUNC_C_GETMECHANISMINFO,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_InitToken( andre@0: CK_SLOT_ID slotID, andre@0: CK_CHAR_PTR pPin, andre@0: CK_ULONG ulPinLen, andre@0: CK_CHAR_PTR pLabel andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_InitToken")); andre@0: PR_LOG(modlog, 3, (fmt_slotID, slotID)); andre@0: PR_LOG(modlog, 3, (fmt_pPin, pPin)); andre@0: PR_LOG(modlog, 3, (fmt_ulPinLen, ulPinLen)); andre@0: PR_LOG(modlog, 3, (" pLabel = 0x%p", pLabel)); andre@0: nssdbg_start_time(FUNC_C_INITTOKEN,&start); andre@0: rv = module_functions->C_InitToken(slotID, andre@0: pPin, andre@0: ulPinLen, andre@0: pLabel); andre@0: nssdbg_finish_time(FUNC_C_INITTOKEN,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_InitPIN( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_CHAR_PTR pPin, andre@0: CK_ULONG ulPinLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_InitPIN")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pPin, pPin)); andre@0: PR_LOG(modlog, 3, (fmt_ulPinLen, ulPinLen)); andre@0: nssdbg_start_time(FUNC_C_INITPIN,&start); andre@0: rv = module_functions->C_InitPIN(hSession, andre@0: pPin, andre@0: ulPinLen); andre@0: nssdbg_finish_time(FUNC_C_INITPIN,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_SetPIN( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_CHAR_PTR pOldPin, andre@0: CK_ULONG ulOldLen, andre@0: CK_CHAR_PTR pNewPin, andre@0: CK_ULONG ulNewLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_SetPIN")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (" pOldPin = 0x%p", pOldPin)); andre@0: PR_LOG(modlog, 3, (" ulOldLen = %d", ulOldLen)); andre@0: PR_LOG(modlog, 3, (" pNewPin = 0x%p", pNewPin)); andre@0: PR_LOG(modlog, 3, (" ulNewLen = %d", ulNewLen)); andre@0: nssdbg_start_time(FUNC_C_SETPIN,&start); andre@0: rv = module_functions->C_SetPIN(hSession, andre@0: pOldPin, andre@0: ulOldLen, andre@0: pNewPin, andre@0: ulNewLen); andre@0: nssdbg_finish_time(FUNC_C_SETPIN,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: static PRUint32 numOpenSessions = 0; andre@0: static PRUint32 maxOpenSessions = 0; andre@0: andre@0: CK_RV NSSDBGC_OpenSession( andre@0: CK_SLOT_ID slotID, andre@0: CK_FLAGS flags, andre@0: CK_VOID_PTR pApplication, andre@0: CK_NOTIFY Notify, andre@0: CK_SESSION_HANDLE_PTR phSession andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_ATOMIC_INCREMENT((PRInt32 *)&numOpenSessions); andre@0: maxOpenSessions = PR_MAX(numOpenSessions, maxOpenSessions); andre@0: PR_LOG(modlog, 1, ("C_OpenSession")); andre@0: PR_LOG(modlog, 3, (fmt_slotID, slotID)); andre@0: PR_LOG(modlog, 3, (fmt_flags, flags)); andre@0: PR_LOG(modlog, 3, (" pApplication = 0x%p", pApplication)); andre@0: PR_LOG(modlog, 3, (" Notify = 0x%x", Notify)); andre@0: PR_LOG(modlog, 3, (" phSession = 0x%p", phSession)); andre@0: nssdbg_start_time(FUNC_C_OPENSESSION,&start); andre@0: rv = module_functions->C_OpenSession(slotID, andre@0: flags, andre@0: pApplication, andre@0: Notify, andre@0: phSession); andre@0: nssdbg_finish_time(FUNC_C_OPENSESSION,start); andre@0: log_handle(4, " *phSession = 0x%x", *phSession); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_CloseSession( andre@0: CK_SESSION_HANDLE hSession andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_ATOMIC_DECREMENT((PRInt32 *)&numOpenSessions); andre@0: PR_LOG(modlog, 1, ("C_CloseSession")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: nssdbg_start_time(FUNC_C_CLOSESESSION,&start); andre@0: rv = module_functions->C_CloseSession(hSession); andre@0: nssdbg_finish_time(FUNC_C_CLOSESESSION,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_CloseAllSessions( andre@0: CK_SLOT_ID slotID andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_CloseAllSessions")); andre@0: PR_LOG(modlog, 3, (fmt_slotID, slotID)); andre@0: nssdbg_start_time(FUNC_C_CLOSEALLSESSIONS,&start); andre@0: rv = module_functions->C_CloseAllSessions(slotID); andre@0: nssdbg_finish_time(FUNC_C_CLOSEALLSESSIONS,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_GetSessionInfo( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_SESSION_INFO_PTR pInfo andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_GetSessionInfo")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pInfo, pInfo)); andre@0: nssdbg_start_time(FUNC_C_GETSESSIONINFO,&start); andre@0: rv = module_functions->C_GetSessionInfo(hSession, andre@0: pInfo); andre@0: nssdbg_finish_time(FUNC_C_GETSESSIONINFO,start); andre@0: if (rv == CKR_OK) { andre@0: PR_LOG(modlog, 4, (fmt_slotID, pInfo->slotID)); andre@0: log_state(pInfo->state); andre@0: PR_LOG(modlog, 4, (" flags = %s %s", andre@0: pInfo->flags & CKF_RW_SESSION ? "CKF_RW_SESSION" : "", andre@0: pInfo->flags & CKF_SERIAL_SESSION ? "CKF_SERIAL_SESSION" : "")); andre@0: PR_LOG(modlog, 4, (" deviceError = 0x%x", pInfo->ulDeviceError)); andre@0: } andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_GetOperationState( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pOperationState, andre@0: CK_ULONG_PTR pulOperationStateLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_GetOperationState")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pOperationState, pOperationState)); andre@0: PR_LOG(modlog, 3, (" pulOperationStateLen = 0x%p", pulOperationStateLen)); andre@0: nssdbg_start_time(FUNC_C_GETOPERATIONSTATE,&start); andre@0: rv = module_functions->C_GetOperationState(hSession, andre@0: pOperationState, andre@0: pulOperationStateLen); andre@0: nssdbg_finish_time(FUNC_C_GETOPERATIONSTATE,start); andre@0: PR_LOG(modlog, 4, (" *pulOperationStateLen = 0x%x", *pulOperationStateLen)); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_SetOperationState( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pOperationState, andre@0: CK_ULONG ulOperationStateLen, andre@0: CK_OBJECT_HANDLE hEncryptionKey, andre@0: CK_OBJECT_HANDLE hAuthenticationKey andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_SetOperationState")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pOperationState, pOperationState)); andre@0: PR_LOG(modlog, 3, (" ulOperationStateLen = %d", ulOperationStateLen)); andre@0: log_handle(3, " hEncryptionKey = 0x%x", hEncryptionKey); andre@0: log_handle(3, " hAuthenticationKey = 0x%x", hAuthenticationKey); andre@0: nssdbg_start_time(FUNC_C_SETOPERATIONSTATE,&start); andre@0: rv = module_functions->C_SetOperationState(hSession, andre@0: pOperationState, andre@0: ulOperationStateLen, andre@0: hEncryptionKey, andre@0: hAuthenticationKey); andre@0: nssdbg_finish_time(FUNC_C_SETOPERATIONSTATE,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_Login( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_USER_TYPE userType, andre@0: CK_CHAR_PTR pPin, andre@0: CK_ULONG ulPinLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_Login")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (" userType = 0x%x", userType)); andre@0: PR_LOG(modlog, 3, (fmt_pPin, pPin)); andre@0: PR_LOG(modlog, 3, (fmt_ulPinLen, ulPinLen)); andre@0: nssdbg_start_time(FUNC_C_LOGIN,&start); andre@0: rv = module_functions->C_Login(hSession, andre@0: userType, andre@0: pPin, andre@0: ulPinLen); andre@0: nssdbg_finish_time(FUNC_C_LOGIN,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_Logout( andre@0: CK_SESSION_HANDLE hSession andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_Logout")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: nssdbg_start_time(FUNC_C_LOGOUT,&start); andre@0: rv = module_functions->C_Logout(hSession); andre@0: nssdbg_finish_time(FUNC_C_LOGOUT,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_CreateObject( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_ATTRIBUTE_PTR pTemplate, andre@0: CK_ULONG ulCount, andre@0: CK_OBJECT_HANDLE_PTR phObject andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_CreateObject")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); andre@0: PR_LOG(modlog, 3, (fmt_ulCount, ulCount)); andre@0: PR_LOG(modlog, 3, (fmt_phObject, phObject)); andre@0: print_template(pTemplate, ulCount); andre@0: nssdbg_start_time(FUNC_C_CREATEOBJECT,&start); andre@0: rv = module_functions->C_CreateObject(hSession, andre@0: pTemplate, andre@0: ulCount, andre@0: phObject); andre@0: nssdbg_finish_time(FUNC_C_CREATEOBJECT,start); andre@0: log_handle(4, " *phObject = 0x%x", *phObject); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_CopyObject( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_OBJECT_HANDLE hObject, andre@0: CK_ATTRIBUTE_PTR pTemplate, andre@0: CK_ULONG ulCount, andre@0: CK_OBJECT_HANDLE_PTR phNewObject andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_CopyObject")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: log_handle(3, fmt_hObject, hObject); andre@0: PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); andre@0: PR_LOG(modlog, 3, (fmt_ulCount, ulCount)); andre@0: PR_LOG(modlog, 3, (" phNewObject = 0x%p", phNewObject)); andre@0: print_template(pTemplate, ulCount); andre@0: nssdbg_start_time(FUNC_C_COPYOBJECT,&start); andre@0: rv = module_functions->C_CopyObject(hSession, andre@0: hObject, andre@0: pTemplate, andre@0: ulCount, andre@0: phNewObject); andre@0: nssdbg_finish_time(FUNC_C_COPYOBJECT,start); andre@0: log_handle(4, " *phNewObject = 0x%x", *phNewObject); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_DestroyObject( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_OBJECT_HANDLE hObject andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_DestroyObject")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: log_handle(3, fmt_hObject, hObject); andre@0: nssdbg_start_time(FUNC_C_DESTROYOBJECT,&start); andre@0: rv = module_functions->C_DestroyObject(hSession, andre@0: hObject); andre@0: nssdbg_finish_time(FUNC_C_DESTROYOBJECT,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_GetObjectSize( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_OBJECT_HANDLE hObject, andre@0: CK_ULONG_PTR pulSize andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_GetObjectSize")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: log_handle(3, fmt_hObject, hObject); andre@0: PR_LOG(modlog, 3, (" pulSize = 0x%p", pulSize)); andre@0: nssdbg_start_time(FUNC_C_GETOBJECTSIZE,&start); andre@0: rv = module_functions->C_GetObjectSize(hSession, andre@0: hObject, andre@0: pulSize); andre@0: nssdbg_finish_time(FUNC_C_GETOBJECTSIZE,start); andre@0: PR_LOG(modlog, 4, (" *pulSize = 0x%x", *pulSize)); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_GetAttributeValue( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_OBJECT_HANDLE hObject, andre@0: CK_ATTRIBUTE_PTR pTemplate, andre@0: CK_ULONG ulCount andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_GetAttributeValue")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: log_handle(3, fmt_hObject, hObject); andre@0: PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); andre@0: PR_LOG(modlog, 3, (fmt_ulCount, ulCount)); andre@0: nssdbg_start_time(FUNC_C_GETATTRIBUTEVALUE,&start); andre@0: rv = module_functions->C_GetAttributeValue(hSession, andre@0: hObject, andre@0: pTemplate, andre@0: ulCount); andre@0: nssdbg_finish_time(FUNC_C_GETATTRIBUTEVALUE,start); andre@0: print_template(pTemplate, ulCount); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_SetAttributeValue( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_OBJECT_HANDLE hObject, andre@0: CK_ATTRIBUTE_PTR pTemplate, andre@0: CK_ULONG ulCount andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_SetAttributeValue")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: log_handle(3, fmt_hObject, hObject); andre@0: PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); andre@0: PR_LOG(modlog, 3, (fmt_ulCount, ulCount)); andre@0: print_template(pTemplate, ulCount); andre@0: nssdbg_start_time(FUNC_C_SETATTRIBUTEVALUE,&start); andre@0: rv = module_functions->C_SetAttributeValue(hSession, andre@0: hObject, andre@0: pTemplate, andre@0: ulCount); andre@0: nssdbg_finish_time(FUNC_C_SETATTRIBUTEVALUE,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_FindObjectsInit( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_ATTRIBUTE_PTR pTemplate, andre@0: CK_ULONG ulCount andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_FindObjectsInit")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); andre@0: PR_LOG(modlog, 3, (fmt_ulCount, ulCount)); andre@0: print_template(pTemplate, ulCount); andre@0: nssdbg_start_time(FUNC_C_FINDOBJECTSINIT,&start); andre@0: rv = module_functions->C_FindObjectsInit(hSession, andre@0: pTemplate, andre@0: ulCount); andre@0: nssdbg_finish_time(FUNC_C_FINDOBJECTSINIT,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_FindObjects( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_OBJECT_HANDLE_PTR phObject, andre@0: CK_ULONG ulMaxObjectCount, andre@0: CK_ULONG_PTR pulObjectCount andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: CK_ULONG i; andre@0: andre@0: PR_LOG(modlog, 1, ("C_FindObjects")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_phObject, phObject)); andre@0: PR_LOG(modlog, 3, (" ulMaxObjectCount = %d", ulMaxObjectCount)); andre@0: PR_LOG(modlog, 3, (" pulObjectCount = 0x%p", pulObjectCount)); andre@0: nssdbg_start_time(FUNC_C_FINDOBJECTS,&start); andre@0: rv = module_functions->C_FindObjects(hSession, andre@0: phObject, andre@0: ulMaxObjectCount, andre@0: pulObjectCount); andre@0: nssdbg_finish_time(FUNC_C_FINDOBJECTS,start); andre@0: PR_LOG(modlog, 4, (" *pulObjectCount = 0x%x", *pulObjectCount)); andre@0: for (i=0; i<*pulObjectCount; i++) { andre@0: PR_LOG(modlog, 4, (" phObject[%d] = 0x%x%s", i, phObject[i], andre@0: phObject[i] ? "" : fmt_invalid_handle)); andre@0: } andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_FindObjectsFinal( andre@0: CK_SESSION_HANDLE hSession andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_FindObjectsFinal")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: nssdbg_start_time(FUNC_C_FINDOBJECTSFINAL,&start); andre@0: rv = module_functions->C_FindObjectsFinal(hSession); andre@0: nssdbg_finish_time(FUNC_C_FINDOBJECTSFINAL,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_EncryptInit( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_MECHANISM_PTR pMechanism, andre@0: CK_OBJECT_HANDLE hKey andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_EncryptInit")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); andre@0: log_handle(3, fmt_hKey, hKey); andre@0: print_mechanism(pMechanism); andre@0: nssdbg_start_time(FUNC_C_ENCRYPTINIT,&start); andre@0: rv = module_functions->C_EncryptInit(hSession, andre@0: pMechanism, andre@0: hKey); andre@0: nssdbg_finish_time(FUNC_C_ENCRYPTINIT,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_Encrypt( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pData, andre@0: CK_ULONG ulDataLen, andre@0: CK_BYTE_PTR pEncryptedData, andre@0: CK_ULONG_PTR pulEncryptedDataLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_Encrypt")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pData, pData)); andre@0: PR_LOG(modlog, 3, (fmt_ulDataLen, ulDataLen)); andre@0: PR_LOG(modlog, 3, (fmt_pEncryptedData, pEncryptedData)); andre@0: PR_LOG(modlog, 3, (" pulEncryptedDataLen = 0x%p", pulEncryptedDataLen)); andre@0: nssdbg_start_time(FUNC_C_ENCRYPT,&start); andre@0: rv = module_functions->C_Encrypt(hSession, andre@0: pData, andre@0: ulDataLen, andre@0: pEncryptedData, andre@0: pulEncryptedDataLen); andre@0: nssdbg_finish_time(FUNC_C_ENCRYPT,start); andre@0: PR_LOG(modlog, 4, (" *pulEncryptedDataLen = 0x%x", *pulEncryptedDataLen)); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_EncryptUpdate( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pPart, andre@0: CK_ULONG ulPartLen, andre@0: CK_BYTE_PTR pEncryptedPart, andre@0: CK_ULONG_PTR pulEncryptedPartLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_EncryptUpdate")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pPart, pPart)); andre@0: PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen)); andre@0: PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart)); andre@0: PR_LOG(modlog, 3, (fmt_pulEncryptedPartLen, pulEncryptedPartLen)); andre@0: nssdbg_start_time(FUNC_C_ENCRYPTUPDATE,&start); andre@0: rv = module_functions->C_EncryptUpdate(hSession, andre@0: pPart, andre@0: ulPartLen, andre@0: pEncryptedPart, andre@0: pulEncryptedPartLen); andre@0: nssdbg_finish_time(FUNC_C_ENCRYPTUPDATE,start); andre@0: PR_LOG(modlog, 4, (fmt_spulEncryptedPartLen, *pulEncryptedPartLen)); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_EncryptFinal( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pLastEncryptedPart, andre@0: CK_ULONG_PTR pulLastEncryptedPartLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_EncryptFinal")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (" pLastEncryptedPart = 0x%p", pLastEncryptedPart)); andre@0: PR_LOG(modlog, 3, (" pulLastEncryptedPartLen = 0x%p", pulLastEncryptedPartLen)); andre@0: nssdbg_start_time(FUNC_C_ENCRYPTFINAL,&start); andre@0: rv = module_functions->C_EncryptFinal(hSession, andre@0: pLastEncryptedPart, andre@0: pulLastEncryptedPartLen); andre@0: nssdbg_finish_time(FUNC_C_ENCRYPTFINAL,start); andre@0: PR_LOG(modlog, 4, (" *pulLastEncryptedPartLen = 0x%x", *pulLastEncryptedPartLen)); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_DecryptInit( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_MECHANISM_PTR pMechanism, andre@0: CK_OBJECT_HANDLE hKey andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_DecryptInit")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); andre@0: log_handle(3, fmt_hKey, hKey); andre@0: print_mechanism(pMechanism); andre@0: nssdbg_start_time(FUNC_C_DECRYPTINIT,&start); andre@0: rv = module_functions->C_DecryptInit(hSession, andre@0: pMechanism, andre@0: hKey); andre@0: nssdbg_finish_time(FUNC_C_DECRYPTINIT,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_Decrypt( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pEncryptedData, andre@0: CK_ULONG ulEncryptedDataLen, andre@0: CK_BYTE_PTR pData, andre@0: CK_ULONG_PTR pulDataLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_Decrypt")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pEncryptedData, pEncryptedData)); andre@0: PR_LOG(modlog, 3, (" ulEncryptedDataLen = %d", ulEncryptedDataLen)); andre@0: PR_LOG(modlog, 3, (fmt_pData, pData)); andre@0: PR_LOG(modlog, 3, (fmt_pulDataLen, pulDataLen)); andre@0: nssdbg_start_time(FUNC_C_DECRYPT,&start); andre@0: rv = module_functions->C_Decrypt(hSession, andre@0: pEncryptedData, andre@0: ulEncryptedDataLen, andre@0: pData, andre@0: pulDataLen); andre@0: nssdbg_finish_time(FUNC_C_DECRYPT,start); andre@0: PR_LOG(modlog, 4, (fmt_spulDataLen, *pulDataLen)); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_DecryptUpdate( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pEncryptedPart, andre@0: CK_ULONG ulEncryptedPartLen, andre@0: CK_BYTE_PTR pPart, andre@0: CK_ULONG_PTR pulPartLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_DecryptUpdate")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart)); andre@0: PR_LOG(modlog, 3, (fmt_ulEncryptedPartLen, ulEncryptedPartLen)); andre@0: PR_LOG(modlog, 3, (fmt_pPart, pPart)); andre@0: PR_LOG(modlog, 3, (fmt_pulPartLen, pulPartLen)); andre@0: nssdbg_start_time(FUNC_C_DECRYPTUPDATE,&start); andre@0: rv = module_functions->C_DecryptUpdate(hSession, andre@0: pEncryptedPart, andre@0: ulEncryptedPartLen, andre@0: pPart, andre@0: pulPartLen); andre@0: nssdbg_finish_time(FUNC_C_DECRYPTUPDATE,start); andre@0: PR_LOG(modlog, 4, (fmt_spulPartLen, *pulPartLen)); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_DecryptFinal( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pLastPart, andre@0: CK_ULONG_PTR pulLastPartLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_DecryptFinal")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (" pLastPart = 0x%p", pLastPart)); andre@0: PR_LOG(modlog, 3, (" pulLastPartLen = 0x%p", pulLastPartLen)); andre@0: nssdbg_start_time(FUNC_C_DECRYPTFINAL,&start); andre@0: rv = module_functions->C_DecryptFinal(hSession, andre@0: pLastPart, andre@0: pulLastPartLen); andre@0: nssdbg_finish_time(FUNC_C_DECRYPTFINAL,start); andre@0: PR_LOG(modlog, 4, (" *pulLastPartLen = 0x%x", *pulLastPartLen)); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_DigestInit( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_MECHANISM_PTR pMechanism andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_DigestInit")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); andre@0: print_mechanism(pMechanism); andre@0: nssdbg_start_time(FUNC_C_DIGESTINIT,&start); andre@0: rv = module_functions->C_DigestInit(hSession, andre@0: pMechanism); andre@0: nssdbg_finish_time(FUNC_C_DIGESTINIT,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_Digest( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pData, andre@0: CK_ULONG ulDataLen, andre@0: CK_BYTE_PTR pDigest, andre@0: CK_ULONG_PTR pulDigestLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_Digest")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pData, pData)); andre@0: PR_LOG(modlog, 3, (fmt_ulDataLen, ulDataLen)); andre@0: PR_LOG(modlog, 3, (fmt_pDigest, pDigest)); andre@0: PR_LOG(modlog, 3, (fmt_pulDigestLen, pulDigestLen)); andre@0: nssdbg_start_time(FUNC_C_DIGEST,&start); andre@0: rv = module_functions->C_Digest(hSession, andre@0: pData, andre@0: ulDataLen, andre@0: pDigest, andre@0: pulDigestLen); andre@0: nssdbg_finish_time(FUNC_C_DIGEST,start); andre@0: PR_LOG(modlog, 4, (fmt_spulDigestLen, *pulDigestLen)); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_DigestUpdate( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pPart, andre@0: CK_ULONG ulPartLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_DigestUpdate")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pPart, pPart)); andre@0: PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen)); andre@0: nssdbg_start_time(FUNC_C_DIGESTUPDATE,&start); andre@0: rv = module_functions->C_DigestUpdate(hSession, andre@0: pPart, andre@0: ulPartLen); andre@0: nssdbg_finish_time(FUNC_C_DIGESTUPDATE,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_DigestKey( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_OBJECT_HANDLE hKey andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_DigestKey")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: nssdbg_start_time(FUNC_C_DIGESTKEY,&start); andre@0: rv = module_functions->C_DigestKey(hSession, andre@0: hKey); andre@0: nssdbg_finish_time(FUNC_C_DIGESTKEY,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_DigestFinal( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pDigest, andre@0: CK_ULONG_PTR pulDigestLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_DigestFinal")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pDigest, pDigest)); andre@0: PR_LOG(modlog, 3, (fmt_pulDigestLen, pulDigestLen)); andre@0: nssdbg_start_time(FUNC_C_DIGESTFINAL,&start); andre@0: rv = module_functions->C_DigestFinal(hSession, andre@0: pDigest, andre@0: pulDigestLen); andre@0: nssdbg_finish_time(FUNC_C_DIGESTFINAL,start); andre@0: PR_LOG(modlog, 4, (fmt_spulDigestLen, *pulDigestLen)); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_SignInit( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_MECHANISM_PTR pMechanism, andre@0: CK_OBJECT_HANDLE hKey andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_SignInit")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); andre@0: log_handle(3, fmt_hKey, hKey); andre@0: print_mechanism(pMechanism); andre@0: nssdbg_start_time(FUNC_C_SIGNINIT,&start); andre@0: rv = module_functions->C_SignInit(hSession, andre@0: pMechanism, andre@0: hKey); andre@0: nssdbg_finish_time(FUNC_C_SIGNINIT,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_Sign( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pData, andre@0: CK_ULONG ulDataLen, andre@0: CK_BYTE_PTR pSignature, andre@0: CK_ULONG_PTR pulSignatureLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_Sign")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pData, pData)); andre@0: PR_LOG(modlog, 3, (fmt_ulDataLen, ulDataLen)); andre@0: PR_LOG(modlog, 3, (fmt_pSignature, pSignature)); andre@0: PR_LOG(modlog, 3, (fmt_pulSignatureLen, pulSignatureLen)); andre@0: nssdbg_start_time(FUNC_C_SIGN,&start); andre@0: rv = module_functions->C_Sign(hSession, andre@0: pData, andre@0: ulDataLen, andre@0: pSignature, andre@0: pulSignatureLen); andre@0: nssdbg_finish_time(FUNC_C_SIGN,start); andre@0: PR_LOG(modlog, 4, (fmt_spulSignatureLen, *pulSignatureLen)); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_SignUpdate( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pPart, andre@0: CK_ULONG ulPartLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_SignUpdate")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pPart, pPart)); andre@0: PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen)); andre@0: nssdbg_start_time(FUNC_C_SIGNUPDATE,&start); andre@0: rv = module_functions->C_SignUpdate(hSession, andre@0: pPart, andre@0: ulPartLen); andre@0: nssdbg_finish_time(FUNC_C_SIGNUPDATE,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_SignFinal( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pSignature, andre@0: CK_ULONG_PTR pulSignatureLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_SignFinal")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pSignature, pSignature)); andre@0: PR_LOG(modlog, 3, (fmt_pulSignatureLen, pulSignatureLen)); andre@0: nssdbg_start_time(FUNC_C_SIGNFINAL,&start); andre@0: rv = module_functions->C_SignFinal(hSession, andre@0: pSignature, andre@0: pulSignatureLen); andre@0: nssdbg_finish_time(FUNC_C_SIGNFINAL,start); andre@0: PR_LOG(modlog, 4, (fmt_spulSignatureLen, *pulSignatureLen)); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_SignRecoverInit( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_MECHANISM_PTR pMechanism, andre@0: CK_OBJECT_HANDLE hKey andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_SignRecoverInit")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); andre@0: log_handle(3, fmt_hKey, hKey); andre@0: print_mechanism(pMechanism); andre@0: nssdbg_start_time(FUNC_C_SIGNRECOVERINIT,&start); andre@0: rv = module_functions->C_SignRecoverInit(hSession, andre@0: pMechanism, andre@0: hKey); andre@0: nssdbg_finish_time(FUNC_C_SIGNRECOVERINIT,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_SignRecover( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pData, andre@0: CK_ULONG ulDataLen, andre@0: CK_BYTE_PTR pSignature, andre@0: CK_ULONG_PTR pulSignatureLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_SignRecover")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pData, pData)); andre@0: PR_LOG(modlog, 3, (fmt_ulDataLen, ulDataLen)); andre@0: PR_LOG(modlog, 3, (fmt_pSignature, pSignature)); andre@0: PR_LOG(modlog, 3, (fmt_pulSignatureLen, pulSignatureLen)); andre@0: nssdbg_start_time(FUNC_C_SIGNRECOVER,&start); andre@0: rv = module_functions->C_SignRecover(hSession, andre@0: pData, andre@0: ulDataLen, andre@0: pSignature, andre@0: pulSignatureLen); andre@0: nssdbg_finish_time(FUNC_C_SIGNRECOVER,start); andre@0: PR_LOG(modlog, 4, (fmt_spulSignatureLen, *pulSignatureLen)); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_VerifyInit( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_MECHANISM_PTR pMechanism, andre@0: CK_OBJECT_HANDLE hKey andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_VerifyInit")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); andre@0: log_handle(3, fmt_hKey, hKey); andre@0: print_mechanism(pMechanism); andre@0: nssdbg_start_time(FUNC_C_VERIFYINIT,&start); andre@0: rv = module_functions->C_VerifyInit(hSession, andre@0: pMechanism, andre@0: hKey); andre@0: nssdbg_finish_time(FUNC_C_VERIFYINIT,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_Verify( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pData, andre@0: CK_ULONG ulDataLen, andre@0: CK_BYTE_PTR pSignature, andre@0: CK_ULONG ulSignatureLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_Verify")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pData, pData)); andre@0: PR_LOG(modlog, 3, (fmt_ulDataLen, ulDataLen)); andre@0: PR_LOG(modlog, 3, (fmt_pSignature, pSignature)); andre@0: PR_LOG(modlog, 3, (fmt_ulSignatureLen, ulSignatureLen)); andre@0: nssdbg_start_time(FUNC_C_VERIFY,&start); andre@0: rv = module_functions->C_Verify(hSession, andre@0: pData, andre@0: ulDataLen, andre@0: pSignature, andre@0: ulSignatureLen); andre@0: nssdbg_finish_time(FUNC_C_VERIFY,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_VerifyUpdate( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pPart, andre@0: CK_ULONG ulPartLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_VerifyUpdate")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pPart, pPart)); andre@0: PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen)); andre@0: nssdbg_start_time(FUNC_C_VERIFYUPDATE,&start); andre@0: rv = module_functions->C_VerifyUpdate(hSession, andre@0: pPart, andre@0: ulPartLen); andre@0: nssdbg_finish_time(FUNC_C_VERIFYUPDATE,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_VerifyFinal( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pSignature, andre@0: CK_ULONG ulSignatureLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_VerifyFinal")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pSignature, pSignature)); andre@0: PR_LOG(modlog, 3, (fmt_ulSignatureLen, ulSignatureLen)); andre@0: nssdbg_start_time(FUNC_C_VERIFYFINAL,&start); andre@0: rv = module_functions->C_VerifyFinal(hSession, andre@0: pSignature, andre@0: ulSignatureLen); andre@0: nssdbg_finish_time(FUNC_C_VERIFYFINAL,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_VerifyRecoverInit( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_MECHANISM_PTR pMechanism, andre@0: CK_OBJECT_HANDLE hKey andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_VerifyRecoverInit")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); andre@0: log_handle(3, fmt_hKey, hKey); andre@0: print_mechanism(pMechanism); andre@0: nssdbg_start_time(FUNC_C_VERIFYRECOVERINIT,&start); andre@0: rv = module_functions->C_VerifyRecoverInit(hSession, andre@0: pMechanism, andre@0: hKey); andre@0: nssdbg_finish_time(FUNC_C_VERIFYRECOVERINIT,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_VerifyRecover( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pSignature, andre@0: CK_ULONG ulSignatureLen, andre@0: CK_BYTE_PTR pData, andre@0: CK_ULONG_PTR pulDataLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_VerifyRecover")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pSignature, pSignature)); andre@0: PR_LOG(modlog, 3, (fmt_ulSignatureLen, ulSignatureLen)); andre@0: PR_LOG(modlog, 3, (fmt_pData, pData)); andre@0: PR_LOG(modlog, 3, (fmt_pulDataLen, pulDataLen)); andre@0: nssdbg_start_time(FUNC_C_VERIFYRECOVER,&start); andre@0: rv = module_functions->C_VerifyRecover(hSession, andre@0: pSignature, andre@0: ulSignatureLen, andre@0: pData, andre@0: pulDataLen); andre@0: nssdbg_finish_time(FUNC_C_VERIFYRECOVER,start); andre@0: PR_LOG(modlog, 4, (fmt_spulDataLen, *pulDataLen)); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_DigestEncryptUpdate( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pPart, andre@0: CK_ULONG ulPartLen, andre@0: CK_BYTE_PTR pEncryptedPart, andre@0: CK_ULONG_PTR pulEncryptedPartLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_DigestEncryptUpdate")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pPart, pPart)); andre@0: PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen)); andre@0: PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart)); andre@0: PR_LOG(modlog, 3, (fmt_pulEncryptedPartLen, pulEncryptedPartLen)); andre@0: nssdbg_start_time(FUNC_C_DIGESTENCRYPTUPDATE,&start); andre@0: rv = module_functions->C_DigestEncryptUpdate(hSession, andre@0: pPart, andre@0: ulPartLen, andre@0: pEncryptedPart, andre@0: pulEncryptedPartLen); andre@0: nssdbg_finish_time(FUNC_C_DIGESTENCRYPTUPDATE,start); andre@0: PR_LOG(modlog, 4, (fmt_spulEncryptedPartLen, *pulEncryptedPartLen)); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_DecryptDigestUpdate( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pEncryptedPart, andre@0: CK_ULONG ulEncryptedPartLen, andre@0: CK_BYTE_PTR pPart, andre@0: CK_ULONG_PTR pulPartLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_DecryptDigestUpdate")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart)); andre@0: PR_LOG(modlog, 3, (fmt_ulEncryptedPartLen, ulEncryptedPartLen)); andre@0: PR_LOG(modlog, 3, (fmt_pPart, pPart)); andre@0: PR_LOG(modlog, 3, (fmt_pulPartLen, pulPartLen)); andre@0: nssdbg_start_time(FUNC_C_DECRYPTDIGESTUPDATE,&start); andre@0: rv = module_functions->C_DecryptDigestUpdate(hSession, andre@0: pEncryptedPart, andre@0: ulEncryptedPartLen, andre@0: pPart, andre@0: pulPartLen); andre@0: nssdbg_finish_time(FUNC_C_DECRYPTDIGESTUPDATE,start); andre@0: PR_LOG(modlog, 4, (fmt_spulPartLen, *pulPartLen)); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_SignEncryptUpdate( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pPart, andre@0: CK_ULONG ulPartLen, andre@0: CK_BYTE_PTR pEncryptedPart, andre@0: CK_ULONG_PTR pulEncryptedPartLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_SignEncryptUpdate")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pPart, pPart)); andre@0: PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen)); andre@0: PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart)); andre@0: PR_LOG(modlog, 3, (fmt_pulEncryptedPartLen, pulEncryptedPartLen)); andre@0: nssdbg_start_time(FUNC_C_SIGNENCRYPTUPDATE,&start); andre@0: rv = module_functions->C_SignEncryptUpdate(hSession, andre@0: pPart, andre@0: ulPartLen, andre@0: pEncryptedPart, andre@0: pulEncryptedPartLen); andre@0: nssdbg_finish_time(FUNC_C_SIGNENCRYPTUPDATE,start); andre@0: PR_LOG(modlog, 4, (fmt_spulEncryptedPartLen, *pulEncryptedPartLen)); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_DecryptVerifyUpdate( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pEncryptedPart, andre@0: CK_ULONG ulEncryptedPartLen, andre@0: CK_BYTE_PTR pPart, andre@0: CK_ULONG_PTR pulPartLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_DecryptVerifyUpdate")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart)); andre@0: PR_LOG(modlog, 3, (fmt_ulEncryptedPartLen, ulEncryptedPartLen)); andre@0: PR_LOG(modlog, 3, (fmt_pPart, pPart)); andre@0: PR_LOG(modlog, 3, (fmt_pulPartLen, pulPartLen)); andre@0: nssdbg_start_time(FUNC_C_DECRYPTVERIFYUPDATE,&start); andre@0: rv = module_functions->C_DecryptVerifyUpdate(hSession, andre@0: pEncryptedPart, andre@0: ulEncryptedPartLen, andre@0: pPart, andre@0: pulPartLen); andre@0: nssdbg_finish_time(FUNC_C_DECRYPTVERIFYUPDATE,start); andre@0: PR_LOG(modlog, 4, (fmt_spulPartLen, *pulPartLen)); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_GenerateKey( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_MECHANISM_PTR pMechanism, andre@0: CK_ATTRIBUTE_PTR pTemplate, andre@0: CK_ULONG ulCount, andre@0: CK_OBJECT_HANDLE_PTR phKey andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_GenerateKey")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); andre@0: PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); andre@0: PR_LOG(modlog, 3, (fmt_ulCount, ulCount)); andre@0: PR_LOG(modlog, 3, (fmt_phKey, phKey)); andre@0: print_template(pTemplate, ulCount); andre@0: print_mechanism(pMechanism); andre@0: nssdbg_start_time(FUNC_C_GENERATEKEY,&start); andre@0: rv = module_functions->C_GenerateKey(hSession, andre@0: pMechanism, andre@0: pTemplate, andre@0: ulCount, andre@0: phKey); andre@0: nssdbg_finish_time(FUNC_C_GENERATEKEY,start); andre@0: log_handle(4, fmt_sphKey, *phKey); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_GenerateKeyPair( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_MECHANISM_PTR pMechanism, andre@0: CK_ATTRIBUTE_PTR pPublicKeyTemplate, andre@0: CK_ULONG ulPublicKeyAttributeCount, andre@0: CK_ATTRIBUTE_PTR pPrivateKeyTemplate, andre@0: CK_ULONG ulPrivateKeyAttributeCount, andre@0: CK_OBJECT_HANDLE_PTR phPublicKey, andre@0: CK_OBJECT_HANDLE_PTR phPrivateKey andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_GenerateKeyPair")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); andre@0: PR_LOG(modlog, 3, (" pPublicKeyTemplate = 0x%p", pPublicKeyTemplate)); andre@0: PR_LOG(modlog, 3, (" ulPublicKeyAttributeCount = %d", ulPublicKeyAttributeCount)); andre@0: PR_LOG(modlog, 3, (" pPrivateKeyTemplate = 0x%p", pPrivateKeyTemplate)); andre@0: PR_LOG(modlog, 3, (" ulPrivateKeyAttributeCount = %d", ulPrivateKeyAttributeCount)); andre@0: PR_LOG(modlog, 3, (" phPublicKey = 0x%p", phPublicKey)); andre@0: print_template(pPublicKeyTemplate, ulPublicKeyAttributeCount); andre@0: PR_LOG(modlog, 3, (" phPrivateKey = 0x%p", phPrivateKey)); andre@0: print_template(pPrivateKeyTemplate, ulPrivateKeyAttributeCount); andre@0: print_mechanism(pMechanism); andre@0: nssdbg_start_time(FUNC_C_GENERATEKEYPAIR,&start); andre@0: rv = module_functions->C_GenerateKeyPair(hSession, andre@0: pMechanism, andre@0: pPublicKeyTemplate, andre@0: ulPublicKeyAttributeCount, andre@0: pPrivateKeyTemplate, andre@0: ulPrivateKeyAttributeCount, andre@0: phPublicKey, andre@0: phPrivateKey); andre@0: nssdbg_finish_time(FUNC_C_GENERATEKEYPAIR,start); andre@0: log_handle(4, " *phPublicKey = 0x%x", *phPublicKey); andre@0: log_handle(4, " *phPrivateKey = 0x%x", *phPrivateKey); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_WrapKey( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_MECHANISM_PTR pMechanism, andre@0: CK_OBJECT_HANDLE hWrappingKey, andre@0: CK_OBJECT_HANDLE hKey, andre@0: CK_BYTE_PTR pWrappedKey, andre@0: CK_ULONG_PTR pulWrappedKeyLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_WrapKey")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); andre@0: log_handle(3, " hWrappingKey = 0x%x", hWrappingKey); andre@0: log_handle(3, fmt_hKey, hKey); andre@0: PR_LOG(modlog, 3, (fmt_pWrappedKey, pWrappedKey)); andre@0: PR_LOG(modlog, 3, (" pulWrappedKeyLen = 0x%p", pulWrappedKeyLen)); andre@0: print_mechanism(pMechanism); andre@0: nssdbg_start_time(FUNC_C_WRAPKEY,&start); andre@0: rv = module_functions->C_WrapKey(hSession, andre@0: pMechanism, andre@0: hWrappingKey, andre@0: hKey, andre@0: pWrappedKey, andre@0: pulWrappedKeyLen); andre@0: nssdbg_finish_time(FUNC_C_WRAPKEY,start); andre@0: PR_LOG(modlog, 4, (" *pulWrappedKeyLen = 0x%x", *pulWrappedKeyLen)); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_UnwrapKey( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_MECHANISM_PTR pMechanism, andre@0: CK_OBJECT_HANDLE hUnwrappingKey, andre@0: CK_BYTE_PTR pWrappedKey, andre@0: CK_ULONG ulWrappedKeyLen, andre@0: CK_ATTRIBUTE_PTR pTemplate, andre@0: CK_ULONG ulAttributeCount, andre@0: CK_OBJECT_HANDLE_PTR phKey andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_UnwrapKey")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); andre@0: log_handle(3, " hUnwrappingKey = 0x%x", hUnwrappingKey); andre@0: PR_LOG(modlog, 3, (fmt_pWrappedKey, pWrappedKey)); andre@0: PR_LOG(modlog, 3, (" ulWrappedKeyLen = %d", ulWrappedKeyLen)); andre@0: PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); andre@0: PR_LOG(modlog, 3, (fmt_ulAttributeCount, ulAttributeCount)); andre@0: PR_LOG(modlog, 3, (fmt_phKey, phKey)); andre@0: print_template(pTemplate, ulAttributeCount); andre@0: print_mechanism(pMechanism); andre@0: nssdbg_start_time(FUNC_C_UNWRAPKEY,&start); andre@0: rv = module_functions->C_UnwrapKey(hSession, andre@0: pMechanism, andre@0: hUnwrappingKey, andre@0: pWrappedKey, andre@0: ulWrappedKeyLen, andre@0: pTemplate, andre@0: ulAttributeCount, andre@0: phKey); andre@0: nssdbg_finish_time(FUNC_C_UNWRAPKEY,start); andre@0: log_handle(4, fmt_sphKey, *phKey); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_DeriveKey( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_MECHANISM_PTR pMechanism, andre@0: CK_OBJECT_HANDLE hBaseKey, andre@0: CK_ATTRIBUTE_PTR pTemplate, andre@0: CK_ULONG ulAttributeCount, andre@0: CK_OBJECT_HANDLE_PTR phKey andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_DeriveKey")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism)); andre@0: log_handle(3, " hBaseKey = 0x%x", hBaseKey); andre@0: PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate)); andre@0: PR_LOG(modlog, 3, (fmt_ulAttributeCount, ulAttributeCount)); andre@0: PR_LOG(modlog, 3, (fmt_phKey, phKey)); andre@0: print_template(pTemplate, ulAttributeCount); andre@0: print_mechanism(pMechanism); andre@0: nssdbg_start_time(FUNC_C_DERIVEKEY,&start); andre@0: rv = module_functions->C_DeriveKey(hSession, andre@0: pMechanism, andre@0: hBaseKey, andre@0: pTemplate, andre@0: ulAttributeCount, andre@0: phKey); andre@0: nssdbg_finish_time(FUNC_C_DERIVEKEY,start); andre@0: log_handle(4, fmt_sphKey, *phKey); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_SeedRandom( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR pSeed, andre@0: CK_ULONG ulSeedLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_SeedRandom")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (" pSeed = 0x%p", pSeed)); andre@0: PR_LOG(modlog, 3, (" ulSeedLen = %d", ulSeedLen)); andre@0: nssdbg_start_time(FUNC_C_SEEDRANDOM,&start); andre@0: rv = module_functions->C_SeedRandom(hSession, andre@0: pSeed, andre@0: ulSeedLen); andre@0: nssdbg_finish_time(FUNC_C_SEEDRANDOM,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_GenerateRandom( andre@0: CK_SESSION_HANDLE hSession, andre@0: CK_BYTE_PTR RandomData, andre@0: CK_ULONG ulRandomLen andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_GenerateRandom")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: PR_LOG(modlog, 3, (" RandomData = 0x%p", RandomData)); andre@0: PR_LOG(modlog, 3, (" ulRandomLen = %d", ulRandomLen)); andre@0: nssdbg_start_time(FUNC_C_GENERATERANDOM,&start); andre@0: rv = module_functions->C_GenerateRandom(hSession, andre@0: RandomData, andre@0: ulRandomLen); andre@0: nssdbg_finish_time(FUNC_C_GENERATERANDOM,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_GetFunctionStatus( andre@0: CK_SESSION_HANDLE hSession andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_GetFunctionStatus")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: nssdbg_start_time(FUNC_C_GETFUNCTIONSTATUS,&start); andre@0: rv = module_functions->C_GetFunctionStatus(hSession); andre@0: nssdbg_finish_time(FUNC_C_GETFUNCTIONSTATUS,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_CancelFunction( andre@0: CK_SESSION_HANDLE hSession andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_CancelFunction")); andre@0: log_handle(3, fmt_hSession, hSession); andre@0: nssdbg_start_time(FUNC_C_CANCELFUNCTION,&start); andre@0: rv = module_functions->C_CancelFunction(hSession); andre@0: nssdbg_finish_time(FUNC_C_CANCELFUNCTION,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_RV NSSDBGC_WaitForSlotEvent( andre@0: CK_FLAGS flags, andre@0: CK_SLOT_ID_PTR pSlot, andre@0: CK_VOID_PTR pRserved andre@0: ) andre@0: { andre@0: COMMON_DEFINITIONS; andre@0: andre@0: PR_LOG(modlog, 1, ("C_WaitForSlotEvent")); andre@0: PR_LOG(modlog, 3, (fmt_flags, flags)); andre@0: PR_LOG(modlog, 3, (" pSlot = 0x%p", pSlot)); andre@0: PR_LOG(modlog, 3, (" pRserved = 0x%p", pRserved)); andre@0: nssdbg_start_time(FUNC_C_WAITFORSLOTEVENT,&start); andre@0: rv = module_functions->C_WaitForSlotEvent(flags, andre@0: pSlot, andre@0: pRserved); andre@0: nssdbg_finish_time(FUNC_C_WAITFORSLOTEVENT,start); andre@0: log_rv(rv); andre@0: return rv; andre@0: } andre@0: andre@0: CK_FUNCTION_LIST_PTR nss_InsertDeviceLog( andre@0: CK_FUNCTION_LIST_PTR devEPV andre@0: ) andre@0: { andre@0: module_functions = devEPV; andre@0: modlog = PR_NewLogModule("nss_mod_log"); andre@0: debug_functions.C_Initialize = NSSDBGC_Initialize; andre@0: debug_functions.C_Finalize = NSSDBGC_Finalize; andre@0: debug_functions.C_GetInfo = NSSDBGC_GetInfo; andre@0: debug_functions.C_GetFunctionList = NSSDBGC_GetFunctionList; andre@0: debug_functions.C_GetSlotList = NSSDBGC_GetSlotList; andre@0: debug_functions.C_GetSlotInfo = NSSDBGC_GetSlotInfo; andre@0: debug_functions.C_GetTokenInfo = NSSDBGC_GetTokenInfo; andre@0: debug_functions.C_GetMechanismList = NSSDBGC_GetMechanismList; andre@0: debug_functions.C_GetMechanismInfo = NSSDBGC_GetMechanismInfo; andre@0: debug_functions.C_InitToken = NSSDBGC_InitToken; andre@0: debug_functions.C_InitPIN = NSSDBGC_InitPIN; andre@0: debug_functions.C_SetPIN = NSSDBGC_SetPIN; andre@0: debug_functions.C_OpenSession = NSSDBGC_OpenSession; andre@0: debug_functions.C_CloseSession = NSSDBGC_CloseSession; andre@0: debug_functions.C_CloseAllSessions = NSSDBGC_CloseAllSessions; andre@0: debug_functions.C_GetSessionInfo = NSSDBGC_GetSessionInfo; andre@0: debug_functions.C_GetOperationState = NSSDBGC_GetOperationState; andre@0: debug_functions.C_SetOperationState = NSSDBGC_SetOperationState; andre@0: debug_functions.C_Login = NSSDBGC_Login; andre@0: debug_functions.C_Logout = NSSDBGC_Logout; andre@0: debug_functions.C_CreateObject = NSSDBGC_CreateObject; andre@0: debug_functions.C_CopyObject = NSSDBGC_CopyObject; andre@0: debug_functions.C_DestroyObject = NSSDBGC_DestroyObject; andre@0: debug_functions.C_GetObjectSize = NSSDBGC_GetObjectSize; andre@0: debug_functions.C_GetAttributeValue = NSSDBGC_GetAttributeValue; andre@0: debug_functions.C_SetAttributeValue = NSSDBGC_SetAttributeValue; andre@0: debug_functions.C_FindObjectsInit = NSSDBGC_FindObjectsInit; andre@0: debug_functions.C_FindObjects = NSSDBGC_FindObjects; andre@0: debug_functions.C_FindObjectsFinal = NSSDBGC_FindObjectsFinal; andre@0: debug_functions.C_EncryptInit = NSSDBGC_EncryptInit; andre@0: debug_functions.C_Encrypt = NSSDBGC_Encrypt; andre@0: debug_functions.C_EncryptUpdate = NSSDBGC_EncryptUpdate; andre@0: debug_functions.C_EncryptFinal = NSSDBGC_EncryptFinal; andre@0: debug_functions.C_DecryptInit = NSSDBGC_DecryptInit; andre@0: debug_functions.C_Decrypt = NSSDBGC_Decrypt; andre@0: debug_functions.C_DecryptUpdate = NSSDBGC_DecryptUpdate; andre@0: debug_functions.C_DecryptFinal = NSSDBGC_DecryptFinal; andre@0: debug_functions.C_DigestInit = NSSDBGC_DigestInit; andre@0: debug_functions.C_Digest = NSSDBGC_Digest; andre@0: debug_functions.C_DigestUpdate = NSSDBGC_DigestUpdate; andre@0: debug_functions.C_DigestKey = NSSDBGC_DigestKey; andre@0: debug_functions.C_DigestFinal = NSSDBGC_DigestFinal; andre@0: debug_functions.C_SignInit = NSSDBGC_SignInit; andre@0: debug_functions.C_Sign = NSSDBGC_Sign; andre@0: debug_functions.C_SignUpdate = NSSDBGC_SignUpdate; andre@0: debug_functions.C_SignFinal = NSSDBGC_SignFinal; andre@0: debug_functions.C_SignRecoverInit = NSSDBGC_SignRecoverInit; andre@0: debug_functions.C_SignRecover = NSSDBGC_SignRecover; andre@0: debug_functions.C_VerifyInit = NSSDBGC_VerifyInit; andre@0: debug_functions.C_Verify = NSSDBGC_Verify; andre@0: debug_functions.C_VerifyUpdate = NSSDBGC_VerifyUpdate; andre@0: debug_functions.C_VerifyFinal = NSSDBGC_VerifyFinal; andre@0: debug_functions.C_VerifyRecoverInit = NSSDBGC_VerifyRecoverInit; andre@0: debug_functions.C_VerifyRecover = NSSDBGC_VerifyRecover; andre@0: debug_functions.C_DigestEncryptUpdate = NSSDBGC_DigestEncryptUpdate; andre@0: debug_functions.C_DecryptDigestUpdate = NSSDBGC_DecryptDigestUpdate; andre@0: debug_functions.C_SignEncryptUpdate = NSSDBGC_SignEncryptUpdate; andre@0: debug_functions.C_DecryptVerifyUpdate = NSSDBGC_DecryptVerifyUpdate; andre@0: debug_functions.C_GenerateKey = NSSDBGC_GenerateKey; andre@0: debug_functions.C_GenerateKeyPair = NSSDBGC_GenerateKeyPair; andre@0: debug_functions.C_WrapKey = NSSDBGC_WrapKey; andre@0: debug_functions.C_UnwrapKey = NSSDBGC_UnwrapKey; andre@0: debug_functions.C_DeriveKey = NSSDBGC_DeriveKey; andre@0: debug_functions.C_SeedRandom = NSSDBGC_SeedRandom; andre@0: debug_functions.C_GenerateRandom = NSSDBGC_GenerateRandom; andre@0: debug_functions.C_GetFunctionStatus = NSSDBGC_GetFunctionStatus; andre@0: debug_functions.C_CancelFunction = NSSDBGC_CancelFunction; andre@0: debug_functions.C_WaitForSlotEvent = NSSDBGC_WaitForSlotEvent; andre@0: return &debug_functions; andre@0: } andre@0: andre@0: /* andre@0: * scale the time factor up accordingly. andre@0: * This routine tries to keep at least 2 significant figures on output. andre@0: * If the time is 0, then indicate that with a 'z' for units. andre@0: * If the time is greater than 10 minutes, output the time in minutes. andre@0: * If the time is less than 10 minutes but greater than 10 seconds output andre@0: * the time in second. andre@0: * If the time is less than 10 seconds but greater than 10 milliseconds andre@0: * output * the time in millisecond. andre@0: * If the time is less than 10 milliseconds but greater than 0 ticks output andre@0: * the time in microsecond. andre@0: * andre@0: */ andre@0: static PRUint32 getPrintTime(PRIntervalTime time ,char **type) andre@0: { andre@0: PRUint32 prTime; andre@0: andre@0: /* detect a programming error by outputting 'bu' to the output stream andre@0: * rather than crashing */ andre@0: *type = "bug"; andre@0: if (time == 0) { andre@0: *type = "z"; andre@0: return 0; andre@0: } andre@0: andre@0: prTime = PR_IntervalToSeconds(time); andre@0: andre@0: if (prTime >= 600) { andre@0: *type="m"; andre@0: return prTime/60; andre@0: } andre@0: if (prTime >= 10) { andre@0: *type="s"; andre@0: return prTime; andre@0: } andre@0: prTime = PR_IntervalToMilliseconds(time); andre@0: if (prTime >= 10) { andre@0: *type="ms"; andre@0: return prTime; andre@0: } andre@0: *type = "us"; andre@0: return PR_IntervalToMicroseconds(time); andre@0: } andre@0: andre@0: static void print_final_statistics(void) andre@0: { andre@0: int total_calls = 0; andre@0: PRIntervalTime total_time = 0; andre@0: PRUint32 pr_total_time; andre@0: char *type; andre@0: char *fname; andre@0: FILE *outfile = NULL; andre@0: int i; andre@0: andre@0: fname = PR_GetEnv("NSS_OUTPUT_FILE"); andre@0: if (fname) { andre@0: /* need to add an optional process id to the filename */ andre@0: outfile = fopen(fname,"w+"); andre@0: } andre@0: if (!outfile) { andre@0: outfile = stdout; andre@0: } andre@0: andre@0: andre@0: fprintf(outfile,"%-25s %10s %12s %12s %10s\n", "Function", "# Calls", andre@0: "Time", "Avg.", "% Time"); andre@0: fprintf(outfile,"\n"); andre@0: for (i=0; i < nssdbg_prof_size; i++) { andre@0: total_calls += nssdbg_prof_data[i].calls; andre@0: total_time += nssdbg_prof_data[i].time; andre@0: } andre@0: for (i=0; i < nssdbg_prof_size; i++) { andre@0: PRIntervalTime time = nssdbg_prof_data[i].time; andre@0: PRUint32 usTime = PR_IntervalToMicroseconds(time); andre@0: PRUint32 prTime = 0; andre@0: PRUint32 calls = nssdbg_prof_data[i].calls; andre@0: /* don't print out functions that weren't even called */ andre@0: if (calls == 0) { andre@0: continue; andre@0: } andre@0: andre@0: prTime = getPrintTime(time,&type); andre@0: andre@0: fprintf(outfile,"%-25s %10d %10d%2s ", nssdbg_prof_data[i].function, andre@0: calls, prTime, type); andre@0: /* for now always output the average in microseconds */ andre@0: fprintf(outfile,"%10.2f%2s", (float)usTime / (float)calls, "us" ); andre@0: fprintf(outfile,"%10.2f%%", ((float)time / (float)total_time) * 100); andre@0: fprintf(outfile,"\n"); andre@0: } andre@0: fprintf(outfile,"\n"); andre@0: andre@0: pr_total_time = getPrintTime(total_time,&type); andre@0: andre@0: fprintf(outfile,"%25s %10d %10d%2s\n", "Totals", total_calls, andre@0: pr_total_time, type); andre@0: fprintf(outfile,"\n\nMaximum number of concurrent open sessions: %d\n\n", andre@0: maxOpenSessions); andre@0: fflush (outfile); andre@0: if (outfile != stdout) { andre@0: fclose(outfile); andre@0: } andre@0: } andre@0: