Skip to content

Commit

Permalink
Refactored acpkm_magma_key_meshing
Browse files Browse the repository at this point in the history
  • Loading branch information
marcfedorow authored and beldmit committed Jul 11, 2022
1 parent fcca1ab commit 624bf7d
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions gost89.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,20 +768,11 @@ void cryptopro_key_meshing(gost_ctx * ctx, unsigned char *iv)
void acpkm_magma_key_meshing(gost_ctx * ctx)
{
unsigned char newkey[32];
int i, j;

int i;
for (i = 0; i < 4; i++) {
unsigned char buf[8], keybuf[8];
for (j = 0; j < 8; j++) {
buf[j] = ACPKM_D_const[8 * i + 7 - j];
}
gostcrypt(ctx, buf, keybuf);
memcpy(newkey + 8 * i, keybuf + 4, 4);
memcpy(newkey + 8 * i + 4, keybuf, 4);
OPENSSL_cleanse(keybuf, sizeof(keybuf));
OPENSSL_cleanse(buf, sizeof(buf));
magmacrypt(ctx, ACPKM_D_const + 8 * i, newkey + 8 * i);
}
/* set new key */
gost_key(ctx, newkey);
magma_key(ctx, newkey);
OPENSSL_cleanse(newkey, sizeof(newkey));
}

0 comments on commit 624bf7d

Please sign in to comment.