]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Several cleanups.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 6 Dec 2001 10:37:23 +0000 (10:37 +0000)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 6 Dec 2001 10:37:23 +0000 (10:37 +0000)
22 files changed:
NEWS
doc/tex/ex1.tex
doc/tex/ex2.tex
doc/tex/ex3.tex
doc/tex/serv1.tex
doc/tex/srp1.tex
lib/auth_rsa.c
lib/auth_x509.c
lib/auth_x509.h
lib/gnutls.h.in
lib/gnutls_algorithms.c
lib/gnutls_cert.c
lib/gnutls_cert.h
lib/gnutls_errors_int.h
lib/gnutls_global.c
lib/gnutls_int.h
lib/gnutls_priority.c
lib/gnutls_priority.h
lib/gnutls_record.c
lib/gnutls_record.h
src/cli.c
src/serv.c

diff --git a/NEWS b/NEWS
index 817010628a531cafaa57ae5c0e5bdb855a7764e3..de4cbc1661fc9ab72c3ed9cea6e323f237e2d0a9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,10 +4,10 @@ Version ?.?.?
   gnutls_set_transport_ptr().
 - introduced gnutls_x509pki_get_peer_certificate_list(). This function returns
   a list containing peer's certificate and issuers DER encoded.
-- Added callback to select the server certificate
 - Updated X.509 certificate handling API
+- Added callback to select the server certificate
+- More consistent function naming (changes in several function names)
 - Buffer overflow checking in ASN.1 structures parser
-- More consistent function naming (changes several function names)
 
 Version 0.2.11 (16/11/2001)
 - Changed the meaning of GNUTLS_E_REHANDSHAKE value. If this value
index 87571149191d5bad0ea6d9f976f13ece30d58fe0..3ac9d3ebf1746b25daeff2ee9161af70fcfe2a8d 100644 (file)
@@ -60,11 +60,11 @@ int main()
          exit(1);
       }
       gnutls_init(&state, GNUTLS_CLIENT);
-      gnutls_set_protocol_priority(state, GNUTLS_TLS1, GNUTLS_SSL3, 0);
-      gnutls_set_cipher_priority(state, GNUTLS_3DES_CBC, GNUTLS_ARCFOUR, 0);
-      gnutls_set_compression_priority(state, GNUTLS_NULL_COMPRESSION, 0);
-      gnutls_set_kx_priority(state, GNUTLS_KX_RSA, 0);
-      gnutls_set_mac_priority(state, GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0);
+      gnutls_protocol_set_priority(state, GNUTLS_TLS1, GNUTLS_SSL3, 0);
+      gnutls_cipher_set_priority(state, GNUTLS_3DES_CBC, GNUTLS_ARCFOUR, 0);
+      gnutls_compression_set_priority(state, GNUTLS_NULL_COMPRESSION, 0);
+      gnutls_kx_set_priority(state, GNUTLS_KX_RSA, 0);
+      gnutls_mac_set_priority(state, GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0);
 
 
       gnutls_set_cred(state, GNUTLS_X509PKI, xcred);
index d68d49f758ad11f62399ae213fc3cdcb4114f9ef..e136e0b19c0425ae7e95e81ae8bfe85df5149a1d 100644 (file)
@@ -58,24 +58,24 @@ int main()
 
    /* allow both SSL3 and TLS1
     */
-   gnutls_set_protocol_priority(state, GNUTLS_TLS1, GNUTLS_SSL3, 0);
+   gnutls_protocol_set_priority(state, GNUTLS_TLS1, GNUTLS_SSL3, 0);
 
    /* allow only ARCFOUR and 3DES ciphers
     * (3DES has the highest priority)
     */
-   gnutls_set_cipher_priority(state, GNUTLS_3DES_CBC, GNUTLS_ARCFOUR, 0);
+   gnutls_cipher_set_priority(state, GNUTLS_3DES_CBC, GNUTLS_ARCFOUR, 0);
 
    /* only allow null compression
     */
-   gnutls_set_compression_priority(state, GNUTLS_NULL_COMPRESSION, 0);
+   gnutls_compression_set_priority(state, GNUTLS_NULL_COMPRESSION, 0);
 
    /* use GNUTLS_KX_RSA
     */
-   gnutls_set_kx_priority(state, GNUTLS_KX_RSA, 0);
+   gnutls_kx_set_priority(state, GNUTLS_KX_RSA, 0);
 
    /* allow the usage of both SHA and MD5
     */
-   gnutls_set_mac_priority(state, GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0);
+   gnutls_mac_set_priority(state, GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0);
 
 
    /* put the x509 credentials to the current state
@@ -83,7 +83,7 @@ int main()
    gnutls_set_cred(state, GNUTLS_X509PKI, xcred);
 
 
-   gnutls_set_transport_ptr( state, sd);
+   gnutls_transport_set_ptr( state, sd);
    /* Perform the TLS handshake
     */
    ret = gnutls_handshake( state);
index 939fe55f5f6214fa35879c494c3617435fa3dc20..01a3caf008778515469c099e6dbcd883c3345249 100644 (file)
@@ -15,7 +15,7 @@ int print_info(GNUTLS_STATE state)
 
    /* print the key exchange's algorithm name
     */
-   tmp = gnutls_kx_get_name(gnutls_get_current_kx(state));
+   tmp = gnutls_kx_get_name( gnutls_kx_get_algo( state));
    printf("- Key Exchange: %s\n", tmp);
 
    /* in case of X509 PKI
@@ -27,7 +27,7 @@ int print_info(GNUTLS_STATE state)
       CertificateStatus status;
       KXAlgorithm kx;
 
-      kx = gnutls_get_current_kx(state);
+      kx = gnutls_kx_get_algo(state);
 
       /* Check if we have been using ephemeral Diffie Hellman.
        */
@@ -72,16 +72,16 @@ int print_info(GNUTLS_STATE state)
       }
    }
 
-   tmp = gnutls_version_get_name(gnutls_get_current_version( state));
+   tmp = gnutls_protocol_get_name( gnutls_protocol_get_version( state));
    printf("- Version: %s\n", tmp);
 
-   tmp = gnutls_compression_get_name(gnutls_get_current_compression_method( state));
+   tmp = gnutls_compression_get_name( gnutls_compression_get_algo( state));
    printf("- Compression: %s\n", tmp);
 
-   tmp = gnutls_cipher_get_name(gnutls_get_current_cipher( state));
+   tmp = gnutls_cipher_get_name( gnutls_cipher_get_algo( state));
    printf("- Cipher: %s\n", tmp);
 
-   tmp = gnutls_mac_get_name(gnutls_get_current_mac_algorithm( state));
+   tmp = gnutls_mac_get_name(gnutls_mac_get_algo( state));
    printf("- MAC: %s\n", tmp);
 
    return 0;
index fc20046606b1a26c2ae783d5e8bd9a50034eb001..8a36d7a159916526796fa310f4b2c3f8d9af5a46 100644 (file)
@@ -45,11 +45,11 @@ GNUTLS_STATE initialize_state()
    if ((ret = gnutls_db_set_name(state, "gnutls-rsm.db")) < 0)
       fprintf(stderr, "*** DB error (%d)\n\n", ret);
 
-   gnutls_set_cipher_priority(state, GNUTLS_RIJNDAEL_CBC, GNUTLS_3DES_CBC, 0);
-   gnutls_set_compression_priority(state, GNUTLS_ZLIB, GNUTLS_NULL_COMPRESSION, 0);
-   gnutls_set_kx_priority(state, GNUTLS_KX_RSA, GNUTLS_KX_SRP, 0);
-   gnutls_set_protocol_priority(state, GNUTLS_TLS1, GNUTLS_SSL3, 0);
-   gnutls_set_mac_priority(state, GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0);
+   gnutls_cipher_set_priority(state, GNUTLS_RIJNDAEL_CBC, GNUTLS_3DES_CBC, 0);
+   gnutls_compression_set_priority(state, GNUTLS_ZLIB, GNUTLS_NULL_COMPRESSION, 0);
+   gnutls_kx_set_priority(state, GNUTLS_KX_RSA, GNUTLS_KX_SRP, 0);
+   gnutls_protocol_set_priority(state, GNUTLS_TLS1, GNUTLS_SSL3, 0);
+   gnutls_mac_set_priority(state, GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0);
 
    gnutls_set_cred(state, GNUTLS_SRP, srp_cred);
    gnutls_set_cred(state, GNUTLS_X509PKI, x509_cred);
@@ -68,7 +68,7 @@ void print_info(GNUTLS_STATE state)
    int sesid_size, i;
 
    /* print session_id specific data */
-   gnutls_get_session_get_id(state, sesid, &sesid_size);
+   gnutls_session_get_id(state, sesid, &sesid_size);
    printf("\n- Session ID: ");
    for (i = 0; i < sesid_size; i++)
       printf("%.2X", sesid[i]);
@@ -81,21 +81,21 @@ void print_info(GNUTLS_STATE state)
    }
 
    /* print state information */
-   tmp = gnutls_version_get_name(gnutls_get_current_version(state));
+   tmp = gnutls_protocol_get_name(gnutls_protocol_get_version(state));
    printf("- Version: %s\n", tmp);
 
-   tmp = gnutls_kx_get_name(gnutls_get_current_kx(state));
+   tmp = gnutls_kx_get_name(gnutls_kx_get_algo(state));
    printf("- Key Exchange: %s\n", tmp);
 
    tmp =
        gnutls_compression_get_name
-       (gnutls_get_current_compression_method(state));
+       (gnutls_compression_get_algo(state));
    printf("- Compression: %s\n", tmp);
 
-   tmp = gnutls_cipher_get_name(gnutls_get_current_cipher(state));
+   tmp = gnutls_cipher_get_name(gnutls_cipher_get_algo(state));
    printf("- Cipher: %s\n", tmp);
 
-   tmp = gnutls_mac_get_name(gnutls_get_current_mac_algorithm(state));
+   tmp = gnutls_mac_get_name(gnutls_mac_get_algo(state));
    printf("- MAC: %s\n", tmp);
 
 }
@@ -172,8 +172,8 @@ int main()
              inet_ntop(AF_INET, &sa_cli.sin_addr, topbuf,
                        sizeof(topbuf)), ntohs(sa_cli.sin_port));
 
-
-      ret = gnutls_handshake(sd, state);
+      gnutls_transport_set_ptr( state, sd);
+      ret = gnutls_handshake( state);
       if (ret < 0) {
          close(sd);
          gnutls_deinit(state);
@@ -188,7 +188,7 @@ int main()
       i = 0;
       for (;;) {
          bzero(buffer, MAX_BUF + 1);
-         ret = gnutls_read(sd, state, buffer, MAX_BUF);
+         ret = gnutls_read( state, buffer, MAX_BUF);
 
          if (gnutls_is_fatal_error(ret) == 1 || ret == 0) {
             if (ret == 0) {
@@ -206,7 +206,7 @@ int main()
          if (ret > 0) {
             /* echo data back to the client
              */
-            gnutls_write(sd, state, buffer,
+            gnutls_write( state, buffer,
                          strlen(buffer));
          }
          if (ret == GNUTLS_E_WARNING_ALERT_RECEIVED || ret == GNUTLS_E_FATAL_ALERT_RECEIVED) {
@@ -215,7 +215,7 @@ int main()
          }
       }
       printf("\n");
-      gnutls_bye(sd, state, 1); /* do not wait for
+      gnutls_bye( state, 1); /* do not wait for
                                  * the peer to close the connection.
                                  */
 
index 365581652a458786a31a361c31d19bc2cea89906..cbbcf5d779f2279ebe06381bcd145c1b1174abd0 100644 (file)
@@ -29,11 +29,11 @@ int main()
       fprintf(stderr, "global state initialization error\n");
       exit(1);
    }
-   if (gnutls_allocate_srp_client_sc(&xcred) < 0) {
+   if (gnutls_srp_allocate_client_sc(&xcred) < 0) {
       fprintf(stderr, "memory error\n");
       exit(1);
    }
-   gnutls_set_srp_client_cred(xcred, USERNAME, PASSWORD);
+   gnutls_srp_set_client_cred(xcred, USERNAME, PASSWORD);
 
    /* connects to server 
     */
@@ -55,31 +55,31 @@ int main()
 
    /* allow both SSL3 and TLS1
     */
-   gnutls_set_protocol_priority(state, GNUTLS_TLS1, GNUTLS_SSL3, 0);
+   gnutls_protocol_set_priority(state, GNUTLS_TLS1, GNUTLS_SSL3, 0);
 
    /* allow only ARCFOUR and 3DES ciphers
     * (3DES has the highest priority)
     */
-   gnutls_set_cipher_priority(state, GNUTLS_3DES_CBC, GNUTLS_ARCFOUR, 0);
+   gnutls_cipher_set_priority(state, GNUTLS_3DES_CBC, GNUTLS_ARCFOUR, 0);
 
    /* only allow null compression
     */
-   gnutls_set_compression_priority(state, GNUTLS_NULL_COMPRESSION, 0);
+   gnutls_compression_set_priority(state, GNUTLS_NULL_COMPRESSION, 0);
 
    /* use GNUTLS_KX_RSA
     */
-   gnutls_set_kx_priority(state, GNUTLS_KX_SRP, 0);
+   gnutls_kx_set_priority(state, GNUTLS_KX_SRP, 0);
 
    /* allow the usage of both SHA and MD5
     */
-   gnutls_set_mac_priority(state, GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0);
+   gnutls_mac_set_priority(state, GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0);
 
 
    /* put the SRP credentials to the current state
     */
    gnutls_set_cred(state, GNUTLS_SRP, xcred);
 
-   gnutls_set_transport_ptr( state, sd);
+   gnutls_transport_set_ptr( state, sd);
 
    /* Perform the TLS handshake
     */
@@ -128,7 +128,7 @@ int main()
 
    gnutls_deinit(state);
 
-   gnutls_free_srp_client_sc(xcred);
+   gnutls_srp_free_client_sc(xcred);
 
    gnutls_global_deinit();
 
index 1073fe7c9bed5971fd0cb1900b93d397e50b1310..f34b96a4fa6f458a3e22dedc7573db8415ab5d0b 100644 (file)
@@ -80,7 +80,7 @@ int proc_rsa_client_kx(GNUTLS_STATE state, opaque * data, int data_size)
        gnutls_datum ciphertext;
        int ret, dsize;
 
-       if ( gnutls_get_current_version(state) == GNUTLS_SSL3) {
+       if ( gnutls_protocol_get_version(state) == GNUTLS_SSL3) {
                /* SSL 3.0 */
                ciphertext.data = data;
                ciphertext.size = data_size;
index f7ce5acc1527950a22820adcd47c9a9589f08233..47039e911ca05a066bec6c156c73ac0010db9b6d 100644 (file)
@@ -602,7 +602,7 @@ int _gnutls_proc_x509_server_certificate(GNUTLS_STATE state, opaque * data,
 
        if ((ret =
             _gnutls_check_x509pki_key_usage(&peer_certificate_list[0],
-                                            gnutls_get_current_kx(state)))
+                                            gnutls_kx_get_algo(state)))
            < 0) {
                gnutls_assert();
                CLEAR_CERTS;
@@ -1281,3 +1281,64 @@ int gnutls_x509pki_get_peer_certificate_status(GNUTLS_STATE state)
 
        return verify;
 }
+
+/* finds the most appropriate certificate in the cert list.
+ * The 'appropriate' is defined by the user.
+ * FIXME: provide user callback.
+ */
+const gnutls_cert *_gnutls_server_find_cert(GNUTLS_STATE state,
+                                           gnutls_cert ** cert_list,
+                                           int cert_list_length)
+{
+       int i;
+
+       i = _gnutls_server_find_cert_list_index(state, cert_list,
+                                        cert_list_length);
+       if (i < 0)
+               return NULL;
+
+       return &cert_list[i][0];
+}
+
+/* finds the most appropriate certificate in the cert list.
+ * The 'appropriate' is defined by the user.
+ */
+int _gnutls_server_find_cert_list_index(GNUTLS_STATE state,
+                                       gnutls_cert ** cert_list,
+                                       int cert_list_length)
+{
+       int i, index = -1;
+       const X509PKI_CREDENTIALS cred;
+
+       cred = _gnutls_get_cred(state->gnutls_key, GNUTLS_X509PKI, NULL);
+       if (cred == NULL) {
+               gnutls_assert();
+               return GNUTLS_E_INSUFICIENT_CRED;
+       }
+
+       if (cred->ncerts > 0)
+               index = 0;      /* default is use the first certificate */
+
+       if (state->gnutls_internals.client_cert_callback != NULL && cred->ncerts > 0) { /* use the callback to get certificate */
+               gnutls_datum *my_certs = NULL;
+
+               my_certs =
+                   gnutls_malloc(cred->ncerts * sizeof(gnutls_datum));
+               if (my_certs == NULL)
+                       goto clear;
+
+               /* put our certificate's issuer and dn into cdn, idn
+                */
+               for (i = 0; i < cred->ncerts; i++) {
+                       my_certs[i] = cred->cert_list[i][0].raw;
+               }
+               index =
+                   state->gnutls_internals.server_cert_callback(my_certs,
+                                                                cred->ncerts);
+
+             clear:
+               gnutls_free(my_certs);
+       }
+
+       return index;
+}
index 3d85d4f34ad6a497a550de04b7ecd1cf442bc684..422f5ff35b908e26291269a66be35fb78da96267 100644 (file)
@@ -63,6 +63,8 @@ int _gnutls_proc_x509_client_cert_vrfy(GNUTLS_STATE, opaque *, int);
 int _gnutls_proc_x509_server_certificate(GNUTLS_STATE, opaque *, int);
 int _gnutls_find_apr_cert( GNUTLS_STATE state, gnutls_cert** apr_cert_list, int *apr_cert_list_length, gnutls_private_key** apr_pkey);
 int _gnutls_find_dn( gnutls_datum* odn, gnutls_cert* cert);
+const gnutls_cert* _gnutls_server_find_cert( struct GNUTLS_STATE_INT*, gnutls_cert** cert_list, int cert_list_length);
+int _gnutls_server_find_cert_list_index( struct GNUTLS_STATE_INT*, gnutls_cert ** cert_list, int cert_list_length);
 
 #define _gnutls_proc_x509_client_certificate _gnutls_proc_x509_server_certificate
 
index b3998bc868c7a1c9d5e87e331a07bc2d93507eaa..e6f4f488f085781a65c4ca721b60b639bd7d6813 100644 (file)
@@ -94,14 +94,14 @@ int gnutls_rehandshake( GNUTLS_STATE state);
 
 
 AlertDescription gnutls_get_last_alert( GNUTLS_STATE state);
-int gnutls_send_alert(GNUTLS_SOCKET_PTR, GNUTLS_STATE, AlertLevel, AlertDescription);
-int gnutls_send_appropriate_alert(  GNUTLS_STATE state, int err);
+int             gnutls_send_alert(GNUTLS_SOCKET_PTR, GNUTLS_STATE, AlertLevel, AlertDescription);
+int             gnutls_send_appropriate_alert(  GNUTLS_STATE state, int err);
 
 /* get information on the current state */
-BulkCipherAlgorithm gnutls_get_current_cipher( GNUTLS_STATE state);
-KXAlgorithm gnutls_get_current_kx( GNUTLS_STATE state);
-MACAlgorithm gnutls_get_current_mac_algorithm( GNUTLS_STATE state);
-CompressionMethod gnutls_get_current_compression_method( GNUTLS_STATE state);
+BulkCipherAlgorithm gnutls_cipher_get_algo( GNUTLS_STATE state);
+KXAlgorithm        gnutls_kx_get_algo( GNUTLS_STATE state);
+MACAlgorithm       gnutls_mac_get_algo( GNUTLS_STATE state);
+CompressionMethod   gnutls_compression_get_algo( GNUTLS_STATE state);
 
 /* the name of the specified algorithms */
 const char *gnutls_cipher_get_name( BulkCipherAlgorithm);
@@ -119,16 +119,16 @@ ssize_t gnutls_write( GNUTLS_STATE state, void *data, size_t sizeofdata);
 ssize_t gnutls_read( GNUTLS_STATE state, void *data, size_t sizeofdata);
 
 /* functions to set priority of cipher suites */
-int gnutls_set_cipher_priority( GNUTLS_STATE state, GNUTLS_LIST);
-int gnutls_set_mac_priority( GNUTLS_STATE state, GNUTLS_LIST);
-int gnutls_set_compression_priority( GNUTLS_STATE state, GNUTLS_LIST);
-int gnutls_set_kx_priority( GNUTLS_STATE state, GNUTLS_LIST);
-int gnutls_set_protocol_priority( GNUTLS_STATE state, GNUTLS_LIST);
+int gnutls_cipher_set_priority( GNUTLS_STATE state, GNUTLS_LIST);
+int gnutls_mac_set_priority( GNUTLS_STATE state, GNUTLS_LIST);
+int gnutls_compression_set_priority( GNUTLS_STATE state, GNUTLS_LIST);
+int gnutls_kx_set_priority( GNUTLS_STATE state, GNUTLS_LIST);
+int gnutls_protocol_set_priority( GNUTLS_STATE state, GNUTLS_LIST);
 
 /* set our version - 0 for TLS 1.0 and 1 for SSL3 */
-GNUTLS_Version gnutls_get_current_version(GNUTLS_STATE state);
+GNUTLS_Version gnutls_protocol_get_version(GNUTLS_STATE state);
 
-const char *gnutls_version_get_name(GNUTLS_Version version);
+const char *gnutls_protocol_get_name(GNUTLS_Version version);
 
 
 /* get/set session */
@@ -231,16 +231,14 @@ void gnutls_global_deinit();
 int gnutls_dh_replace_params( gnutls_datum prime, gnutls_datum generator, int bits);
 int gnutls_dh_generate_params( gnutls_datum* prime, gnutls_datum* generator, int bits);
 
-typedef ssize_t (*PULL_FUNC)(GNUTLS_SOCKET_PTR, void*, size_t);
-typedef ssize_t (*PUSH_FUNC)(GNUTLS_SOCKET_PTR, const void*, size_t);
-void gnutls_set_transport_ptr(GNUTLS_STATE state, GNUTLS_SOCKET_PTR ptr);
+typedef ssize_t (*GNUTLS_PULL_FUNC)(GNUTLS_SOCKET_PTR, void*, size_t);
+typedef ssize_t (*GNUTLS_PUSH_FUNC)(GNUTLS_SOCKET_PTR, const void*, size_t);
+void gnutls_transport_set_ptr(GNUTLS_STATE state, GNUTLS_SOCKET_PTR ptr);
 
 typedef void (*LOG_FUNC)( const char*);
 
-void gnutls_set_push_function( GNUTLS_STATE, PUSH_FUNC push_func);
-void gnutls_set_pull_function( GNUTLS_STATE, PULL_FUNC pull_func);
-#define gnutls_set_push_func gnutls_set_push_function
-#define gnutls_set_pull_func gnutls_set_pull_function
+void gnutls_transport_set_push_function( GNUTLS_STATE, GNUTLS_PUSH_FUNC push_func);
+void gnutls_transport_set_pull_function( GNUTLS_STATE, GNUTLS_PULL_FUNC pull_func);
 
 size_t gnutls_get_max_record_size( GNUTLS_STATE state);
 size_t gnutls_set_max_record_size( GNUTLS_STATE state, size_t size);
index e5072e12fd3e1b3b4bbfdba8f79b602ae189aeb6..f0768967fa905cde5635f0dc662bbd5c984c57c1 100644 (file)
@@ -761,13 +761,13 @@ GNUTLS_Version _gnutls_version_max(GNUTLS_STATE state)
 
 
 /**
-  * gnutls_version_get_name - Returns a string with the name of the specified SSL/TLS version
+  * gnutls_protocol_get_name - Returns a string with the name of the specified SSL/TLS version
   * @version: is a (gnutls) version number
   *
   * Returns a string that contains the name 
   * of the specified TLS version.
   **/
-const char *gnutls_version_get_name(GNUTLS_Version version)
+const char *gnutls_protocol_get_name(GNUTLS_Version version)
 {
        char *ret = NULL;
 
index 1df1ce3ba461d18e86f197ad691e474fc1203796..8281885e1cdc934e3de019679d5603c6a8639f56 100644 (file)
@@ -33,7 +33,6 @@
 #include <x509_extensions.h>
 #include <gnutls_algorithms.h>
 #include <gnutls_dh.h>
-#include <gnutls_auth_int.h>
 
 #ifdef DEBUG
 # warning MAX ALGORITHM PARAMS == 2, ok for RSA
@@ -1026,66 +1025,6 @@ int _gnutls_cert_supported_kx(const gnutls_cert * cert, KXAlgorithm ** alg,
        return 0;
 }
 
-/* finds the most appropriate certificate in the cert list.
- * The 'appropriate' is defined by the user.
- * FIXME: provide user callback.
- */
-const gnutls_cert *_gnutls_server_find_cert(GNUTLS_STATE state,
-                                           gnutls_cert ** cert_list,
-                                           int cert_list_length)
-{
-       int i;
-
-       i = _gnutls_server_find_cert_list_index(state, cert_list,
-                                        cert_list_length);
-       if (i < 0)
-               return NULL;
-
-       return &cert_list[i][0];
-}
-
-/* finds the most appropriate certificate in the cert list.
- * The 'appropriate' is defined by the user.
- */
-int _gnutls_server_find_cert_list_index(GNUTLS_STATE state,
-                                       gnutls_cert ** cert_list,
-                                       int cert_list_length)
-{
-       int i, index = -1;
-       const X509PKI_CREDENTIALS cred;
-
-       cred = _gnutls_get_cred(state->gnutls_key, GNUTLS_X509PKI, NULL);
-       if (cred == NULL) {
-               gnutls_assert();
-               return GNUTLS_E_INSUFICIENT_CRED;
-       }
-
-       if (cred->ncerts > 0)
-               index = 0;      /* default is use the first certificate */
-
-       if (state->gnutls_internals.client_cert_callback != NULL && cred->ncerts > 0) { /* use the callback to get certificate */
-               gnutls_datum *my_certs = NULL;
-
-               my_certs =
-                   gnutls_malloc(cred->ncerts * sizeof(gnutls_datum));
-               if (my_certs == NULL)
-                       goto clear;
-
-               /* put our certificate's issuer and dn into cdn, idn
-                */
-               for (i = 0; i < cred->ncerts; i++) {
-                       my_certs[i] = cred->cert_list[i][0].raw;
-               }
-               index =
-                   state->gnutls_internals.server_cert_callback(my_certs,
-                                                                cred->ncerts);
-
-             clear:
-               gnutls_free(my_certs);
-       }
-
-       return index;
-}
 
 /**
   * gnutls_x509pki_server_set_cert_request - Used to set whether to request a client certificate
index d15217122c7c609c7fa36aee09740d3ff5d4efe2..dca77b9a7ac5dc78becb96b404e94cfbada3b2b4 100644 (file)
@@ -49,8 +49,6 @@ struct GNUTLS_STATE_INT; /* because GNUTLS_STATE is not defined when this file i
 int _gnutls_cert_supported_kx( const gnutls_cert* cert, KXAlgorithm **alg, int *alg_size);
 PKAlgorithm _gnutls_map_pk_get_pk(KXAlgorithm kx_algorithm);
 int _gnutls_cert2gnutlsCert(gnutls_cert * gCert, gnutls_datum derCert);
-const gnutls_cert* _gnutls_server_find_cert( struct GNUTLS_STATE_INT*, gnutls_cert** cert_list, int cert_list_length);
-int _gnutls_server_find_cert_list_index( struct GNUTLS_STATE_INT*, gnutls_cert ** cert_list, int cert_list_length);
 
 #define MAX_INT_DIGITS 4
 void _gnutls_int2str(int k, char* data);
index c1962a28d0ca66ef1e3e1fecbfe751b798261c47..cd3758e4ea739267f3ffec43e2eb2c959c317ec8 100644 (file)
@@ -2,7 +2,7 @@
  */
 
 #define GNUTLS_E_SUCCESS 0
-#define        GNUTLS_E_MAC_FAILED  -1
+#define        GNUTLS_E_MAC_FAILED  -1 /* GNUTLS_BAD_RECORD_MAC */
 #define        GNUTLS_E_UNKNOWN_CIPHER -2
 #define        GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM -3
 #define        GNUTLS_E_UNKNOWN_MAC_ALGORITHM -4
 #define GNUTLS_E_FATAL_ALERT_RECEIVED -12
 #define GNUTLS_E_RECEIVED_BAD_MESSAGE -13
 #define GNUTLS_E_RECEIVED_MORE_DATA -14
-#define GNUTLS_E_UNEXPECTED_PACKET -15
+#define GNUTLS_E_UNEXPECTED_PACKET -15 /* GNUTLS_UNEXPECTED_MESSAGE */
 #define GNUTLS_E_WARNING_ALERT_RECEIVED -16
 #define GNUTLS_E_ERROR_IN_FINISHED_PACKET -18
 #define GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET -19
 #define GNUTLS_E_UNKNOWN_KX_ALGORITHM -20
-#define        GNUTLS_E_UNKNOWN_CIPHER_SUITE -21
+#define        GNUTLS_E_UNKNOWN_CIPHER_SUITE -21 /* GNUTLS_HANDSHAKE_FAILURE */
 #define        GNUTLS_E_UNWANTED_ALGORITHM -22
 #define        GNUTLS_E_MPI_SCAN_FAILED -23
-#define GNUTLS_E_DECRYPTION_FAILED -24
+#define GNUTLS_E_DECRYPTION_FAILED -24 /* GNUTLS_DECRYPTION_FAILED */
 #define GNUTLS_E_MEMORY_ERROR -25
-#define GNUTLS_E_DECOMPRESSION_FAILED -26
+#define GNUTLS_E_DECOMPRESSION_FAILED -26 /* GNUTLS_DECOMPRESSION_FAILURE */
 #define GNUTLS_E_COMPRESSION_FAILED -27
 #define GNUTLS_E_AGAIN -28
 #define GNUTLS_E_EXPIRED -29
 #define GNUTLS_E_HASH_FAILED -33
 #define GNUTLS_E_PARSING_ERROR -34
 #define        GNUTLS_E_MPI_PRINT_FAILED -35
-#define GNUTLS_E_REHANDSHAKE -37
+#define GNUTLS_E_REHANDSHAKE -37 /* GNUTLS_NO_RENEGOTIATION */
 #define GNUTLS_E_GOT_APPLICATION_DATA -38
 #define GNUTLS_E_RECORD_LIMIT_REACHED -39
 #define GNUTLS_E_ENCRYPTION_FAILED -40
 #define GNUTLS_E_ASN1_ERROR -41
-#define GNUTLS_E_ASN1_PARSING_ERROR -42
+#define GNUTLS_E_ASN1_PARSING_ERROR -42 /* GNUTLS_BAD_CERTIFICATE */
 #define GNUTLS_E_X509_CERTIFICATE_ERROR -43
 #define GNUTLS_E_PK_ENCRYPTION_FAILED -44
 #define GNUTLS_E_PK_DECRYPTION_FAILED -45
 #define GNUTLS_E_PK_SIGNATURE_FAILED -46
 #define GNUTLS_E_X509_UNSUPPORTED_CRITICAL_EXTENSION -47
 #define GNUTLS_E_X509_KEY_USAGE_VIOLATION -48
-#define GNUTLS_E_NO_CERTIFICATE_FOUND -49
+#define GNUTLS_E_NO_CERTIFICATE_FOUND -49 /* GNUTLS_BAD_CERTIFICATE */
 #define GNUTLS_E_INVALID_PARAMETERS -50
 #define GNUTLS_E_INVALID_REQUEST -51
 #define GNUTLS_E_INTERRUPTED -52
 #define GNUTLS_E_PUSH_ERROR -53
 #define GNUTLS_E_PULL_ERROR -54
-#define GNUTLS_E_ILLEGAL_PARAMETER -55
+#define GNUTLS_E_ILLEGAL_PARAMETER -55  /* GNUTLS_ILLEGAL_PARAMETER */
 #define GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE -56
 #define GNUTLS_E_PKCS1_WRONG_PAD -57
 
index 5e62e94be77da7626cc429d1769c13a69d20b530..5273faac5d4c2b8a39b934f99eebb4cd02ed9d0f 100644 (file)
@@ -135,7 +135,7 @@ void gnutls_global_deinit() {
  */
 
 /**
-  * gnutls_set_pull_function - This function sets a read like function
+  * gnutls_transport_set_pull_function - This function sets a read like function
   * @pull_func: it's a function like read
   * @state: gnutls state
   *
@@ -147,12 +147,12 @@ void gnutls_global_deinit() {
   * PULL_FUNC is of the form, 
   * ssize_t (*PULL_FUNC)(GNUTLS_SOCKET_PTR, const void*, size_t);
   **/
-void gnutls_set_pull_function( GNUTLS_STATE state, PULL_FUNC pull_func) {
+void gnutls_transport_set_pull_function( GNUTLS_STATE state, PULL_FUNC pull_func) {
        state->gnutls_internals._gnutls_pull_func = pull_func;
 }
 
 /**
-  * gnutls_set_push_function - This function sets the function to send data
+  * gnutls_transport_set_push_function - This function sets the function to send data
   * @push_func: it's a function like write
   * @state: gnutls state
   *
@@ -166,6 +166,6 @@ void gnutls_set_pull_function( GNUTLS_STATE state, PULL_FUNC pull_func) {
   * PUSH_FUNC is of the form, 
   * ssize_t (*PUSH_FUNC)(GNUTLS_SOCKET_PTR, const void*, size_t);
   **/
-void gnutls_set_push_function( GNUTLS_STATE state, PUSH_FUNC push_func) {
+void gnutls_transport_set_push_function( GNUTLS_STATE state, PUSH_FUNC push_func) {
        state->gnutls_internals._gnutls_push_func = push_func;
 }
index 0878fe398ea07bc311a77a6ecc8f3d85ef5db575..3674a5ae1c887893bd4fbc4d011d31454b60fffb 100644 (file)
@@ -502,7 +502,7 @@ svoid *gnutls_PRF( opaque * secret, int secret_size, uint8 * label,
                  int label_size, opaque * seed, int seed_size,
                  int total_bytes);
 void _gnutls_set_current_version(GNUTLS_STATE state, GNUTLS_Version version);
-GNUTLS_Version gnutls_get_current_version(GNUTLS_STATE state);
+GNUTLS_Version gnutls_protocol_get_version(GNUTLS_STATE state);
 void _gnutls_free_auth_info( GNUTLS_STATE state);
 
 /* These two macros return the advertized TLS version of
index d20ac5a0b1579e324429a11c9a7705d31bb4681f..e2d556a9cd4259129cbd7bd34705d41730f527e4 100644 (file)
@@ -25,7 +25,7 @@
 /* the prototypes for these are in gnutls.h */
 
 /**
-  * gnutls_set_cipher_priority - Sets the priority on the ciphers supported by gnutls.
+  * gnutls_cipher_set_priority - Sets the priority on the ciphers supported by gnutls.
   * @state: is a &GNUTLS_STATE structure.
   * @GNUTLS_LIST: is a 0 terminated list of BulkCipherAlgorithm elements.
   *
@@ -36,7 +36,7 @@
   * not use the algorithm's priority except for disabling
   * algorithms that were not specified.
   **/
-int gnutls_set_cipher_priority( GNUTLS_STATE state, GNUTLS_LIST) {
+int gnutls_cipher_set_priority( GNUTLS_STATE state, GNUTLS_LIST) {
        
        va_list ap;
        int i,num=0;
@@ -73,7 +73,7 @@ int gnutls_set_cipher_priority( GNUTLS_STATE state, GNUTLS_LIST) {
 }
 
 /**
-  * gnutls_set_kx_priority - Sets the priority on the key exchange algorithms supported by gnutls.
+  * gnutls_kx_set_priority - Sets the priority on the key exchange algorithms supported by gnutls.
   * @state: is a &GNUTLS_STATE structure.
   * @GNUTLS_LIST: is a 0 terminated list of KXAlgorithm elements.
   *
@@ -84,7 +84,7 @@ int gnutls_set_cipher_priority( GNUTLS_STATE state, GNUTLS_LIST) {
   * not use the algorithm's priority except for disabling
   * algorithms that were not specified.
  **/
-int gnutls_set_kx_priority( GNUTLS_STATE state, GNUTLS_LIST) {
+int gnutls_kx_set_priority( GNUTLS_STATE state, GNUTLS_LIST) {
        
        va_list ap;
        va_list _ap;
@@ -118,7 +118,7 @@ int gnutls_set_kx_priority( GNUTLS_STATE state, GNUTLS_LIST) {
 }
 
 /**
-  * gnutls_set_mac_priority - Sets the priority on the mac algorithms supported by gnutls.
+  * gnutls_mac_set_priority - Sets the priority on the mac algorithms supported by gnutls.
   * @state: is a &GNUTLS_STATE structure.
   * @GNUTLS_LIST: is a 0 terminated list of MACAlgorithm elements.
   *
@@ -129,7 +129,7 @@ int gnutls_set_kx_priority( GNUTLS_STATE state, GNUTLS_LIST) {
   * not use the algorithm's priority except for disabling
   * algorithms that were not specified.
   **/
-int gnutls_set_mac_priority( GNUTLS_STATE state, GNUTLS_LIST) {
+int gnutls_mac_set_priority( GNUTLS_STATE state, GNUTLS_LIST) {
        
        va_list ap;
        int i, num=0;
@@ -163,7 +163,7 @@ int gnutls_set_mac_priority( GNUTLS_STATE state, GNUTLS_LIST) {
 }
 
 /**
-  * gnutls_set_compression_priority - Sets the priority on the compression algorithms supported by gnutls.
+  * gnutls_compression_set_priority - Sets the priority on the compression algorithms supported by gnutls.
   * @state: is a &GNUTLS_STATE structure.
   * @GNUTLS_LIST: is a 0 terminated list of CompressionMethod elements.
   *
@@ -174,7 +174,7 @@ int gnutls_set_mac_priority( GNUTLS_STATE state, GNUTLS_LIST) {
   * not use the algorithm's priority except for disabling
   * algorithms that were not specified.
   **/
-int gnutls_set_compression_priority( GNUTLS_STATE state, GNUTLS_LIST) {
+int gnutls_compression_set_priority( GNUTLS_STATE state, GNUTLS_LIST) {
        
        va_list ap;
        int i,num=0;
@@ -207,7 +207,7 @@ int gnutls_set_compression_priority( GNUTLS_STATE state, GNUTLS_LIST) {
 }
 
 /**
-  * gnutls_set_protocol_priority - Sets the priority on the protocol versions supported by gnutls.
+  * gnutls_protocol_set_priority - Sets the priority on the protocol versions supported by gnutls.
   * @state: is a &GNUTLS_STATE structure.
   * @GNUTLS_LIST: is a 0 terminated list of GNUTLS_Version elements.
   *
@@ -218,7 +218,7 @@ int gnutls_set_compression_priority( GNUTLS_STATE state, GNUTLS_LIST) {
   * not use the protocols's priority except for disabling
   * protocols that were not specified.
   **/
-int gnutls_set_protocol_priority( GNUTLS_STATE state, GNUTLS_LIST) {
+int gnutls_protocol_set_priority( GNUTLS_STATE state, GNUTLS_LIST) {
        
        va_list ap;
        int i,num=0;
index 37a7711ba1f6d3a036b470b11779824bec8eca0e..4fb4bda6451114b30022a1c1bd677017b578aad5 100644 (file)
@@ -18,8 +18,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
-int gnutls_set_cipher_priority( GNUTLS_STATE state, GNUTLS_LIST);
-int gnutls_set_kx_priority( GNUTLS_STATE state, GNUTLS_LIST); 
-int gnutls_set_mac_priority( GNUTLS_STATE state, GNUTLS_LIST);
-int gnutls_set_compression_priority( GNUTLS_STATE state, GNUTLS_LIST);
-int gnutls_set_protocol_priority( GNUTLS_STATE state, GNUTLS_LIST);
+int gnutls_cipher_set_priority( GNUTLS_STATE state, GNUTLS_LIST);
+int gnutls_kx_set_priority( GNUTLS_STATE state, GNUTLS_LIST); 
+int gnutls_mac_set_priority( GNUTLS_STATE state, GNUTLS_LIST);
+int gnutls_compression_set_priority( GNUTLS_STATE state, GNUTLS_LIST);
+int gnutls_protocol_set_priority( GNUTLS_STATE state, GNUTLS_LIST);
index a49ca4b18611759e9368bc744240d487c3787639..fd2e046bad20af5bb49244b773362ea69bbb03b1 100644 (file)
 #include "gnutls_datum.h"
 #include "ext_max_record.h"
 
-GNUTLS_Version gnutls_get_current_version(GNUTLS_STATE state) {
+/**
+  * gnutls_protocol_get_version - Returns the version of the currently used protocol
+  * @state: is a &GNUTLS_STATE structure.
+  *
+  * Returns the version of the currently used protocol. 
+  *
+  **/
+GNUTLS_Version gnutls_protocol_get_version(GNUTLS_STATE state) {
 GNUTLS_Version ver;
        ver = state->security_parameters.version;
        return ver;
@@ -64,7 +71,7 @@ void gnutls_set_lowat(GNUTLS_STATE state, int num) {
 }
 
 /**
-  * gnutls_set_transport_ptr - Used to set first argument of the transport functions
+  * gnutls_transport_set_ptr - Used to set first argument of the transport functions
   * @state: is a &GNUTLS_STATE structure.
   * @ptr: is the value.
   *
@@ -73,7 +80,7 @@ void gnutls_set_lowat(GNUTLS_STATE state, int num) {
   * handle.
   *
   **/
-void gnutls_set_transport_ptr(GNUTLS_STATE state, GNUTLS_SOCKET_PTR ptr) {
+void gnutls_transport_set_ptr(GNUTLS_STATE state, GNUTLS_SOCKET_PTR ptr) {
        state->gnutls_internals.transport_ptr = ptr;
 }
 
@@ -109,7 +116,7 @@ int gnutls_init(GNUTLS_STATE * state, ConnectionEnd con_end)
 
        (*state)->gnutls_internals.resumable = RESUME_TRUE;
 
-       gnutls_set_protocol_priority( *state, GNUTLS_TLS1, 0); /* default */
+       gnutls_protocol_set_priority( *state, GNUTLS_TLS1, 0); /* default */
        
        (*state)->gnutls_key = gnutls_calloc(1, sizeof(struct GNUTLS_KEY_INT));
        if ( (*state)->gnutls_key == NULL) {
@@ -547,7 +554,7 @@ ssize_t gnutls_send_int( GNUTLS_STATE state, ContentType type, HandshakeType hty
                        return GNUTLS_E_UNSUPPORTED_VERSION_PACKET;
                }
        } else { /* send the current */
-               lver = gnutls_get_current_version( state);
+               lver = gnutls_protocol_get_version( state);
        }
 
        headers[1]=_gnutls_version_get_major( lver);
@@ -778,7 +785,7 @@ ssize_t gnutls_recv_int( GNUTLS_STATE state, ContentType type, HandshakeType hty
         * negotiated in the handshake.
         */
 #ifdef CHECK_RECORD_VERSION
-       if ( (htype!=GNUTLS_CLIENT_HELLO && htype!=GNUTLS_SERVER_HELLO) && gnutls_get_current_version(state) != version) {
+       if ( (htype!=GNUTLS_CLIENT_HELLO && htype!=GNUTLS_SERVER_HELLO) && gnutls_protocol_get_version(state) != version) {
                gnutls_assert();
 # ifdef RECORD_DEBUG
                _gnutls_log( "Record: INVALID VERSION PACKET: (%d/%d) %d.%d\n", headers[0], htype, headers[1], headers[2]);
@@ -993,42 +1000,42 @@ ssize_t gnutls_recv_int( GNUTLS_STATE state, ContentType type, HandshakeType hty
 }
 
 /**
-  * gnutls_get_current_cipher - Returns the currently used cipher.
+  * gnutls_cipher_get_algo - Returns the currently used cipher.
   * @state: is a &GNUTLS_STATE structure.
   *
   * Returns the currently used cipher.
   **/
-BulkCipherAlgorithm gnutls_get_current_cipher( GNUTLS_STATE state) {
+BulkCipherAlgorithm gnutls_cipher_get_algo( GNUTLS_STATE state) {
        return state->security_parameters.read_bulk_cipher_algorithm;
 }
 
 /**
-  * gnutls_get_current_kx - Returns the key exchange algorithm.
+  * gnutls_kx_get_algo - Returns the key exchange algorithm.
   * @state: is a &GNUTLS_STATE structure.
   *
   * Returns the key exchange algorithm used in the last handshake.
   **/
-KXAlgorithm gnutls_get_current_kx( GNUTLS_STATE state) {
+KXAlgorithm gnutls_kx_get_algo( GNUTLS_STATE state) {
        return state->security_parameters.kx_algorithm;
 }
 
 /**
-  * gnutls_get_current_mac_algorithm - Returns the currently used mac algorithm.
+  * gnutls_mac_get_algo - Returns the currently used mac algorithm.
   * @state: is a &GNUTLS_STATE structure.
   *
   * Returns the currently used mac algorithm.
   **/
-MACAlgorithm gnutls_get_current_mac_algorithm( GNUTLS_STATE state) {
+MACAlgorithm gnutls_mac_get_algo( GNUTLS_STATE state) {
        return state->security_parameters.read_mac_algorithm;
 }
 
 /**
-  * gnutls_get_current_compression_method - Returns the currently used compression algorithm.
+  * gnutls_compression_get_algo - Returns the currently used compression algorithm.
   * @state: is a &GNUTLS_STATE structure.
   *
   * Returns the currently used compression method.
   **/
-CompressionMethod gnutls_get_current_compression_method( GNUTLS_STATE state) {
+CompressionMethod gnutls_compression_get_algo( GNUTLS_STATE state) {
        return state->security_parameters.read_compression_algorithm;
 }
 
index 04ee6ab137332dead1ee0c64210da9311a874b26..15e70423f43ef071e7b29ca5c98df87caf08550a 100644 (file)
@@ -1,5 +1,5 @@
 AlertDescription gnutls_get_last_alert( GNUTLS_STATE state);
-KXAlgorithm gnutls_get_current_kx( GNUTLS_STATE state);
+KXAlgorithm gnutls_kx_get_algo( GNUTLS_STATE state);
 ssize_t gnutls_send_int( GNUTLS_STATE state, ContentType type, HandshakeType htype, const void* data, size_t sizeofdata);
 ssize_t gnutls_recv_int( GNUTLS_STATE state, ContentType type, HandshakeType, char* data, size_t sizeofdata);
 ssize_t _gnutls_send_change_cipher_spec( GNUTLS_STATE state, int again);
index a2e22a62db443295b846603b496d3b42a4925f7c..3fd230b4c4667818a4dae8ee90c9300b51ae8505 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -61,7 +61,7 @@ const gnutls_datum* cert_list;
 CertificateStatus status;
 int cert_list_size = 0;
 
-       tmp = gnutls_kx_get_name(gnutls_get_current_kx( state));
+       tmp = gnutls_kx_get_name(gnutls_kx_get_algo( state));
        printf("- Key Exchange: %s\n", tmp);
 
        cred = gnutls_get_auth_type(state);
@@ -105,16 +105,16 @@ int cert_list_size = 0;
                        }
        }
 
-       tmp = gnutls_version_get_name(gnutls_get_current_version(state));
+       tmp = gnutls_protocol_get_name(gnutls_protocol_get_version(state));
        printf("- Version: %s\n", tmp);
 
-       tmp = gnutls_compression_get_name(gnutls_get_current_compression_method( state));
+       tmp = gnutls_compression_get_name(gnutls_compression_get_algo( state));
        printf("- Compression: %s\n", tmp);
 
-       tmp = gnutls_cipher_get_name(gnutls_get_current_cipher( state));
+       tmp = gnutls_cipher_get_name(gnutls_cipher_get_algo( state));
        printf("- Cipher: %s\n", tmp);
 
-       tmp = gnutls_mac_get_name(gnutls_get_current_mac_algorithm( state));
+       tmp = gnutls_mac_get_name(gnutls_mac_get_algo( state));
        printf("- MAC: %s\n", tmp);
 
        return 0;
@@ -222,11 +222,11 @@ int main(int argc, char** argv)
 #ifdef RESUME
        gnutls_init(&state, GNUTLS_CLIENT);
        
-       gnutls_set_protocol_priority( state, GNUTLS_TLS1, GNUTLS_SSL3, 0);
-       gnutls_set_cipher_priority( state, GNUTLS_3DES_CBC, GNUTLS_RIJNDAEL_CBC, 0);
-       gnutls_set_compression_priority( state, GNUTLS_ZLIB, GNUTLS_NULL_COMPRESSION, 0);
-       gnutls_set_kx_priority( state, GNUTLS_KX_DHE_RSA, GNUTLS_KX_RSA, GNUTLS_KX_SRP, GNUTLS_KX_DH_ANON, 0);
-       gnutls_set_mac_priority( state, GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0);
+       gnutls_protocol_set_priority( state, GNUTLS_TLS1, GNUTLS_SSL3, 0);
+       gnutls_cipher_set_priority( state, GNUTLS_3DES_CBC, GNUTLS_RIJNDAEL_CBC, 0);
+       gnutls_compression_set_priority( state, GNUTLS_ZLIB, GNUTLS_NULL_COMPRESSION, 0);
+       gnutls_kx_set_priority( state, GNUTLS_KX_DHE_RSA, GNUTLS_KX_RSA, GNUTLS_KX_SRP, GNUTLS_KX_DH_ANON, 0);
+       gnutls_mac_set_priority( state, GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0);
 
        gnutls_set_cred( state, GNUTLS_ANON, NULL);
        gnutls_set_cred( state, GNUTLS_SRP, cred);
@@ -236,7 +236,7 @@ int main(int argc, char** argv)
  */
        gnutls_ext_set_name_ind( state, GNUTLS_DNSNAME, "localhost"); 
 
-       gnutls_set_transport_ptr( state, sd);
+       gnutls_transport_set_ptr( state, sd);
        do {
                ret = gnutls_handshake( state);
        } while( ret==GNUTLS_E_INTERRUPTED || ret==GNUTLS_E_AGAIN);
@@ -285,10 +285,11 @@ int main(int argc, char** argv)
        /* Begin handshake again */
        gnutls_init(&state, GNUTLS_CLIENT);
        
-       gnutls_set_protocol_priority( state, GNUTLS_TLS1, GNUTLS_SSL3, 0);
-       gnutls_set_cipher_priority( state, GNUTLS_3DES_CBC, GNUTLS_TWOFISH_CBC, GNUTLS_RIJNDAEL_CBC, 0);
-       gnutls_set_compression_priority( state, GNUTLS_NULL_COMPRESSION, 0);
-       gnutls_set_kx_priority( state, GNUTLS_KX_RSA, GNUTLS_KX_DHE_RSA, GNUTLS_KX_SRP, GNUTLS_KX_DH_ANON, 0);
+       gnutls_protocol_set_priority( state, GNUTLS_TLS1, GNUTLS_SSL3, 0);
+       gnutls_cipher_set_priority( state, GNUTLS_3DES_CBC, GNUTLS_RIJNDAEL_CBC, 0);
+       gnutls_compression_set_priority( state, GNUTLS_ZLIB, GNUTLS_NULL_COMPRESSION, 0);
+       gnutls_kx_set_priority( state, GNUTLS_KX_DHE_RSA, GNUTLS_KX_RSA, GNUTLS_KX_SRP, GNUTLS_KX_DH_ANON, 0);
+       gnutls_mac_set_priority( state, GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0);
 
        gnutls_set_cred( state, GNUTLS_ANON, NULL);
        gnutls_set_cred( state, GNUTLS_SRP, cred);
@@ -296,14 +297,12 @@ int main(int argc, char** argv)
 
        gnutls_ext_set_name_ind( state, GNUTLS_DNSNAME, "hello.server.org");
 
-       gnutls_set_mac_priority( state, GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0);
-
 #ifdef RESUME
        gnutls_session_set_data( state, session, session_size);
        free(session);
 #endif
 
-       gnutls_set_transport_ptr( state, sd);
+       gnutls_transport_set_ptr( state, sd);
        do {
                ret = gnutls_handshake( state);
        } while( ret==GNUTLS_E_INTERRUPTED || ret==GNUTLS_E_AGAIN);
index 0c119fd5d4fa666243e5d41c4573598b59f87f26..9f458198739258cf818c173d7c3f87d5a73059c2 100644 (file)
@@ -83,17 +83,17 @@ GNUTLS_STATE initialize_state()
        /* null cipher is here only for debuging 
         * purposes.
         */
-       gnutls_set_cipher_priority(state, GNUTLS_NULL_CIPHER, 
+       gnutls_cipher_set_priority(state, GNUTLS_NULL_CIPHER, 
                                   GNUTLS_RIJNDAEL_CBC, GNUTLS_3DES_CBC, GNUTLS_ARCFOUR, 0);
-       gnutls_set_compression_priority(state, GNUTLS_ZLIB, GNUTLS_NULL_COMPRESSION, 0);
-       gnutls_set_kx_priority(state, GNUTLS_KX_RSA, GNUTLS_KX_DHE_RSA, GNUTLS_KX_SRP, GNUTLS_KX_DH_ANON, 0);
-       gnutls_set_protocol_priority( state, GNUTLS_TLS1, GNUTLS_SSL3, 0);
+       gnutls_compression_set_priority(state, GNUTLS_ZLIB, GNUTLS_NULL_COMPRESSION, 0);
+       gnutls_kx_set_priority(state, GNUTLS_KX_RSA, GNUTLS_KX_DHE_RSA, GNUTLS_KX_SRP, GNUTLS_KX_DH_ANON, 0);
+       gnutls_protocol_set_priority( state, GNUTLS_TLS1, GNUTLS_SSL3, 0);
        
        gnutls_set_cred(state, GNUTLS_ANON, dh_cred);
        gnutls_set_cred(state, GNUTLS_SRP, srp_cred);
        gnutls_set_cred(state, GNUTLS_X509PKI, x509_cred);
 
-       gnutls_set_mac_priority(state, GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0);
+       gnutls_mac_set_priority(state, GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0);
 
        gnutls_x509pki_server_set_cert_request( state, GNUTLS_CERT_REQUEST);
 
@@ -162,7 +162,7 @@ void print_info(GNUTLS_STATE state)
                                break;
                        }
                
-                       if (gnutls_get_current_kx(state) == GNUTLS_KX_DHE_RSA || gnutls_get_current_kx(state) == GNUTLS_KX_DHE_DSS) {
+                       if (gnutls_kx_get_algo(state) == GNUTLS_KX_DHE_RSA || gnutls_kx_get_algo(state) == GNUTLS_KX_DHE_DSS) {
                                printf("\n- Ephemeral DH using prime of %d bits\n",
                                gnutls_x509pki_server_get_dh_bits( state));
                        }
@@ -185,21 +185,21 @@ void print_info(GNUTLS_STATE state)
 
        /* print state information */
 
-       tmp = gnutls_version_get_name(gnutls_get_current_version(state));
+       tmp = gnutls_protocol_get_name( gnutls_protocol_get_version(state));
        printf("- Version: %s\n", tmp);
 
-       tmp = gnutls_kx_get_name(gnutls_get_current_kx(state));
+       tmp = gnutls_kx_get_name(gnutls_kx_get_algo(state));
        printf("- Key Exchange: %s\n", tmp);
 
        tmp =
            gnutls_compression_get_name
-           (gnutls_get_current_compression_method(state));
+           (gnutls_compression_get_algo(state));
        printf("- Compression: %s\n", tmp);
 
-       tmp = gnutls_cipher_get_name(gnutls_get_current_cipher(state));
+       tmp = gnutls_cipher_get_name(gnutls_cipher_get_algo(state));
        printf("- Cipher: %s\n", tmp);
 
-       tmp = gnutls_mac_get_name(gnutls_get_current_mac_algorithm(state));
+       tmp = gnutls_mac_get_name(gnutls_mac_get_algo(state));
        printf("- MAC: %s\n", tmp);
 
 
@@ -234,12 +234,12 @@ void peer_print_info( GNUTLS_STATE state)
         */ 
 
        /* print srp specific data */
-       if (gnutls_get_current_kx(state) == GNUTLS_KX_SRP) {
+       if (gnutls_kx_get_algo(state) == GNUTLS_KX_SRP) {
                sprintf(tmp2, "<p>Connected as user '%s'.</p>\n",
                       gnutls_srp_server_get_username( state));
        }
 
-       if (gnutls_get_current_kx(state) == GNUTLS_KX_DH_ANON) {
+       if (gnutls_kx_get_algo(state) == GNUTLS_KX_DH_ANON) {
                sprintf(tmp2, "<p> Connect using anonymous DH (prime of %d bits)</p>\n",
                       gnutls_anon_server_get_dh_bits( state));
        }
@@ -247,26 +247,26 @@ void peer_print_info( GNUTLS_STATE state)
        /* print state information */
        strcat( http_buffer, "<P>\n");
 
-       tmp = gnutls_version_get_name(gnutls_get_current_version(state));
+       tmp = gnutls_protocol_get_name(gnutls_protocol_get_version(state));
        sprintf(tmp2, "Protocol version: <b>%s</b><br>\n", tmp);
 
-       tmp = gnutls_kx_get_name(gnutls_get_current_kx(state));
+       tmp = gnutls_kx_get_name(gnutls_kx_get_algo(state));
        sprintf(tmp2, "Key Exchange: <b>%s</b><br>\n", tmp);
 
-       if (gnutls_get_current_kx(state) == GNUTLS_KX_DHE_RSA || gnutls_get_current_kx(state) == GNUTLS_KX_DHE_DSS) {
+       if (gnutls_kx_get_algo(state) == GNUTLS_KX_DHE_RSA || gnutls_kx_get_algo(state) == GNUTLS_KX_DHE_DSS) {
                sprintf(tmp2, "Ephemeral DH using prime of <b>%d</b> bits.<br>\n",
                                gnutls_x509pki_server_get_dh_bits( state));
        }
                        
        tmp =
            gnutls_compression_get_name
-           (gnutls_get_current_compression_method(state));
+           (gnutls_compression_get_algo(state));
        sprintf(tmp2, "Compression: <b>%s</b><br>\n", tmp);
        
-       tmp = gnutls_cipher_get_name(gnutls_get_current_cipher(state));
+       tmp = gnutls_cipher_get_name(gnutls_cipher_get_algo(state));
        sprintf(tmp2, "Cipher: <b>%s</b><br>\n", tmp);
        
-       tmp = gnutls_mac_get_name(gnutls_get_current_mac_algorithm(state));
+       tmp = gnutls_mac_get_name(gnutls_mac_get_algo(state));
        sprintf(tmp2, "MAC: <b>%s</b><br>\n", tmp);
 
        strcat( http_buffer, "</P>\n");
@@ -410,7 +410,7 @@ int main(int argc, char **argv)
                                 sizeof(topbuf)), ntohs(sa_cli.sin_port));
 
 
-               gnutls_set_transport_ptr( state, sd);
+               gnutls_transport_set_ptr( state, sd);
                do {
                        ret = gnutls_handshake( state);
                } while( ret==GNUTLS_E_INTERRUPTED || ret==GNUTLS_E_AGAIN);