]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
benchmark: use mac key size instead of block size
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Mon, 23 Dec 2019 23:32:17 +0000 (02:32 +0300)
committerDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Fri, 27 Dec 2019 08:59:42 +0000 (11:59 +0300)
Use newly added gnutls_hmac_get_key_size() to get key size instead of
assuming that key size = block size (incorrect for GOST 28147 IMIT).

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
src/benchmark-cipher.c

index b6945a2920a06351a730fb88e8a3bf4b22d6632a..2d2bc30a669525875eddce04b35adc02eb5afb7b 100644 (file)
@@ -231,7 +231,7 @@ static void cipher_bench(int algo, int size, int aead)
 static void mac_bench(int algo, int size)
 {
        void *_key;
-       int blocksize = gnutls_hmac_get_len(algo);
+       int key_size = gnutls_hmac_get_key_size(algo);
        int step = size * 1024;
        struct benchmark_st st;
        void *input;
@@ -240,10 +240,10 @@ static void mac_bench(int algo, int size)
        ALLOCM(input, MAX_MEM);
        i = input;
 
-       _key = malloc(blocksize);
+       _key = malloc(key_size);
        if (_key == NULL)
                return;
-       memset(_key, 0xf0, blocksize);
+       memset(_key, 0xf0, key_size);
 
        printf("%16s ", gnutls_mac_get_name(algo));
        fflush(stdout);
@@ -253,7 +253,7 @@ static void mac_bench(int algo, int size)
        start_benchmark(&st);
 
        do {
-               gnutls_hmac_fast(algo, _key, blocksize, i, step, _key);
+               gnutls_hmac_fast(algo, _key, key_size, i, step, _key);
                st.size += step;
                INC(input, i, step);
        }