]> www.wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
test_grasshopper: Warn if EVP_MD_meth_set_result_size is performed
authorVitaly Chikunov <vt@altlinux.org>
Wed, 25 Jul 2018 07:49:38 +0000 (10:49 +0300)
committerGleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
Tue, 21 Aug 2018 17:09:13 +0000 (20:09 +0300)
(cherry picked from commit 641223f4d077bfd41143420c852aabbef8ca7fdf)

test_grasshopper.c

index 4ea195c136cf3c3f7017ca35b8eb0343388b0f1e..14252bcaf36bd0ce4ced08e71b032c3e363ec6cd 100644 (file)
@@ -23,7 +23,9 @@
     }
 
 #define cRED   "\033[1;31m"
+#define cDRED  "\033[0;31m"
 #define cGREEN "\033[1;32m"
+#define cDGREEN        "\033[0;32m"
 #define cNORM  "\033[m"
 #define TEST_ASSERT(e) {if ((test = (e))) \
                 printf(cRED "Test FAILED\n" cNORM); \
@@ -240,10 +242,11 @@ static int test_omac()
     /* preload cbc cipher for omac set key */
     EVP_add_cipher(cipher_gost_grasshopper_cbc());
     T(EVP_DigestInit_ex(ctx, grasshopper_omac(), NULL));
-    if (EVP_MD_CTX_size(ctx) != 8) {
+    if (EVP_MD_CTX_size(ctx) != sizeof(mac)) {
        /* strip const out of EVP_MD_CTX_md() to
         * overwrite output size, as test vector is 8 bytes */
-       T(EVP_MD_meth_set_result_size((EVP_MD *)EVP_MD_CTX_md(ctx), 8));
+       printf("Resize result size from %d to %zu\n", EVP_MD_CTX_size(ctx), sizeof(mac));
+       T(EVP_MD_meth_set_result_size((EVP_MD *)EVP_MD_CTX_md(ctx), sizeof(mac)));
     }
     T(EVP_MD_meth_get_ctrl(EVP_MD_CTX_md(ctx))(ctx, EVP_MD_CTRL_SET_KEY, sizeof(K), (void *)K));
     T(EVP_DigestUpdate(ctx, P, sizeof(P)));
@@ -283,8 +286,8 @@ int main(int argc, char **argv)
     ret |= test_omac();
 
     if (ret)
-       printf(cRED "= Some tests FAILED!\n" cNORM);
+       printf(cDRED "= Some tests FAILED!\n" cNORM);
     else
-       printf(cGREEN "= All tests passed!\n" cNORM);
+       printf(cDGREEN "= All tests passed!\n" cNORM);
     return ret;
 }