]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Modernized the test applications that now use the gnutls_priority_set_direct().
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Wed, 9 Feb 2011 22:09:27 +0000 (23:09 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Wed, 9 Feb 2011 22:09:27 +0000 (23:09 +0100)
tests/anonself.c
tests/dhepskself.c
tests/mini-eagain.c
tests/mini.c
tests/openpgp-auth.c
tests/pskself.c
tests/resume.c

index f110e18c71dbfdc1722b039fb9ef0ce1a06f718e..134b88babb11281a9ce40121c7ea9652dc3c524d 100644 (file)
@@ -62,7 +62,6 @@ client (void)
   char buffer[MAX_BUF + 1];
   gnutls_anon_client_credentials_t anoncred;
   /* Need to enable anonymous KX specifically. */
-  const int kx_prio[] = { GNUTLS_KX_ANON_DH, 0 };
 
   gnutls_global_init ();
 
@@ -77,8 +76,7 @@ client (void)
   gnutls_init (&session, GNUTLS_CLIENT);
 
   /* Use default priorities */
-  gnutls_set_default_priority (session);
-  gnutls_kx_set_priority (session, kx_prio);
+  gnutls_priority_set_direct (session, "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
 
   /* put the anonymous credentials to the current session
    */
@@ -164,15 +162,13 @@ static gnutls_session_t
 initialize_tls_session (void)
 {
   gnutls_session_t session;
-  const int kx_prio[] = { GNUTLS_KX_ANON_DH, 0 };
 
   gnutls_init (&session, GNUTLS_SERVER);
 
   /* avoid calling all the priority functions, since the defaults
    * are adequate.
    */
-  gnutls_set_default_priority (session);
-  gnutls_kx_set_priority (session, kx_prio);
+  gnutls_priority_set_direct (session, "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
 
   gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
 
index 00bf67906278c33447947d487e6e72cfb6deb679..931962488a6149c145e3a1798d0a695ed35f6dc9 100644 (file)
@@ -66,8 +66,8 @@ client (void)
   gnutls_global_init ();
 
   gnutls_global_set_log_function (tls_log_func);
-//  if (debug)
-//    gnutls_global_set_log_level (99);
+  if (debug)
+    gnutls_global_set_log_level (5);
 
   gnutls_psk_allocate_client_credentials (&pskcred);
   gnutls_psk_set_client_credentials (pskcred, "test", &key,
@@ -78,7 +78,7 @@ client (void)
   gnutls_init (&session, GNUTLS_CLIENT);
 
   /* Use default priorities */
-  gnutls_set_default_priority (session);
+  gnutls_priority_set_direct (session, "NORMAL:+DHE-PSK", NULL);
 
   /* put the anonymous credentials to the current session
    */
@@ -162,7 +162,7 @@ initialize_tls_session (void)
   /* avoid calling all the priority functions, since the defaults
    * are adequate.
    */
-  gnutls_set_default_priority (session);
+  gnutls_priority_set_direct(session, "NORMAL:+DHE-PSK", NULL);
 
   gnutls_credentials_set (session, GNUTLS_CRD_PSK, server_pskcred);
 
index 92c912aee1b6264e82bd2b46ec6ae08e53893f85..9bb7e2c321385054cd47e9faee7649ea772ac80b 100644 (file)
@@ -161,7 +161,6 @@ doit (void)
   gnutls_session_t client;
   int cret = GNUTLS_E_AGAIN;
   /* Need to enable anonymous KX specifically. */
-  const int kx_prio[] = { GNUTLS_KX_ANON_DH, 0 };
   char buffer[MAX_BUF + 1];
   ssize_t ns;
   int ret, transferred = 0, msglen;
@@ -178,8 +177,7 @@ doit (void)
   gnutls_dh_params_import_pkcs3 (dh_params, &p3, GNUTLS_X509_FMT_PEM);
   gnutls_anon_set_server_dh_params (s_anoncred, dh_params);
   gnutls_init (&server, GNUTLS_SERVER);
-  gnutls_set_default_priority (server);
-  gnutls_kx_set_priority (server, kx_prio);
+  gnutls_priority_set_direct (server, "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
   gnutls_credentials_set (server, GNUTLS_CRD_ANON, s_anoncred);
   gnutls_dh_set_prime_bits (server, 1024);
   gnutls_transport_set_push_function (server, server_push);
@@ -188,8 +186,7 @@ doit (void)
   /* Init client */
   gnutls_anon_allocate_client_credentials (&c_anoncred);
   gnutls_init (&client, GNUTLS_CLIENT);
-  gnutls_set_default_priority (client);
-  gnutls_kx_set_priority (client, kx_prio);
+  gnutls_priority_set_direct (client, "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
   gnutls_credentials_set (client, GNUTLS_CRD_ANON, c_anoncred);
   gnutls_transport_set_push_function (client, client_push);
   gnutls_transport_set_pull_function (client, client_pull);
index 30678ecb5ae7e9fea2ebfd82f7269ad321d23b84..21f76878374487c30b6f884c0034fc7d9494293b 100644 (file)
@@ -153,7 +153,6 @@ doit (void)
   gnutls_session_t client;
   int n, cret = GNUTLS_E_AGAIN;
   /* Need to enable anonymous KX specifically. */
-  const int kx_prio[] = { GNUTLS_KX_ANON_DH, 0 };
   char buffer[MAX_BUF + 1];
   ssize_t ns;
   int ret;
@@ -170,8 +169,7 @@ doit (void)
   gnutls_dh_params_import_pkcs3 (dh_params, &p3, GNUTLS_X509_FMT_PEM);
   gnutls_anon_set_server_dh_params (s_anoncred, dh_params);
   gnutls_init (&server, GNUTLS_SERVER);
-  gnutls_set_default_priority (server);
-  gnutls_kx_set_priority (server, kx_prio);
+  gnutls_priority_set_direct (server, "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
   gnutls_credentials_set (server, GNUTLS_CRD_ANON, s_anoncred);
   gnutls_dh_set_prime_bits (server, 1024);
   gnutls_transport_set_push_function (server, server_push);
@@ -180,8 +178,7 @@ doit (void)
   /* Init client */
   gnutls_anon_allocate_client_credentials (&c_anoncred);
   gnutls_init (&client, GNUTLS_CLIENT);
-  gnutls_set_default_priority (client);
-  gnutls_kx_set_priority (client, kx_prio);
+  gnutls_priority_set_direct (client, "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
   gnutls_credentials_set (client, GNUTLS_CRD_ANON, c_anoncred);
   gnutls_transport_set_push_function (client, client_push);
   gnutls_transport_set_pull_function (client, client_pull);
index 77a1bfd34019710fdd279ce05703cefdbd9298ba..2622f7749db0dfe950d45fdbba7aed642cc67e72 100644 (file)
@@ -50,26 +50,6 @@ static const char *key_id = NULL
 
 static const char rsa_params_file[] = "../guile/tests/rsa-parameters.pem";
 
-static const int protocols[] = { GNUTLS_TLS1_0, 0 };
-static const int cert_types[] = { GNUTLS_CRT_OPENPGP, 0 };
-
-static const int ciphers[] = {
-  GNUTLS_CIPHER_NULL, GNUTLS_CIPHER_ARCFOUR,
-  GNUTLS_CIPHER_AES_128_CBC, GNUTLS_CIPHER_AES_256_CBC,
-  0
-};
-
-static const int kx[] = {
-  GNUTLS_KX_RSA, GNUTLS_KX_RSA_EXPORT,
-  GNUTLS_KX_DHE_RSA, GNUTLS_KX_DHE_DSS,
-  0
-};
-
-static const int macs[] = {
-  GNUTLS_MAC_SHA1, GNUTLS_MAC_RMD160, GNUTLS_MAC_MD5,
-  0
-};
-
 static void
 log_message (int level, const char *message)
 {
@@ -133,7 +113,7 @@ doit ()
       if (err != 0)
         fail ("client session %d\n", err);
 
-      gnutls_set_default_priority (session);
+      gnutls_priority_set_direct (session, "NORMAL:+CTYPE-OPENPGP:-CTYPE-X.509", NULL);
       gnutls_transport_set_ptr (session,
                                 (gnutls_transport_ptr_t) (intptr_t)
                                 sockets[0]);
@@ -154,16 +134,11 @@ doit ()
       if (err != 0)
         fail ("client credential_set %d\n", err);
 
-      gnutls_protocol_set_priority (session, protocols);
-      gnutls_certificate_type_set_priority (session, cert_types);
-      gnutls_cipher_set_priority (session, ciphers);
-      gnutls_kx_set_priority (session, kx);
-      gnutls_mac_set_priority (session, macs);
       gnutls_dh_set_prime_bits (session, 1024);
 
       err = gnutls_handshake (session);
       if (err != 0)
-        fail ("client handshake %d\n", err);
+        fail ("client handshake %s (%d) \n", gnutls_strerror(err), err);
       else if (debug)
         printf ("client handshake successful\n");
 
@@ -201,7 +176,7 @@ doit ()
       if (err != 0)
         fail ("server session %d\n", err);
 
-      gnutls_set_default_priority (session);
+      gnutls_priority_set_direct (session, "NORMAL:+CTYPE-OPENPGP:-CTYPE-X.509", NULL);
       gnutls_transport_set_ptr (session,
                                 (gnutls_transport_ptr_t) (intptr_t)
                                 sockets[1]);
@@ -250,16 +225,11 @@ doit ()
       if (err != 0)
         fail ("server credential_set %d\n", err);
 
-      gnutls_protocol_set_priority (session, protocols);
-      gnutls_certificate_type_set_priority (session, cert_types);
-      gnutls_cipher_set_priority (session, ciphers);
-      gnutls_kx_set_priority (session, kx);
-      gnutls_mac_set_priority (session, macs);
       gnutls_certificate_server_set_request (session, GNUTLS_CERT_REQUIRE);
 
       err = gnutls_handshake (session);
       if (err != 0)
-        fail ("server handshake %d\n", err);
+        fail ("server handshake %s (%d) \n", gnutls_strerror(err), err);
 
       received = gnutls_record_recv (session, greetings, sizeof (greetings));
       if (received != sizeof (message)
@@ -269,7 +239,7 @@ doit ()
 
       err = gnutls_bye (session, GNUTLS_SHUT_RDWR);
       if (err != 0)
-        fail ("server bye %d\n", err);
+        fail ("server bye %s (%d) \n", gnutls_strerror(err), err);
 
       if (debug)
         printf ("server done\n");
index 36377c23b2873053200bec7532b5b483909966f6..09001fff4acfad58dcfb0d909e52045be5c7f87e 100644 (file)
@@ -55,7 +55,6 @@ client (void)
   char buffer[MAX_BUF + 1];
   gnutls_psk_client_credentials_t pskcred;
   /* Need to enable anonymous KX specifically. */
-  const int kx_prio[] = { GNUTLS_KX_PSK, 0 };
   const gnutls_datum_t key = { (char *) "DEADBEEF", 8 };
 
   gnutls_global_init ();
@@ -69,8 +68,7 @@ client (void)
   gnutls_init (&session, GNUTLS_CLIENT);
 
   /* Use default priorities */
-  gnutls_set_default_priority (session);
-  gnutls_kx_set_priority (session, kx_prio);
+  gnutls_priority_set_direct (session, "NORMAL:+PSK", NULL);
 
   /* put the anonymous credentials to the current session
    */
@@ -150,15 +148,13 @@ static gnutls_session_t
 initialize_tls_session (void)
 {
   gnutls_session_t session;
-  const int kx_prio[] = { GNUTLS_KX_PSK, 0 };
 
   gnutls_init (&session, GNUTLS_SERVER);
 
   /* avoid calling all the priority functions, since the defaults
    * are adequate.
    */
-  gnutls_set_default_priority (session);
-  gnutls_kx_set_priority (session, kx_prio);
+  gnutls_priority_set_direct (session, "NORMAL:+PSK", NULL);
 
   gnutls_credentials_set (session, GNUTLS_CRD_PSK, server_pskcred);
 
index 835d432579f60e1d19ef2169f3e3815678c9d400..f016c9a50c6325b3f54a2bbcfe79dd03e9fb476d 100644 (file)
@@ -91,7 +91,6 @@ client (struct params_res *params)
   char buffer[MAX_BUF + 1];
   gnutls_anon_client_credentials_t anoncred;
   /* Need to enable anonymous KX specifically. */
-  const int kx_prio[] = { GNUTLS_KX_ANON_DH, 0 };
 
   /* variables used in session resuming
    */
@@ -118,8 +117,7 @@ client (struct params_res *params)
       gnutls_init (&session, GNUTLS_CLIENT);
 
       /* Use default priorities */
-      gnutls_set_default_priority (session);
-      gnutls_kx_set_priority (session, kx_prio);
+  gnutls_priority_set_direct (session, "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
 
       /* put the anonymous credentials to the current session
        */
@@ -243,15 +241,13 @@ static gnutls_session_t
 initialize_tls_session (struct params_res *params)
 {
   gnutls_session_t session;
-  const int kx_prio[] = { GNUTLS_KX_ANON_DH, 0 };
 
   gnutls_init (&session, GNUTLS_SERVER);
 
   /* avoid calling all the priority functions, since the defaults
    * are adequate.
    */
-  gnutls_set_default_priority (session);
-  gnutls_kx_set_priority (session, kx_prio);
+  gnutls_priority_set_direct (session, "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
 
   gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);