X-Git-Url: http://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=gost_crypt.c;h=4e22145a46d27097ec4aa44d98b7a5e0c9c9cff4;hb=41b4121253a9c0e8d82d3eebcfe728d5d43e1b51;hp=930d40adc76941aedef3479efb841c44d7e55801;hpb=12be7c21781eba9f7a37762e7e307571225c6c47;p=openssl-gost%2Fengine.git diff --git a/gost_crypt.c b/gost_crypt.c index 930d40a..4e22145 100644 --- a/gost_crypt.c +++ b/gost_crypt.c @@ -302,7 +302,7 @@ EVP_MD *imit_gost_cpa(void) || !EVP_MD_meth_set_input_blocksize(md, 8) || !EVP_MD_meth_set_app_datasize(md, sizeof(struct ossl_gost_imit_ctx)) - || !EVP_MD_meth_set_flags(md, 0) + || !EVP_MD_meth_set_flags(md, EVP_MD_FLAG_XOF) || !EVP_MD_meth_set_init(md, gost_imit_init_cpa) || !EVP_MD_meth_set_update(md, gost_imit_update) || !EVP_MD_meth_set_final(md, gost_imit_final) @@ -333,7 +333,7 @@ EVP_MD *imit_gost_cp_12(void) || !EVP_MD_meth_set_input_blocksize(md, 8) || !EVP_MD_meth_set_app_datasize(md, sizeof(struct ossl_gost_imit_ctx)) - || !EVP_MD_meth_set_flags(md, 0) + || !EVP_MD_meth_set_flags(md, EVP_MD_FLAG_XOF) || !EVP_MD_meth_set_init(md, gost_imit_init_cp_12) || !EVP_MD_meth_set_update(md, gost_imit_update) || !EVP_MD_meth_set_final(md, gost_imit_final) @@ -876,7 +876,7 @@ int gost_cipher_ctl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) #endif case EVP_CTRL_RAND_KEY: { - if (RAND_bytes + if (RAND_priv_bytes ((unsigned char *)ptr, EVP_CIPHER_CTX_key_length(ctx)) <= 0) { GOSTerr(GOST_F_GOST_CIPHER_CTL, GOST_R_RNG_ERROR); return -1; @@ -1001,7 +1001,6 @@ int gost89_set_asn1_parameters(EVP_CIPHER_CTX *ctx, ASN1_TYPE *params) /* Store parameters into ASN1 structure */ int gost89_get_asn1_parameters(EVP_CIPHER_CTX *ctx, ASN1_TYPE *params) { - int ret = -1; int len; GOST_CIPHER_PARAMS *gcp = NULL; unsigned char *p; @@ -1009,7 +1008,7 @@ int gost89_get_asn1_parameters(EVP_CIPHER_CTX *ctx, ASN1_TYPE *params) int nid; if (ASN1_TYPE_get(params) != V_ASN1_SEQUENCE) { - return ret; + return -1; } p = params->value.sequence->data; @@ -1071,15 +1070,14 @@ static int gost_imit_init_cp_12(EVP_MD_CTX *ctx) static void mac_block_mesh(struct ossl_gost_imit_ctx *c, const unsigned char *data) { - unsigned char buffer[8]; /* - * We are using local buffer for iv because CryptoPro doesn't interpret + * We are using NULL for iv because CryptoPro doesn't interpret * internal state of MAC algorithm as iv during keymeshing (but does * initialize internal state from iv in key transport */ assert(c->count % 8 == 0 && c->count <= 1024); if (c->key_meshing && c->count == 1024) { - cryptopro_key_meshing(&(c->cctx), buffer); + cryptopro_key_meshing(&(c->cctx), NULL); } mac_block(&(c->cctx), c->buffer, data); c->count = c->count % 1024 + 8; @@ -1089,12 +1087,13 @@ int gost_imit_update(EVP_MD_CTX *ctx, const void *data, size_t count) { struct ossl_gost_imit_ctx *c = EVP_MD_CTX_md_data(ctx); const unsigned char *p = data; - size_t bytes = count, i; + size_t bytes = count; if (!(c->key_set)) { GOSTerr(GOST_F_GOST_IMIT_UPDATE, GOST_R_MAC_KEY_NOT_SET); return 0; } if (c->bytes_left) { + size_t i; for (i = c->bytes_left; i < 8 && bytes > 0; bytes--, i++, p++) { c->partial_block[i] = *p; } @@ -1180,7 +1179,7 @@ int gost_imit_ctrl(EVP_MD_CTX *ctx, int type, int arg, void *ptr) GOSTerr(GOST_F_GOST_IMIT_CTRL, GOST_R_INVALID_MAC_KEY_SIZE); return 0; } - case EVP_MD_CTRL_MAC_LEN: + case EVP_MD_CTRL_XOF_LEN: { struct ossl_gost_imit_ctx *c = EVP_MD_CTX_md_data(ctx); if (arg < 1 || arg > 8) {