X-Git-Url: http://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=test_digest.c;h=68c0e3253f7366cea9d8525dd7199821d92d7093;hb=4c531340c8ca3cff32e8c8790e1caf5ef7dd5dbe;hp=9d3019a9cc8363848bd63d5194038177b3b35bdb;hpb=b92c6c80b9a1790933d1fd6817b674e724658dc8;p=openssl-gost%2Fengine.git diff --git a/test_digest.c b/test_digest.c index 9d3019a..68c0e32 100644 --- a/test_digest.c +++ b/test_digest.c @@ -7,6 +7,11 @@ * See https://www.openssl.org/source/license.html for details */ +#ifdef _MSC_VER +# pragma warning(push, 3) +# include +# pragma warning(pop) +#endif #include #include #include @@ -29,17 +34,17 @@ #endif /* Helpers to test OpenSSL API calls. */ -#define T(e) ({ if (!(e)) { \ - ERR_print_errors_fp(stderr); \ - OpenSSLDie(__FILE__, __LINE__, #e); \ - } \ - }) -#define TE(e) ({ if (!(e)) { \ - ERR_print_errors_fp(stderr); \ - fprintf(stderr, "Error at %s:%d %s\n", __FILE__, __LINE__, #e); \ - return -1; \ - } \ - }) +#define T(e) \ + if (!(e)) { \ + ERR_print_errors_fp(stderr); \ + OpenSSLDie(__FILE__, __LINE__, #e); \ + } +#define TE(e) \ + if (!(e)) { \ + ERR_print_errors_fp(stderr); \ + fprintf(stderr, "Error at %s:%d %s\n", __FILE__, __LINE__, #e); \ + return -1; \ + } #define cRED "\033[1;31m" #define cDRED "\033[0;31m" @@ -54,8 +59,10 @@ else \ printf(cGREEN " Test passed" cNORM "\n");} +#ifdef __GNUC__ /* To test older APIs. */ -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif /* * Test keys from both GOST R 34.12-2015 and GOST R 34.13-2015, @@ -180,7 +187,7 @@ struct hash_testvec { const char *hmac; /* Expected output for HMAC tests. */ const char *key; /* MAC key.*/ int psize; /* Input (plaintext) size. */ - int outsize; /* Compare to EVP_MD_size() / EVP_MAC_size() if non-zero. */ + size_t outsize; /* Compare to EVP_MD_size() / EVP_MAC_size() if non-zero. */ int truncate; /* Truncated output (digest) size. */ int key_size; /* MAC key size. */ int block_size; /* Internal block size. */ @@ -633,11 +640,11 @@ static int do_mac(int iter, EVP_MAC *mac, const char *plaintext, const struct hash_testvec *t) { if (!iter) - printf("[MAC %d] ", t->outsize); + printf("[MAC %zu] ", t->outsize); size_t acpkm = (size_t)t->acpkm; size_t acpkm_t = (size_t)t->acpkm_t; - OSSL_PARAM params[] = { OSSL_PARAM_END, OSSL_PARAM_END, OSSL_PARAM_END }; + OSSL_PARAM params[] = { OSSL_PARAM_END, OSSL_PARAM_END, OSSL_PARAM_END, OSSL_PARAM_END }; OSSL_PARAM *p = params; if (acpkm) { *p++ = OSSL_PARAM_construct_size_t("key-mesh", &acpkm); @@ -650,8 +657,10 @@ static int do_mac(int iter, EVP_MAC *mac, const char *plaintext, if (t->outsize) T(EVP_MAC_CTX_get_mac_size(ctx) == t->outsize); size_t outsize; - if (t->truncate) + if (t->truncate) { outsize = t->truncate; + *p++ = OSSL_PARAM_construct_size_t("size", &outsize); + } else outsize = EVP_MAC_CTX_get_mac_size(ctx); @@ -687,7 +696,7 @@ static int do_digest(int iter, const EVP_MD *type, const char *plaintext, const struct hash_testvec *t) { if (!iter) - printf("[MD %d] ", t->outsize); + printf("[MD %zu] ", t->outsize); if (t->outsize) T(EVP_MD_size(type) == t->outsize); size_t outsize;