/* HCSP.err: Handle error for CSP engine */ static void ERR_load_HCSP_strings(void); static void ERR_unload_HCSP_strings(void); static void ERR_HCSP_error(int function, int reason, char* file, int line); #define HCSP_err(f,r) ERR_HCSP_error((f),(r),__FILE__,__LINE__) /* Error codes for the HCSP functions. */ /* Function codes. */ #define HCSP_F_CTRL 100 #define HCSP_F_RSA_SIGN 101 #define HCSP_F_RSA_VERIFY 102 #define HCSP_F_LOAD_PRIVKEY 103 /* Reason codes. */ #define HCSP_R_UNKNOWN_FAULT 100 #define HCSP_R_COMMAND_NOT_IMPLEMENTED 101 #define HCSP_ERROR_INVALID_PARAMETER 102 #define HCSP_ERROR_NOT_ENOUGH_MEMORY 103 #define HCSP_NTE_BAD_FLAGS 104 #define HCSP_NTE_BAD_KEYSET 105 #define HCSP_NTE_BAD_KEYSET_PARAM 106 #define HCSP_NTE_BAD_PROV_TYPE 107 #define HCSP_NTE_BAD_SIGNATURE 108 #define HCSP_NTE_EXISTS 109 #define HCSP_NTE_KEYSET_ENTRY_BAD 110 #define HCSP_NTE_KEYSET_NOT_DEF 111 #define HCSP_NTE_NO_MEMORY 112 #define HCSP_NTE_PROV_DLL_NOT_FOUND 113 #define HCSP_NTE_PROV_TYPE_ENTRY_BAD 114 #define HCSP_NTE_PROV_TYPE_NO_MATCH 115 #define HCSP_NTE_PROV_TYPE_NOT_DEF 116 #define HCSP_NTE_PROVIDER_DLL_FAIL 117 #define HCSP_NTE_SIGNATURE_FILE_BAD 118 static ERR_STRING_DATA HCSP_str_functs[] = { { ERR_PACK(0, HCSP_F_CTRL, 0), "HCSP_CTRL" }, { ERR_PACK(0, HCSP_F_RSA_SIGN, 0), "HCSP_RSA_SIGN" }, { ERR_PACK(0, HCSP_F_RSA_VERIFY, 0), "HCSP_RSA_VERIFY" }, { ERR_PACK(0, HCSP_F_LOAD_PRIVKEY, 0), "HCSP_LOAD_PRIVKEY" }, { 0, NULL } }; static ERR_STRING_DATA HCSP_str_reasons[] = { { HCSP_R_UNKNOWN_FAULT, "unknown fault" }, { HCSP_R_COMMAND_NOT_IMPLEMENTED, "ctrl command not implemented" }, { HCSP_ERROR_INVALID_PARAMETER, "one of the parameters contains an invalid value" }, { HCSP_ERROR_NOT_ENOUGH_MEMORY, "the operating system ran out of memory during the operation" }, { HCSP_NTE_BAD_FLAGS, "the dwFlags parameter has an illegal value" }, { HCSP_NTE_BAD_KEYSET, "the Registry entry for the key container could not be opened " "and may not exist" }, { HCSP_NTE_BAD_KEYSET_PARAM, "the pszContainer or pszProvider parameter is set to an illegal value" }, { HCSP_NTE_BAD_PROV_TYPE, "the value of the dwProvType parameter is out of range. " "All provider types must be from 1 to 999, inclusive" }, { HCSP_NTE_BAD_SIGNATURE, "the provider DLL signature did not verify correctly. " "Either the DLL or the digital signature has been tampered with" }, { HCSP_NTE_EXISTS, "the dwFlags parameter is CRYPT_NEWKEYSET, " "but the key container already exists" }, { HCSP_NTE_KEYSET_ENTRY_BAD, "the Registry entry for the pszContainer key container was found " "(in the HKEY_CURRENT_USER window), but is corrupt. " "See the section System Administration for details about " "CryptoAPI's Registry usage" }, { HCSP_NTE_KEYSET_NOT_DEF, "no Registry entry exists in the HKEY_CURRENT_USER window " "for the key container specified by pszContainer" }, { HCSP_NTE_NO_MEMORY, "the CSP ran out of memory during the operation" }, { HCSP_NTE_PROV_DLL_NOT_FOUND,"the provider DLL file does not exist or is not on the current path" }, { HCSP_NTE_PROV_TYPE_ENTRY_BAD, "the Registry entry for the provider type specified by dwProvType is " "corrupt. This error may relate to either the user default CSP list " "or the machine default CSP list. See the section System Administration " "for details about CryptoAPI's Registry usage" }, { HCSP_NTE_PROV_TYPE_NO_MATCH, "the provider type specified by dwProvType does not match the provider " "type found in the Registry. Note that this error can only occur when " "pszProvider specifies an actual CSP name" }, { HCSP_NTE_PROV_TYPE_NOT_DEF, "no Registry entry exists for the provider type specified by dwProvType"}, { HCSP_NTE_PROVIDER_DLL_FAIL, "the provider DLL file could not be loaded, and may not exist. " "If it exists, then the file is not a valid DLL" }, { HCSP_NTE_SIGNATURE_FILE_BAD, "an error occurred while loading the DLL file image, prior to " "verifying its signature" }, { 0, NULL } }; static ERR_STRING_DATA HCSP_lib_name[] = { { 0, "HCSP engine" }, { 0, NULL } }; static int HCSP_error_init = 1; static int HCSP_lib_error_code = 0; static void ERR_load_HCSP_strings(void) { if (HCSP_lib_error_code == 0) { HCSP_lib_error_code = ERR_get_next_error_library(); } if (HCSP_error_init) { HCSP_error_init = 0; ERR_load_strings(HCSP_lib_error_code, HCSP_str_functs); ERR_load_strings(HCSP_lib_error_code, HCSP_str_reasons); HCSP_lib_name->error = ERR_PACK(HCSP_lib_error_code, 0, 0); ERR_load_strings(0, HCSP_lib_name); } } static void ERR_unload_HCSP_strings(void) { if (HCSP_error_init == 0) { ERR_unload_strings(HCSP_lib_error_code, HCSP_str_functs); ERR_unload_strings(HCSP_lib_error_code, HCSP_str_reasons); ERR_unload_strings(0, HCSP_lib_name); HCSP_error_init = 1; } } static void ERR_HCSP_error(int function, int reason, char* file, int line) { #ifdef DEBUG BIO_printf(err, "Error at function %s(%s:%d) - (%d,%x)\n", routine, file, line, function, reason); ERR_print_errors(err); #endif if (HCSP_lib_error_code == 0) { HCSP_lib_error_code = ERR_get_next_error_library(); } switch (reason) { case HCSP_R_COMMAND_NOT_IMPLEMENTED: break; case ERROR_INVALID_PARAMETER: reason = HCSP_ERROR_INVALID_PARAMETER; break; case ERROR_NOT_ENOUGH_MEMORY: reason = HCSP_ERROR_NOT_ENOUGH_MEMORY; break; case NTE_BAD_FLAGS: reason = HCSP_NTE_BAD_FLAGS; break; case NTE_BAD_KEYSET: reason = HCSP_NTE_BAD_KEYSET; break; case NTE_BAD_KEYSET_PARAM: reason = HCSP_NTE_BAD_KEYSET_PARAM; break; case NTE_BAD_PROV_TYPE: reason = HCSP_NTE_BAD_PROV_TYPE; break; case NTE_BAD_SIGNATURE: reason = HCSP_NTE_BAD_SIGNATURE; break; case NTE_EXISTS: reason = HCSP_NTE_EXISTS; break; case NTE_KEYSET_ENTRY_BAD: reason = HCSP_NTE_KEYSET_ENTRY_BAD; break; case NTE_KEYSET_NOT_DEF: reason = HCSP_NTE_KEYSET_NOT_DEF; break; case NTE_NO_MEMORY: reason = HCSP_NTE_NO_MEMORY; break; case NTE_PROV_DLL_NOT_FOUND: reason = HCSP_NTE_PROV_DLL_NOT_FOUND; break; case NTE_PROV_TYPE_ENTRY_BAD: reason = HCSP_NTE_PROV_TYPE_ENTRY_BAD; break; case NTE_PROV_TYPE_NO_MATCH: reason = HCSP_NTE_PROV_TYPE_NO_MATCH; break; case NTE_PROV_TYPE_NOT_DEF: reason = HCSP_NTE_PROV_TYPE_NOT_DEF; break; case NTE_PROVIDER_DLL_FAIL: reason = HCSP_NTE_PROVIDER_DLL_FAIL; break; case NTE_SIGNATURE_FILE_BAD: reason = HCSP_NTE_SIGNATURE_FILE_BAD; break; default: reason = HCSP_R_UNKNOWN_FAULT; break; } ERR_PUT_error(HCSP_lib_error_code, function, reason, file, line); }