]> www.wagner.pp.ru Git - openssl-gost/engine.git/blobdiff - test_params.c
tcl_tests: ca.try: Ignore openssl crl exit status for 'corrupted CRL' test
[openssl-gost/engine.git] / test_params.c
index 8ce946d1caeef7753cd12d0a21f81f86d0c00358..114193346e63da2362a1b265ae74ac134e424b3b 100644 (file)
@@ -7,6 +7,11 @@
  * See https://www.openssl.org/source/license.html for details
  */
 
+#ifdef _MSC_VER
+# pragma warning(push, 3)
+# include <openssl/applink.c>
+# pragma warning(pop)
+#endif
 #include "e_gost_err.h"
 #include "gost_lcl.h"
 #include <openssl/evp.h>
 #include <openssl/safestack.h>
 #include <string.h>
 
-#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"
@@ -39,9 +44,9 @@
 #define cDBLUE "\033[0;34m"
 #define cNORM  "\033[m"
 #define TEST_ASSERT(e) {if ((test = (e))) \
-                printf(cRED "  Test FAILED\n" cNORM); \
+                printf(cRED "  Test FAILED" cNORM "\n"); \
             else \
-                printf(cGREEN "  Test passed\n" cNORM);}
+                printf(cGREEN "  Test passed" cNORM "\n");}
 
 struct test_param {
     unsigned int param;                /* NID of EC parameters */
@@ -873,9 +878,9 @@ static void hexdump(const void *ptr, size_t len)
 static void print_test_result(int err)
 {
     if (err == 1)
-       printf(cGREEN "correct\n" cNORM);
+       printf(cGREEN "correct" cNORM "\n");
     else if (err == 0)
-       printf(cRED "incorrect\n" cNORM);
+       printf(cRED "incorrect" cNORM "\n");
     else
        ERR_print_errors_fp(stderr);
 }
@@ -1050,7 +1055,7 @@ static int test_param(struct test_param *t)
     int hash_nid = 0;
     const char *sn = OBJ_nid2sn(t->param);
 
-    printf(cBLUE "Test %s (cp):\n" cNORM, sn);
+    printf(cBLUE "Test %s (cp):" cNORM "\n", sn);
 
     switch (t->len) {
        case 256 / 8:
@@ -1127,7 +1132,7 @@ static int test_param(struct test_param *t)
        T(mdtype = EVP_get_digestbynid(hash_nid));
        T(EVP_VerifyInit(md_ctx, mdtype));
        /* Feed byte-by-byte. */
-       int i;
+       size_t i;
        for (i = 0; i < t->data_len; i++)
            T(EVP_VerifyUpdate(md_ctx, &t->data[i], 1));
        err = EVP_VerifyFinal(md_ctx, sig, siglen, pkey);
@@ -1160,13 +1165,7 @@ int main(int argc, char **argv)
 {
     int ret = 0;
 
-    setenv("OPENSSL_ENGINES", ENGINE_DIR, 0);
     OPENSSL_add_all_algorithms_conf();
-    ERR_load_crypto_strings();
-    ENGINE *eng;
-    T(eng = ENGINE_by_id("gost"));
-    T(ENGINE_init(eng));
-    T(ENGINE_set_default(eng, ENGINE_METHOD_ALL));
 
     struct test_param **tpp;
     for (tpp = test_params; *tpp; tpp++)
@@ -1176,12 +1175,9 @@ int main(int argc, char **argv)
     for (tc = test_certs; tc->cert; tc++)
        ret |= test_cert(tc);
 
-    ENGINE_finish(eng);
-    ENGINE_free(eng);
-
     if (ret)
-       printf(cDRED "= Some tests FAILED!\n" cNORM);
+       printf(cDRED "= Some tests FAILED!" cNORM "\n");
     else
-       printf(cDGREEN "= All tests passed!\n" cNORM);
+       printf(cDGREEN "= All tests passed!" cNORM "\n");
     return ret;
 }