]> www.wagner.pp.ru Git - openssl-gost/engine.git/blobdiff - test_tls.c
MSVC: Disable deprecated declarations (C4996) warning
[openssl-gost/engine.git] / test_tls.c
index b763bf4c51583816ee24dcd3fbed296fd61fb3bb..a6ac41eb264946069bdf2f8d91053b639b76d19e 100644 (file)
@@ -29,7 +29,6 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
-#include <err.h>
 
 /* For X509_NAME_add_entry_by_txt */
 #pragma GCC diagnostic ignored "-Wpointer-sign"
@@ -69,6 +68,17 @@ static const char *cipher_list;
 /* How much K to transfer between client and server. */
 #define KTRANSFER (1 * 1024)
 
+static void err(int eval, const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    vprintf(fmt, ap);
+    va_end(ap);
+    printf(": %s\n", strerror(errno));
+    exit(eval);
+}
+
 /*
  * Simple TLS Server code is based on
  * https://wiki.openssl.org/index.php/Simple_TLS_Server
@@ -274,7 +284,7 @@ int test(const char *algname, const char *paramset)
     ck = certgen(algname, paramset);
 
     int sockfd[2];
-    if (socketpair(AF_LOCAL, SOCK_STREAM, 0, sockfd) == -1)
+    if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockfd) == -1)
        err(1, "socketpair");
 
     setpgid(0, 0);
@@ -307,14 +317,14 @@ int test(const char *algname, const char *paramset)
     ret = (WIFEXITED(status) && WEXITSTATUS(status)) ||
        (WIFSIGNALED(status) && WTERMSIG(status));
     if (ret) {
-       warnx(cRED "%s child %s with %d %s" cNORM,
+       fprintf(stderr, cRED "%s child %s with %d %s" cNORM,
            exited_pid == server_pid? "server" : "client",
            WIFSIGNALED(status)? "killed" : "exited",
            WIFSIGNALED(status)? WTERMSIG(status) : WEXITSTATUS(status),
            WIFSIGNALED(status)? strsignal(WTERMSIG(status)) : "");
 
        /* If first child exited with error, kill other. */
-       warnx("terminating %s by force",
+       fprintf(stderr, "terminating %s by force",
            exited_pid == server_pid? "client" : "server");
        kill(exited_pid == server_pid? client_pid : server_pid, SIGTERM);
     }
@@ -322,7 +332,7 @@ int test(const char *algname, const char *paramset)
     exited_pid = wait(&status);
     /* Report error unless we killed it. */
     if (!ret && (!WIFEXITED(status) || WEXITSTATUS(status)))
-       warnx(cRED "%s child %s with %d %s" cNORM,
+       fprintf(stderr, cRED "%s child %s with %d %s" cNORM,
            exited_pid == server_pid? "server" : "client",
            WIFSIGNALED(status)? "killed" : "exited",
            WIFSIGNALED(status)? WTERMSIG(status) : WEXITSTATUS(status),
@@ -345,19 +355,13 @@ 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));
 
     char *p;
     if ((p = getenv("VERBOSE")))
        verbose = atoi(p);
 
-    /* ret |= test("rsa", NULL); */
+    ret |= test("rsa", NULL);
     cipher_list = "LEGACY-GOST2012-GOST8912-GOST8912";
     ret |= test("gost2012_256", "A");
     ret |= test("gost2012_256", "B");
@@ -367,9 +371,6 @@ int main(int argc, char **argv)
     ret |= test("gost2012_512", "B");
     ret |= test("gost2012_512", "C");
 
-    ENGINE_finish(eng);
-    ENGINE_free(eng);
-
     if (ret)
        printf(cDRED "= Some tests FAILED!\n" cNORM);
     else