From 6b41c2e3f9335af1437a05e6f48bfec7e1841a75 Mon Sep 17 00:00:00 2001 From: Dmitry Belyavskiy Date: Thu, 30 Aug 2018 18:07:01 +0300 Subject: [PATCH] Error codes fixed --- e_gost_err.c | 4 ++++ e_gost_err.h | 4 ++++ gost.txt | 5 +++++ gost_omac_acpkm.c | 16 ++++++++-------- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/e_gost_err.c b/e_gost_err.c index e28c314..7e8730d 100644 --- a/e_gost_err.c +++ b/e_gost_err.c @@ -37,6 +37,10 @@ static ERR_STRING_DATA GOST_str_functs[] = { {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_GOST_KEXP15, 0), "gost_kexp15"}, + {ERR_PACK(0, GOST_F_OMAC_ACPKM_IMIT_CTRL, 0), "omac_acpkm_imit_ctrl"}, + {ERR_PACK(0, GOST_F_OMAC_ACPKM_IMIT_FINAL, 0), "omac_acpkm_imit_final"}, + {ERR_PACK(0, GOST_F_OMAC_ACPKM_IMIT_UPDATE, 0), "omac_acpkm_imit_update"}, + {ERR_PACK(0, GOST_F_OMAC_ACPKM_KEY, 0), "omac_acpkm_key"}, {ERR_PACK(0, GOST_F_OMAC_IMIT_CTRL, 0), "omac_imit_ctrl"}, {ERR_PACK(0, GOST_F_OMAC_IMIT_FINAL, 0), "omac_imit_final"}, {ERR_PACK(0, GOST_F_OMAC_IMIT_UPDATE, 0), "omac_imit_update"}, diff --git a/e_gost_err.h b/e_gost_err.h index 96d7501..79f8673 100644 --- a/e_gost_err.h +++ b/e_gost_err.h @@ -44,6 +44,10 @@ void ERR_GOST_error(int function, int reason, char *file, int line); # define GOST_F_GOST_IMIT_FINAL 114 # define GOST_F_GOST_IMIT_UPDATE 115 # define GOST_F_GOST_KEXP15 143 +# define GOST_F_OMAC_ACPKM_IMIT_CTRL 144 +# define GOST_F_OMAC_ACPKM_IMIT_FINAL 145 +# define GOST_F_OMAC_ACPKM_IMIT_UPDATE 146 +# define GOST_F_OMAC_ACPKM_KEY 147 # define GOST_F_OMAC_IMIT_CTRL 116 # define GOST_F_OMAC_IMIT_FINAL 117 # define GOST_F_OMAC_IMIT_UPDATE 118 diff --git a/gost.txt b/gost.txt index 4a515f9..4c66dec 100644 --- a/gost.txt +++ b/gost.txt @@ -23,6 +23,11 @@ GOST_F_GOST_GRASSHOPPER_SET_ASN1_PARAMETERS:112:\ GOST_F_GOST_IMIT_CTRL:113:gost_imit_ctrl GOST_F_GOST_IMIT_FINAL:114:gost_imit_final GOST_F_GOST_IMIT_UPDATE:115:gost_imit_update +GOST_F_GOST_KEXP15:143:gost_kexp15 +GOST_F_OMAC_ACPKM_IMIT_CTRL:144:omac_acpkm_imit_ctrl +GOST_F_OMAC_ACPKM_IMIT_FINAL:145:omac_acpkm_imit_final +GOST_F_OMAC_ACPKM_IMIT_UPDATE:146:omac_acpkm_imit_update +GOST_F_OMAC_ACPKM_KEY:147:omac_acpkm_key GOST_F_OMAC_IMIT_CTRL:116:omac_imit_ctrl GOST_F_OMAC_IMIT_FINAL:117:omac_imit_final GOST_F_OMAC_IMIT_UPDATE:118:omac_imit_update diff --git a/gost_omac_acpkm.c b/gost_omac_acpkm.c index 6542bbf..9bdb05f 100644 --- a/gost_omac_acpkm.c +++ b/gost_omac_acpkm.c @@ -331,7 +331,7 @@ static int omac_acpkm_imit_update(EVP_MD_CTX *ctx, const void *data, { OMAC_ACPKM_CTX *c = EVP_MD_CTX_md_data(ctx); if (!c->key_set) { - GOSTerr(GOST_F_OMAC_IMIT_UPDATE, GOST_R_MAC_KEY_NOT_SET); + GOSTerr(GOST_F_OMAC_ACPKM_IMIT_UPDATE, GOST_R_MAC_KEY_NOT_SET); return 0; } @@ -345,7 +345,7 @@ int omac_acpkm_imit_final(EVP_MD_CTX *ctx, unsigned char *md) size_t mac_size = sizeof(mac); if (!c->key_set) { - GOSTerr(GOST_F_OMAC_IMIT_FINAL, GOST_R_MAC_KEY_NOT_SET); + GOSTerr(GOST_F_OMAC_ACPKM_IMIT_FINAL, GOST_R_MAC_KEY_NOT_SET); return 0; } @@ -399,7 +399,7 @@ static int omac_acpkm_key(OMAC_ACPKM_CTX *c, const EVP_CIPHER *cipher, c->cmac_ctx = CMAC_ACPKM_CTX_new(); if (c->cmac_ctx == NULL) { - GOSTerr(GOST_F_OMAC_KEY, ERR_R_MALLOC_FAILURE); + GOSTerr(GOST_F_OMAC_ACPKM_KEY, ERR_R_MALLOC_FAILURE); return 0; } @@ -431,15 +431,15 @@ int omac_acpkm_imit_ctrl(EVP_MD_CTX *ctx, int type, int arg, void *ptr) } cipher = EVP_get_cipherbynid(c->cipher_nid); if (cipher == NULL) { - GOSTerr(GOST_F_OMAC_IMIT_CTRL, GOST_R_CIPHER_NOT_FOUND); + GOSTerr(GOST_F_OMAC_ACPKM_IMIT_CTRL, GOST_R_CIPHER_NOT_FOUND); } if (EVP_MD_meth_get_init(EVP_MD_CTX_md(ctx)) (ctx) <= 0) { - GOSTerr(GOST_F_OMAC_IMIT_CTRL, GOST_R_MAC_KEY_NOT_SET); + GOSTerr(GOST_F_OMAC_ACPKM_IMIT_CTRL, GOST_R_MAC_KEY_NOT_SET); return 0; } EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_NO_INIT); if (c->key_set) { - GOSTerr(GOST_F_OMAC_IMIT_CTRL, GOST_R_BAD_ORDER); + GOSTerr(GOST_F_OMAC_ACPKM_IMIT_CTRL, GOST_R_BAD_ORDER); return 0; } if (arg == 0) { @@ -448,7 +448,7 @@ int omac_acpkm_imit_ctrl(EVP_MD_CTX *ctx, int type, int arg, void *ptr) } else if (arg == 32) { return omac_acpkm_key(c, cipher, ptr, 32); } - GOSTerr(GOST_F_OMAC_IMIT_CTRL, GOST_R_INVALID_MAC_KEY_SIZE); + GOSTerr(GOST_F_OMAC_ACPKM_IMIT_CTRL, GOST_R_INVALID_MAC_KEY_SIZE); return 0; } case EVP_CTRL_KEY_MESH: @@ -470,7 +470,7 @@ int omac_acpkm_imit_ctrl(EVP_MD_CTX *ctx, int type, int arg, void *ptr) switch (c->cipher_nid) { case NID_grasshopper_cbc: if (arg < 1 || arg > 16) { - GOSTerr(GOST_F_OMAC_IMIT_CTRL, GOST_R_INVALID_MAC_SIZE); + GOSTerr(GOST_F_OMAC_ACPKM_IMIT_CTRL, GOST_R_INVALID_MAC_SIZE); return 0; } c->dgst_size = arg; -- 2.39.5