From 957b11334a7afb14537322f0e4795b2e368b3f59 Mon Sep 17 00:00:00 2001 From: beck <> Date: Sun, 29 Jan 2017 17:49:23 +0000 Subject: Send the function codes from the error functions to the bit bucket, as was done earlier in libssl. Thanks inoguchi@ for noticing libssl had more reacharounds into this. ok jsing@ inoguchi@ --- src/lib/libcrypto/engine/eng_aesni.c | 4 +-- src/lib/libcrypto/engine/eng_cnf.c | 14 ++++------ src/lib/libcrypto/engine/eng_ctrl.c | 54 +++++++++++++----------------------- src/lib/libcrypto/engine/eng_err.c | 42 ++-------------------------- src/lib/libcrypto/engine/eng_fat.c | 5 ++-- src/lib/libcrypto/engine/eng_init.c | 11 ++++---- src/lib/libcrypto/engine/eng_lib.c | 13 ++++----- src/lib/libcrypto/engine/eng_list.c | 48 ++++++++++++-------------------- src/lib/libcrypto/engine/eng_pkey.c | 35 ++++++++--------------- src/lib/libcrypto/engine/eng_table.c | 5 ++-- src/lib/libcrypto/engine/tb_asnmth.c | 5 ++-- src/lib/libcrypto/engine/tb_cipher.c | 5 ++-- src/lib/libcrypto/engine/tb_digest.c | 5 ++-- src/lib/libcrypto/engine/tb_pkmeth.c | 5 ++-- 14 files changed, 80 insertions(+), 171 deletions(-) (limited to 'src/lib/libcrypto/engine') diff --git a/src/lib/libcrypto/engine/eng_aesni.c b/src/lib/libcrypto/engine/eng_aesni.c index 92794f6086..cd14bbc8cd 100644 --- a/src/lib/libcrypto/engine/eng_aesni.c +++ b/src/lib/libcrypto/engine/eng_aesni.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_aesni.c,v 1.9 2016/11/04 17:30:30 miod Exp $ */ +/* $OpenBSD: eng_aesni.c,v 1.10 2017/01/29 17:49:23 beck Exp $ */ /* * Support for Intel AES-NI intruction set * Author: Huang Ying @@ -411,7 +411,7 @@ aesni_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *user_key, ret = aesni_set_decrypt_key(user_key, ctx->key_len * 8, key); if (ret < 0) { - EVPerr(EVP_F_AESNI_INIT_KEY, EVP_R_AES_KEY_SETUP_FAILED); + EVPerror(EVP_R_AES_KEY_SETUP_FAILED); return 0; } diff --git a/src/lib/libcrypto/engine/eng_cnf.c b/src/lib/libcrypto/engine/eng_cnf.c index acdebda6a6..2ac077d492 100644 --- a/src/lib/libcrypto/engine/eng_cnf.c +++ b/src/lib/libcrypto/engine/eng_cnf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_cnf.c,v 1.13 2015/02/11 03:19:37 doug Exp $ */ +/* $OpenBSD: eng_cnf.c,v 1.14 2017/01/29 17:49:23 beck Exp $ */ /* Written by Stephen Henson (steve@openssl.org) for the OpenSSL * project 2001. */ @@ -115,8 +115,7 @@ int_engine_configure(char *name, char *value, const CONF *cnf) ecmds = NCONF_get_section(cnf, value); if (!ecmds) { - ENGINEerr(ENGINE_F_INT_ENGINE_CONFIGURE, - ENGINE_R_ENGINE_SECTION_ERROR); + ENGINEerror(ENGINE_R_ENGINE_SECTION_ERROR); return 0; } @@ -175,8 +174,7 @@ int_engine_configure(char *name, char *value, const CONF *cnf) if (!int_engine_init(e)) goto err; } else if (do_init != 0) { - ENGINEerr(ENGINE_F_INT_ENGINE_CONFIGURE, - ENGINE_R_INVALID_INIT_VALUE); + ENGINEerror(ENGINE_R_INVALID_INIT_VALUE); goto err; } } @@ -196,8 +194,7 @@ int_engine_configure(char *name, char *value, const CONF *cnf) err: if (ret != 1) { - ENGINEerr(ENGINE_F_INT_ENGINE_CONFIGURE, - ENGINE_R_ENGINE_CONFIGURATION_ERROR); + ENGINEerror(ENGINE_R_ENGINE_CONFIGURATION_ERROR); if (ecmd) ERR_asprintf_error_data( "section=%s, name=%s, value=%s", @@ -224,8 +221,7 @@ int_engine_module_init(CONF_IMODULE *md, const CONF *cnf) elist = NCONF_get_section(cnf, CONF_imodule_get_value(md)); if (!elist) { - ENGINEerr(ENGINE_F_INT_ENGINE_MODULE_INIT, - ENGINE_R_ENGINES_SECTION_ERROR); + ENGINEerror(ENGINE_R_ENGINES_SECTION_ERROR); return 0; } diff --git a/src/lib/libcrypto/engine/eng_ctrl.c b/src/lib/libcrypto/engine/eng_ctrl.c index bf832dc626..1a3c25fbae 100644 --- a/src/lib/libcrypto/engine/eng_ctrl.c +++ b/src/lib/libcrypto/engine/eng_ctrl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_ctrl.c,v 1.10 2015/02/11 03:19:37 doug Exp $ */ +/* $OpenBSD: eng_ctrl.c,v 1.11 2017/01/29 17:49:23 beck Exp $ */ /* ==================================================================== * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. * @@ -125,8 +125,7 @@ int_ctrl_helper(ENGINE *e, int cmd, long i, void *p, void (*f)(void)) (cmd == ENGINE_CTRL_GET_NAME_FROM_CMD) || (cmd == ENGINE_CTRL_GET_DESC_FROM_CMD)) { if (s == NULL) { - ENGINEerr(ENGINE_F_INT_CTRL_HELPER, - ERR_R_PASSED_NULL_PARAMETER); + ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return -1; } } @@ -134,8 +133,7 @@ int_ctrl_helper(ENGINE *e, int cmd, long i, void *p, void (*f)(void)) if (cmd == ENGINE_CTRL_GET_CMD_FROM_NAME) { if ((e->cmd_defns == NULL) || ((idx = int_ctrl_cmd_by_name(e->cmd_defns, s)) < 0)) { - ENGINEerr(ENGINE_F_INT_CTRL_HELPER, - ENGINE_R_INVALID_CMD_NAME); + ENGINEerror(ENGINE_R_INVALID_CMD_NAME); return -1; } return e->cmd_defns[idx].cmd_num; @@ -144,8 +142,7 @@ int_ctrl_helper(ENGINE *e, int cmd, long i, void *p, void (*f)(void)) * valie command number - so we need to conduct a search. */ if ((e->cmd_defns == NULL) || ((idx = int_ctrl_cmd_by_num(e->cmd_defns, (unsigned int)i)) < 0)) { - ENGINEerr(ENGINE_F_INT_CTRL_HELPER, - ENGINE_R_INVALID_CMD_NUMBER); + ENGINEerror(ENGINE_R_INVALID_CMD_NUMBER); return -1; } /* Now the logic splits depending on command type */ @@ -188,7 +185,7 @@ int_ctrl_helper(ENGINE *e, int cmd, long i, void *p, void (*f)(void)) } /* Shouldn't really be here ... */ - ENGINEerr(ENGINE_F_INT_CTRL_HELPER, ENGINE_R_INTERNAL_LIST_ERROR); + ENGINEerror(ENGINE_R_INTERNAL_LIST_ERROR); return -1; } @@ -198,7 +195,7 @@ ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)) int ctrl_exists, ref_exists; if (e == NULL) { - ENGINEerr(ENGINE_F_ENGINE_CTRL, ERR_R_PASSED_NULL_PARAMETER); + ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); @@ -206,7 +203,7 @@ ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)) CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); ctrl_exists = ((e->ctrl == NULL) ? 0 : 1); if (!ref_exists) { - ENGINEerr(ENGINE_F_ENGINE_CTRL, ENGINE_R_NO_REFERENCE); + ENGINEerror(ENGINE_R_NO_REFERENCE); return 0; } /* Intercept any "root-level" commands before trying to hand them on to @@ -225,8 +222,7 @@ ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)) if (ctrl_exists && !(e->flags & ENGINE_FLAGS_MANUAL_CMD_CTRL)) return int_ctrl_helper(e, cmd, i, p, f); if (!ctrl_exists) { - ENGINEerr(ENGINE_F_ENGINE_CTRL, - ENGINE_R_NO_CONTROL_FUNCTION); + ENGINEerror(ENGINE_R_NO_CONTROL_FUNCTION); /* For these cmd-related functions, failure is indicated * by a -1 return value (because 0 is used as a valid * return in some places). */ @@ -237,7 +233,7 @@ ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)) } /* Anything else requires a ctrl() handler to exist. */ if (!ctrl_exists) { - ENGINEerr(ENGINE_F_ENGINE_CTRL, ENGINE_R_NO_CONTROL_FUNCTION); + ENGINEerror(ENGINE_R_NO_CONTROL_FUNCTION); return 0; } return e->ctrl(e, cmd, i, p, f); @@ -250,8 +246,7 @@ ENGINE_cmd_is_executable(ENGINE *e, int cmd) if ((flags = ENGINE_ctrl(e, ENGINE_CTRL_GET_CMD_FLAGS, cmd, NULL, NULL)) < 0) { - ENGINEerr(ENGINE_F_ENGINE_CMD_IS_EXECUTABLE, - ENGINE_R_INVALID_CMD_NUMBER); + ENGINEerror(ENGINE_R_INVALID_CMD_NUMBER); return 0; } if (!(flags & ENGINE_CMD_FLAG_NO_INPUT) && @@ -268,8 +263,7 @@ ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, long i, void *p, int num; if ((e == NULL) || (cmd_name == NULL)) { - ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD, - ERR_R_PASSED_NULL_PARAMETER); + ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } if ((e->ctrl == NULL) || @@ -285,7 +279,7 @@ ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, long i, void *p, ERR_clear_error(); return 1; } - ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD, ENGINE_R_INVALID_CMD_NAME); + ENGINEerror(ENGINE_R_INVALID_CMD_NAME); return 0; } @@ -306,8 +300,7 @@ ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, char *ptr; if ((e == NULL) || (cmd_name == NULL)) { - ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING, - ERR_R_PASSED_NULL_PARAMETER); + ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } if ((e->ctrl == NULL) || @@ -323,29 +316,25 @@ ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, ERR_clear_error(); return 1; } - ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING, - ENGINE_R_INVALID_CMD_NAME); + ENGINEerror(ENGINE_R_INVALID_CMD_NAME); return 0; } if (!ENGINE_cmd_is_executable(e, num)) { - ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING, - ENGINE_R_CMD_NOT_EXECUTABLE); + ENGINEerror(ENGINE_R_CMD_NOT_EXECUTABLE); return 0; } if ((flags = ENGINE_ctrl(e, ENGINE_CTRL_GET_CMD_FLAGS, num, NULL, NULL)) < 0) { /* Shouldn't happen, given that ENGINE_cmd_is_executable() * returned success. */ - ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING, - ENGINE_R_INTERNAL_LIST_ERROR); + ENGINEerror(ENGINE_R_INTERNAL_LIST_ERROR); return 0; } /* If the command takes no input, there must be no input. And vice * versa. */ if (flags & ENGINE_CMD_FLAG_NO_INPUT) { if (arg != NULL) { - ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING, - ENGINE_R_COMMAND_TAKES_NO_INPUT); + ENGINEerror(ENGINE_R_COMMAND_TAKES_NO_INPUT); return 0; } /* We deliberately force the result of ENGINE_ctrl() to 0 or 1 @@ -359,8 +348,7 @@ ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, } /* So, we require input */ if (arg == NULL) { - ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING, - ENGINE_R_COMMAND_TAKES_INPUT); + ENGINEerror(ENGINE_R_COMMAND_TAKES_INPUT); return 0; } /* If it takes string input, that's easy */ @@ -375,14 +363,12 @@ ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, * should never happen though, because ENGINE_cmd_is_executable() was * used. */ if (!(flags & ENGINE_CMD_FLAG_NUMERIC)) { - ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING, - ENGINE_R_INTERNAL_LIST_ERROR); + ENGINEerror(ENGINE_R_INTERNAL_LIST_ERROR); return 0; } l = strtol(arg, &ptr, 10); if ((arg == ptr) || (*ptr != '\0')) { - ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING, - ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER); + ENGINEerror(ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER); return 0; } /* Force the result of the control command to 0 or 1, for the reasons diff --git a/src/lib/libcrypto/engine/eng_err.c b/src/lib/libcrypto/engine/eng_err.c index d65efde991..b604cbba9e 100644 --- a/src/lib/libcrypto/engine/eng_err.c +++ b/src/lib/libcrypto/engine/eng_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_err.c,v 1.10 2014/07/10 22:45:57 jsing Exp $ */ +/* $OpenBSD: eng_err.c,v 1.11 2017/01/29 17:49:23 beck Exp $ */ /* ==================================================================== * Copyright (c) 1999-2010 The OpenSSL Project. All rights reserved. * @@ -72,45 +72,7 @@ #define ERR_REASON(reason) ERR_PACK(ERR_LIB_ENGINE,0,reason) static ERR_STRING_DATA ENGINE_str_functs[] = { - {ERR_FUNC(ENGINE_F_DYNAMIC_CTRL), "DYNAMIC_CTRL"}, - {ERR_FUNC(ENGINE_F_DYNAMIC_GET_DATA_CTX), "DYNAMIC_GET_DATA_CTX"}, - {ERR_FUNC(ENGINE_F_DYNAMIC_LOAD), "DYNAMIC_LOAD"}, - {ERR_FUNC(ENGINE_F_DYNAMIC_SET_DATA_CTX), "DYNAMIC_SET_DATA_CTX"}, - {ERR_FUNC(ENGINE_F_ENGINE_ADD), "ENGINE_add"}, - {ERR_FUNC(ENGINE_F_ENGINE_BY_ID), "ENGINE_by_id"}, - {ERR_FUNC(ENGINE_F_ENGINE_CMD_IS_EXECUTABLE), "ENGINE_cmd_is_executable"}, - {ERR_FUNC(ENGINE_F_ENGINE_CTRL), "ENGINE_ctrl"}, - {ERR_FUNC(ENGINE_F_ENGINE_CTRL_CMD), "ENGINE_ctrl_cmd"}, - {ERR_FUNC(ENGINE_F_ENGINE_CTRL_CMD_STRING), "ENGINE_ctrl_cmd_string"}, - {ERR_FUNC(ENGINE_F_ENGINE_FINISH), "ENGINE_finish"}, - {ERR_FUNC(ENGINE_F_ENGINE_FREE_UTIL), "ENGINE_FREE_UTIL"}, - {ERR_FUNC(ENGINE_F_ENGINE_GET_CIPHER), "ENGINE_get_cipher"}, - {ERR_FUNC(ENGINE_F_ENGINE_GET_DEFAULT_TYPE), "ENGINE_GET_DEFAULT_TYPE"}, - {ERR_FUNC(ENGINE_F_ENGINE_GET_DIGEST), "ENGINE_get_digest"}, - {ERR_FUNC(ENGINE_F_ENGINE_GET_NEXT), "ENGINE_get_next"}, - {ERR_FUNC(ENGINE_F_ENGINE_GET_PKEY_ASN1_METH), "ENGINE_get_pkey_asn1_meth"}, - {ERR_FUNC(ENGINE_F_ENGINE_GET_PKEY_METH), "ENGINE_get_pkey_meth"}, - {ERR_FUNC(ENGINE_F_ENGINE_GET_PREV), "ENGINE_get_prev"}, - {ERR_FUNC(ENGINE_F_ENGINE_INIT), "ENGINE_init"}, - {ERR_FUNC(ENGINE_F_ENGINE_LIST_ADD), "ENGINE_LIST_ADD"}, - {ERR_FUNC(ENGINE_F_ENGINE_LIST_REMOVE), "ENGINE_LIST_REMOVE"}, - {ERR_FUNC(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY), "ENGINE_load_private_key"}, - {ERR_FUNC(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY), "ENGINE_load_public_key"}, - {ERR_FUNC(ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT), "ENGINE_load_ssl_client_cert"}, - {ERR_FUNC(ENGINE_F_ENGINE_NEW), "ENGINE_new"}, - {ERR_FUNC(ENGINE_F_ENGINE_REMOVE), "ENGINE_remove"}, - {ERR_FUNC(ENGINE_F_ENGINE_SET_DEFAULT_STRING), "ENGINE_set_default_string"}, - {ERR_FUNC(ENGINE_F_ENGINE_SET_DEFAULT_TYPE), "ENGINE_SET_DEFAULT_TYPE"}, - {ERR_FUNC(ENGINE_F_ENGINE_SET_ID), "ENGINE_set_id"}, - {ERR_FUNC(ENGINE_F_ENGINE_SET_NAME), "ENGINE_set_name"}, - {ERR_FUNC(ENGINE_F_ENGINE_TABLE_REGISTER), "ENGINE_TABLE_REGISTER"}, - {ERR_FUNC(ENGINE_F_ENGINE_UNLOAD_KEY), "ENGINE_UNLOAD_KEY"}, - {ERR_FUNC(ENGINE_F_ENGINE_UNLOCKED_FINISH), "ENGINE_UNLOCKED_FINISH"}, - {ERR_FUNC(ENGINE_F_ENGINE_UP_REF), "ENGINE_up_ref"}, - {ERR_FUNC(ENGINE_F_INT_CTRL_HELPER), "INT_CTRL_HELPER"}, - {ERR_FUNC(ENGINE_F_INT_ENGINE_CONFIGURE), "INT_ENGINE_CONFIGURE"}, - {ERR_FUNC(ENGINE_F_INT_ENGINE_MODULE_INIT), "INT_ENGINE_MODULE_INIT"}, - {ERR_FUNC(ENGINE_F_LOG_MESSAGE), "LOG_MESSAGE"}, + {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; diff --git a/src/lib/libcrypto/engine/eng_fat.c b/src/lib/libcrypto/engine/eng_fat.c index b54757d8ad..c97695a7d3 100644 --- a/src/lib/libcrypto/engine/eng_fat.c +++ b/src/lib/libcrypto/engine/eng_fat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_fat.c,v 1.15 2015/02/11 03:19:37 doug Exp $ */ +/* $OpenBSD: eng_fat.c,v 1.16 2017/01/29 17:49:23 beck Exp $ */ /* ==================================================================== * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. * @@ -147,8 +147,7 @@ ENGINE_set_default_string(ENGINE *e, const char *def_list) unsigned int flags = 0; if (!CONF_parse_list(def_list, ',', 1, int_def_cb, &flags)) { - ENGINEerr(ENGINE_F_ENGINE_SET_DEFAULT_STRING, - ENGINE_R_INVALID_STRING); + ENGINEerror(ENGINE_R_INVALID_STRING); ERR_asprintf_error_data("str=%s",def_list); return 0; } diff --git a/src/lib/libcrypto/engine/eng_init.c b/src/lib/libcrypto/engine/eng_init.c index b50e22594c..75d6698c70 100644 --- a/src/lib/libcrypto/engine/eng_init.c +++ b/src/lib/libcrypto/engine/eng_init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_init.c,v 1.7 2015/02/11 03:19:37 doug Exp $ */ +/* $OpenBSD: eng_init.c,v 1.8 2017/01/29 17:49:23 beck Exp $ */ /* ==================================================================== * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. * @@ -106,8 +106,7 @@ engine_unlocked_finish(ENGINE *e, int unlock_for_handlers) /* Release the structural reference too */ if (!engine_free_util(e, 0)) { - ENGINEerr(ENGINE_F_ENGINE_UNLOCKED_FINISH, - ENGINE_R_FINISH_FAILED); + ENGINEerror(ENGINE_R_FINISH_FAILED); return 0; } return to_return; @@ -120,7 +119,7 @@ ENGINE_init(ENGINE *e) int ret; if (e == NULL) { - ENGINEerr(ENGINE_F_ENGINE_INIT, ERR_R_PASSED_NULL_PARAMETER); + ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); @@ -136,14 +135,14 @@ ENGINE_finish(ENGINE *e) int to_return = 1; if (e == NULL) { - ENGINEerr(ENGINE_F_ENGINE_FINISH, ERR_R_PASSED_NULL_PARAMETER); + ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); to_return = engine_unlocked_finish(e, 1); CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); if (!to_return) { - ENGINEerr(ENGINE_F_ENGINE_FINISH, ENGINE_R_FINISH_FAILED); + ENGINEerror(ENGINE_R_FINISH_FAILED); return 0; } return to_return; diff --git a/src/lib/libcrypto/engine/eng_lib.c b/src/lib/libcrypto/engine/eng_lib.c index f5f54fc657..d2da29fe69 100644 --- a/src/lib/libcrypto/engine/eng_lib.c +++ b/src/lib/libcrypto/engine/eng_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_lib.c,v 1.11 2015/02/11 03:19:37 doug Exp $ */ +/* $OpenBSD: eng_lib.c,v 1.12 2017/01/29 17:49:23 beck Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ @@ -72,7 +72,7 @@ ENGINE_new(void) ret = malloc(sizeof(ENGINE)); if (ret == NULL) { - ENGINEerr(ENGINE_F_ENGINE_NEW, ERR_R_MALLOC_FAILURE); + ENGINEerror(ERR_R_MALLOC_FAILURE); return NULL; } memset(ret, 0, sizeof(ENGINE)); @@ -113,8 +113,7 @@ engine_free_util(ENGINE *e, int locked) int i; if (e == NULL) { - ENGINEerr(ENGINE_F_ENGINE_FREE_UTIL, - ERR_R_PASSED_NULL_PARAMETER); + ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } if (locked) @@ -245,8 +244,7 @@ int ENGINE_set_id(ENGINE *e, const char *id) { if (id == NULL) { - ENGINEerr(ENGINE_F_ENGINE_SET_ID, - ERR_R_PASSED_NULL_PARAMETER); + ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } e->id = id; @@ -257,8 +255,7 @@ int ENGINE_set_name(ENGINE *e, const char *name) { if (name == NULL) { - ENGINEerr(ENGINE_F_ENGINE_SET_NAME, - ERR_R_PASSED_NULL_PARAMETER); + ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } e->name = name; diff --git a/src/lib/libcrypto/engine/eng_list.c b/src/lib/libcrypto/engine/eng_list.c index fc1d16b183..8bb1bc58f2 100644 --- a/src/lib/libcrypto/engine/eng_list.c +++ b/src/lib/libcrypto/engine/eng_list.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_list.c,v 1.21 2015/07/19 00:56:48 bcook Exp $ */ +/* $OpenBSD: eng_list.c,v 1.22 2017/01/29 17:49:23 beck Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ @@ -105,8 +105,7 @@ engine_list_add(ENGINE *e) ENGINE *iterator = NULL; if (e == NULL) { - ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, - ERR_R_PASSED_NULL_PARAMETER); + ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } iterator = engine_list_head; @@ -115,15 +114,13 @@ engine_list_add(ENGINE *e) iterator = iterator->next; } if (conflict) { - ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, - ENGINE_R_CONFLICTING_ENGINE_ID); + ENGINEerror(ENGINE_R_CONFLICTING_ENGINE_ID); return 0; } if (engine_list_head == NULL) { /* We are adding to an empty list. */ if (engine_list_tail) { - ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, - ENGINE_R_INTERNAL_LIST_ERROR); + ENGINEerror(ENGINE_R_INTERNAL_LIST_ERROR); return 0; } engine_list_head = e; @@ -135,8 +132,7 @@ engine_list_add(ENGINE *e) /* We are adding to the tail of an existing list. */ if ((engine_list_tail == NULL) || (engine_list_tail->next != NULL)) { - ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, - ENGINE_R_INTERNAL_LIST_ERROR); + ENGINEerror(ENGINE_R_INTERNAL_LIST_ERROR); return 0; } engine_list_tail->next = e; @@ -158,8 +154,7 @@ engine_list_remove(ENGINE *e) ENGINE *iterator; if (e == NULL) { - ENGINEerr(ENGINE_F_ENGINE_LIST_REMOVE, - ERR_R_PASSED_NULL_PARAMETER); + ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } /* We need to check that e is in our linked list! */ @@ -167,8 +162,7 @@ engine_list_remove(ENGINE *e) while (iterator && (iterator != e)) iterator = iterator->next; if (iterator == NULL) { - ENGINEerr(ENGINE_F_ENGINE_LIST_REMOVE, - ENGINE_R_ENGINE_IS_NOT_IN_LIST); + ENGINEerror(ENGINE_R_ENGINE_IS_NOT_IN_LIST); return 0; } /* un-link e from the chain. */ @@ -223,8 +217,7 @@ ENGINE_get_next(ENGINE *e) ENGINE *ret = NULL; if (e == NULL) { - ENGINEerr(ENGINE_F_ENGINE_GET_NEXT, - ERR_R_PASSED_NULL_PARAMETER); + ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); @@ -246,8 +239,7 @@ ENGINE_get_prev(ENGINE *e) ENGINE *ret = NULL; if (e == NULL) { - ENGINEerr(ENGINE_F_ENGINE_GET_PREV, - ERR_R_PASSED_NULL_PARAMETER); + ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); @@ -270,18 +262,15 @@ ENGINE_add(ENGINE *e) int to_return = 1; if (e == NULL) { - ENGINEerr(ENGINE_F_ENGINE_ADD, - ERR_R_PASSED_NULL_PARAMETER); + ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } if ((e->id == NULL) || (e->name == NULL)) { - ENGINEerr(ENGINE_F_ENGINE_ADD, - ENGINE_R_ID_OR_NAME_MISSING); + ENGINEerror(ENGINE_R_ID_OR_NAME_MISSING); } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); if (!engine_list_add(e)) { - ENGINEerr(ENGINE_F_ENGINE_ADD, - ENGINE_R_INTERNAL_LIST_ERROR); + ENGINEerror(ENGINE_R_INTERNAL_LIST_ERROR); to_return = 0; } CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); @@ -295,14 +284,12 @@ ENGINE_remove(ENGINE *e) int to_return = 1; if (e == NULL) { - ENGINEerr(ENGINE_F_ENGINE_REMOVE, - ERR_R_PASSED_NULL_PARAMETER); + ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); if (!engine_list_remove(e)) { - ENGINEerr(ENGINE_F_ENGINE_REMOVE, - ENGINE_R_INTERNAL_LIST_ERROR); + ENGINEerror(ENGINE_R_INTERNAL_LIST_ERROR); to_return = 0; } CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); @@ -350,8 +337,7 @@ ENGINE_by_id(const char *id) ENGINE *iterator; if (id == NULL) { - ENGINEerr(ENGINE_F_ENGINE_BY_ID, - ERR_R_PASSED_NULL_PARAMETER); + ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return NULL; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); @@ -378,7 +364,7 @@ ENGINE_by_id(const char *id) CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); if (iterator == NULL) { - ENGINEerr(ENGINE_F_ENGINE_BY_ID, ENGINE_R_NO_SUCH_ENGINE); + ENGINEerror(ENGINE_R_NO_SUCH_ENGINE); ERR_asprintf_error_data("id=%s", id); } return iterator; @@ -388,7 +374,7 @@ int ENGINE_up_ref(ENGINE *e) { if (e == NULL) { - ENGINEerr(ENGINE_F_ENGINE_UP_REF, ERR_R_PASSED_NULL_PARAMETER); + ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } CRYPTO_add(&e->struct_ref, 1, CRYPTO_LOCK_ENGINE); diff --git a/src/lib/libcrypto/engine/eng_pkey.c b/src/lib/libcrypto/engine/eng_pkey.c index 74b1ce03b7..a0320e973f 100644 --- a/src/lib/libcrypto/engine/eng_pkey.c +++ b/src/lib/libcrypto/engine/eng_pkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_pkey.c,v 1.6 2015/02/11 03:19:37 doug Exp $ */ +/* $OpenBSD: eng_pkey.c,v 1.7 2017/01/29 17:49:23 beck Exp $ */ /* ==================================================================== * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. * @@ -108,27 +108,23 @@ ENGINE_load_private_key(ENGINE *e, const char *key_id, UI_METHOD *ui_method, EVP_PKEY *pkey; if (e == NULL) { - ENGINEerr(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY, - ERR_R_PASSED_NULL_PARAMETER); + ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); if (e->funct_ref == 0) { CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); - ENGINEerr(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY, - ENGINE_R_NOT_INITIALISED); + ENGINEerror(ENGINE_R_NOT_INITIALISED); return 0; } CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); if (!e->load_privkey) { - ENGINEerr(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY, - ENGINE_R_NO_LOAD_FUNCTION); + ENGINEerror(ENGINE_R_NO_LOAD_FUNCTION); return 0; } pkey = e->load_privkey(e, key_id, ui_method, callback_data); if (!pkey) { - ENGINEerr(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY, - ENGINE_R_FAILED_LOADING_PRIVATE_KEY); + ENGINEerror(ENGINE_R_FAILED_LOADING_PRIVATE_KEY); return 0; } return pkey; @@ -141,27 +137,23 @@ ENGINE_load_public_key(ENGINE *e, const char *key_id, UI_METHOD *ui_method, EVP_PKEY *pkey; if (e == NULL) { - ENGINEerr(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY, - ERR_R_PASSED_NULL_PARAMETER); + ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); if (e->funct_ref == 0) { CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); - ENGINEerr(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY, - ENGINE_R_NOT_INITIALISED); + ENGINEerror(ENGINE_R_NOT_INITIALISED); return 0; } CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); if (!e->load_pubkey) { - ENGINEerr(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY, - ENGINE_R_NO_LOAD_FUNCTION); + ENGINEerror(ENGINE_R_NO_LOAD_FUNCTION); return 0; } pkey = e->load_pubkey(e, key_id, ui_method, callback_data); if (!pkey) { - ENGINEerr(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY, - ENGINE_R_FAILED_LOADING_PUBLIC_KEY); + ENGINEerror(ENGINE_R_FAILED_LOADING_PUBLIC_KEY); return 0; } return pkey; @@ -173,21 +165,18 @@ ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s, STACK_OF(X509_NAME) *ca_dn, UI_METHOD *ui_method, void *callback_data) { if (e == NULL) { - ENGINEerr(ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT, - ERR_R_PASSED_NULL_PARAMETER); + ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); if (e->funct_ref == 0) { CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); - ENGINEerr(ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT, - ENGINE_R_NOT_INITIALISED); + ENGINEerror(ENGINE_R_NOT_INITIALISED); return 0; } CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); if (!e->load_ssl_client_cert) { - ENGINEerr(ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT, - ENGINE_R_NO_LOAD_FUNCTION); + ENGINEerror(ENGINE_R_NO_LOAD_FUNCTION); return 0; } return e->load_ssl_client_cert(e, s, ca_dn, pcert, ppkey, pother, diff --git a/src/lib/libcrypto/engine/eng_table.c b/src/lib/libcrypto/engine/eng_table.c index 342c76fa1b..a8aded5aaf 100644 --- a/src/lib/libcrypto/engine/eng_table.c +++ b/src/lib/libcrypto/engine/eng_table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_table.c,v 1.8 2015/02/11 03:19:37 doug Exp $ */ +/* $OpenBSD: eng_table.c,v 1.9 2017/01/29 17:49:23 beck Exp $ */ /* ==================================================================== * Copyright (c) 2001 The OpenSSL Project. All rights reserved. * @@ -172,8 +172,7 @@ engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup, fnd->uptodate = 0; if (setdefault) { if (!engine_unlocked_init(e)) { - ENGINEerr(ENGINE_F_ENGINE_TABLE_REGISTER, - ENGINE_R_INIT_FAILED); + ENGINEerror(ENGINE_R_INIT_FAILED); goto end; } if (fnd->funct) diff --git a/src/lib/libcrypto/engine/tb_asnmth.c b/src/lib/libcrypto/engine/tb_asnmth.c index 3ba5541933..51e5198b40 100644 --- a/src/lib/libcrypto/engine/tb_asnmth.c +++ b/src/lib/libcrypto/engine/tb_asnmth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tb_asnmth.c,v 1.5 2015/02/11 03:19:37 doug Exp $ */ +/* $OpenBSD: tb_asnmth.c,v 1.6 2017/01/29 17:49:23 beck Exp $ */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * @@ -135,8 +135,7 @@ ENGINE_get_pkey_asn1_meth(ENGINE *e, int nid) ENGINE_PKEY_ASN1_METHS_PTR fn = ENGINE_get_pkey_asn1_meths(e); if (!fn || !fn(e, &ret, NULL, nid)) { - ENGINEerr(ENGINE_F_ENGINE_GET_PKEY_ASN1_METH, - ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD); + ENGINEerror(ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD); return NULL; } return ret; diff --git a/src/lib/libcrypto/engine/tb_cipher.c b/src/lib/libcrypto/engine/tb_cipher.c index a888d7a958..ed87ff199e 100644 --- a/src/lib/libcrypto/engine/tb_cipher.c +++ b/src/lib/libcrypto/engine/tb_cipher.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tb_cipher.c,v 1.7 2015/02/11 03:19:37 doug Exp $ */ +/* $OpenBSD: tb_cipher.c,v 1.8 2017/01/29 17:49:23 beck Exp $ */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * @@ -130,8 +130,7 @@ ENGINE_get_cipher(ENGINE *e, int nid) ENGINE_CIPHERS_PTR fn = ENGINE_get_ciphers(e); if (!fn || !fn(e, &ret, NULL, nid)) { - ENGINEerr(ENGINE_F_ENGINE_GET_CIPHER, - ENGINE_R_UNIMPLEMENTED_CIPHER); + ENGINEerror(ENGINE_R_UNIMPLEMENTED_CIPHER); return NULL; } return ret; diff --git a/src/lib/libcrypto/engine/tb_digest.c b/src/lib/libcrypto/engine/tb_digest.c index f7720d39e7..f1a2e8a6b3 100644 --- a/src/lib/libcrypto/engine/tb_digest.c +++ b/src/lib/libcrypto/engine/tb_digest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tb_digest.c,v 1.7 2015/02/11 03:19:37 doug Exp $ */ +/* $OpenBSD: tb_digest.c,v 1.8 2017/01/29 17:49:23 beck Exp $ */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * @@ -130,8 +130,7 @@ ENGINE_get_digest(ENGINE *e, int nid) ENGINE_DIGESTS_PTR fn = ENGINE_get_digests(e); if (!fn || !fn(e, &ret, NULL, nid)) { - ENGINEerr(ENGINE_F_ENGINE_GET_DIGEST, - ENGINE_R_UNIMPLEMENTED_DIGEST); + ENGINEerror(ENGINE_R_UNIMPLEMENTED_DIGEST); return NULL; } return ret; diff --git a/src/lib/libcrypto/engine/tb_pkmeth.c b/src/lib/libcrypto/engine/tb_pkmeth.c index 3840434262..05566a3464 100644 --- a/src/lib/libcrypto/engine/tb_pkmeth.c +++ b/src/lib/libcrypto/engine/tb_pkmeth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tb_pkmeth.c,v 1.5 2015/02/11 03:19:37 doug Exp $ */ +/* $OpenBSD: tb_pkmeth.c,v 1.6 2017/01/29 17:49:23 beck Exp $ */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * @@ -131,8 +131,7 @@ ENGINE_get_pkey_meth(ENGINE *e, int nid) ENGINE_PKEY_METHS_PTR fn = ENGINE_get_pkey_meths(e); if (!fn || !fn(e, &ret, NULL, nid)) { - ENGINEerr(ENGINE_F_ENGINE_GET_PKEY_METH, - ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD); + ENGINEerror(ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD); return NULL; } return ret; -- cgit v1.2.3-55-g6feb