diff options
author | Arseniy Ankudinov <afalinuz@gmail.com> | 2020-09-23 18:54:58 +0300 |
---|---|---|
committer | Dmitry Belyavskiy <beldmit@users.noreply.github.com> | 2020-09-23 20:09:38 +0300 |
commit | e9a7bfc3a6ef368dcc7eba482356c166f7d888d7 (patch) | |
tree | 6d86564807d302c7a554b62ff284960b22b8cc29 | |
parent | 8fff4a245e57cd2e3479a35cf5a8be534bee5e1c (diff) | |
download | gost-engine-e9a7bfc3a6ef368dcc7eba482356c166f7d888d7.zip gost-engine-e9a7bfc3a6ef368dcc7eba482356c166f7d888d7.tar.gz gost-engine-e9a7bfc3a6ef368dcc7eba482356c166f7d888d7.tar.bz2 |
disable gost key mask on gost94 digest steps due to performance issues
-rw-r--r-- | gost89.c | 20 | ||||
-rw-r--r-- | gost89.h | 2 |
2 files changed, 18 insertions, 4 deletions
@@ -444,15 +444,13 @@ void gost_dec_cfb(gost_ctx * ctx, const byte * iv, const byte * cipher, void gost_enc_with_key(gost_ctx * c, byte * key, byte * inblock, byte * outblock) { - gost_key(c, key); + gost_key_nomask(c, key); gostcrypt(c, inblock, outblock); } -/* Set 256 bit gost89 key into context */ -void gost_key(gost_ctx * c, const byte * k) +static void gost_key_impl(gost_ctx * c, const byte * k) { int i, j; - RAND_priv_bytes((unsigned char *)c->mask, sizeof(c->mask)); for (i = 0, j = 0; i < 8; ++i, j += 4) { c->key[i] = (k[j] | (k[j + 1] << 8) | (k[j + 2] << 16) | ((word32) k[j + 3] << @@ -460,6 +458,20 @@ void gost_key(gost_ctx * c, const byte * k) } } +/* Set 256 bit gost89 key into context */ +void gost_key(gost_ctx * c, const byte * k) +{ + RAND_priv_bytes((unsigned char *)c->mask, sizeof(c->mask)); + gost_key_impl(c, k); +} + +/* Set 256 bit gost89 key into context without key mask */ +void gost_key_nomask(gost_ctx * c, const byte * k) +{ + memset(c->mask, 0, sizeof(c->mask)); + gost_key_impl(c, k); +} + /* Set 256 bit Magma key into context */ void magma_key(gost_ctx * c, const byte * k) { @@ -60,6 +60,8 @@ void gostcrypt(gost_ctx * c, const byte * in, byte * out); void gostdecrypt(gost_ctx * c, const byte * in, byte * out); /* Set key into context */ void gost_key(gost_ctx * c, const byte * k); +/* Set key into context without key mask */ +void gost_key_nomask(gost_ctx * c, const byte * k); /* Set key into context */ void magma_key(gost_ctx * c, const byte * k); /* Get key from context */ |