From 62e85837c5b1979ab96800d6f91ff2708d5e984c Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Mon, 23 Mar 2020 23:55:07 +0300 Subject: [PATCH 32/87] gost: use key_meshing for specifying section size In preparation to adding ACPKM support, switch key_meshing to be a section size rather than just a flag. Signed-off-by: Dmitry Baryshkov --- src/lib/libcrypto/gost/gost.h | 2 +- src/lib/libcrypto/gost/gost2814789.c | 8 ++++---- src/lib/libcrypto/gost/gost89_params.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/libcrypto/gost/gost.h b/src/lib/libcrypto/gost/gost.h index b6e5b51c4..a9ed5a1c5 100644 --- a/src/lib/libcrypto/gost/gost.h +++ b/src/lib/libcrypto/gost/gost.h @@ -69,7 +69,7 @@ typedef struct gost2814789_key_st { unsigned int key[8]; unsigned int k87[256],k65[256],k43[256],k21[256]; unsigned int count; - unsigned key_meshing : 1; + unsigned int key_meshing; } GOST2814789_KEY; int Gost2814789_set_sbox(GOST2814789_KEY *key, int nid); diff --git a/src/lib/libcrypto/gost/gost2814789.c b/src/lib/libcrypto/gost/gost2814789.c index 5016ed004..e5c7f6a2b 100644 --- a/src/lib/libcrypto/gost/gost2814789.c +++ b/src/lib/libcrypto/gost/gost2814789.c @@ -169,7 +169,7 @@ void Gost2814789_ecb_encrypt(const unsigned char *in, unsigned char *out, GOST2814789_KEY *key, const int enc) { - if (key->key_meshing && key->count == 1024) { + if (key->key_meshing && key->count == key->key_meshing) { Gost2814789_cryptopro_key_mesh(key); key->count = 0; } @@ -183,7 +183,7 @@ Gost2814789_ecb_encrypt(const unsigned char *in, unsigned char *out, static inline void Gost2814789_encrypt_mesh(unsigned char *iv, GOST2814789_KEY *key) { - if (key->key_meshing && key->count == 1024) { + if (key->key_meshing && key->count == key->key_meshing) { Gost2814789_cryptopro_key_mesh(key); Gost2814789_encrypt(iv, iv, key); key->count = 0; @@ -196,7 +196,7 @@ static inline void Gost2814789_mac_mesh(const unsigned char *data, unsigned char *mac, GOST2814789_KEY *key) { - if (key->key_meshing && key->count == 1024) { + if (key->key_meshing && key->count == key->key_meshing) { Gost2814789_cryptopro_key_mesh(key); key->count = 0; } @@ -328,7 +328,7 @@ Gost2814789_cnt_next(unsigned char *ivec, unsigned char *out, if (key->count == 0) Gost2814789_encrypt(ivec, ivec, key); - if (key->key_meshing && key->count == 1024) { + if (key->key_meshing && key->count == key->key_meshing) { Gost2814789_cryptopro_key_mesh(key); Gost2814789_encrypt(ivec, ivec, key); key->count = 0; diff --git a/src/lib/libcrypto/gost/gost89_params.c b/src/lib/libcrypto/gost/gost89_params.c index 526710cb0..c454fd7af 100644 --- a/src/lib/libcrypto/gost/gost89_params.c +++ b/src/lib/libcrypto/gost/gost89_params.c @@ -191,7 +191,7 @@ Gost2814789_set_sbox(GOST2814789_KEY *key, int nid) continue; b = gost_cipher_list[i].sblock; - key->key_meshing = gost_cipher_list[i].key_meshing; + key->key_meshing = gost_cipher_list[i].key_meshing ? 1024 : 0; break; } -- 2.17.1