From: Dmitry Belyavskiy Date: Thu, 14 Jun 2018 12:12:32 +0000 (+0300) Subject: Error codes rebuild X-Git-Tag: v3.0.0~412^2~14 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=debbfa1ae38f18ea06750514dd950775ad9889d8;p=openssl-gost%2Fengine.git Error codes rebuild --- diff --git a/e_gost_err.c b/e_gost_err.c index baaeb44..9089c4b 100644 --- a/e_gost_err.c +++ b/e_gost_err.c @@ -1,207 +1,148 @@ -/* e_gost_err.c */ -/* ==================================================================== - * Copyright (c) 1999-2016 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - /* - * NOTE: this file was auto generated by the mkerr.pl script: any changes - * made to it will be overwritten when the script next updates this file, - * only reason strings will be preserved. + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html */ -#include #include #include "e_gost_err.h" -/* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR -# define ERR_FUNC(func) ERR_PACK(0,func,0) -# define ERR_REASON(reason) ERR_PACK(0,0,reason) - static ERR_STRING_DATA GOST_str_functs[] = { - {ERR_FUNC(GOST_F_DECODE_GOST_ALGOR_PARAMS), "DECODE_GOST_ALGOR_PARAMS"}, - {ERR_FUNC(GOST_F_ENCODE_GOST_ALGOR_PARAMS), "ENCODE_GOST_ALGOR_PARAMS"}, - {ERR_FUNC(GOST_F_FILL_GOST_EC_PARAMS), "FILL_GOST_EC_PARAMS"}, - {ERR_FUNC(GOST_F_GET_ENCRYPTION_PARAMS), "GET_ENCRYPTION_PARAMS"}, - {ERR_FUNC(GOST_F_GOST89_GET_ASN1_PARAMETERS), - "GOST89_GET_ASN1_PARAMETERS"}, - {ERR_FUNC(GOST_F_GOST89_SET_ASN1_PARAMETERS), - "GOST89_SET_ASN1_PARAMETERS"}, - {ERR_FUNC(GOST_F_GOST_CIPHER_CTL), "GOST_CIPHER_CTL"}, - {ERR_FUNC(GOST_F_GOST_EC_COMPUTE_PUBLIC), "GOST_EC_COMPUTE_PUBLIC"}, - {ERR_FUNC(GOST_F_GOST_EC_KEYGEN), "GOST_EC_KEYGEN"}, - {ERR_FUNC(GOST_F_GOST_EC_SIGN), "GOST_EC_SIGN"}, - {ERR_FUNC(GOST_F_GOST_EC_VERIFY), "GOST_EC_VERIFY"}, - {ERR_FUNC(GOST_F_GOST_IMIT_CTRL), "GOST_IMIT_CTRL"}, - {ERR_FUNC(GOST_F_GOST_IMIT_FINAL), "GOST_IMIT_FINAL"}, - {ERR_FUNC(GOST_F_GOST_IMIT_UPDATE), "GOST_IMIT_UPDATE"}, - {ERR_FUNC(GOST_F_PARAM_COPY_GOST_EC), "PARAM_COPY_GOST_EC"}, - {ERR_FUNC(GOST_F_PKEY_GOST01_PARAMGEN), "PKEY_GOST01_PARAMGEN"}, - {ERR_FUNC(GOST_F_PKEY_GOST12_PARAMGEN), "PKEY_GOST12_PARAMGEN"}, - {ERR_FUNC(GOST_F_PKEY_GOST_CTRL), "PKEY_GOST_CTRL"}, - {ERR_FUNC(GOST_F_PKEY_GOST_ECCP_DECRYPT), "PKEY_GOST_ECCP_DECRYPT"}, - {ERR_FUNC(GOST_F_PKEY_GOST_ECCP_ENCRYPT), "PKEY_GOST_ECCP_ENCRYPT"}, - {ERR_FUNC(GOST_F_PKEY_GOST_EC_CTRL_STR_256), "PKEY_GOST_EC_CTRL_STR_256"}, - {ERR_FUNC(GOST_F_PKEY_GOST_EC_CTRL_STR_512), "PKEY_GOST_EC_CTRL_STR_512"}, - {ERR_FUNC(GOST_F_PKEY_GOST_EC_DERIVE), "PKEY_GOST_EC_DERIVE"}, - {ERR_FUNC(GOST_F_PKEY_GOST_MAC_CTRL), "PKEY_GOST_MAC_CTRL"}, - {ERR_FUNC(GOST_F_PKEY_GOST_MAC_CTRL_STR), "PKEY_GOST_MAC_CTRL_STR"}, - {ERR_FUNC(GOST_F_PKEY_GOST_MAC_KEYGEN), "PKEY_GOST_MAC_KEYGEN"}, - {ERR_FUNC(GOST_F_PKEY_GOST_MAC_SIGNCTX_INIT), - "PKEY_GOST_MAC_SIGNCTX_INIT"}, - {ERR_FUNC(GOST_F_PRINT_GOST_EC_PUB), "PRINT_GOST_EC_PUB"}, - {ERR_FUNC(GOST_F_PRIV_DECODE_GOST), "PRIV_DECODE_GOST"}, - {ERR_FUNC(GOST_F_PUB_DECODE_GOST_EC), "PUB_DECODE_GOST_EC"}, - {ERR_FUNC(GOST_F_PUB_ENCODE_GOST_EC), "PUB_ENCODE_GOST_EC"}, - {ERR_FUNC(GOST_F_UNPACK_CP_SIGNATURE), "UNPACK_CP_SIGNATURE"}, - {ERR_FUNC(GOST_F_VKO_COMPUTE_KEY), "VKO_COMPUTE_KEY"}, + {ERR_PACK(0, GOST_F_DECODE_GOST_ALGOR_PARAMS, 0), + "decode_gost_algor_params"}, + {ERR_PACK(0, GOST_F_ENCODE_GOST_ALGOR_PARAMS, 0), + "encode_gost_algor_params"}, + {ERR_PACK(0, GOST_F_FILL_GOST_EC_PARAMS, 0), "fill_GOST_EC_params"}, + {ERR_PACK(0, GOST_F_GET_ENCRYPTION_PARAMS, 0), "get_encryption_params"}, + {ERR_PACK(0, GOST_F_GOST89_GET_ASN1_PARAMETERS, 0), + "gost89_get_asn1_parameters"}, + {ERR_PACK(0, GOST_F_GOST89_SET_ASN1_PARAMETERS, 0), + "gost89_set_asn1_parameters"}, + {ERR_PACK(0, GOST_F_GOST_CIPHER_CTL, 0), "gost_cipher_ctl"}, + {ERR_PACK(0, GOST_F_GOST_EC_COMPUTE_PUBLIC, 0), "gost_ec_compute_public"}, + {ERR_PACK(0, GOST_F_GOST_EC_KEYGEN, 0), "gost_ec_keygen"}, + {ERR_PACK(0, GOST_F_GOST_EC_SIGN, 0), "gost_ec_sign"}, + {ERR_PACK(0, GOST_F_GOST_EC_VERIFY, 0), "gost_ec_verify"}, + {ERR_PACK(0, GOST_F_GOST_GRASSHOPPER_CIPHER_CTL, 0), + "gost_grasshopper_cipher_ctl"}, + {ERR_PACK(0, GOST_F_GOST_GRASSHOPPER_SET_ASN1_PARAMETERS, 0), + "gost_grasshopper_set_asn1_parameters"}, + {ERR_PACK(0, GOST_F_GOST_IMIT_CTRL, 0), "gost_imit_ctrl"}, + {ERR_PACK(0, GOST_F_GOST_IMIT_FINAL, 0), "gost_imit_final"}, + {ERR_PACK(0, GOST_F_GOST_IMIT_UPDATE, 0), "gost_imit_update"}, + {ERR_PACK(0, GOST_F_MAGMA_IMIT_FINAL, 0), "magma_imit_final"}, + {ERR_PACK(0, GOST_F_MAGMA_IMIT_UPDATE, 0), "magma_imit_update"}, + {ERR_PACK(0, GOST_F_PARAM_COPY_GOST_EC, 0), "param_copy_gost_ec"}, + {ERR_PACK(0, GOST_F_PKEY_GOST2001_PARAMGEN, 0), "pkey_gost2001_paramgen"}, + {ERR_PACK(0, GOST_F_PKEY_GOST2012_PARAMGEN, 0), "pkey_gost2012_paramgen"}, + {ERR_PACK(0, GOST_F_PKEY_GOST_CTRL, 0), "pkey_gost_ctrl"}, + {ERR_PACK(0, GOST_F_PKEY_GOST_ECCP_DECRYPT, 0), "pkey_GOST_ECcp_decrypt"}, + {ERR_PACK(0, GOST_F_PKEY_GOST_ECCP_ENCRYPT, 0), "pkey_GOST_ECcp_encrypt"}, + {ERR_PACK(0, GOST_F_PKEY_GOST_EC_CTRL_STR_256, 0), + "pkey_gost_ec_ctrl_str_256"}, + {ERR_PACK(0, GOST_F_PKEY_GOST_EC_CTRL_STR_512, 0), + "pkey_gost_ec_ctrl_str_512"}, + {ERR_PACK(0, GOST_F_PKEY_GOST_EC_DERIVE, 0), "pkey_gost_ec_derive"}, + {ERR_PACK(0, GOST_F_PKEY_GOST_MAC_CTRL, 0), "pkey_gost_mac_ctrl"}, + {ERR_PACK(0, GOST_F_PKEY_GOST_MAC_CTRL_STR, 0), "pkey_gost_mac_ctrl_str"}, + {ERR_PACK(0, GOST_F_PKEY_GOST_MAC_KEYGEN_BASE, 0), + "pkey_gost_mac_keygen_base"}, + {ERR_PACK(0, GOST_F_PKEY_GOST_MAC_SIGNCTX_INIT, 0), + "pkey_gost_mac_signctx_init"}, + {ERR_PACK(0, GOST_F_PRINT_GOST_EC_PUB, 0), "print_gost_ec_pub"}, + {ERR_PACK(0, GOST_F_PRIV_DECODE_GOST, 0), "priv_decode_gost"}, + {ERR_PACK(0, GOST_F_PUB_DECODE_GOST_EC, 0), "pub_decode_gost_ec"}, + {ERR_PACK(0, GOST_F_PUB_ENCODE_GOST_EC, 0), "pub_encode_gost_ec"}, + {ERR_PACK(0, GOST_F_UNPACK_CP_SIGNATURE, 0), "unpack_cp_signature"}, + {ERR_PACK(0, GOST_F_VKO_COMPUTE_KEY, 0), "VKO_compute_key"}, {0, NULL} }; static ERR_STRING_DATA GOST_str_reasons[] = { - {ERR_REASON(GOST_R_BAD_KEY_PARAMETERS_FORMAT), - "bad key parameters format"}, - {ERR_REASON(GOST_R_BAD_PKEY_PARAMETERS_FORMAT), - "bad pkey parameters format"}, - {ERR_REASON(GOST_R_CANNOT_PACK_EPHEMERAL_KEY), - "cannot pack ephemeral key"}, - {ERR_REASON(GOST_R_CTRL_CALL_FAILED), "ctrl call failed"}, - {ERR_REASON(GOST_R_ERROR_COMPUTING_SHARED_KEY), - "error computing shared key"}, - {ERR_REASON(GOST_R_ERROR_PARSING_KEY_TRANSPORT_INFO), - "error parsing key transport info"}, - {ERR_REASON(GOST_R_ERROR_POINT_MUL), "error point mul"}, - {ERR_REASON(GOST_R_INCOMPATIBLE_ALGORITHMS), "incompatible algorithms"}, - {ERR_REASON(GOST_R_INCOMPATIBLE_PEER_KEY), "incompatible peer key"}, - {ERR_REASON(GOST_R_INVALID_CIPHER_PARAMS), "invalid cipher params"}, - {ERR_REASON(GOST_R_INVALID_CIPHER_PARAM_OID), "invalid cipher param oid"}, - {ERR_REASON(GOST_R_INVALID_DIGEST_TYPE), "invalid digest type"}, - {ERR_REASON(GOST_R_INVALID_IV_LENGTH), "invalid iv length"}, - {ERR_REASON(GOST_R_INVALID_MAC_KEY_LENGTH), "invalid mac key length"}, - {ERR_REASON(GOST_R_INVALID_MAC_KEY_SIZE), "invalid mac key size"}, - {ERR_REASON(GOST_R_INVALID_MAC_PARAMS), "invalid mac params"}, - {ERR_REASON(GOST_R_INVALID_MAC_SIZE), "invalid mac size"}, - {ERR_REASON(GOST_R_INVALID_PARAMSET), "invalid paramset"}, - {ERR_REASON(GOST_R_KEY_IS_NOT_INITIALIZED), "key is not initialized"}, - {ERR_REASON(GOST_R_KEY_PARAMETERS_MISSING), "key parameters missing"}, - {ERR_REASON(GOST_R_MAC_KEY_NOT_SET), "mac key not set"}, - {ERR_REASON(GOST_R_NO_PARAMETERS_SET), "no parameters set"}, - {ERR_REASON(GOST_R_NO_PEER_KEY), "no peer key"}, - {ERR_REASON(GOST_R_NO_PRIVATE_PART_OF_NON_EPHEMERAL_KEYPAIR), - "no private part of non ephemeral keypair"}, - {ERR_REASON(GOST_R_PUBLIC_KEY_UNDEFINED), "public key undefined"}, - {ERR_REASON(GOST_R_RNG_ERROR), "rng error"}, - {ERR_REASON(GOST_R_SIGNATURE_MISMATCH), "signature mismatch"}, - {ERR_REASON(GOST_R_SIGNATURE_PARTS_GREATER_THAN_Q), - "signature parts greater than q"}, - {ERR_REASON(GOST_R_UKM_NOT_SET), "ukm not set"}, - {ERR_REASON(GOST_R_UNSUPPORTED_CIPHER_CTL_COMMAND), - "unsupported cipher ctl command"}, - {ERR_REASON(GOST_R_UNSUPPORTED_PARAMETER_SET), - "unsupported parameter set"}, + {ERR_PACK(0, 0, GOST_R_BAD_KEY_PARAMETERS_FORMAT), + "bad key parameters format"}, + {ERR_PACK(0, 0, GOST_R_BAD_PKEY_PARAMETERS_FORMAT), + "bad pkey parameters format"}, + {ERR_PACK(0, 0, GOST_R_CANNOT_PACK_EPHEMERAL_KEY), + "cannot pack ephemeral key"}, + {ERR_PACK(0, 0, GOST_R_CTRL_CALL_FAILED), "ctrl call failed"}, + {ERR_PACK(0, 0, GOST_R_ERROR_COMPUTING_SHARED_KEY), + "error computing shared key"}, + {ERR_PACK(0, 0, GOST_R_ERROR_PARSING_KEY_TRANSPORT_INFO), + "error parsing key transport info"}, + {ERR_PACK(0, 0, GOST_R_ERROR_POINT_MUL), "error point mul"}, + {ERR_PACK(0, 0, GOST_R_INCOMPATIBLE_ALGORITHMS), "incompatible algorithms"}, + {ERR_PACK(0, 0, GOST_R_INCOMPATIBLE_PEER_KEY), "incompatible peer key"}, + {ERR_PACK(0, 0, GOST_R_INVALID_CIPHER_PARAMS), "invalid cipher params"}, + {ERR_PACK(0, 0, GOST_R_INVALID_CIPHER_PARAM_OID), + "invalid cipher param oid"}, + {ERR_PACK(0, 0, GOST_R_INVALID_DIGEST_TYPE), "invalid digest type"}, + {ERR_PACK(0, 0, GOST_R_INVALID_IV_LENGTH), "invalid iv length"}, + {ERR_PACK(0, 0, GOST_R_INVALID_MAC_KEY_LENGTH), "invalid mac key length"}, + {ERR_PACK(0, 0, GOST_R_INVALID_MAC_KEY_SIZE), "invalid mac key size"}, + {ERR_PACK(0, 0, GOST_R_INVALID_MAC_PARAMS), "invalid mac params"}, + {ERR_PACK(0, 0, GOST_R_INVALID_MAC_SIZE), "invalid mac size"}, + {ERR_PACK(0, 0, GOST_R_INVALID_PARAMSET), "invalid paramset"}, + {ERR_PACK(0, 0, GOST_R_KEY_IS_NOT_INITIALIZED), "key is not initialized"}, + {ERR_PACK(0, 0, GOST_R_KEY_PARAMETERS_MISSING), "key parameters missing"}, + {ERR_PACK(0, 0, GOST_R_MAC_KEY_NOT_SET), "mac key not set"}, + {ERR_PACK(0, 0, GOST_R_NO_PARAMETERS_SET), "no parameters set"}, + {ERR_PACK(0, 0, GOST_R_NO_PEER_KEY), "no peer key"}, + {ERR_PACK(0, 0, GOST_R_NO_PRIVATE_PART_OF_NON_EPHEMERAL_KEYPAIR), + "no private part of non ephemeral keypair"}, + {ERR_PACK(0, 0, GOST_R_PUBLIC_KEY_UNDEFINED), "public key undefined"}, + {ERR_PACK(0, 0, GOST_R_RNG_ERROR), "rng error"}, + {ERR_PACK(0, 0, GOST_R_SIGNATURE_MISMATCH), "signature mismatch"}, + {ERR_PACK(0, 0, GOST_R_SIGNATURE_PARTS_GREATER_THAN_Q), + "signature parts greater than q"}, + {ERR_PACK(0, 0, GOST_R_UKM_NOT_SET), "ukm not set"}, + {ERR_PACK(0, 0, GOST_R_UNSUPPORTED_CIPHER_CTL_COMMAND), + "unsupported cipher ctl command"}, + {ERR_PACK(0, 0, GOST_R_UNSUPPORTED_PARAMETER_SET), + "unsupported parameter set"}, {0, NULL} }; #endif -#ifdef GOST_LIB_NAME -static ERR_STRING_DATA GOST_lib_name[] = { - {0, GOST_LIB_NAME}, - {0, NULL} -}; -#endif +static int lib_code = 0; +static int error_loaded = 0; -static int GOST_lib_error_code = 0; -static int GOST_error_init = 1; - -void ERR_load_GOST_strings(void) +int ERR_load_GOST_strings(void) { - if (GOST_lib_error_code == 0) - GOST_lib_error_code = ERR_get_next_error_library(); + if (lib_code == 0) + lib_code = ERR_get_next_error_library(); - if (GOST_error_init) { - GOST_error_init = 0; + if (!error_loaded) { #ifndef OPENSSL_NO_ERR - ERR_load_strings(GOST_lib_error_code, GOST_str_functs); - ERR_load_strings(GOST_lib_error_code, GOST_str_reasons); -#endif - -#ifdef GOST_LIB_NAME - GOST_lib_name->error = ERR_PACK(GOST_lib_error_code, 0, 0); - ERR_load_strings(0, GOST_lib_name); + ERR_load_strings(lib_code, GOST_str_functs); + ERR_load_strings(lib_code, GOST_str_reasons); #endif + error_loaded = 1; } + return 1; } void ERR_unload_GOST_strings(void) { - if (GOST_error_init == 0) { + if (error_loaded) { #ifndef OPENSSL_NO_ERR - ERR_unload_strings(GOST_lib_error_code, GOST_str_functs); - ERR_unload_strings(GOST_lib_error_code, GOST_str_reasons); -#endif - -#ifdef GOST_LIB_NAME - ERR_unload_strings(0, GOST_lib_name); + ERR_unload_strings(lib_code, GOST_str_functs); + ERR_unload_strings(lib_code, GOST_str_reasons); #endif - GOST_error_init = 1; + error_loaded = 0; } } void ERR_GOST_error(int function, int reason, char *file, int line) { - if (GOST_lib_error_code == 0) - GOST_lib_error_code = ERR_get_next_error_library(); - ERR_PUT_error(GOST_lib_error_code, function, reason, file, line); + if (lib_code == 0) + lib_code = ERR_get_next_error_library(); + ERR_PUT_error(lib_code, function, reason, file, line); } diff --git a/e_gost_err.h b/e_gost_err.h index d0f7d89..9276df1 100644 --- a/e_gost_err.h +++ b/e_gost_err.h @@ -1,77 +1,32 @@ -/* ==================================================================== - * Copyright (c) 2001-2015 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html */ -#ifndef HEADER_GOST_ERR_H -# define HEADER_GOST_ERR_H +#ifndef HEADER_GOSTERR_H +# define HEADER_GOSTERR_H + +# define GOSTerr(f, r) ERR_GOST_error((f), (r), OPENSSL_FILE, OPENSSL_LINE) + # ifdef __cplusplus extern "C" { # endif +int ERR_load_GOST_strings(void); +void ERR_unload_GOST_strings(void); +void ERR_GOST_error(int function, int reason, char *file, int line); +# ifdef __cplusplus +} +# endif -/* BEGIN ERROR CODES */ /* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. + * GOST function codes. */ - void ERR_load_GOST_strings(void); - void ERR_unload_GOST_strings(void); - void ERR_GOST_error(int function, int reason, char *file, int line); -# define GOSTerr(f,r) ERR_GOST_error((f),(r),__FILE__,__LINE__) - -/* Error codes for the GOST functions. */ - -/* Function codes. */ # define GOST_F_DECODE_GOST_ALGOR_PARAMS 100 # define GOST_F_ENCODE_GOST_ALGOR_PARAMS 101 # define GOST_F_FILL_GOST_EC_PARAMS 102 @@ -83,30 +38,36 @@ extern "C" { # define GOST_F_GOST_EC_KEYGEN 108 # define GOST_F_GOST_EC_SIGN 109 # define GOST_F_GOST_EC_VERIFY 110 -# define GOST_F_GOST_IMIT_CTRL 111 -# define GOST_F_GOST_IMIT_FINAL 112 -# define GOST_F_GOST_IMIT_UPDATE 113 -# define GOST_F_PARAM_COPY_GOST_EC 114 -# define GOST_F_PKEY_GOST01_PARAMGEN 115 -# define GOST_F_PKEY_GOST12_PARAMGEN 116 -# define GOST_F_PKEY_GOST_CTRL 117 -# define GOST_F_PKEY_GOST_ECCP_DECRYPT 118 -# define GOST_F_PKEY_GOST_ECCP_ENCRYPT 119 -# define GOST_F_PKEY_GOST_EC_CTRL_STR_256 120 -# define GOST_F_PKEY_GOST_EC_CTRL_STR_512 121 -# define GOST_F_PKEY_GOST_EC_DERIVE 122 -# define GOST_F_PKEY_GOST_MAC_CTRL 123 -# define GOST_F_PKEY_GOST_MAC_CTRL_STR 124 -# define GOST_F_PKEY_GOST_MAC_KEYGEN 125 -# define GOST_F_PKEY_GOST_MAC_SIGNCTX_INIT 132 -# define GOST_F_PRINT_GOST_EC_PUB 126 -# define GOST_F_PRIV_DECODE_GOST 127 -# define GOST_F_PUB_DECODE_GOST_EC 128 -# define GOST_F_PUB_ENCODE_GOST_EC 129 -# define GOST_F_UNPACK_CP_SIGNATURE 130 -# define GOST_F_VKO_COMPUTE_KEY 131 +# define GOST_F_GOST_GRASSHOPPER_CIPHER_CTL 111 +# define GOST_F_GOST_GRASSHOPPER_SET_ASN1_PARAMETERS 112 +# define GOST_F_GOST_IMIT_CTRL 113 +# define GOST_F_GOST_IMIT_FINAL 114 +# define GOST_F_GOST_IMIT_UPDATE 115 +# define GOST_F_MAGMA_IMIT_FINAL 116 +# define GOST_F_MAGMA_IMIT_UPDATE 117 +# define GOST_F_PARAM_COPY_GOST_EC 118 +# define GOST_F_PKEY_GOST2001_PARAMGEN 119 +# define GOST_F_PKEY_GOST2012_PARAMGEN 120 +# define GOST_F_PKEY_GOST_CTRL 121 +# define GOST_F_PKEY_GOST_ECCP_DECRYPT 122 +# define GOST_F_PKEY_GOST_ECCP_ENCRYPT 123 +# define GOST_F_PKEY_GOST_EC_CTRL_STR_256 124 +# define GOST_F_PKEY_GOST_EC_CTRL_STR_512 125 +# define GOST_F_PKEY_GOST_EC_DERIVE 126 +# define GOST_F_PKEY_GOST_MAC_CTRL 127 +# define GOST_F_PKEY_GOST_MAC_CTRL_STR 128 +# define GOST_F_PKEY_GOST_MAC_KEYGEN_BASE 129 +# define GOST_F_PKEY_GOST_MAC_SIGNCTX_INIT 130 +# define GOST_F_PRINT_GOST_EC_PUB 131 +# define GOST_F_PRIV_DECODE_GOST 132 +# define GOST_F_PUB_DECODE_GOST_EC 133 +# define GOST_F_PUB_ENCODE_GOST_EC 134 +# define GOST_F_UNPACK_CP_SIGNATURE 135 +# define GOST_F_VKO_COMPUTE_KEY 136 -/* Reason codes. */ +/* + * GOST reason codes. + */ # define GOST_R_BAD_KEY_PARAMETERS_FORMAT 100 # define GOST_R_BAD_PKEY_PARAMETERS_FORMAT 101 # define GOST_R_CANNOT_PACK_EPHEMERAL_KEY 102 @@ -121,25 +82,22 @@ extern "C" { # define GOST_R_INVALID_DIGEST_TYPE 111 # define GOST_R_INVALID_IV_LENGTH 112 # define GOST_R_INVALID_MAC_KEY_LENGTH 113 -# define GOST_R_INVALID_MAC_KEY_SIZE 128 -# define GOST_R_INVALID_MAC_PARAMS 130 -# define GOST_R_INVALID_MAC_SIZE 129 -# define GOST_R_INVALID_PARAMSET 114 -# define GOST_R_KEY_IS_NOT_INITIALIZED 115 -# define GOST_R_KEY_PARAMETERS_MISSING 116 -# define GOST_R_MAC_KEY_NOT_SET 117 -# define GOST_R_NO_PARAMETERS_SET 118 -# define GOST_R_NO_PEER_KEY 119 -# define GOST_R_NO_PRIVATE_PART_OF_NON_EPHEMERAL_KEYPAIR 120 -# define GOST_R_PUBLIC_KEY_UNDEFINED 121 -# define GOST_R_RNG_ERROR 122 -# define GOST_R_SIGNATURE_MISMATCH 123 -# define GOST_R_SIGNATURE_PARTS_GREATER_THAN_Q 124 -# define GOST_R_UKM_NOT_SET 125 -# define GOST_R_UNSUPPORTED_CIPHER_CTL_COMMAND 126 -# define GOST_R_UNSUPPORTED_PARAMETER_SET 127 +# define GOST_R_INVALID_MAC_KEY_SIZE 114 +# define GOST_R_INVALID_MAC_PARAMS 115 +# define GOST_R_INVALID_MAC_SIZE 116 +# define GOST_R_INVALID_PARAMSET 117 +# define GOST_R_KEY_IS_NOT_INITIALIZED 118 +# define GOST_R_KEY_PARAMETERS_MISSING 119 +# define GOST_R_MAC_KEY_NOT_SET 120 +# define GOST_R_NO_PARAMETERS_SET 121 +# define GOST_R_NO_PEER_KEY 122 +# define GOST_R_NO_PRIVATE_PART_OF_NON_EPHEMERAL_KEYPAIR 123 +# define GOST_R_PUBLIC_KEY_UNDEFINED 124 +# define GOST_R_RNG_ERROR 125 +# define GOST_R_SIGNATURE_MISMATCH 126 +# define GOST_R_SIGNATURE_PARTS_GREATER_THAN_Q 127 +# define GOST_R_UKM_NOT_SET 128 +# define GOST_R_UNSUPPORTED_CIPHER_CTL_COMMAND 129 +# define GOST_R_UNSUPPORTED_PARAMETER_SET 130 -# ifdef __cplusplus -} -# endif #endif diff --git a/gost.ec b/gost.ec index 6c2c85e..7cf8662 100644 --- a/gost.ec +++ b/gost.ec @@ -1,5 +1 @@ L GOST e_gost_err.h e_gost_err.c -L NONE asymm.h NONE -L NONE md.h NONE -L NONE crypt.h NONE -L NONE gostkeyx.h NONE diff --git a/gost.txt b/gost.txt new file mode 100644 index 0000000..e69de29 diff --git a/gost_grasshopper_cipher.c b/gost_grasshopper_cipher.c index c797fe1..20c04b0 100644 --- a/gost_grasshopper_cipher.c +++ b/gost_grasshopper_cipher.c @@ -541,7 +541,7 @@ int gost_grasshopper_set_asn1_parameters(EVP_CIPHER_CTX* ctx, ASN1_TYPE* params) if (!os || !ASN1_OCTET_STRING_set(os, buf, len)) { OPENSSL_free(buf); - GOSTerr(GOST_F_GOST89_SET_ASN1_PARAMETERS, ERR_R_MALLOC_FAILURE); + GOSTerr(GOST_F_GOST_GRASSHOPPER_SET_ASN1_PARAMETERS, ERR_R_MALLOC_FAILURE); return 0; } OPENSSL_free(buf); @@ -564,13 +564,13 @@ int gost_grasshopper_cipher_ctl(EVP_CIPHER_CTX* ctx, int type, int arg, void* pt switch (type) { case EVP_CTRL_RAND_KEY: { if (RAND_bytes((unsigned char*) ptr, EVP_CIPHER_CTX_key_length(ctx)) <= 0) { - GOSTerr(GOST_F_GOST_CIPHER_CTL, GOST_R_RNG_ERROR); + GOSTerr(GOST_F_GOST_GRASSHOPPER_CIPHER_CTL, GOST_R_RNG_ERROR); return -1; } break; } default: - GOSTerr(GOST_F_GOST_CIPHER_CTL, GOST_R_UNSUPPORTED_CIPHER_CTL_COMMAND); + GOSTerr(GOST_F_GOST_GRASSHOPPER_CIPHER_CTL, GOST_R_UNSUPPORTED_CIPHER_CTL_COMMAND); return -1; } return 1; diff --git a/gost_pmeth.c b/gost_pmeth.c index ce162f5..787b480 100644 --- a/gost_pmeth.c +++ b/gost_pmeth.c @@ -283,7 +283,7 @@ static int pkey_gost2001_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) EC_KEY *ec = NULL; if (!data || data->sign_param_nid == NID_undef) { - GOSTerr(GOST_F_PKEY_GOST01_PARAMGEN, GOST_R_NO_PARAMETERS_SET); + GOSTerr(GOST_F_PKEY_GOST2001_PARAMGEN, GOST_R_NO_PARAMETERS_SET); return 0; } @@ -303,7 +303,7 @@ static int pkey_gost2012_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) int result = 0; if (!data || data->sign_param_nid == NID_undef) { - GOSTerr(GOST_F_PKEY_GOST12_PARAMGEN, GOST_R_NO_PARAMETERS_SET); + GOSTerr(GOST_F_PKEY_GOST2012_PARAMGEN, GOST_R_NO_PARAMETERS_SET); return 0; } @@ -657,7 +657,7 @@ static int pkey_gost_mac_keygen_base(EVP_PKEY_CTX *ctx, struct gost_mac_pmeth_data *data = EVP_PKEY_CTX_get_data(ctx); struct gost_mac_key *keydata; if (!data || !data->key_set) { - GOSTerr(GOST_F_PKEY_GOST_MAC_KEYGEN, GOST_R_MAC_KEY_NOT_SET); + GOSTerr(GOST_F_PKEY_GOST_MAC_KEYGEN_BASE, GOST_R_MAC_KEY_NOT_SET); return 0; } keydata = OPENSSL_malloc(sizeof(struct gost_mac_key));