In preparation to adding ACPKM support, switch key_meshing to be a
section size rather than just a flag.

Signed-off-by: Dmitry Baryshkov <dbarysh...@gmail.com>
---
 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 b6e5b51c40d4..a9ed5a1c50df 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 5016ed004b32..e5c7f6a2b3dd 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 526710cb043f..c454fd7afc40 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.25.1

Reply via email to