Skip to content

Commit

Permalink
Remove unset local buffer meshing. This removes valgrind errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
NMorozxov authored and beldmit committed Feb 1, 2020
1 parent 5dfb598 commit 28c0663
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 6 additions & 3 deletions gost89.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,15 +621,18 @@ int gost_mac_iv(gost_ctx * ctx, int mac_len, const unsigned char *iv,
/* Implements key meshing algorithm by modifing ctx and IV in place */
void cryptopro_key_meshing(gost_ctx * ctx, unsigned char *iv)
{
unsigned char newkey[32], newiv[8];
unsigned char newkey[32];
/* Set static keymeshing key */
/* "Decrypt" key with keymeshing key */
gost_dec(ctx, CryptoProKeyMeshingKey, newkey, 4);
/* set new key */
gost_key(ctx, newkey);
/* Encrypt iv with new key */
gostcrypt(ctx, iv, newiv);
memcpy(iv, newiv, 8);
if (iv != NULL ) {
unsigned char newiv[8];
gostcrypt(ctx, iv, newiv);
memcpy(iv, newiv, 8);
}
}

void acpkm_magma_key_meshing(gost_ctx * ctx)
Expand Down
5 changes: 2 additions & 3 deletions gost_crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1071,15 +1071,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;
Expand Down

0 comments on commit 28c0663

Please sign in to comment.