]> www.wagner.pp.ru Git - openssl-gost/engine.git/blobdiff - test_sign.c
gost_prov: OPENSSL_free what is OPENSSL_zalloc'd
[openssl-gost/engine.git] / test_sign.c
index 983b63ef83cd11e05e4f06d4b353f63148f30d23..50b6643ef79286ad54a6b237d87ae68895210113 100644 (file)
@@ -7,7 +7,11 @@
  * See https://www.openssl.org/source/license.html for details
  */
 
-#include "e_gost_err.h"
+#ifdef _MSC_VER
+# pragma warning(push, 3)
+# include <openssl/applink.c>
+# pragma warning(pop)
+#endif
 #include "gost_lcl.h"
 #include <openssl/evp.h>
 #include <openssl/rand.h>
 #include <openssl/ec.h>
 #include <openssl/bn.h>
 #include <openssl/store.h>
+#include <openssl/engine.h>
 #include <string.h>
 #include <stdlib.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"
@@ -47,7 +52,7 @@
 
 struct test_sign {
     const char *name;
-    unsigned int nid;
+    int nid;
     size_t bits;
     const char *paramset;
 };
@@ -177,7 +182,7 @@ static int test_sign(struct test_sign *t)
     fflush(stdout);
     pkey = NULL;
     OSSL_STORE_CTX *cts;
-    T(cts = OSSL_STORE_attach(bp, "file", NULL, NULL, NULL, NULL, NULL, NULL));
+    T(cts = OSSL_STORE_attach(bp, "file", NULL, NULL, NULL, NULL, NULL, NULL, NULL));
     for (;;) {
        OSSL_STORE_INFO *info = OSSL_STORE_load(cts);
        if (!info) {
@@ -239,7 +244,7 @@ static int test_sign(struct test_sign *t)
     const EC_GROUP *group = EC_KEY_get0_group(ec);
     int curve_name = EC_GROUP_get_curve_name(group);
     err = curve_name == t->nid;
-    printf("\tcurve_name (%u):\t", t->nid);
+    printf("\tcurve_name (%d):\t", t->nid);
     print_test_tf(err, curve_name, "match", "mismatch");
     ret |= !err;
 
@@ -318,21 +323,12 @@ 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_sign *sp;
     for (sp = test_signs; sp->name; sp++)
        ret |= test_sign(sp);
 
-    ENGINE_finish(eng);
-    ENGINE_free(eng);
-
     if (ret)
        printf(cDRED "= Some tests FAILED!" cNORM "\n");
     else