When _XOPEN_SOURCE is defined, make sure it's defined to 500. Required in
[openssl.git] / ssl / ssltest.c
index 085456c90ec126bc896a4a3d752abd9304e9d649..e47af50a4b7ac9c0c05dcffd457c14b497f81de9 100644 (file)
 #define USE_SOCKETS
 #include "e_os.h"
 
-#define _XOPEN_SOURCE 1                /* Or isascii won't be declared properly on
+#define _XOPEN_SOURCE 500      /* Or isascii won't be declared properly on
                                   VMS (at least with DECompHP C).  */
 #include <ctype.h>
 
@@ -720,36 +720,30 @@ bad:
 #ifndef OPENSSL_NO_ECDH
        if (!no_ecdhe)
                {
-               ecdh = EC_KEY_new();
-               if (ecdh != NULL)
-                       {
-                       if (named_curve)
-                               {
-                               int nid = OBJ_sn2nid(named_curve);
-
-                               if (nid == 0)
-                                       {
-                                       BIO_printf(bio_err, "unknown curve name (%s)\n", named_curve);
-                                       EC_KEY_free(ecdh);
-                                       goto end;
-                                       }
+               int nid;
 
-                               ecdh->group = EC_GROUP_new_by_curve_name(nid);
-                               if (ecdh->group == NULL)
-                                       {
-                                       BIO_printf(bio_err, "unable to create curve (%s)\n", named_curve);
-                                       EC_KEY_free(ecdh);
-                                       goto end;
-                                       }
+               if (named_curve != NULL)
+                       {
+                       nid = OBJ_sn2nid(named_curve);
+                       if (nid == 0)
+                       {
+                               BIO_printf(bio_err, "unknown curve name (%s)\n", named_curve);
+                               goto end;
                                }
-                       
-                       if (ecdh->group == NULL)
-                               ecdh->group=EC_GROUP_new_by_curve_name(NID_sect163r2);
+                       }
+               else
+                       nid = NID_sect163r2;
 
-                       SSL_CTX_set_tmp_ecdh(s_ctx, ecdh);
-                       SSL_CTX_set_options(s_ctx, SSL_OP_SINGLE_ECDH_USE);
-                       EC_KEY_free(ecdh);
+               ecdh = EC_KEY_new_by_curve_name(nid);
+               if (ecdh == NULL)
+                       {
+                       BIO_printf(bio_err, "unable to create curve\n");
+                       goto end;
                        }
+
+               SSL_CTX_set_tmp_ecdh(s_ctx, ecdh);
+               SSL_CTX_set_options(s_ctx, SSL_OP_SINGLE_ECDH_USE);
+               EC_KEY_free(ecdh);
                }
 #else
        (void)no_ecdhe;